Class Simu

Class Documentation

class Simu

This class contains Simu API functions.

Public Functions

Simu(WMX3Api *f)

Constructor to initialize an object of this class. The device created by the WMX3Api object passed to this constructor is used to execute API functions. Also see Devices.

Simu(const Simu &src)

Copy constructor to initialize an object of this class based on an existing object of this class. Also see Copy Operators.

Simu &operator=(const Simu &src)

Copy assignment operator to initialize an object of this class based on an existing object of this class. Also see Copy Operators.

Simu()

Constructor to initialize an object of this class with a self device. Also see Self Devices.

Simu(DeviceType::T type)

Constructor to initialize an object of this class with a self device of the specified device type. Also see Self Devices.

~Simu()

Destructor for this class.

bool IsDeviceValid()

Return TRUE if this class object has access to a device, and FALSE otherwise. A device is required to execute most functions in this class. If this function returns FALSE, a device can be created by calling the CreateDevice function from the WMX3Api object that was passed to the constructor of this class.

Return TRUE if this class object has access to a device, and FALSE otherwise. A device is required to execute most functions in this class. If this function returns FALSE, a device can be created by calling the CreateDevice function from the WMX3Api object that was passed to the constructor of this class.

SIMUAPIFUNC GetVersion(int *pMajorVersion, int *pMinorVersion, int *pRevisionVersion, int *pFixVersion)

Get the version of the module rtdll.

Get the version of the module rtdll.

Parameters:
  • pMajorVersion[out] The major version number.

  • pMinorVersion[out] The minor version number.

  • pRevisionVersion[out] The revision version number.

  • pFixVersion[out] The fix version number.

SIMUAPIFUNC SetInBit(int byte, int bit, unsigned char data)

Set the value of a simulator input bit.

Set the value of a simulator input bit.

The input bit will be updated during the next communication cycle.

Remark

Parameters:
  • byte[in] The byte address of the bit to set.

  • bit[in] The bit offset of the bit to set.

  • data[in] The value to set the bit to.

SIMUAPIFUNC SetInByte(int byte, unsigned char data)

Set the value of a simulator input byte.

Set the value of a simulator input byte.

The input byte will be updated during the next communication cycle.

Remark

Parameters:
  • byte[in] The address of the byte to set.

  • data[in] The value to set the byte to.

SIMUAPIFUNC SetInBytes(int byte, int size, unsigned char *pData)

Set the value of multiple simulator input bytes.

Set the value of multiple simulator input bytes.

The input bytes will be updated during the next communication cycle.

Remark

Parameters:
  • byte[in] The byte address of the head byte.

  • size[in] The number of bytes to set.

  • pData[in] A pointer to a char array that contains the values to set the bytes to. The size of the array must be greater than or equal to the size parameter.

SIMUAPIFUNC SetInBits(int *pByte, int *pBit, unsigned char *pData, int count)

Set the value of multiple simulator input bits.

Set the value of multiple simulator input bits.

This function is equivalent to calling the

SetInBit function multiple times, but can be faster due to the reduced overhead. There is no limit to the number of bits that may be specified at once. pByte[0], pBit[0], and pData[0] specify the first input bit to set, pByte[1], pBit[1], and pData[1] specify the second input bit to set, and so on. The bits can be specified in any order.

Remark

The input bits will be updated during the next communication cycle.

Parameters:
  • pByte[in] A pointer to an int array that contains the byte addresses of the input bits. The size of the array must be equal to the count parameter.

  • pBit[in] A pointer to an int array that contains the bit addresses of the input bits. The size of the array must be equal to the count parameter.

  • pData[in] A pointer to an unsigned char array that contains the values to set the bits to. The size of the array must be equal to the count parameter.

  • count[in] The number of bits to set.

SIMUAPIFUNC ClearInBit(int byte, int bit)

Clear the set value of a simulator input bit.

Clear the set value of a simulator input bit.

The input bit will be updated during the next communication cycle.

Remark

Parameters:
  • byte[in] The byte address of the bit to clear.

  • bit[in] The bit offset of the bit to clear.

SIMUAPIFUNC ClearInByte(int byte)

Clear the set value of a simulator input byte.

Clear the set value of a simulator input byte.

The input byte will be updated during the next communication cycle.

Remark

Parameters:

byte[in] The address of the byte to clear.

SIMUAPIFUNC ClearInBytes(int byte, int size)

Clear the set value of multiple simulator input bytes.

Clear the set value of multiple simulator input bytes.

The input bytes will be updated during the next communication cycle.

Remark

Parameters:
  • byte[in] The byte address of the head byte.

  • size[in] The number of bytes to clear.

SIMUAPIFUNC ClearInBits(int *pByte, int *pBit, int count)

