Reporting method for the services info received.
1323 const bool isItaReport = fmt!=
"C";
1344 if (
lastFlush < timeNow-boost::posix_time::minutes(1))
1347 SubscriptionsListType::iterator x;
1348 map<string, SubscriptionType>::iterator y;
1351 for (y=x->second.begin(); y!=x->second.end();y++)
1352 if (y->second.nightlyFile.IsOpen())
1354 y->second.nightlyFile.Flush();
1358 Debug(
"Just flushed nightly fits files to the disk");
1366 SubscriptionsListType::iterator x;
1367 map<string, SubscriptionType>::iterator y;
1370 for (y=x->second.begin(); y!=x->second.end();y++)
1372 if (y->second.nightlyFile.IsOpen())
1374 y->second.nightlyFile.Close();
1376 y->second.increment = 0;
1381 Debug(
"Day have changed! Closing and reopening nightly files");
1411 if (!sub.
fConv->valid())
1414 str <<
"Couldn't properly parse the format... service " << evt.
GetName() <<
" ignored.";
1420 ostringstream header;
1429 fMjD = cTime.Mjd() ? cTime.Mjd()-40587 : 0;
1479 if (!sub.nightlyFile.IsOpen())
1482 WriteToFITS(sub, evt.
GetData());
1487 vector<string> strings;
1492 catch (
const runtime_error &e)
1495 str <<
"Parsing service " << evt.
GetName();
1496 str <<
" failed: " << e.what() <<
" removing the subscription for now.";
1503 if (strings.size() > 1)
1506 err <<
"There was more than one string message in service " << evt.
GetName() <<
" going to fatal error state";
1510 bool isMessage = (sub.
service ==
"MESSAGE");
1512 string serviceName = isMessage ?
"" :
"_"+sub.
service;
1513 msg << sub.
server << serviceName;
1525 msg <<
"[" << fQuality <<
"]";
1530 if (isMessage && (fQuality ==
kAlarm) && (strings[0] ==
""))
1533 strings[0] =
"Alarm reset";
1535 msg <<
": " << strings[0];
1546 fQuality = backup_quality;
1549 if (!sub.nightlyFile.IsOpen())
1552 WriteToFITS(sub, evt.
GetData());
the folder specified for Nightly logging does not exist or has bad permissions
void updateSubscriptionList()
update the service
Mainloop running, state machine in operation.
int GetCurrentState() const
return the current state of the machine
int Debug(const std::string &str)
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
bool CheckForOfstreamError(ofstream &out, bool isDailyStream)
Checks if the input osftream is in error state, and if so close it.
Time lastReceivedEvent
time of the latest received event
string fFilePath
ofstream for the Nightly report file
std::ostream & Out() const
An info telling something which can be interesting to know.
Just a message, usually obsolete.
int GoToReady()
stop and reset transition
virtual int Write(const Time &time, const std::string &txt, int qos=kMessage)
virtual Time GetTime() const
virtual std::string GetFormat() const
int Error(const std::string &str)
virtual int GetQoS() const
bool OpenTextFile(ofstream &stream, const string &name)
Subscribe to a given server and service.
int fQuality
Current Service Quality.
SubscriptionsListType fServiceSubscriptions
All the services to which we have subscribed to, sorted by server name.
shared_ptr< Converter > fConv
the converter for outputting the data according to the format
virtual std::string GetName() const
Error, something unexpected happened, but needs user intervention (i.e. it needs a signal to the user...
void RemoveService(const string, const string, bool)
Remove a given service subscription.
double fMjD
Modified Julian Date.
int Info(const std::string &str)
string fFullNightlyLogFileName
full name of the nightly log file
MessageImp fNightlyLogImp
Log stream to fNightlyLogFile.
virtual const void * GetData() const
A compiler for the DIM data format string.
string service
the service
string CompileFileNameWithPath(const string &path, const string &service, const string &extension)
Get the digits of year, month and day for filenames and paths.
virtual size_t GetSize() const
std::string SetCurrentState(int state, const char *txt="", const std::string &cmd="")