FACT++  1.0
StateMachineSmartFACT Class Reference
+ Inheritance diagram for StateMachineSmartFACT:
+ Collaboration diagram for StateMachineSmartFACT:


struct  EventElement
class  EventHist
struct  Statistics

Public Member Functions

 StateMachineSmartFACT (ostream &out=cout)
int EvalOptions (Configuration &conf)
- Public Member Functions inherited from StateMachineDim
 StateMachineDim (std::ostream &out=std::cout, const std::string &name="DEFAULT")
int Write (const Time &time, const std::string &txt, int qos=kMessage)
 Redirect our own logging to fLog. More...
bool AddStateName (const int state, const std::string &name, const std::string &doc="")
bool MessageQueueEmpty () const
- Public Member Functions inherited from DimCommandHandler
DimCommandgetCommand ()
virtual ~DimCommandHandler ()
- Public Member Functions inherited from DimInfoHandler
DimInfogetInfo ()
virtual ~DimInfoHandler ()
- Public Member Functions inherited from DimErrorRedirecter
 DimErrorRedirecter (MessageImp &imp)
 ~DimErrorRedirecter ()
- Public Member Functions inherited from DimErrorHandler
virtual ~DimErrorHandler ()
- Public Member Functions inherited from DimExitHandler
virtual ~DimExitHandler ()
- Public Member Functions inherited from StateMachineImp
 StateMachineImp (std::ostream &out=std::cout, const std::string &name="")
 ~StateMachineImp ()
 delete all object stored in fListOfEvent and in fEventQueue More...
std::function< int(const EventImp &)> Wrap (const std::function< int(const EventImp &)> &func)
const std::string & GetName () const
EventImpSubscribe (const std::string &name)
void Unsubscribe (EventImp *evt)
int GetCurrentState () const
 return the current state of the machine More...
void SetReady ()
void SetNotReady ()
virtual int Run (bool dummy)
 Start the mainloop. More...
int Run ()
virtual void Stop (int code=0)
 Request to stop the mainloop. More...
bool IsRunning () const
 Used to check if the main loop is already running or still running. More...
void EnableBuffer (bool b=true)
 Used to enable or disable buffering of events outside of the main loop. More...
bool PostEvent (std::ostream &lout, const std::string &str)
 Post an event to the event queue. More...
bool PostEvent (const std::string &evt)
bool PostEvent (const EventImp &evt)
bool PostEvent (const EventImp &evt, const char *ptr, size_t siz)
bool HasEvent (const EventImp *cmd)
EventImpFindEvent (const std::string &evt)
bool IsQueueEmpty () const
const std::vector< std::string > GetEventNames ()
void PrintListOfEvents (std::ostream &out, const std::string &evt="")
void PrintListOfEvents (const std::string &str="")
void PrintListOfAllowedEvents (std::ostream &out)
void PrintListOfAllowedEvents ()
void PrintListOfStates (std::ostream &out) const
void PrintListOfStates () const
 Print a list of all states with descriptions. More...
int GetStateIndex (const std::string &name) const
bool HasState (int index) const
const std::string GetStateName (int state) const
const std::string GetStateName () const
const std::string GetStateDesc (int state) const
const std::string GetStateDesc () const
const std::string GetStateDescription (int state) const
const std::string GetStateDescription () const
- Public Member Functions inherited from MainImp
virtual ~MainImp ()
- Public Member Functions inherited from MessageImp
 MessageImp (std::ostream &out=std::cout)
virtual ~MessageImp ()
virtual void IndicateStateChange (const Time &, const std::string &)
void StateChanged (const Time &time, const std::string &server, const std::string &msg, int state)
int Update (const std::string &txt, int severity=kMessage)
int Update (const char *txt, int severity=kMessage)
int Update (const std::ostringstream &str, int severity=kMessage)
int Debug (const std::string &str)
int Message (const std::string &str)
int Info (const std::string &str)
int Warn (const std::string &str)
int Error (const std::string &str)
int Alarm (const std::string &str)
int Fatal (const std::string &str)
int Comment (const std::string &str)
int Debug (const char *txt)
int Message (const char *txt)
int Info (const char *txt)
int Warn (const char *txt)
int Error (const char *txt)
int Alarm (const char *txt)
int Fatal (const char *txt)
int Comment (const char *txt)
int Debug (const std::ostringstream &str)
int Message (const std::ostringstream &str)
int Info (const std::ostringstream &str)
int Warn (const std::ostringstream &str)
int Alarm (const std::ostringstream &str)
int Error (const std::ostringstream &str)
int Fatal (const std::ostringstream &str)
int Comment (const std::ostringstream &str)
std::ostream & operator() () const
std::ostream & Out () const

