/* @filename ctrl_machine.h * @author Derek Ditch * @date 03 NOV 2008 * */ #ifndef CTRL_MACHINE_H_ #define CTRL_MACHINE_H_ #include #include #include #include #include #include #include namespace sc = boost::statechart; #include namespace mpl = boost::mpl; struct EvSwitch : sc::event< EvSwitch > {}; struct EvTemp : sc::event< EvTemp > {}; struct Fan1On; struct Fan1Off; struct Fan2On; struct Fan2Off; struct PowerOn; struct PowerOff; /* State Machine */ struct Controller : sc::state_machine< Controller, PowerOff > { Controller(); void setTemp( double p_temp ); int16_t getAirFlow(); void toggleSwitch(); bool m_switch; double m_temp; }; /* States */ struct PowerOff : sc::simple_state< PowerOff, Controller > { typedef sc::transition< EvSwitch, PowerOn > reactions; }; struct PowerOn : sc::simple_state< PowerOn, Controller, mpl::list< Fan1Off, Fan2Off > > { typedef sc::transition< EvSwitch, PowerOff > reactions; }; struct Fan1On : sc::simple_state< Fan1On, PowerOn::orthogonal< 0 > > { typedef sc::custom_reaction< EvTemp > reactions; sc::result react( const EvTemp & evt); }; struct Fan1Off : sc::simple_state< Fan1Off, PowerOn::orthogonal< 0 > > { typedef sc::custom_reaction< EvTemp > reactions; sc::result react( const EvTemp & ); }; struct Fan2On : sc::simple_state< Fan2On, PowerOn::orthogonal< 1 > > { typedef sc::custom_reaction< EvTemp > reactions; sc::result react( const EvTemp & ); }; struct Fan2Off : sc::simple_state< Fan2Off, PowerOn::orthogonal< 1 > > { typedef sc::custom_reaction< EvTemp > reactions; sc::result react( const EvTemp & ); }; #endif // CTRL_MACHINE_H_