Setup the allows states, configs and transitions for the data logger.
Default constructor. The name of the machine is given DATA_LOGGER and the state is set to kSM_Ready at the end of the function.
936 AddStateName(
kSM_Logging,
"Logging",
"The summary files for the night and the files for a single run are open.");
944 (
"Start the nightly logging. Nightly file location must be specified already");
948 (
"Stop all data logging, close all files.");
952 (
"Transition to exit error states. Closes the any open file.");
956 (
"Go to waiting for run number state. In this state with any received run-number a new file is opened.");
960 (
"Go from the wait for run to nightly open state.");
965 (
"Print information about the internal status of the data logger.");
973 "Path and base name used for the nightly files." 974 "|Type[int]:type of open files (1=log, 2=rep, 4=fits)" 975 "|Name[string]:path and base file name");
978 "Path and base name used for the run files." 979 "|Type[int]:type of open files (1=log, 2=rep, 4=fits)" 980 "|Name[string]:path and base file name");
985 "Num. open files + num. subscribed services" 986 "|NSubAndOpenFiles[int]:Num. of subs and open files");
993 string emptyString=
"";
996 "List of all the services subscribed by datalogger, except the ones provided by itself." 997 "|Liste[string]:list of logged services and the delay in seconds since last update");
1004 (
"Switch debug mode on or off. Debug mode prints information about every service written to a file." 1005 "|Enable[bool]:Enable of disable debug mode (yes/no).");
1009 (
"Interval in which the data-logger statistics service (STATS) is updated." 1010 "|Interval[ms]:Value in milliseconds (<=0: no update).");
1014 (
"Switch service which distributes information about the open files on or off." 1015 "|Enable[bool]:Enable of disable filename services (yes/no).");
1019 (
"Switch the service which distributes information about the number of subscriptions and open files on or off." 1020 "|Enable[bool]:Enable of disable NUM_SUBS service (yes/no).");
1024 (
"Set the timeout delay for old run numbers." 1025 "|timeout[min]:Time out in minutes after which files for expired runs are closed.");
1029 (
"Set the min interval between two services-list updates." 1030 "|duration[sec]:The interval between two updates, in seconds.");
1052 Debug(
"DataLogger Init Done.");
int PrintState(const Event &evt)
print the current state of the dataLogger
DimWriteStatistics fFilesStats
uint32_t numSubscriptions
the folder specified for Nightly logging does not exist or has bad permissions
EventImp & AddEvent(const std::string &name, const std::string &states, const std::string &fmt)
int fCurrentSubscriptionUpdateRate
Number of seconds since the last update of the subscribed list.
Mainloop running, state machine in operation.
int setSubscriptionListUpdateTimeLapse(const Event &evt)
set the duration between two updates. a zero or negative value disables the service updates ...
int SetOpenedFilesOnOff(const Event &evt)
void NotifyOpenedFile(const string &name, int type, DimDescribedService *service)
int Debug(const std::string &str)
bool fDestructing
boolean to prevent DIM update while desctructing the dataLogger
both files openned and writing
const std::string & GetName() const
ofstream fNightlyLogFile
ofstream for the NightlyLogfile
Adds some functionality to boost::posix_time::ptime for our needs.
Time GetNextSunRise(double horizon) const
bool fDebugIsOn
configuration flags
StateMachineDim(std::ostream &out=std::cout, const std::string &name="DEFAULT")
Time fPreviousOldRunNumberCheck
variable to track when the statistic were last calculated
DimDnsServiceList fDimList
Denots that an error occured while writing a daily file (text or fits).
string fFilePath
ofstream for the Nightly report file
char fileName[FILENAME_MAX]
void AddService(const Service &svc)
Add a new service subscription.
DimDescribedService * fOpenedNightlyFiles
Service for opened files.
distributes which files were opened.
int SetRunTimeoutDelay(const Event &evt)
unsigned int fRunNumberService
pointer to the dim's subscription that should distribute the run numbers.
int SetDebugOnOff(const Event &evt)
int GoToReady()
stop and reset transition
uint32_t fRunNumberTimeout
old run numbers time-out delay (in seconds)
DimDescribedService * fCurrentSubscription
Service for broadcasting subscription status.
int SetNumSubsAndFitsOnOff(const Event &evt)
void SetCallbackServiceAdd(const callback_svc &cb)
DimDescribedService * fNumSubAndFits
int BackToNightlyOpen()
from wait for run number to nightly open
Denotes that an error occured while writing a run file (text or fits).
DimDescribedService * fOpenedRunFiles
NumSubAndFitsType fNumSubAndFitsData
Error states should be between 0x100 and 0xffff.
list< RunNumberType > fRunNumber
run numbers
Nightly file openned and writing.
void AddServer(const string &server)
Add a new server subscription.
MessageImp fNightlyLogImp
Log stream to fNightlyLogFile.
int NightlyToWaitRun()
from NightlyOpen to waiting transition
void SetCallbackServerAdd(const callback_srv &cb)
bool AddStateName(const int state, const std::string &name, const std::string &doc="")
int Start()
start transition
unsigned int servicesCounter
int SetStatsPeriod(const Event &evt)
bool fDailyFileDayChangedAlready
boolean to know whether we should close and reopen daily files or not
Run number record. Used to keep track of which run numbers are still active.
void Subscribe(StateMachineImp &imp)
waiting for the run number to open the run file
Time fLastSubscriptionUpdate
The last time in seconds of the day when the service was update.