CommandHandler (FB) ¶ FUNCTION_BLOCK CommandHandler IMPLEMENTS ICmpEventCallback Command Handler for the PLCShell. This function block can be used as a base to register custom Command Handlers in the PLCShell. To implement a new Command Handler, just: extend this function block</li> Call SUPER^.Register() on FB_init</li> Overload CommandHandler() with your own command</li> An example in Pseudocode: FUNCTION BLOCK MyCommandHandler EXTENDS CommandHandler METHOD CommandHandler PlcShellAppend(‘The output of my command’, iBlockID); METHOD FB_init SUPER^.Register(‘myCmd’, ‘myCmd$r$n$tmyHelp’); METHOD FB_exit The registration is done in the function Register() and the deregistration is done in the FB_exit of the base FB. Methods: CommandHandler EventCallback FB_exit FB_init Register Structure: CommandHandler (Method) EventCallback (Method) FB_exit (Method) FB_init (Method) Register (Method)
CommandHandler.CommandHandler (METH) ¶ METHOD CommandHandler : UDINT InOut: Scope Name Type Return CommandHandler UDINT Input pszArguments REFERENCE TO STRING diBlockID DINT udiBlockSize UDINT
CommandHandler.EventCallback (METH) ¶ METHOD EventCallback : UDINT InOut: Scope Name Type Return EventCallback UDINT Input pEventParam POINTER TO EventParam
CommandHandler.FB_exit (METH) ¶ METHOD FB_exit InOut: Scope Name Type Input bInCopyCode BOOL
CommandHandler.FB_init (METH) ¶ METHOD FB_init InOut: Scope Name Type Input bInitRetains BOOL bInCopyCode BOOL
CommandHandler.Register (METH) ¶ METHOD Register InOut: Scope Name Type Input pszCommand REFERENCE TO STRING pszHelp REFERENCE TO STRING
PlcShellAppend (FUN) ¶ FUNCTION PlcShellAppend : RTS_IEC_RESULT Append a line to the command output The passed parameter iBlockID, has TO be the BlockID, which was passed to the command handler! The communication layer automatically manages the split of blocks. If you want to avoid this and write only the current block that is sent to CoDeSys, use the function PlcShellSkip(). RETURN: Returns the runtime system error code (see CmpErrors.library) InOut: Scope Name Type Return PlcShellAppend RTS_IEC_RESULT Input pszString REFERENCE TO STRING iBlockID DINT
EVTPARAM_PlcShellCommand (STRUCT) ¶ TYPE EVTPARAM_PlcShellCommand : STRUCT Event Parameter, passed to the Command Handler</b> The Command Handlers are called, using the event interface of the EventMgr. These are the parameters that are passed to the event. To get the parameters, you need to cast the element “pParameter” from the “pEventParam”, that is passed to the EventCallback. METHOD EventCallback : UDINT VAR_INPUT pEventParam : POINTER TO EventParam; END_VAR pParam := pEventParam^.pParameter; InOut: Name Type pszCommand REFERENCE TO STRING pszArguments REFERENCE TO STRING diBlockID DINT udiBlockSize UDINT
PlcShellRegister (FUN) ¶ FUNCTION PlcShellRegister : RTS_IEC_RESULT Register a new Command Handler The command is sent TO the handler as an event OF the EventMgr. So the CommandHandler needs to implement the Interface ICmpEventCallback. Note: For the ease of use, you can also derive your Command Handler from the FB “CommandHandler” in this library. This helps you in the registration and deregistration of the handler. RETURN: Returns the runtime system error code (see CmpErrors.library) InOut: Scope Name Type Return PlcShellRegister RTS_IEC_RESULT Input pszName REFERENCE TO STRING pszHelp REFERENCE TO STRING pICallback ICmpEventCallback
PlcShellSetEof (FUN) ¶ FUNCTION PlcShellSetEof : RTS_IEC_RESULT Set EOF This function should be called when the Command Handler is finished with it’s output. RETURN: Returns the runtime system error code (see CmpErrors.library) InOut: Scope Name Type Return PlcShellSetEof RTS_IEC_RESULT