INOS
TINOSTaskExCmd< ObjectType, ParamType > Class Template Reference

Template class that can be used for methods that take the command parameters as function arguments. More...

#include <cinostaskextmpl.h>

Inheritance diagram for TINOSTaskExCmd< ObjectType, ParamType >:

Classes

struct  CallStruct
 

Public Types

typedef void(ObjectType::* tCommandFunction) (ParamType... Params)
 Type of functions of this command. Functions of this type must be used in the constructor of this command.
 
- Public Types inherited from CINOSTaskExCmdBase
typedef bool(CINOSTaskEx::* tPreDispatchFunction) (CINOSTaskExMsg *apMsg)
 Type of pre-dispatch functions. Functions of this type can be used as a callback in SetPreDispatcher.
 
typedef void(CINOSTaskEx::* tOnMsgDoneFunction) (CINOSTaskExMsg *apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError)
 Type of OnMsgDone functions. Functions of this type can be used as a callback in SetOnMsgDone.
 

Public Member Functions

 TINOSTaskExCmd (const char *apName, tCommandFunction apFunction, tCommandFunction apFunctionTmd, ObjectType &aObject, TINOSTaskExValDef< ParamType >... apParamDefinitions, uint32 auStateBitmap=0xFFFFFFFF, const char *apOption=nullptr, uint64 auCharacteristics=0, uint16 auKeyLevel=cKeyLevelMin, bool abRegisterInco=true)
 Constructor. This variant takes the parameter definitions and INCO item properties. It does not add the command to the command registry.
 
 TINOSTaskExCmd (const char *apName, CINOSTaskEx *apTask, ObjectType *apObject, tCommandFunction apFunction, tCommandFunction apFunctionTmd, TINOSTaskExValDef< ParamType >... apParamDefinitions, uint32 auStateBitmap=0xFFFFFFFF, const char *apOption=nullptr, uint64 auCharacteristics=0, uint16 auKeyLevel=cKeyLevelMin, bool abRegisterInco=true)
 Constructor. This variant takes a separate object pointer and task pointer the command is only added to the registry if the task pointer is not null.
 
virtual ~TINOSTaskExCmd ()
 Destructor.
 
- Public Member Functions inherited from TINOSTaskExCmdBaseParam< ObjectType, ParamType... >
CMcResult operator() (ParamType... Params, CINOSSync *apSync=DF_INOS_SYNCHRONOUS)
 Calls this command (dispatched). This function creates and puts a message of this command to the task ex of the command.
 
virtual uint32 AddCommand (bool abDeleteOnRemove=false) override
 Adds this command to the module it belongs to. And makes it therefore callable. This function also checks if the parameter definitions match the types declared in the template parameters.
 
virtual uint32 AddCommand (uint64 aChar, uint16 aKeyLevel, bool abRegisterInco=true, bool abDeleteOnRemove=false) override
 Adds this command to the module it belongs to. And makes it therefore callable. This function also checks if the parameter definitions match the types declared in the template parameters.
 
virtual void SetDefaults (ParamType... Default)
 
virtual ~TINOSTaskExCmdBaseParam ()
 Destructor.
 
- Public Member Functions inherited from CINOSTaskExCmdBase
virtual void SetPreDispatcher (const CINOSTaskExCmdHookBase *apPreDispatchHook)
 Sets the pre dispatch callback which is called before a message is of this command is dispatched.
 
virtual void SetOnMsgDone (const CINOSTaskExCmdHookBase *apOnMsgDoneHook)
 Sets the OnMsgDone callback which is called when MsgDone is called on a message of this command.
 
CINOSTaskExMsgCreateMsg (CINOSSync *apSync=DF_INOS_SYNCHRONOUS)
 Create a message of this command. Can be used for manual, customized call.
 
const charGetOption () const
 Returns the option string of this command.
 
const charGetName ()
 Returns the name of this command.
 
void SetName (const char *apName)
 Returns the name of this command.
 
CINOSTaskExMsgGetMsg ()
 Returns the message of this command.
 
void SetTask (CINOSTaskEx *apTask)
 
void AddParam (const char *apName, real64 arValue, real64 arMin, real64 arMax, const char *apUnit="", uint32 auChar=0, uint32 auFlags=0)
 Adds a real64 param description. This function may only be used if the param description has not be provided in the constructor. The funcion needs to be called in the same order as the template type definition.
 
void AddParam (const char *apName, const char *apValue, const char *apComboData=nullptr, uint32 auFlags=0)
 Adds a string (char*) param description. This function may only be used if the param description has not be provided in the constructor. The funcion needs to be called in the same order as the template type definition.
 
void AddParam (const char *apName, bool abValue, uint32 auFlags=0)
 Adds a bool param description. This function may only be used if the param description has not be provided in the constructor. The funcion needs to be called in the same order as the template type definition.
 
void SetAllowedStates (uint32 auStateBitmap)
 Sets the states in which this command is allowed to be called.
 
int operator< (CINOSTaskExCmdBase &aTaskExMsg)
 binary tree operators
 
int operator== (CINOSTaskExCmdBase &aTaskExMsg)
 
int operator< (const char *aName)
 
int operator== (const char *aName)
 
virtual ~CINOSTaskExCmdBase ()
 Destructor.
 
void Claim ()
 Claims the object of this command. This ensures that in case this command.
 
void Release (CINOSTaskExMsg *apMsg=nullptr)
 Releases the object of this command. This ensures that in case this command.
 

Protected Member Functions

virtual void Dispatch (CINOSTaskExMsg *apMsg)
 Dispatches a message if this command. Used by CINOSTaskEx.
 
virtual void DispatchTmd (CINOSTaskExMsg *apMsg)
 Dispatches a timed message if this command. Used by CINOSTaskEx.
 
- Protected Member Functions inherited from TINOSTaskExCmdBaseParam< ObjectType, ParamType... >
 TINOSTaskExCmdBaseParam (const char *apName, CINOSTaskEx *apTask, ObjectType *apObject, TINOSTaskExValDef< ParamType >... apDefaultParams, uint32 auStateBitmap, const char *apOption, uint64 auCharacteristics, uint16 auKeyLevel, bool abRegisterInco)
 Constructor (base constructor is protected, as this class is abstract)
 
CINOSTaskExMsgParamAddParam (CINOSTaskExMsg *apMsg, T aValue)
 
CINOSTaskExMsgParamAddParam (CINOSTaskExMsg *apMsg, const char *pValue)
 
- Protected Member Functions inherited from CINOSTaskExCmdBase
bool PreDispatch (CINOSTaskExMsg *apMsg)
 Function is called by the module (CINOSTaskEx) before the message of this command is dispatched.
 
void OnMsgDone (CINOSTaskExMsg *apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError)
 Function is called by the module (CINOSTaskEx) when MsgDone is called on a message of this command.
 
 CINOSTaskExCmdBase (const char *apName, CINOSTaskEx *apTask, uint32 auStateBitmap, const char *apOption, uint64 auCharacteristics, uint16 auKeyLevel, bool abRegisterInco)
 Constructor (base constructor is protected, as this class is abstract)
 
bool CheckParams (size_t count,...)
 Checks if thie added parameters match the template definition.
 
virtual void DeleteCommand ()
 Deletes the object of this command, dispatch if called from.
 

Additional Inherited Members

- Protected Attributes inherited from TINOSTaskExCmdBaseParam< ObjectType, ParamType... >
ObjectTypem_pObject
 Object of this command.
 
- Protected Attributes inherited from CINOSTaskExCmdBase
CINOSTaskExm_pTask
 Task of this command.
 
tPreDispatchFunction m_pPreDispatchFunction = nullptr
 Function that is called before messages of this command are dispatched.
 
tOnMsgDoneFunction m_pMsgDoneFunction = nullptr
 Function that is called when MsgDone is called on messages of this command.
 
uint64 m_uCharacteristics = 0
 Characteristics of the INCO registration of this commands.
 
uint64 m_uIsStructureBitmap = 0
 Bitmap that defines if the parameter corresponding to the bit number is a structure.
 
uint16 m_uKeyLevel = cKeyLevelMin
 Key level of the INCO registration of this commands.
 
bool m_bRegisterInco = true
 Defines if this command is registered to the INCO tree if not.
 