Clear the set value of multiple simulator input bits.

Clear the set value of multiple simulator input bits.

This function is equivalent to calling the

ClearInBit function multiple times, but can be faster due to the reduced overhead. There is no limit to the number of bits that may be specified at once. pByte[0], pBit[0], and pData[0] specify the first input bit to clear, pByte[1], pBit[1], and pData[1] specify the second input bit to clear, and so on. The bits can be specified in any order.

Remark

The input bits will be updated during the next communication cycle.

Parameters:
  • pByte[in] A pointer to an int array that contains the byte addresses of the input bits. The size of the array must be equal to the count parameter.

  • pBit[in] A pointer to an int array that contains the bit addresses of the input bits. The size of the array must be equal to the count parameter.

  • count[in] The number of bits to clear.

SIMUAPIFUNC SetServoOnFeedback(int axis, int newStatus)

Set the value of the “servo on feedback” signal of a simulator axis.

Set the value of the “servo on feedback” signal of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • newStatus[in] The new servo on status to set. 0: servo off, 1: servo on.

SIMUAPIFUNC SetAlarm(int axis, int alarmCode)

Set the alarm state of a simulator axis.

Set the alarm state of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • alarmCode[in] The value of alarm code. 0: no alarm, others: alarm with set alarm code.

SIMUAPIFUNC SetWarning(int axis, int warningCode)

Set the warning state of a simulator axis.

Set the warning state of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • warningCode[in] The value of warning code. 0: no warning, others: warning with set warning code.

SIMUAPIFUNC SetHomeSwitch(int axis, int newStatus)

Set the home switch state of a simulator axis.

Set the home switch state of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • newStatus[in] The new home switch status to set. 0: home switch off, 1: home switch on.

SIMUAPIFUNC SetLimitSwitchNegative(int axis, int newStatus)

Set the negative limit switch state of a simulator axis.

Set the negative limit switch state of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • newStatus[in] The new negative limit switch status to set. 0: negative limit switch off, 1: negative limit switch on.

SIMUAPIFUNC SetLimitSwitchPositive(int axis, int newStatus)

Set the positive limit switch state of a simulator axis.

Set the positive limit switch state of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • newStatus[in] The new positive limit switch status to set. 0: positive limit switch off, 1: positive limit switch on.

SIMUAPIFUNC SetZPulse0Detected(int axis, int latchedZPulseFeedback)

Set the “ZPulse 0 detected” signal and the latched ZPulse position feedback of a simulator axis.

Set the “ZPulse 0 detected” signal and the latched ZPulse position feedback of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • latchedZPulseFeedback[in] The latched ZPulse 0 position feedback to set.

SIMUAPIFUNC SetZPulse1Detected(int axis, int latchedZPulseFeedback)

Set the “ZPulse 1 detected” signal and the latched ZPulse position feedback of a simulator axis.

Set the “ZPulse 1 detected” signal and the latched ZPulse position feedback of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • latchedZPulseFeedback[in] The latched ZPulse 1 position feedback to set.

SIMUAPIFUNC SetTouchProbe0Detected(int axis, int touchProbeDetectedFeedback)

Set the “touch probe 0 detected” signal and the latched touch probe 0 position feedback of a simulator axis.

Set the “touch probe 0 detected” signal and the latched touch probe 0 position feedback of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • touchProbeDetectedFeedback[in] The latched touch probe 0 position feedback to set.

SIMUAPIFUNC SetTouchProbe1Detected(int axis, int touchProbeDetectedFeedback)

Set the “touch probe 1 detected” signal and the latched touch probe 1 position feedback of a simulator axis.

Set the “touch probe 1 detected” signal and the latched touch probe 1 position feedback of a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:
  • axis[in] The axis to set.

  • touchProbeDetectedFeedback[in] The latched touch probe 1 position feedback to set.

SIMUAPIFUNC ClearServoOnFeedback(int axis)

Clear the set “servo on feedback” signal for a simulator axis.

Clear the set “servo on feedback” signal for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearAlarm(int axis)

Clear the set alarm state for a simulator axis.

Clear the set alarm state for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearWarning(int axis)

Clear the set warning state for a simulator axis.

Clear the set warning state for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearHomeSwitch(int axis)

Clear the set home switch state for a simulator axis.

Clear the set home switch state for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearLimitSwitchNegative(int axis)

Clear the set negative limit switch state for a simulator axis.

Clear the set negative limit switch state for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearLimitSwitchPositive(int axis)

Clear the set positive limit switch state for a simulator axis.

Clear the set positive limit switch state for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearZPulse0Detected(int axis)

Clear the set “ZPulse 0 detected” signal for a simulator axis.

Clear the set “ZPulse 0 detected” signal for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearZPulse1Detected(int axis)

Clear the set “ZPulse 1 detected” signal for a simulator axis.

Clear the set “ZPulse 1 detected” signal for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearTouchProbe0Detected(int axis)

Clear the set “touch probe 0 detected signal” for a simulator axis.

Clear the set “touch probe 0 detected signal” for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC ClearTouchProbe1Detected(int axis)

Clear the set “touch probe 1 detected signal” for a simulator axis.

Clear the set “touch probe 1 detected signal” for a simulator axis.

The signal will be updated during the next communication cycle.

Remark

Parameters:

axis[in] The axis to clear.

SIMUAPIFUNC SetUpdatePeriod(unsigned int period)

Set the master info update period.

Set the master info update period.

The default update period is 1ms. If the master info does not need to be updated so often, system resource use can be reduced by specifying a larger period to reduce the update frequency.

Remark

Parameters:

period[in] New master info update period in unit ms.

SIMUAPIFUNC GetMasterInfo(SimuMasterInfo *masterInfo)

Read the current master information from the engine.

Read the current master information from the engine.

Parameters:

masterInfo[out] A pointer to a SimuMasterInfo class that will be filled in with the current master information.

Public Static Functions

static SIMUAPIFUNC ErrorToString(int errCode, char *pString, unsigned int size)

Get a string representation of the specified error code.

Get a string representation of the specified error code.

This function returns a string representation of the specified error code. The error code must be defined in the

SimuErrorCode enum or the ErrorCode enum in the WMX3Api.h header. All errors returned by functions in class Simu will be defined in one of these enums. Errors returned by functions in other classes may not be defined in one of these enums, and when such errors are passed to this function, an ErrorCodeNotDefined error will be returned and pString will contain the string representation of this error.

Remark

If pString is too small to contain the entire string representation of the error code, pString will be set to an empty string. An array size of 256 characters will be enough to hold all string representations.

This function is static, and may be called without declaring an instance of the Simu class or creating a device.

Parameters:
  • errCode[in] The error code to get the string representation of.

  • pString[in] A char array that will contain the string representation of the error.

  • size[in] The size of the char array in number of characters.

static SIMUAPIFUNC ErrorToString(int errCode, wchar_t *pString, unsigned int size)

Get a string representation of the specified error code.

Get a string representation of the specified error code.

This function is a variation of

ErrorToString that accepts a wchar_t array. Use this function when using Unicode character sets.

Remark

Parameters:
  • errCode[in] The error code to get the string representation of.

  • pString[in] A wchar_t array that will contain the string representation of the error.

  • size[in] The size of the wchar_t array in number of characters.

static SIMUAPIFUNC ApiLogToString(unsigned char *pLogData, unsigned int logDataSize, char *pString, unsigned int size)

Get a string representation of the raw data of an API log.

Get a string representation of the raw data of an API log.

This function converts the raw data for one API function call that was extracted from the API log with the

GetApiLogData function.

Remark

Parameters:
  • pLogData[in] A char array containing the raw data.

  • logDataSize[in] The size of the pLogData char array. This size must be equal to or greater than the size of the raw data.

  • pString[out] A char array that will contain the string representation of the raw data of the API log.

  • size[in] The size of the pString char array in number of characters.

static SIMUAPIFUNC ApiLogToString(unsigned char *pLogData, unsigned int logDataSize, wchar_t *pString, unsigned int size)

Get a string representation of the raw data of an API log.

Get a string representation of the raw data of an API log.

This function is a variation of

ApiLogToString that accepts a wchar_t array. Use this function when using Unicode character sets.

Remark

Parameters:
  • pLogData[in] A char array containing the raw data.

  • logDataSize[in] The size of the char array. This size must be equal to or greater than the size of the raw data.

  • pString[out] A wchar_t array that will contain the string representation of the raw data of the API log.

  • size[out] The size of the pString wchar_t array in number of characters.

static SIMUAPIFUNC GetLibVersion(int *pMajorVersion, int *pMinorVersion, int *pRevisionVersion, int *pFixVersion)

Get the library version information of current using SimuApi.lib.

Get the library version information of current using SimuApi.lib.

Remark

This function is used to retrieve the version information of the library used to compile the application. This function is static, and may be called without declaring an instance of the Simu class or creating a device. The function GetVersion is used to retrieve the version information of the loaded SimuPlatform.rtdll, which could be different from the library. The version of the SimuPlatform.rtdll is determined by the rtdll file that is loaded by WMX3Engine.

Parameters:
  • pMajorVersion[out] The major version number.

  • pMinorVersion[out] The minor version number.

  • pRevisionVersion[out] The revision version number.

  • pFixVersion[out] The fix version number.