Static Public Attributes

static bool fIsServer = false

Private Types

enum  states_t { kStateDimNetworkNA = 1, kStateRunning }
enum  weather_t {
  kWeatherBegin =0, kTemp = kWeatherBegin, kDew, kHum,
  kPress, kWind, kGusts, kDir,
  kWeatherEnd = kDir+1

Private Member Functions

string Header (const Time &d)
string Header (const EventImp &d)
void SetAudio (const string &name)
string GetDir (const double angle)
bool CheckDataSize (const EventImp &d, const char *name, size_t size, bool min=false)
template<class T >
void WriteBinaryVec (const Time &tm, const string &fname, const vector< T > &vec, double scale, double offset=0, const string &title="", const string &col="")
template<class T >
void WriteHist (const EventImp &d, const string &fname, const T &t, double scale, double offset=0)
template<class T >
void WriteCam (const EventImp &d, const string &fname, const T &t, double scale, double offset=0)
void HandleControlMessageImp (const EventImp &d)
int HandleDimControlMessage (const EventImp &d)
int HandleControlStateChange (const EventImp &d)
void AddMcpConfigurationHist (const EventImp &d, const string &msg)
int HandleFscControlStateChange (const EventImp &d)
int HandleMcpConfiguration (const EventImp &d)
void WriteWeather (const EventImp &d, const string &name, int i, float min, float max)
int HandleMagicWeatherData (const EventImp &d)
int HandleTngWeatherDust (const EventImp &d)
int HandleDriveControlStateChange (const EventImp &d)
int HandleDrivePointing (const EventImp &d)
int HandleDriveTracking (const EventImp &d)
int HandleDriveSource (const EventImp &d)
int HandleFeedbackCalibratedCurrents (const EventImp &d)
int HandleBiasCurrent (const EventImp &d)
int HandleBiasVoltage (const EventImp &d)
int HandleFadEvents (const EventImp &d)
int HandleFadStartRun (const EventImp &d)
int HandleFadDrsRuns (const EventImp &d)
int HandleFadConnections (const EventImp &d)
int HandleFtmTriggerRates (const EventImp &d)
int HandleFtmStaticData (const EventImp &d)
int HandleFtmFtuList (const EventImp &d)
int HandleFadEventData (const EventImp &d)
int HandleStats (const EventImp &d)
int HandleFscTemperature (const EventImp &d)
int HandleFscBiasTemp (const EventImp &d)
int HandleFscHumidity (const EventImp &d)
int HandlePfMiniData (const EventImp &d)
int HandleGpsNema (const EventImp &d)
int HandleSqmData (const EventImp &d)
string GetTempColor (float t)
int HandleTemperatureData (const EventImp &d)
int HandleAgilentData (const EventImp &d, const string &ext)
int HandleRateScanData (const EventImp &d)
int HandleRateControlThreshold (const EventImp &d)
int HandleChatMsg (const EventImp &d)
int HandleDoTest (const EventImp &d)
int Print () const
string GetStateHtml (const DimState &state, int green) const
bool SetError (bool b, const string &err)
void UpdateAstronomy ()
int Execute ()
 Is called continously to execute actions in the current state. More...

Private Attributes

const Time fRunTime
PixelMap fPixelMap
string fDatabase
Time fLastUpdate
Time fLastAstroCalc
string fPath
EventHist fControlMessageHist
EventHist fControlAlarmHist
int32_t fControlScriptDepth
int32_t fMcpConfigurationState
int64_t fMcpConfigurationMaxTime
int64_t fMcpConfigurationMaxEvents
string fMcpConfigurationName
Time fMcpConfigurationRunStart
EventHist fMcpConfigurationHist
bool fLastRunFinishedWithZeroEvents
deque< float > fMagicWeatherHist [kWeatherEnd]
deque< float > fTngWeatherDustHist
Time fTngWeatherDustTime
vector< float > fBiasControlVoltageVec
float fBiasControlPowerTot
float fBiasControlVoltageMed
float fBiasControlCurrentMed
float fBiasControlCurrentMax
deque< float > fBiasControlCurrentHist
deque< float > fFscControlTemperatureHist
float fFscControlHumidityAvg
deque< float > fPfMiniHumidityHist
deque< float > fPfMiniTemperatureHist
deque< float > fTemperatureControlHist
float fDriveControlPointingZd
string fDriveControlPointingAz
string fDriveControlSourceName
float fDriveControlMoonDist
deque< float > fDriveControlTrackingDevHist
int64_t fFadControlNumEvents
int64_t fFadControlStartRun
int32_t fFadControlDrsStep
vector< uint32_t > fFadControlDrsRuns
deque< float > fFtmControlTriggerRateHist
int32_t fFtmControlTriggerRateTooLow
int fFtmControlState
float fFtmPatchThresholdMed
float fFtmBoardThresholdMed
bool fFtmControlFtuOk
deque< float > fRateControlThreshold
uint64_t fRateScanDataId
uint8_t fRateScanBoard
deque< float > fRateScanDataHist [41]
set< string > fErrorList
EventHist fErrorHist
EventHist fChatHist
uint64_t fFreeSpace
Sun fSun
Moon fMoon
Time fAudioTime
string fAudioName
DimVersion fDimDNS
DimControl fDimControl
DimDescribedState fDimMcp
DimDescribedState fDimDataLogger
DimDescribedState fDimDriveControl
DimDescribedState fDimTimeCheck
DimDescribedState fDimMagicWeather
DimDescribedState fDimMagicLidar
DimDescribedState fDimTngWeather
DimDescribedState fDimTemperature
DimDescribedState fDimFeedback
DimDescribedState fDimBiasControl
DimDescribedState fDimFtmControl
DimDescribedState fDimFadControl
DimDescribedState fDimFscControl
DimDescribedState fDimPfMiniControl
DimDescribedState fDimGpsControl
DimDescribedState fDimSqmControl
DimDescribedState fDimAgilentControl24
DimDescribedState fDimAgilentControl50
DimDescribedState fDimAgilentControl80
DimDescribedState fDimPwrControl
DimDescribedState fDimLidControl
DimDescribedState fDimRateControl
DimDescribedState fDimRateScan
DimDescribedState fDimChat
DimDescribedState fDimSkypeClient

Additional Inherited Members

- Public Types inherited from StateMachineImp
enum  DefaultStates_t {
  kSM_KeepState = -42, kSM_NotAvailable = -2, kSM_NotReady = -1, kSM_Ready = 0,
  kSM_UserMode = 1, kSM_Error = 0x100, kSM_FatalError = 0xffff
- Public Types inherited from MessageImp
enum  Severity {
  kMessage = 10, kInfo = 20, kWarn = 30, kError = 40,
  kAlarm = 45, kFatal = 50, kComment = 90, kDebug = 99
 Severity of a message. More...
- Public Attributes inherited from DimCommandHandler
- Public Attributes inherited from DimInfoHandler
- Protected Member Functions inherited from StateMachineDim
std::string SetCurrentState (int state, const char *txt="", const std::string &cmd="")
void Lock ()
void UnLock ()
- Protected Member Functions inherited from DimStart
 DimStart (const std::string &name, MessageImp &imp)
 ~DimStart ()
- Protected Member Functions inherited from StateMachineImp
virtual void PushEvent (Event *cmd)
 This is a flag which is set true if the main loop should stop. More...
std::shared_ptr< EventPopEvent ()
 Pop a command from the fifo. More...
bool HandleNewState (int newstate, const EventImp *evt, const char *txt)
bool HandleEvent (const EventImp &evt)
EventImpAddEvent (const std::string &name, const std::string &states, const std::string &fmt)
EventImpAddEvent (const std::string &name, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1)
EventImpAddEvent (const std::string &name, const std::string &fmt, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1)
void SetDefaultStateNames ()
- Protected Attributes inherited from StateMachineImp
StateNames fStateNames
 Human readable names associated with the states. More...
bool fRunning
 Flag if events should be buffered outside the event loop. More...
int fExitRequested
 Machine is in main-loop. More...

Detailed Description

Definition at line 439 of file smartfact.cc.

The documentation for this class was generated from the following file: