class prsSEQ_MAIN_TASK : public evhDB_TASK { public: prsSEQ_MAIN_TASK(const dbSYMADDRESS dbPoint); ~prsSEQ_MAIN_TASK(); // Callbacks for public commands evhCB_COMPL_STAT ClearReadySetupCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT CenterObjCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT PrsAltAzCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT PrsCoordCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT PrsNamedPosCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT SetupCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT StopCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT SaveCurrSetupCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT SaveReadySetupCB(msgMESSAGE &msg, void *udata); virtual evhCB_COMPL_STAT ExitCB(msgMESSAGE &msg, void *udata); virtual evhCB_COMPL_STAT InitCB(msgMESSAGE &msg, void *udata); virtual evhCB_COMPL_STAT OnlineCB(msgMESSAGE &msg, void *udata); ccsCOMPL_STAT Init(); ccsCOMPL_STAT Recover(); protected: evhCB_COMPL_STAT Execute(msgMESSAGE &msg,vltLOGICAL moveFlag=prsMOVE); evhCB_COMPL_STAT ExeReadyCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT ExeErrorCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT StopOKCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT StopErrorCB(msgMESSAGE &msg, void *udata); ccsCOMPL_STAT RejectIfNotOnline(msgMESSAGE &msg, vltLOGICAL *rejected); oslxSETUP *readySetupFile; oslxSETUP *checkSetupFile; evhDB_COMMAND stopCmd; evhDB_COMMAND presetCmd; private: msgMESSAGE stopMsg; msgMESSAGE setupMsg; // Configuration parameters (read from DB) in Init(): vltBYTES64 readySetup; vltBYTES64 defaultSetup; vltBYTES64 currentSetup; vltBYTES64 setupDictionary; vltBYTES64 setupAliasTable; vltINT32 readyTimeout; vltINT32 stopTimeout; };
evhDB_TASK
An instance of this class is the core of the prsSeqncr program and is used receive and handle Preset commands and to perform all the "administrative work" to check and handle setup files and configuration. When it is created it registers the callbacks for the supported commands and reads from the online database the configuration parameters. Whenever one of these commands is received, the corresponding action is issued.
prsSEQ_MAIN_TASK(const dbSYMADDRESS dbPoint) The constructor receives as parameter the symbolic address of online database support point for the object, i.e. the point where the object can find configuration and run time values. It prepares all the internal structures, install the callbacks and call Init() to read and initialize all configuration parms. ~prsAH_MAIN_TASK() evhCB_COMPL_STAT ClearReadySetupCB(msgMESSAGE &msg, void *udata) The ready to run setup file is replaced with the reference setup file, where all the entries have default values. The Execute() method is called with "NOMOVE" evhCB_COMPL_STAT CenterObjCB(msgMESSAGE &msg, void *udata); Sets to YES the corresponding entry in the ready to run setup file. The Execute() method is called with "MOVE" evhCB_COMPL_STAT PrsAltAzCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT PrsCoordCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT PrsNamedPosCB(msgMESSAGE &msg, void *udata); Preset to give coordinates ( Real coordinate, Alt/Az or predefined position) Converts the parameters in setup file entries and generates a new ready to run setup file merging the given information with the ready to run setup file. Sets also the type of coordinates in the setup file All the optional parameters will keep the current value in the ready to run setup file, if not specified. The Execute() method is called with "MOVE" evhCB_COMPL_STAT SetupCB(msgMESSAGE &msg, void *udata); Generates a new ready to run setup file merging the given setup files and individual parameters settings with the actual ready to run setup file. The incoming setup information is checked for syntax errors. The Execute() method is called. evhCB_COMPL_STAT StopCB(msgMESSAGE &msg, void *udata); Send the stop command to the Preset Action Handling and installs callbacks for the reply and the error reply. evhCB_COMPL_STAT SaveCurrSetupCB(msgMESSAGE &msg, void *udata); evhCB_COMPL_STAT SaveReadySetupCB(msgMESSAGE &msg, void *udata); Saves the current setup file or the ready setup file with the given name. evhCB_COMPL_STAT InitCB(msgMESSAGE &msg, void *udata); This is called when the INIT or ONLINE command is received. If the message buffer contains the prsMGS_BUFF_ALL string value, the command is first propagated to prsAction. Anyway the system does not wait for replies and does not handle error conditions due to failure in INIT for prsAction virtual evhCB_COMPL_STAT OnlineCB(msgMESSAGE &msg, void *udata); This callback is called when the ONLINE command is received. If the module is already ONLINE, sends back a reply and returns, otherwise it behaves like InitCB. ccsCOMPL_STAT Init() Overwrite of the Init method inherited from the base class. Reads from the database all the configuration parameters. This method is called also by the inherited InitCB whenever an Init() command is received. If a setup is on course it is aborted. ccsCOMPL_STAT Recover(); Try to recover from a severe error. It can be used for example (like in prsControl) when a callback generates a severe error e make the main loop to return. The main can then try to recover using this method and to go back in the main-loop. It calls Init() to reinitialize the objects. Is a setup is on course it is aborted. evhCB_COMPL_STAT ExitCB(msgMESSAGE &msg, void *udata); Overload the inherited callback. It first propagate the command to prsAction, without waiting for any reply
evhCB_COMPL_STAT Execute(msgMESSAGE &msg, vltLOGICAL moveFlag = prsMOVE); This method starts the actual setup. It receives as first parameter the incoming message with the command requesting for the setup and as second parameter a flag to specify if the setup must be executed (prsMOVE) or only stored in the setup file (prsNOMOVE). It also saves on file the new ready to run setup file. If it is a preset with prsMOVE, it sends the PRESET command to the Preset Action Handling and installs callbacks for the reply and the error reply. It sets the state to PRESETTING. evhCB_COMPL_STAT ExeReadyCB(msgMESSAGE &msg, void *udata); Receive the replies from prsAction to PRESET commands. When it receives the last reply, send back the final reply to the originator and set the state to prsATATE_READY evhCB_COMPL_STAT ExeErrorCB(msgMESSAGE &msg, void *udata); This callback is called when a PRESET command to prsAction timeouts or gets an error reply. It sends an error reply to the originator and sets back the state to prsSTATE_READY evhCB_COMPL_STAT StopOKCB(msgMESSAGE &msg, void *udata); This callback is executed when the tracking has been stopped. It sends back the READY reply to the originator. evhCB_COMPL_STAT StopErrorCB(msgMESSAGE &msg, void *udata); This callback is executed when the STOP/STOPTRK request has failed, both for a timeout or because an error reply has been received. It sends back the READY error reply to the originator. ccsCOMPL_STAT RejectIfNotOnline(msgMESSAGE &msg, vltLOGICAL *rejected); Gets a message containing a received command. If current state is not ONLINE, the command is rejected, and an error reply is returned. In this case the returned value in "rejected" == TRUE, otherwise it is
oslxSETUP *readySetup; object to handle the ready setup file oslxSETUP *checkSetup; object to handle checking of SETUP commands evhCOMMAND stopCmd; to handle the sending of STOP command evhCOMMAND presetCmd; to handle the sending of PRESET command msgMESSAGE stopMsg; local copy of the received STOP message msgMESSAGE setupMsg; local copy or the setup message Configuration parameters: char *defaultSetup name of the default setup file double readyTimeout timeout for setup ready double stopTimeout timeout for stop completed
State values: Defines for the MOVE/NOMOVE flag in Execute() #define prsNOMOVE 0 #define prsMOVE 1
The class shares with prsSEQ_STD_COMMANDS an instance of the prsCONTROL class. CLASS evhSTD_COMMANDS prsCONTROL
ATTRIBUTE BYTES64 readySetup "prsReadySetup.targ" ATTRIBUTE BYTES64 defaultSetup "prsDefaultSetup.targ" ATTRIBUTE BYTES64 currentSetup "prsCurrentSetup.targ" ATTRIBUTE BYTES64 setupDic "ESO-VLT-DIC.TCS" ATTRIBUTE BYTES64 setupAlias "prs.alias" ATTRIBUTE INT32 readyTimeout 0 ATTRIBUTE INT32 stopTimeout 0 ATTRIBUTE evhDB_COMMAND presetDbCmd
ATTRIBUTE BYTES32 destination "prsAction"
ATTRIBUTE evhDB_COMMAND stopDbCmd
ATTRIBUTE BYTES32 destination "prsAction"
ATTRIBUTE evhDB_COMMAND actionStdDbCmd
ATTRIBUTE BYTES32 destination "prsAction"
Here it is not considered a fatal error not to be able to send back a reply to the originator of a command: an error is logged, but it is recoved since it has no effect on the behaviour of the task itself.
evhDB_TASK(4)