RCC Worker Best Practice

In RCC workers, C++ should be used, not C. When a worker’s purpose is to provide an alternative implementation that uses minimum resources, C is acceptable.

Worker Description XML File

Where used, a specproperty should not have a default attribute set, as the property in the component specification should have a default value and there is a desire to keep this behavior the same across workers. If a property (not specproperty) is defined in the worker description, then it should have a default value.

For each writable property it is encouraged for the RCC worker to have a specproperty for that sets writesync to true in order to act on any changes when they happen. However, there are cases where checking for new and changing values on some time schedule is required and writesync is unnecessary.

Any properties that are set in the worker description should follow the same guidelines as for component wide properties in the component specification XML file.

Input Data and Properties

At initialization and on value change there should be a check on the validity of initial or writable property values. If any value that will fit into the property’s data type is acceptable, no check is required. Where there is a check on such a property, if the property is outside the specified and tested property bound the worker should return RCC_FATAL.

In cases where the component specification indicates the writable attribute of a property, dynamic changing of property must be supported, unless the component documentation specifies some optional behavior.

When an optional port is used then a check should be made that this port is valid before the port is used.

Return values

As required by OpenCPI the normally expected return value for an RCC worker which streams values should be RCC_ADVANCE or, if ports are manually advanced by the worker and does not rely on OpenCPI to advance the port RCC_OK should be returned.

When an error state needs to be returned by an RCC worker then RCC_FATAL should be used, rather than RCC_ERROR, so errors are handled and applications cannot continue to attempt to function. When RCC_FATAL is returned the setError method should be used before returning to give a description of the error.

RCC_ERROR should not be used.

Internal Variables

Within RCC worker’s code the variable types uint8_t, int32_t, float, etc. which are supported by OpenCPI should be used (rather than int, long, etc.).