FACT++  1.0
EventImp & StateMachineImp::AddEvent ( const std::string &  name,
const std::string &  states,
const std::string &  fmt 
)
protected

Calling this function, a new (named) event is added to the state machine. Via a call to CreateEvent a new event is created with the given targetstate, name and format.

The allowed states are passed to the new event and a message is written to the output-stream.

Parameters
nameThe command name which should initiate the transition. The DimCommand will be constructed with the name given to the constructor and this name, e.g. "DRIVE/CHANGE_STATE_TO_NEW_STATE"
statesA comma sepeareted list of ints, e.g. "1, 4, 5, 9" with states in which this new state transition is allowed and will be accepted.
fmtA format as defined by the dim system can be given for the command. However, it has no real meaning except that it is stored within the DimCommand object. However, the user must make sure that the data of received commands is properly extracted. No check is done.

Definition at line 529 of file StateMachineImp.cc.

References EventImp::AddAllowedStates(), CreateEvent(), fListOfEvents, fMutexEvt, Time::GetAsStr(), EventImp::GetName(), and MessageImp::Out().

Referenced by AddEvent(), DataLogger::DataLogger(), FitsLoader::FitsLoader(), StateMachineDimControl::StateMachineDimControl(), and Wrapper().

530 {
531  EventImp *evt = CreateEvent(name, fmt);
532 
533  evt->AddAllowedStates(states);
534 
535 #ifdef DEBUG
536  Out() << ": " << Time().GetAsStr("%H:%M:%S.%f");
537  Out() << " - Adding command " << evt->GetName();
538  Out() << endl;
539 #endif
540 
541  const lock_guard<mutex> guard(fMutexEvt);
542  fListOfEvents.push_back(evt);
543  return *evt;
544 }
void AddAllowedStates(const std::string &states)
Definition: EventImp.cc:151
A general base-class describing events issues in a state machine.
Definition: EventImp.h:11
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
std::ostream & Out() const
Definition: MessageImp.h:73
virtual EventImp * CreateEvent(const std::string &name, const std::string &fmt)=0
Is called when a configuration event is to be processed (no transition of state)
Warning states
Definition: smartfact.txt:92
std::vector< EventImp * > fListOfEvents
virtual std::string GetName() const
Definition: EventImp.h:51
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
Definition: Time.cc:240
std::mutex fMutexEvt
Mutex to ensure thread-safe access to the command fifo.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: