SetConfiguredIoCount

Configures a number of simulated I/O modules. The number of simulated I/Os is determined by how much the given value exceeds the number of the real hardware. If the given number is greater than the number of the real I/Os, KINGSTAR will display all real I/Os plus simulated ones. For example, if you have five real I/Os and you give the number seven, you'll get five real I/Os plus two simulated I/Os. If the given number is less than or equal to the number of the real I/Os, KINGSTAR will display all real I/Os without simulated ones.

Syntax

KsError SetConfiguredIoCount(
     int Count
);

Parameters

Count: the number of simulated I/O modules. The maximum is 256.

Return value

If the function succeeds, it returns errNoError, otherwise an error code. For more information about the error code, see the KsError list.

Remarks

This function is only available for use with simulated I/O modules. Simulated I/O modules must be created using SetConfiguredIoCount before they are configured with ConfigureIo. This function must be called after Create and before Start. Once the link is established the simulated I/O modules cannot be modified.

Usable EtherCAT states

ecatOffline

Example

Copy
/////////////////////////////////////////////////////////////////////////
//
// This code snippet demonstrates how to configure simulated hardware
// in KINGSTAR subsystem. Please be aware that if any actual hardware
// detected in the bus scan procedure the configuration will be replaced
// by automated configuration.
//
/////////////////////////////////////////////////////////////////////////

#define AXIS_COUNT  2
#define IO_COUNT    3

// Variable declaration
KsError nRet = errNoError;
KsCommandStatus Command = { 0 };
SubsystemStatus Subsystem = { ecatOffline, ecatOffline, 0, 0, 0, {ecatOffline}, {ecatOffline}, {axisOffline} };
int axesCount = 0, ioCount = 0;

// Link to the KINGSTAR subsystem
nRet = Create(0, 0);

nRet = SetConfiguredAxesCount(AXIS_COUNT);
nRet = SetConfiguredIoCount(IO_COUNT);

for (int i = 0; i < AXIS_COUNT; i++)
{
    SlaveStatus axisDefinition = { "Simulated Axis", 0 };
    
    // Assign resolution for the simulated axes
    nRet = ConfigureAxis(0, axisDefinition, 131072);
}

for (int i = 0; i < IO_COUNT; i++)
{
    SlaveStatus simulatedIo = { "Simulated IO", 0 };
    
    // Assign input length for the simulated IOs
    simulatedIo.InputLength = 32;
    nRet = ConfigureIo(i, simulatedIo);
}

// By setting the timeout to a short interval and abort Start() on timeout,
// KINGSTAR subsystem will stop scanning for real hardware and start with
// the simulated hardware instead.
Command = WaitForCommand(2, TRUE, Start());

// Get the configured hardware count. It can be used by another KINGSTAR application process.
nRet = GetConfiguredAxesCount(&axesCount);
nRet = GetConfiguredIoCount(&ioCount);

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header ksapi.h ksapi.h
Library KsApi_Rtss.lib KsApi.lib

See also

ConfigureIo

GetConfiguredIoCount