CINOSTaskExMsg m_CommandMsg
 Prototype message for this command.
 
CINOSTaskExMsgm_pRegisterMsg = nullptr
 Register message for this command (in the task ex for INCO tree)
 
uint32 m_uAllowedStates
 Bitmap of states in which this command is allowed to be called.
 
const charm_pOption = nullptr
 Option(s) of the module which are required for this command to be added.
 
std::atomic_ulong m_uReferenceCount
 Reference count for dynamically created and added objects. If count is 0 the.
 

Detailed Description

template<class ObjectType, typename... ParamType>
class TINOSTaskExCmd< ObjectType, ParamType >

Template class that can be used for methods that take the command parameters as function arguments.

Template Parameters
ObjectTypeType of the class this command is added to. Class must be inherited from CINOSTaskEx.
ParamType...List of types of the parameters of this command. Which corresponds to the arguments of the internal method.

Member Typedef Documentation

◆ tCommandFunction

template<class ObjectType , typename... ParamType>
typedef void(ObjectType::* TINOSTaskExCmd< ObjectType, ParamType >::tCommandFunction) (ParamType... Params)

Type of functions of this command. Functions of this type must be used in the constructor of this command.

Parameters
ParamsParamType... list of parameters according to the template parameters.

Constructor & Destructor Documentation

◆ TINOSTaskExCmd() [1/2]

template<class ObjectType , typename... ParamType>
TINOSTaskExCmd< ObjectType, ParamType >::TINOSTaskExCmd ( const char apName,
tCommandFunction  apFunction,
tCommandFunction  apFunctionTmd,
ObjectType aObject,
TINOSTaskExValDef< ParamType >...  apParamDefinitions,
uint32  auStateBitmap = 0xFFFFFFFF,
const char apOption = nullptr,
uint64  auCharacteristics = 0,
uint16  auKeyLevel = cKeyLevelMin,
bool  abRegisterInco = true 
)
inline

Constructor. This variant takes the parameter definitions and INCO item properties. It does not add the command to the command registry.

Parameters
apNameconst char* name of the command.
apFunctiontCommandFunction main function of this command. This function is called when the message of this command is dispatched.
m_pFunctionTmdtCommandFunction timed function of this command will be called immediately when this command msg is put into the queue even if the msg has a trigger.
aTaskObjectType the CINOSTaskEx to which this command belongs.
apParamDefinitionsTINOSTaskExValDef<ParamType>... The parameter definitions. A list of TINOSTaskExValDef with the types according to the template parameters.
auStateBitmapuint32 uint32 Bitmap of the allowed states, each bit represents if the according state. 1 = allowed, 0 = not-allowed.
Option(s)of the module which are required for this command to be added at startup. Options may be seperated by comma. Nullptr defines that the command is always registered. Empty string defines that is never registered at startup.
auCharacteristicsuint64 defines the characteristics of the item, e.g. defCharShowHex | defCharReadOnly
auKeyLeveluint16 defines the key level of the item, from cKeyLevelMin (default) to cKeyLevelMax.
abRegisterIncobool defines if the command should be registered to the inco tree.

This construction is intended to be used directly in the header file. Since C++11 direct member initialization in the header file is supported. To avoid defining the type of the command and parameter twice, list initialization (using curly brackets without =) should be used.

Simple Example: Lets assume the is an internal function void CEXPModule::iSwitchOn() That takes no parameters, should always be callable and is always available.

This function can be added as command by the following code:

TINOSTaskExCmd<CEXPModule> SwitchOn { "SwitchOn", &CEXPModule::iSwitchOn, nullptr, *this, };

Full example: Lets assume the is an internal function void CEXPModule::iMoveZ(double adPos, const char* apParam) that takes two parameters position "pos" as double and a parameter set "param" as string, is allowed in the states ready and busy and needs option Axs=Z. The function should also be called immediately if it has a trigger.

This function can be added as command by the following code:

TINOSTaskExCmd<CEXPModule, double, const char*> MoveZ { "MoveZ", &CEXPModule::iMoveZ, &CEXPModule::iMoveZ, *this, { "Pos", 0.0, REAL64MIN, REAL64MAX , "mm", defCharShowFix + SHOW_DIGIT(6)}, { "Param", ""}, STATIC_UINT32_BITMAP(eStaReady,eStaBusy), "Axs=Z" };

