#ifndef chsm_1559 #define chsm_1559 /***** <> *****/ #include namespace CHSM_ns_alias = CHSM_NS; /***** user-declarations *****/ #line 1 "JDAQCHSM.chsm" #include "chsm.h" #include #include /** * DAQ state machine interface. */ class JDAQCHSM : public CHSM::machine { public: /** * DAQ state class. * * The member method enter() makes a call to the virtual method JDAQCHSM::enterState(...), * where: * - first argument is the state entered; * - second argument is the event that caused the transition; * * This method should be overwritten by the run control client to reply to the run control. */ class JDAQState : public CHSM::state { public: /** * Default CHSM constructor. */ JDAQState(CHSM_STATE_ARGS) : CHSM::state(CHSM_STATE_INIT) {} /** * Enter this state. * * \param event event that triggered transition * \param from pointer to state from where transition started * \return true if all OK; else false */ bool enter(const CHSM::event& event, CHSM::state* from) { try { dynamic_cast(this->chsm()).enterState(*this, event); return CHSM::state::enter(event, from); } catch(const std::exception& error) { return false; } } }; /** * Constructor. * * \param __name name of state machine */ JDAQCHSM(CHSM_MACHINE_ARGS, const std::string& __name) : CHSM::machine(CHSM_MACHINE_INIT), name (__name), detector_id(-1), run_number (-1) {} /** * Get name of state machine. * * \return name */ const std::string& getName() const { return name; } /** * Get detector identifier. * * \return detector identifier. */ int getDetectorID() const { return detector_id; } /** * Get run number. * * \return run number */ int getRunNumber() const { return run_number; } /** * Interface methods for actions corresponding to state transitions. */ virtual void actionEnter() {} virtual void actionExit() {} virtual void actionInit (int, const char*) {} virtual void actionConfigure (int, const char*) {} virtual void actionStart (int, const char*) {} virtual void actionPause (int, const char*) {} virtual void actionContinue (int, const char*) {} virtual void actionStop (int, const char*) {} virtual void actionReset (int, const char*) {} virtual void actionQuit (int, const char*) {} virtual void actionCheck(int, const char*) {} virtual void actionInput(int, const char*) {} virtual void actionError() {} virtual void actionRecover(int, const char*) {} protected: /** * Action when entering state. * * \param state entered state * \param event event that triggered transition */ virtual void enterState(const CHSM::state& state, const CHSM::event& event) = 0; /** * Type definition of action method. */ typedef void (JDAQCHSM::*action)(int, const char*); /** * The method to execute the action. * * This method shall be implemented in the derived class. * * \param __action pointer to action method * \param __event event that triggered the action */ virtual void execute(action __action, const CHSM::event& __event) = 0; std::string name; int detector_id; int run_number; }; /***** CHSM class declaration *****/ class JDAQStateMachine : public JDAQCHSM { public: JDAQStateMachine( const std ::string ); ~JDAQStateMachine(); // states class state_root : public CHSM_ns_alias::cluster { // -1 public: state_root( CHSM_STATE_ARGS, bool chsm_history_ ); private: static int const children_[]; } root; class state_Main : public CHSM_ns_alias::set { // 0 public: class state_RunControl : public CHSM_ns_alias::cluster { // 1 public: class state_Operational : public CHSM_ns_alias::cluster { // 2 public: JDAQState Idle; // 3 JDAQState Standby; // 4 JDAQState Ready; // 5 JDAQState Paused; // 6 JDAQState Running; // 7 state_Operational( CHSM_STATE_ARGS, bool chsm_history_ ); private: static int const children_[]; } Operational; JDAQState Error; // 8 state_RunControl( CHSM_STATE_ARGS, bool chsm_history_ ); private: static int const children_[]; } RunControl; CHSM_ns_alias::state Responder; // 9 state_Main( CHSM_STATE_ARGS ); private: static int const children_[]; } Main; // events private: static int const ev_daq_transitions[]; public: class ev_daq_event : public CHSM_ns_alias::event { public: typedef CHSM_ns_alias::event::param_block base_param_block; struct param_block : CHSM_ns_alias::event::param_block { #line 172 "JDAQCHSM.chsm" int length; #line 172 "JDAQCHSM.chsm" const char * buffer; param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_daq_event( CHSM_EVENT_ARGS ) : CHSM_ns_alias::event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_daq; char ev_daq_param_block[ sizeof( ev_daq_event::param_block ) ]; private: static int const ev_init_transitions[]; public: class ev_init_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_init_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_init; char ev_init_param_block[ sizeof( ev_init_event::param_block ) ]; private: static int const ev_configure_transitions[]; public: class ev_configure_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_configure_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_configure; char ev_configure_param_block[ sizeof( ev_configure_event::param_block ) ]; private: static int const ev_start_transitions[]; public: class ev_start_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_start_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_start; char ev_start_param_block[ sizeof( ev_start_event::param_block ) ]; private: static int const ev_pause_transitions[]; public: class ev_pause_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_pause_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_pause; char ev_pause_param_block[ sizeof( ev_pause_event::param_block ) ]; private: static int const ev_continue_transitions[]; public: class ev_continue_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_continue_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_continue; char ev_continue_param_block[ sizeof( ev_continue_event::param_block ) ]; private: static int const ev_stop_transitions[]; public: class ev_stop_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_stop_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_stop; char ev_stop_param_block[ sizeof( ev_stop_event::param_block ) ]; private: static int const ev_reset_transitions[]; public: class ev_reset_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_reset_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_reset; char ev_reset_param_block[ sizeof( ev_reset_event::param_block ) ]; private: static int const ev_quit_transitions[]; public: class ev_quit_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_quit_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_quit; char ev_quit_param_block[ sizeof( ev_quit_event::param_block ) ]; private: static int const ev_off_transitions[]; public: class ev_off_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_off_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_off; char ev_off_param_block[ sizeof( ev_off_event::param_block ) ]; private: static int const ev_check_transitions[]; public: class ev_check_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_check_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_check; char ev_check_param_block[ sizeof( ev_check_event::param_block ) ]; private: static int const ev_input_transitions[]; public: class ev_input_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_input_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_input; char ev_input_param_block[ sizeof( ev_input_event::param_block ) ]; private: static int const ev_recover_transitions[]; public: class ev_recover_event : public JDAQStateMachine::ev_daq_event { public: typedef JDAQStateMachine::ev_daq_event::param_block base_param_block; struct param_block : JDAQStateMachine::ev_daq_event::param_block { param_block( CHSM_ns_alias::event const &, int , const char * ); protected: virtual ~param_block(); }; param_block* operator->() const { return (param_block*)param_block_; } void operator()( int , const char * ); protected: ev_recover_event( CHSM_EVENT_ARGS ) : JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_recover; char ev_recover_param_block[ sizeof( ev_recover_event::param_block ) ]; private: static int const ev_error_transitions[]; public: class ev_error_event : public CHSM_ns_alias::event { public: typedef CHSM_ns_alias::event::param_block base_param_block; struct param_block : CHSM_ns_alias::event::param_block { param_block( CHSM_ns_alias::event const &event ) : CHSM_ns_alias::event::param_block( event ) { } protected: virtual ~param_block(); }; protected: ev_error_event( CHSM_EVENT_ARGS ) : CHSM_ns_alias::event( CHSM_EVENT_INIT ) { } friend class JDAQStateMachine; } ev_error; char ev_error_param_block[ sizeof( ev_error_event::param_block ) ]; // transition conditions // transition targets // transition actions void A1( CHSM_ns_alias::event const& ); void A2( CHSM_ns_alias::event const& ); void A3( CHSM_ns_alias::event const& ); void A4( CHSM_ns_alias::event const& ); void A5( CHSM_ns_alias::event const& ); void A6( CHSM_ns_alias::event const& ); void A7( CHSM_ns_alias::event const& ); void A8( CHSM_ns_alias::event const& ); void A9( CHSM_ns_alias::event const& ); void A10( CHSM_ns_alias::event const& ); void A11( CHSM_ns_alias::event const& ); void A12( CHSM_ns_alias::event const& ); void A13( CHSM_ns_alias::event const& ); void A14( CHSM_ns_alias::event const& ); // enter/exit actions void EAM4root( CHSM_ns_alias::state const&, CHSM_ns_alias::event const& ); void XAM4root( CHSM_ns_alias::state const&, CHSM_ns_alias::event const& ); private: CHSM_ns_alias::state *state_[ 11 ]; static CHSM_ns_alias::transition const transition_[]; CHSM_ns_alias::event const *taken_[ 14 ]; CHSM_ns_alias::state *target_[ 14 ]; }; /***** THE END *****/ #endif