// Author: David Lawrence August 23, 2014 // // // hdmon.cc // #include #include "DANA/DApplication.h" using namespace std; void Usage(JApplication &app); //----------- // main //----------- int main(int narg, char *argv[]) { // Instantiate an event loop object DApplication app(narg, argv); if(narg<=1)Usage(app); // Start RootSpy thread giving it out JApplication's rwlock // (to get pointer to it, we must lock and then unlock it) app.RootReadLock(); pthread_rwlock_t *root_rwlock = app.RootUnLock(); DRootSpy *rs = new DRootSpy(root_rwlock); gROOTSPY_PROGRAM_NAME = "hdmon"; // sim-recon contains a large number of histograms to hold // covariance matrices. Filter those from responses so they // are not seen by remote processes. rs->AddNameFilter("covariance_"); rs->PrintNameFilters(); // hdmon runs in "ONLINE mode" by default. To make it easy to // cut and paste this, create the parameter with SetDefaultParameter // but then change the value to be true (this avoids warnings about // mismatched default values from plugins that will set the default // value to "false". bool ONLINE_MODE = false; gPARMS->SetDefaultParameter("ONLINE_MODE", ONLINE_MODE, "Sets online mode so plugins may reduce bin sizes or restrict which histograms are defined."); gPARMS->SetParameter("ONLINE_MODE", true); // Make the number of respawns available as a configuration parameter // so janactl can pass it to hdmongui. int Nrespawns = 0; const char *HDLOG_NUM_RESPAWNS = getenv("HDLOG_NUM_RESPAWNS"); if(HDLOG_NUM_RESPAWNS) Nrespawns = atoi(HDLOG_NUM_RESPAWNS); gPARMS->SetDefaultParameter("HDLOG_NUM_RESPAWNS", Nrespawns, "Number of times hdlog has had to respawn this process"); // Run though all events, calling our event processor's methods app.Run(NULL, 1); delete rs; // If the exit code is 10, it may mean corrupted data was encountered // by the parser. In this case, run the corrupt_data_alarm_set script // to set an alarm through ActiveMQ->EPICS to notify shift workers if(app.GetExitCode() == 10 ) system("corrupt_data_alarm_set"); return app.GetExitCode(); } //----------- // Usage //----------- void Usage(JApplication &app) { cout<