◆ TINOSTaskExCmd() [2/2]

template<class ObjectType , typename... ParamType>
TINOSTaskExCmd< ObjectType, ParamType >::TINOSTaskExCmd ( const char apName,
CINOSTaskEx apTask,
ObjectType apObject,
tCommandFunction  apFunction,
tCommandFunction  apFunctionTmd,
TINOSTaskExValDef< ParamType >...  apParamDefinitions,
uint32  auStateBitmap = 0xFFFFFFFF,
const char apOption = nullptr,
uint64  auCharacteristics = 0,
uint16  auKeyLevel = cKeyLevelMin,
bool  abRegisterInco = true 
)
inline

Constructor. This variant takes a separate object pointer and task pointer the command is only added to the registry if the task pointer is not null.

Parameters
apNameconst char* name of the command.
apFunctiontCommandFunction main function of this command. This function is called when the message of this command is dispatched.
m_pFunctionTmdtCommandFunction timed function of this command will be called immediately when this command msg is put into the queue even if the msg has a trigger.
aTaskObjectType the CINOSTaskEx to which this command belongs.
apParamDefinitionsTINOSTaskExValDef<ParamType>... The parameter definitions. A list of TINOSTaskExValDef with the types according to the template parameters.
auStateBitmapuint32 uint32 Bitmap of the allowed states, each bit represents if the according state. 1 = allowed, 0 = not-allowed.
Option(s)of the module which are required for this command to be added at startup. Options may be seperated by comma. Nullptr defines that the command is always registered. Empty string defines that is never registered at startup.
auCharacteristicsuint64 defines the characteristics of the item, e.g. defCharShowHex | defCharReadOnly
auKeyLeveluint16 defines the key level of the item, from cKeyLevelMin (default) to cKeyLevelMax.
abRegisterIncobool defines if the command should be registered to the inco tree.

This construction is intended to be used directly in the header file. Since C++11 direct member initialization in the header file is supported. To avoid defining the type of the command and parameter twice, list initialization (using curly brackets without =) should be used.

Simple Example: Lets assume the is an internal function void CEXPModule::iSwitchOn() That takes no parameters, should always be callable and is always available.

This function can be added as command by the following code:

TINOSTaskExCmd<CEXPModule> SwitchOn { "SwitchOn", &CEXPModule::iSwitchOn, nullptr, *this, };

Full example: Lets assume the is an internal function void CEXPModule::iMoveZ(double adPos, const char* apParam) that takes two parameters position "pos" as double and a parameter set "param" as string, is allowed in the states ready and busy and needs option Axs=Z. The function should also be called immediately if it has a trigger.

This function can be added as command by the following code:

TINOSTaskExCmd<CEXPModule, double, const char*> MoveZ { "MoveZ", &CEXPModule::iMoveZ, &CEXPModule::iMoveZ, *this, { "Pos", 0.0, REAL64MIN, REAL64MAX , "mm", defCharShowFix + SHOW_DIGIT(6)}, { "Param", ""}, STATIC_UINT32_BITMAP(eStaReady,eStaBusy), "Axs=Z" };

Member Function Documentation

◆ Dispatch()

template<class ObjectType , typename... ParamType>
virtual void TINOSTaskExCmd< ObjectType, ParamType >::Dispatch ( CINOSTaskExMsg apMsg)
inlineprotectedvirtual

Dispatches a message if this command. Used by CINOSTaskEx.

Parameters
apMsgCINOSTaskExMsg* message to be dispatched.

Implements CINOSTaskExCmdBase.

◆ DispatchTmd()

template<class ObjectType , typename... ParamType>
virtual void TINOSTaskExCmd< ObjectType, ParamType >::DispatchTmd ( CINOSTaskExMsg apMsg)
inlineprotectedvirtual

Dispatches a timed message if this command. Used by CINOSTaskEx.

Parameters
apMsgCINOSTaskExMsg* message to be dispatched.

Implements CINOSTaskExCmdBase.


The documentation for this class was generated from the following file: