9 #include "../svn-revision.h"
16 #define ISISDAE_MAX_DAE2TIMECHAN 65500
18 #define LV_NUM_TIME_REGIMES 6
20 static const char*
star_line80 =
"********************************************************************************\n";
21 static const char*
hash_line80 =
"################################################################################\n";
31 static const std::string data_dae =
m_app->config().getString(
"isisicp.datadae.file",
"c:\\labview modules\\dae\\data_dae.xml");
32 static const bool do_data_dae =
m_app->config().getBool(
"isisicp.datadae.use",
false);
57 Poco::NotificationCenter& notify_centre = Poco::NotificationCenter::defaultCenter();
86 static const char*
muon_daes[] = {
"NDXMUSR",
"NDXEMU",
"NDXHIFI",
"NDXCHRONUS",
"NDXARGUS" };
98 throw std::runtime_error(
"ISISinstrumentControl::purecallHandler()");
118 _set_se_translator(old_func);
123 m_shutdown_requested(false), m_period_error(false), m_nexus_files(false), m_vms_raw_files(true), m_use_full_inst_name_for_files(true),
124 m_icp_options(0),m_event_log_func(event_func),m_num_async_requests(0),m_async_complete_event(NULL),m_app(pApp),
125 m_beam_current_timer(5 * 1000, 5 * 1000), m_simulation_mode(false), m_registersetranslator(false)
128 DWORD len_comp_name = MAX_COMPUTERNAME_LENGTH + 1;
129 char comp_name[MAX_COMPUTERNAME_LENGTH + 1];
131 char time_buffer[128];
135 if (
m_app->config().getBool(
"isisicp.registerpurecallhandler",
false) )
140 _se_translator_function old_se_trans = NULL;
141 if (
m_app->config().getBool(
"isisicp.registersetranslator",
false) )
148 srand(static_cast<unsigned>(time(NULL)));
152 Poco::ThreadPool::defaultPool().addCapacity(50);
159 GetComputerName(comp_name, &len_comp_name);
160 comp_name[len_comp_name] =
'\0';
169 CoInitializeEx(NULL, COINIT_MULTITHREADED);
181 SECURITY_ATTRIBUTES sec_attr = {
sizeof(SECURITY_ATTRIBUTES), NULL, FALSE };
184 ISOtime(time(NULL), time_buffer,
sizeof(time_buffer));
188 m_status.
addInfoVa(
FAC_CRPT,
"SVN revision %s (%s, %s %s, %s)\n", ICPSVN_Revision.c_str(), ICPSVN_Date.c_str(), ICPSVN_Mixed.c_str(), ICPSVN_Range.c_str(), ICPSVN_Modified.c_str());
197 Poco::Path icp_config_path(
m_icp_dir,
"icp_config.xml");
198 std::string icp_config_file = icp_config_path.absolute().toString();
202 mess =
"*** ISIS ICP STARTUP FAILED (cannot load " + icp_config_file +
") ***";
234 Poco::NotificationCenter& notify_centre = Poco::NotificationCenter::defaultCenter();
239 mess =
"*** ISIS ICP STARTUP FAILED (raw size mismatch) ***";
245 for(i=0; i<
sizeof(
muon_daes) /
sizeof(
const char*); i++)
274 mess =
"*** ISIS ICP STARTUP FAILED (Cannot determine DAE Type) ***";
346 bool endian_workaround =
true;
351 endian_workaround =
false;
358 std::string dae_device;
359 bool dae_found =
false;
360 for(i=0; i < 256; i++)
362 _snprintf(dae_tag,
sizeof(dae_tag),
"DAEDevice%d", i);
377 dae_device =
"ISISDAE0";
389 noinit = (i == 1 ?
true :
false);
393 mess =
"*** ICP failed to start - your DAE may be switched OFF or is missing cards ***\r\n"
405 std::string res = Poco::format(
"ISISICP_MIN_TCBWIDTH=%f", static_cast<double>(temp_f));
410 mess =
"ICP failed to start - " +
m_data_dir +
"\\CURRENT.RUN is either corrupt or locked out by another process; check " +
m_log_dir +
"\\icp*.log and " +
m_crpt.
debugLog();
432 FILETIME icp_ft, system_ft;
434 GetSystemTimeAsFileTime(&system_ft);
473 logEventVa(
m_crpt,
m_status,
"ICP_STARTUP_SUCCESS - SVN revision %s (%s, %s %s, %s)", ICPSVN_Revision.c_str(), ICPSVN_Date.c_str(), ICPSVN_Mixed.c_str(), ICPSVN_Range.c_str(), ICPSVN_Modified.c_str());
474 _snprintf(
m_crpt->
icp_version,
sizeof(
m_crpt->
icp_version),
"SVN R%s (%s, %s %s, %s)", ICPSVN_Revision.c_str(), ICPSVN_Date.c_str(), ICPSVN_Mixed.c_str(), ICPSVN_Range.c_str(), ICPSVN_Modified.c_str());
496 ISOtime(time(NULL), time_buffer,
sizeof(time_buffer));
499 ResumeThread(datasvr_thread);
500 CloseHandle(datasvr_thread);
513 bool enable_web_server =
m_app->config().getBool(
"isisicp.services.web",
true);
514 if (enable_web_server)
516 Poco::UInt16 http_server_port =
m_app->config().getInt(
"isisicp.services.web.port", 10999);
517 Poco::Net::HTTPServerParams* http_params =
new Poco::Net::HTTPServerParams;
518 http_params->setMaxQueued(100);
519 http_params->setMaxThreads(5);
520 m_http_svs =
new Poco::Net::ServerSocket(http_server_port);
531 if (
m_app->config().getBool(
"isisicp.failedends.rerun",
false) )
547 if (
m_app->config().getBool(
"isisicp.epicsdb.use",
false))
557 std::set<std::string> files;
558 Poco::Path search_expr(
"c:\\data\\current.run[0-9]?[0-9]*");
559 Poco::Glob::glob(search_expr, files, Poco::Glob::GLOB_CASELESS);
560 Poco::RegularExpression re(
"current.run([0-9]+)", Poco::RegularExpression::RE_CASELESS);
561 Poco::RegularExpression::MatchVec matches;
562 Poco::SharedPtr<Poco::Event> finish_event(
new Poco::Event);
563 BOOST_FOREACH(
const std::string& file, files)
565 re.match(file, 0, matches);
566 if (matches.size() == 2)
568 int run_num = Poco::NumberParser::parse(file.substr(matches[1].offset, matches[1].length));
572 Poco::SharedPtr<CRPTProxy> prev_run(
new CRPTProxy());
573 prev_run->loadCRPT(Poco::format(
"c:\\data\\current.run%d", run_num).c_str(),
574 Poco::format(
"c%d", run_num).c_str(),
575 Poco::format(
"c:\\data\\data.run%d", run_num).c_str(),
577 if ( prev_run->CRPT() != NULL )
582 m_app->config().getBool(
"isisicp.failedends.keepfiles",
false),
583 m_app->config().getBool(
"isisicp.failedends.keepfiles",
false),
590 LOGSTR_ERROR(
"Unable to reload CRPT to re-end run " << run_num);
620 Sleep(poll_time * 1000);
625 catch(
const std::exception& ex)
645 crpt_data_size = 200 * 1000 * 1000;
647 std::string crpt_file =
m_data_dir +
"\\current.run";
648 std::string crpt_data_file =
m_data_dir +
"\\data.run";
649 std::string crpt_name =
"isis_current";
650 std::string crpt_data_name =
"isis_data";
664 bool did_pause =
false;
705 if (period != daq_period)
730 int period, daq_period;
752 period + 1, igf, irf, goodua);
774 int period, daq_period;
778 status.
addInfoVa(
FAC_DAE,
"Run stopped in period %d (DAQ %d), sequence %d", period+1, daq_period+1, value32);
802 period + 1, igf, irf, goodua, dur);
833 icptimer1.
info(
"stopDataCollection()", status);
838 #define MAX_RC_RETRY 5
849 stat = func(
this, status);
856 catch(
const std::exception& ex)
916 bool reread_tcb_file =
false;
920 if ( (tcr[0].mode ==
TCBRANGE_FILE) && (tcr[0].tcb_file.hasFileChanged(status)) )
922 status.
addInfoVa(
FAC_TCB,
"Re-reading time channels from %s", tcr[0].tcb_file.fname);
923 reread_tcb_file =
true;
987 if (period >= 0 && period < m_crpt->nper)
1023 Poco::Thread zero_crpt(
"zero_crpt"), zero_crpt_run(
"zero_crpt_run");
1026 zero_crpt.start(zc_runnable);
1027 LOGSTR_DEBUG(
"zero_crpt thread id " << zero_crpt.tid());
1028 zero_crpt_run.start(zcr_runnable);
1029 LOGSTR_DEBUG(
"zero_crpt_run thread id " << zero_crpt_run.tid());
1034 zero_crpt_run.join();
1078 icptimer.
info(
"BEGIN", status);
1084 std::string lastrun_file =
m_app->config().getString(
"isisicp.lastrunfile",
"c:\\data\\lastrun.txt");
1090 std::fstream fs(lastrun_file, std::ios::out | std::ios::trunc);
1091 fs << file_prefix <<
" " << run_num_string <<
" " << sav_file_count << std::endl;
1095 catch(
const std::exception& ex)
1104 std::string run_command =
m_app->config().getString(property_name,
"");
1105 if ( run_command.size() > 0 )
1108 return spawnCommand(run_command, arg,
true,
false, NULL,
"", out_file, out_file, 0, status);
1166 word = (value & 0xffff);
1170 word = (value >> 16) & 0xffff;
1174 word = (value & 0xffff);
1178 word = (value >> 16) & 0xffff;
1182 word = (value & 0xffff);
1186 word = (value >> 16) & 0xffff;
1190 word = (value & 0xffff);
1194 word = (value & 0xffff);
1198 word = (value >> 16) & 0xffff;
1202 word = (value & 0xffff);
1215 static bool run_external_reset_cmds = Poco::Util::Application::instance().config().getBool(
"isisicp.daereset.run");
1216 std::map<int,int> trcn;
1217 int i, j, dae1_vetos[30];
1220 int ic, maxcrate = -1, maxcard = -1, maxdae = -1;
1231 if ( (j = (
m_crpt->
crat[i] / DAE2CardPolicy::CRATE_MOD)) > maxdae )
1236 dstatus.
addInfoVa(
FAC_CRPT,
"Highest dae, detector card, crate number used = %d, %d, %d", maxdae, maxcard, maxcrate);
1238 std::map<int,int>::iterator tr_it;
1239 bool dae_event_mode =
false;
1243 if ( (tr_it = trcn.find(ic)) != trcn.end() )
1253 trcn.insert(std::map<int,int>::value_type(ic,
m_crpt->
fullTR(j)));
1262 dae_event_mode =
true;
1265 for(tr_it = trcn.begin(); tr_it != trcn.end(); ++tr_it)
1267 if (tr_it->second < 1)
1298 dstatus.
addInfoVa(
FAC_CRPT,
"CRPT memory used for histograms = %u Mb", (len * 4) / (1024 * 1024));
1300 dstatus.
addInfo(
FAC_CRPT,
"Resetting DAE - ignore veto counter values as not yet cleared");
1301 if ( run_external_reset_cmds && (tables_only == 0) )
1304 typedef std::pair<std::string,std::string> string_pair_t;
1305 std::list< string_pair_t > commands;
1308 BOOST_FOREACH(
const string_pair_t& comm, commands)
1310 dstatus.
addInfoVa(
FAC_CRPT,
"Running: %s %s", comm.first.c_str(), comm.second.c_str());
1311 spawnCommand(comm.first, comm.second,
true,
false, NULL,
"", out_file, out_file, 30, dstatus);
1318 for(tr_it = trcn.begin(); tr_it != trcn.end(); ++tr_it)
1329 if (tables_only == 0)
1339 dstatus.
addInfo(
FAC_CRPT,
"RELOAD TABLES ONLY requested - DAE memory not zeroed");
1351 unsigned long* new_tcb = 0;
1355 new_tcb =
new unsigned long[1+
m_crpt->
ntc[k]];
1366 if ( (new_tcb[i] & 0xff000000) != 0 )
1369 new_tcb[i] = 0xffffff;
1383 if ( (new_tcb[i] & 0xff000000) != 0 )
1386 new_tcb[i] = 0xffffff;
1390 for(tr_it = trcn.begin(); tr_it != trcn.end(); ++tr_it)
1393 if ( dae_tr == k+1 )
1405 dstatus.
addInfoVa(
FAC_CRPT,
"Setting FS delay on DC %d to %d us", tr_it->first, det_fs_delay);
1414 if ( dae_tr == k+1 )
1426 dstatus.
addInfoVa(
FAC_CRPT,
"Setting FS delay on data dae DC %d to %d us", crate, det_fs_delay);
1458 dstatus.
addInfo(
FAC_CRPT,
"(setting period card, if present, to 1 hardware period of 15000 frames)");
1465 dstatus.
addInfo(
FAC_CRPT,
"Programming PERIOD card for hardware period control");
1472 dwell_flags[i] = (
m_crpt->
period[i].type == 2 ? 1 : 0);
1482 delete[] outputs;
delete[] dwell_flags;
delete[] frames;
1504 if (tables_only == 0)
1661 ICPTimer icptimer(
"updateCRPTwithSE", dstatus);
1669 ICPTimer icptimer(
"updateCRPTWithDAE", dstatus);
1697 double up_time = icptimer1.
info(
"UPDATE", dstatus);
1700 dstatus.
addInfoVa(
FAC_DAE,
"Average DAE transfer rate = %d KByte / s", (
int)((len * 4.0) / (1000.0 * up_time)) );
1713 icptimer.
info(
"IMPORT timing", dstatus);
1719 ICPTimer icptimer(
"getSE", dstatus);
1730 static const int CARD_MOD = 100;
1731 static const bool check_noncount =
m_app->config().getBool(
"isisicp.noncountingdetectors.check",
false);
1732 static const bool email_noncount =
m_app->config().getBool(
"isisicp.noncountingdetectors.email",
false);
1738 crat_id_t() : c(0), s(0), u(0) { }
1740 typedef std::map<int,crat_id_t> crat_map_t;
1741 if ( !check_noncount )
1745 crat_map_t crat_map;
1746 std::ostringstream oss;
1749 for(
int i=0; i<crpt->
ndet; ++i)
1751 id = CARD_MOD * crpt->
crat[i] + crpt->
modn[i];
1753 crat_id_t& ci = crat_map[id];
1755 ci.s = crpt->
spec[i];
1756 ci.u = crpt->
udet[i];
1758 for(crat_map_t::const_iterator it = crat_map.begin(); it != crat_map.end(); ++it)
1760 if (it->second.c == 0)
1766 if (oss.str().size() > 0)
1769 if ( email_noncount )
1779 ICPTimer icptimer(
"saveCRPTToFile", dstatus);
1780 if (raw_filename.size() > 0)
1782 remove(raw_filename.c_str());
1784 if (nexus_filename.size() > 0)
1786 remove(nexus_filename.c_str());
1788 bool do_nexus = (
m_nexus_files && (nexus_filename.size() > 0) );
1791 dstatus.
addInfoVa(
FAC_DAE,
"Writing muon data file %s", nexus_filename.c_str());
1794 runPostCommand(
"isisicp.exportfilecmd", nexus_filename.c_str(), dstatus);
1798 Poco::SharedPtr<Poco::Event> finish_event(
new Poco::Event);
1801 dstatus.
addInfoVa(
FAC_DAE,
"Writing nexus data file %s", nexus_filename.c_str());
1804 boost::ref(
m_nxwriter), boost::cref(crpt), nexus_filename.c_str(),
false, boost::cref(blocks),
1805 boost::cref(events_nxfile), boost::ref(dstatus)));
1810 dstatus.
addInfoVa(
FAC_DAE,
"Writing raw data file %s", raw_filename.c_str());
1813 runPostCommand(
"isisicp.exportfilecmd", raw_filename.c_str(), dstatus);
1817 finish_event->wait();
1819 runPostCommand(
"isisicp.exportfilecmd", nexus_filename.c_str(), dstatus);
1827 static bool use_shadow = Poco::Util::Application::instance().config().getBool(
"isisicp.shadow.use",
false);
1828 ICPTimer icptimer(
"updateCRPTWithSEandSaveToFile", dstatus);
1830 std::string events_nxfile =
"";
1831 getSE(crpt, blocks, dstatus);
1835 events_nxfile =
"c:\\data\\snap.tmp";
1838 saveCRPTToFile(crpt, raw_filename, nexus_filename, blocks, events_nxfile, dstatus);
1845 static bool nexus_snapshot = Poco::Util::Application::instance().config().getBool(
"isisicp.writenexuscrptsnapshot",
true);
1852 Poco::Path file_path(filename);
1853 file_path.setExtension(
"");
1858 icptimer.
info(
"CRPT_SNAPSHOT", dstatus);
1881 std::string sav_file = Poco::format(
m_data_dir +
"\\%s%s.s%02d", file_prefix, run_num_string, crpt->
sav_file_count);
1882 std::string nx_sav_file = Poco::format(
m_data_dir +
"\\%s%s.n%03d", file_prefix, run_num_string, crpt->
sav_file_count);
1888 icptimer.
info(
"STORE", dstatus);
1904 std::string auto_filename = Poco::format(
m_data_dir +
"\\%sauto_%c.tmp", file_prefix, letter);
1906 runPostCommand(
"isisicp.endautosavecmd", Poco::format(
"%sauto_%c.tmp", file_prefix, letter), dstatus);
1922 const char* userprofile = getenv(
"USERPROFILE");
1923 std::string commfile = std::string(userprofile != NULL ? userprofile :
"") +
1924 "\\My Documents\\configurations\\common\\setcycle.cmd";
1925 std::fstream fs(commfile.c_str(), std::ios::in);
1930 fs.getline(buffer,
sizeof(buffer));
1931 buffer[
sizeof(buffer)-1] =
'\0';
1936 line =
"cycle_??_?";
1941 catch(
const std::exception& ex) {
1951 ICPTimer icptimer(
"loadCRPTWithHistogrammedEvents", dstatus);
1960 Poco::Thread::sleep(500);
1969 bool savehistogramsineventsfile = Poco::Util::Application::instance().config().getBool(
"isisicp.savehistogramsineventsfile",
true);
1970 static Poco::Semaphore end_semaphore(1);
1974 if ( crpt_end.
CRPT() == NULL )
1989 getSE(crpt_end, blocks, dstatus);
2003 Poco::format(
m_data_dir +
"\\%s%s.nxs", file_prefix, run_num_string), blocks,
2004 events_nxfile, dstatus);
2006 icptimer2.
info(
"File Write", dstatus);
2011 journal_timer.
info(
"write journal", dstatus);
2018 se_clear_timer.
info(
"se_clear_values", dstatus);
2021 if ( !keep_raw_events )
2050 icptimer1.
info(
"END " + run_num_string, dstatus);
2051 status.
add(dstatus,
true);
2066 icptimer2.
info(
"lockCRPT()", dstatus);
2075 icptimer2.
info(
"stopDataCollection()", dstatus);
2113 Poco::SharedPtr<Poco::Event> finish_event(
new Poco::Event);
2116 Poco::Util::Application::instance().config().getBool(
"isisicp.keepraweventfiles",
false),
2117 Poco::Util::Application::instance().config().getBool(
"isisicp.keependcrpt",
false),
2121 if ( !Poco::Util::Application::instance().config().getBool(
"isisicp.asyncend",
false) )
2123 finish_event->wait();
2132 icptimer1.
info(
"END " + run_num_string, dstatus);
2141 std::string xml_data;
2142 std::list<std::string> entries;
2143 std::list<std::string>::const_iterator entries_iter;
2144 std::pair<recovery_map_t::iterator, bool> insert_ret;
2154 for(entries_iter = entries.begin(); entries_iter != entries.end(); entries_iter++)
2158 insert_ret =
m_recovery_map.insert(recovery_map_t::value_type(*entries_iter, xml_data));
2159 if (!insert_ret.second)
2161 dstatus.
addWarningVa(
FAC_DAE,
"Found duplicate for %s in recovery map\n", entries_iter->c_str());
2200 recovery_map_t::const_iterator recovery_iter;
2203 (this->*func)(recovery_iter->second, dstatus);
2217 recovery_map_t::const_iterator iter;
2232 nx.
writeData(iter->first.c_str(), iter->second.c_str());
2253 spawnCommand(datasvr,
"",
false,
false, &h,
"",
"",
"", 0, dstatus);
2258 struct SendNagiosData
2261 std::string service;
2262 std::string message;
2264 SendNagiosData(
int status_,
const std::string& service_,
const std::string& message_,
DAEstatus& dstatus_) :
2265 status(status_), service(service_), message(message_), dstatus(dstatus_) { }
2268 Poco::NotificationQueue m_queue;
2270 Poco::Thread m_worker_thread;
2274 class SendNagiosWorker :
public GenericWorker<SendNagiosData>
2277 virtual void doWork(SendNagiosData* data);
2278 SendNagiosWorker(Poco::NotificationQueue& queue) :
GenericWorker<SendNagiosData>(queue) { }
2289 static const bool use_nagios =
m_app->config().getBool(
"isisicp.nagios.use",
false);
2290 static const int nagios_timeout =
m_app->config().getInt(
"isisicp.nagios.timeout", 5);
2291 static const std::string nagios_host =
m_app->config().getString(
"isisicp.nagios.host",
"130.246.39.24");
2294 static const std::string send_nsca_args = std::string(
"-H ") + nagios_host +
" -c \"" + send_nsca_cfg +
"\"";
2295 char* tfile = tempnam(getenv(
"TEMP"),
"send_nsca");
2301 std::string temp_file = tfile;
2302 std::ostringstream nagios_mess;
2305 f.open(temp_file, std::ios::out);
2308 nagios_mess <<
m_comp_name <<
'\t' << service <<
'\t' << status <<
'\t' << message <<
'\n';
2309 f << nagios_mess.str();
2313 spawnCommand(send_nsca, send_nsca_args,
false,
false, NULL, temp_file,
"",
"", nagios_timeout, dstatus);
2324 remove(temp_file.c_str());
2328 static bool getBeamlogFloat(Poco::XML::Document* pDoc,
const std::string& path,
float& value)
2330 Poco::XML::Node* pNode = pDoc->getNodeByPath(path);
2333 value = atof(pNode->innerText().c_str());
2340 static bool getBeamlogInt(Poco::XML::Document* pDoc,
const std::string& path,
int& value)
2342 Poco::XML::Node* pNode = pDoc->getNodeByPath(path);
2345 value = atoi(pNode->innerText().c_str());
2352 static bool getBeamlogInt64(Poco::XML::Document* pDoc,
const std::string& path, int64_t& value)
2354 Poco::XML::Node* pNode = pDoc->getNodeByPath(path);
2357 value = _atoi64(pNode->innerText().c_str());
2364 static bool getBeamlogString(Poco::XML::Document* pDoc,
const std::string& path, std::string& value)
2366 Poco::XML::Node* pNode = pDoc->getNodeByPath(path);
2369 value = pNode->innerText();
2378 static char buffer[10000];
2379 static const int NBEAMREAD = 3;
2380 Poco::Net::DatagramSocket ds_recv;
2381 Poco::Net::SocketAddress sa_recv(
"0.0.0.0", 7004);
2382 Poco::Timespan recv_tmo(15,0);
2387 ds_recv.setReceiveTimeout(recv_tmo);
2388 ds_recv.bind(sa_recv);
2390 catch(
const std::exception& ex)
2392 LOGSTR_ERROR(
"readBeamloggerBroadcast: " << ex.what());
2396 unsigned nbeamz = 0, nbeamnz = 0;
2397 std::string shutter_status(
"OPEN");
2406 if (difftime(time(NULL), bl.
time) > 10.0)
2414 n = ds_recv.receiveBytes(buffer,
sizeof(buffer)-1);
2417 LOGSTR_ERROR(
"readBeamloggerBroadcast: received " << n);
2418 Poco::Thread::sleep(10 * 1000);
2422 std::stringstream inp;
2425 Poco::XML::InputSource xml_src(inp);
2426 Poco::XML::DOMParser parser;
2427 Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&xml_src);
2437 if (
"OPEN" == shutter_status)
2441 else if (
"CLOSED" == shutter_status)
2463 if (bl.
beamt <= 0.0)
2473 if (bl.
beam_on && nbeamz > NBEAMREAD)
2479 else if (!bl.
beam_on && nbeamnz > NBEAMREAD)
2486 catch(
const std::exception& ex)
2488 LOGSTR_ERROR(
"readBeamloggerBroadcast: " << ex.what());
2489 Poco::Thread::sleep(10 * 1000);
2515 const std::string& std_in_file,
const std::string& std_out_file,
const std::string& std_error_file,
int wait_time,
DAEstatus& dstatus)
2517 char command_line[MAX_PATH];
2518 SECURITY_ATTRIBUTES proc_attr;
2519 DWORD proc_create_flags = 0;
2520 BOOL inherit_handles = FALSE;
2521 ZeroMemory( &proc_attr,
sizeof(proc_attr) );
2522 PROCESS_INFORMATION pi;
2523 ZeroMemory( &pi,
sizeof(pi) );
2526 _snprintf(command_line,
sizeof(command_line),
"\"%s\" /c \"%s\" %s", getenv(
"ComSpec"), program.c_str(), args.c_str());
2530 _snprintf(command_line,
sizeof(command_line),
"\"%s\" %s", program.c_str(), args.c_str());
2534 ZeroMemory( &si,
sizeof(si) );
2536 HANDLE proc_stdin = INVALID_HANDLE_VALUE;
2537 HANDLE proc_stdout = INVALID_HANDLE_VALUE;
2538 HANDLE proc_stderr = INVALID_HANDLE_VALUE;
2539 if (suspended_thread_handle != NULL)
2541 proc_create_flags |= CREATE_SUSPENDED;
2542 *suspended_thread_handle = NULL;
2546 si.dwFlags = STARTF_USESHOWWINDOW;
2547 si.wShowWindow = SW_MINIMIZE;
2548 proc_create_flags |= CREATE_NEW_CONSOLE;
2552 si.dwFlags |= STARTF_USESTDHANDLES;
2553 proc_attr.bInheritHandle = TRUE;
2554 inherit_handles = TRUE;
2555 if (std_out_file.size() > 0)
2557 proc_stdout = CreateFile(std_out_file.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &proc_attr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
2558 SetFilePointer(proc_stdout, 0, NULL, FILE_END);
2562 DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_OUTPUT_HANDLE), GetCurrentProcess(), &proc_stdout, 0, TRUE, DUPLICATE_SAME_ACCESS);
2564 if (std_error_file.size() > 0)
2566 if (std_error_file == std_out_file)
2568 DuplicateHandle(GetCurrentProcess(), proc_stdout, GetCurrentProcess(), &proc_stderr, 0, TRUE, DUPLICATE_SAME_ACCESS);
2572 proc_stderr = CreateFile(std_error_file.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &proc_attr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
2573 SetFilePointer(proc_stderr, 0, NULL, FILE_END);
2578 DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_ERROR_HANDLE), GetCurrentProcess(), &proc_stderr, 0, TRUE, DUPLICATE_SAME_ACCESS);
2580 if (std_in_file.size() > 0)
2582 proc_stdin = CreateFile(std_in_file.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, &proc_attr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
2586 DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE), GetCurrentProcess(), &proc_stdin, 0, TRUE, DUPLICATE_SAME_ACCESS);
2588 si.hStdInput = proc_stdin;
2589 si.hStdOutput = proc_stdout;
2590 si.hStdError = proc_stderr;
2593 if(CreateProcess(NULL,
2607 DWORD ret = WaitForSingleObject(pi.hProcess, wait_time * 1000);
2608 if (ret == WAIT_TIMEOUT)
2610 dstatus.
addInfoVa(
FAC_DAE,
"Timout after waiting %d seconds for %s.", wait_time, command_line);
2612 else if (ret != WAIT_OBJECT_0)
2619 if (GetExitCodeProcess(pi.hProcess, &exit_code) != 0)
2623 dstatus.
addInfoVa(
FAC_DAE,
"Process exit code %d for %s", exit_code, command_line);
2628 dstatus.
addInfoVa(
FAC_DAE,
"GetExitCodeProcess() failed for %s", command_line);
2632 CloseHandle(pi.hProcess);
2633 if (suspended_thread_handle != NULL)
2635 *suspended_thread_handle = pi.hThread;
2639 CloseHandle(pi.hThread);
2641 CloseHandle(proc_stdin);
2642 CloseHandle(proc_stdout);
2643 CloseHandle(proc_stderr);
2654 DWORD aProcesses[1024], cbNeeded, cProcesses;
2658 if ( !EnumProcesses( aProcesses,
sizeof(aProcesses), &cbNeeded ) )
2663 cProcesses = cbNeeded /
sizeof(DWORD);
2667 for ( i = 0; i < cProcesses; i++ )
2669 if( aProcesses[i] != 0 )
2672 if (name == process_name)
2674 HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, aProcesses[i]);
2675 if (hProcess != NULL)
2677 TerminateProcess(hProcess, 0);
2678 CloseHandle(hProcess);
2691 TCHAR szProcessName[MAX_PATH] = TEXT(
"<unknown>");
2695 HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
2700 if (NULL != hProcess )
2705 if ( EnumProcessModules( hProcess, &hMod,
sizeof(hMod), &cbNeeded) )
2707 GetModuleBaseName( hProcess, hMod, szProcessName,
2708 sizeof(szProcessName)/
sizeof(TCHAR) );
2710 CloseHandle( hProcess );
2713 result = szProcessName;
2731 struct stat stat_struct;
2735 typedef std::map<unsigned,unsigned> wiring_map_t;
2736 typedef std::pair<wiring_map_t::iterator,bool> wiring_insert_t;
2737 wiring_map_t::const_iterator wiring_iterator;
2738 wiring_map_t wiring_map, crate_map;
2739 wiring_insert_t insert_ret;
2741 int *index, *det_no, *time_reg, *crate, *module, *mpos, *monitor, *mon_prescale;
2742 if ( stat(filename, &stat_struct) != 0 )
2748 if ( (strncmp(wiring_table.fname, filename,
sizeof(wiring_table.fname)) == 0) &&
2749 (wiring_table.mod_time == stat_struct.st_mtime) &&
2750 (wiring_table.file_size == stat_struct.st_size) &&
2753 status.
addInfoVa(
FAC_DAE,
"Wiring table %s is unchanged - reload skipped", filename);
2757 f.open(filename, std::ios::in);
2758 f.ignore(50000,
'\n');
2775 index =
new int[ndet];
2776 det_no =
new int[ndet];
2777 time_reg =
new int[ndet];
2778 crate =
new int[ndet];
2779 module =
new int[ndet];
2780 mpos =
new int[ndet];
2781 monitor =
new int[ndet];
2782 mon_prescale =
new int[ndet];
2783 f.ignore(50000,
'\n');
2784 f.ignore(50000,
'\n');
2787 unsigned crate_index;
2788 for(i=0; i<ndet && f.good(); i++)
2790 f >> index[i] >> det_no[i] >> time_reg[i] >> crate[i]
2791 >> module[i] >> mpos[i] >> monitor[i] >> mon_prescale[i];
2792 f.ignore(50000,
'\n');
2793 if (index[i] != i+1)
2801 crate[i], module[i], mpos[i], det_no[i], filename);
2804 crate_index = ( (crate[i] << 16) | (module[i] << 12) | mpos[i] );
2805 insert_ret = wiring_map.insert(wiring_map_t::value_type(det_no[i],crate_index));
2806 if (!insert_ret.second)
2811 insert_ret = crate_map.insert(wiring_map_t::value_type(crate_index,det_no[i]));
2812 if (!insert_ret.second)
2828 memcpy(
m_crpt->
crat, crate, ndet*
sizeof(
int));
2829 memcpy(
m_crpt->
modn, module, ndet*
sizeof(
int));
2830 memcpy(
m_crpt->
mpos, mpos, ndet*
sizeof(
int));
2831 for(i=0; i<ndet; ++i)
2838 memcpy(
m_crpt->
udet, det_no, ndet*
sizeof(
int));
2846 for(i=0; i<ndet; i++)
2848 j = abs(monitor[i]);
2879 status.
addWarningVa(
FAC_DAE,
"Monitor %d is not properly defined in wiring table %s", i+1, filename);
2885 strncpy(wiring_table.fname, filename,
sizeof(wiring_table.fname));
2887 memcpy(wiring_table.checksum, checksum,
sizeof(wiring_table.checksum));
2888 wiring_table.mod_time = stat_struct.st_mtime;
2889 wiring_table.file_size = stat_struct.st_size;
2890 status.
addInfoVa(
FAC_DAE,
"Loaded %d detectors (%d monitors) from wiring table %s", ndet, nmon, filename);
2894 wiring_table.file_size = wiring_table.mod_time = 0;
2895 memset(wiring_table.checksum, 0,
sizeof(wiring_table.checksum));
2911 delete []mon_prescale;
2920 struct stat stat_struct;
2922 typedef std::map<int,DETECTOR> detector_map_t;
2923 typedef std::pair<detector_map_t::iterator,bool> detector_insert_t;
2924 detector_map_t detector_map;
2925 detector_map_t::const_iterator detector_iterator;
2926 std::set<unsigned> udet_set;
2928 if ( stat(filename, &stat_struct) != 0 )
2934 if ( (strncmp(detector_table.
fname, filename,
sizeof(detector_table.
fname)) == 0) &&
2935 (detector_table.
mod_time == stat_struct.st_mtime) &&
2936 (detector_table.
file_size == stat_struct.st_size) &&
2939 status.
addInfoVa(
FAC_DAE,
"Detector table \"%s\" is unchanged - reload skipped", filename);
2946 Poco::SharedPtr<IDetectorFile> det_file;
2947 std::string det_filename(filename);
2949 if ( (det_filename.size() > 4) && !Poco::icompare(det_filename.substr(det_filename.size() - 4),
".nxs") )
2957 if (!det_file->good())
2962 nlines = det_file->numLines();
2963 nuse = det_file->numUserTables();
2971 detector_insert_t insert_ret;
2972 int n_extra_dets = 0;
2973 for(i=0; i<nlines && det_file->good(); i++)
2975 det_file->readLine(det_no, det);
2976 insert_ret = detector_map.insert(detector_map_t::value_type(det_no,det));
2977 if (!insert_ret.second)
2982 if (udet_set.count(det_no) == 0)
2987 if (n_extra_dets > 0)
2989 status.
addWarningVa(
FAC_DAE,
"%d detectors defined in detector table %s but not in wiring table", n_extra_dets, filename);
2991 if (!det_file->good())
2996 if (detector_map.size() != nlines)
3006 detector_iterator = detector_map.find(
m_crpt->
udet[i]);
3007 if (detector_iterator != detector_map.end())
3009 det_ref = detector_iterator->second;
3014 det_ref = empty_det;
3022 for(j=0; j<nuse; j++)
3030 strncpy(detector_table.
fname, filename,
sizeof(detector_table.
fname));
3032 memcpy(detector_table.
checksum, checksum,
sizeof(detector_table.
checksum));
3033 detector_table.
mod_time = stat_struct.st_mtime;
3034 detector_table.
file_size = stat_struct.st_size;
3082 struct stat stat_struct;
3083 typedef std::map<int,int> spectra_map_t;
3084 typedef std::pair<spectra_map_t::iterator,bool> spectra_insert_t;
3085 spectra_map_t spectra_map;
3086 std::set<unsigned> udet_set;
3087 spectra_map_t::const_iterator spectra_iterator;
3089 if ( stat(filename, &stat_struct) != 0 )
3095 if ( (strncmp(spectra_table.
fname, filename,
sizeof(spectra_table.
fname)) == 0) &&
3096 (spectra_table.
mod_time == stat_struct.st_mtime) &&
3097 (spectra_table.
file_size == stat_struct.st_size) &&
3100 status.
addInfoVa(
FAC_DAE,
"Spectra table %s is unchanged - reload skipped", filename);
3108 f.open(filename, std::ios::in);
3109 f.ignore(50000,
'\n');
3116 f.ignore(50000,
'\n');
3117 f.ignore(50000,
'\n');
3118 spectra_insert_t insert_ret;
3119 for(i=0; i<nlines && f.good(); i++)
3121 f >> det_no >> spec_no;
3122 f.ignore(50000,
'\n');
3128 if (udet_set.count(det_no) == 0)
3133 insert_ret = spectra_map.insert(spectra_map_t::value_type(det_no,spec_no));
3134 if (!insert_ret.second)
3145 if (spectra_map.size() != nlines)
3152 boost::array<int,ISISCRPT_MAX_NTRG>& spec_min =
m_crpt->
spec_min;
3153 boost::array<int,ISISCRPT_MAX_NTRG>& spec_max =
m_crpt->
spec_max;
3154 const int SPEC_MIN_FILLER=10000000, SPEC_MAX_FILLER=-1;
3155 spec_min.fill(SPEC_MIN_FILLER);
3156 spec_max.fill(SPEC_MAX_FILLER);
3157 int n_unassigned_detectors = 0;
3162 spectra_iterator = spectra_map.find(
m_crpt->
udet[i]);
3164 if (spectra_iterator != spectra_map.end())
3166 spec_no = spectra_iterator->second;
3171 n_unassigned_detectors++;
3174 max_spec_no = std::max(spec_no, max_spec_no);
3177 spec_tr[tr_index].insert(spec_no);
3178 spec_min[tr_index] = std::min(spec_no, spec_min[tr_index]);
3179 spec_max[tr_index] = std::max(spec_no, spec_max[tr_index]);
3185 spec_min[spec0_tr-1] = 0;
3186 spec_tr[spec0_tr-1].insert(0);
3188 if (n_unassigned_detectors > 0)
3190 status.
addWarningVa(
FAC_DAE,
"%d detectors unassigned in spectra table and mapped to spectrum 0", n_unassigned_detectors);
3193 typedef std::map<int,int> minmax_map_t;
3194 minmax_map_t minmax_map;
3197 if ( (spec_min[i] != SPEC_MIN_FILLER) && (minmax_map.insert(minmax_map_t::value_type(spec_min[i],spec_max[i])).second ==
false) )
3203 std::vector< std::pair<int,int> > minmax_vec;
3204 for(minmax_map_t::const_iterator it = minmax_map.begin(); it != minmax_map.end(); ++it)
3206 minmax_vec.push_back(*it);
3208 for(i=0; i < (minmax_vec.size() - 1); ++i)
3210 if ( (minmax_vec[i].second != SPEC_MAX_FILLER) && (minmax_vec[i+1].first != SPEC_MIN_FILLER)
3211 && ((minmax_vec[i+1].first - minmax_vec[i].second) != 1) )
3220 int nsp = ( (spec_max[i] != SPEC_MAX_FILLER) ? (spec_max[i] - spec_min[i] + 1) : 0 );
3221 if ( nsp != spec_tr[i].size() )
3231 if ( n != max_spec_no )
3245 strncpy(spectra_table.
fname, filename,
sizeof(spectra_table.
fname));
3247 spectra_table.
mod_time = stat_struct.st_mtime;
3248 spectra_table.
file_size = stat_struct.st_size;
3250 status.
addInfoVa(
FAC_DAE,
"Assigned %d spectra from spectra table %s", max_spec_no, filename);
3262 Poco::XML::Node* node = attrs->getNamedItem(name);
3266 val = atoi(node->getNodeValue().c_str());
3274 Poco::XML::Node* node = attrs->getNamedItem(name);
3278 val = atof(node->getNodeValue().c_str());
3288 struct stat stat_struct;
3290 if ( stat(filename, &stat_struct) != 0 )
3297 if ( (strncmp(data_dae_table.fname, filename,
sizeof(data_dae_table.fname)) == 0) &&
3298 (data_dae_table.mod_time == stat_struct.st_mtime) &&
3299 (data_dae_table.file_size == stat_struct.st_size) &&
3302 status.
addInfoVa(
FAC_DAE,
"Data DAE table %s is unchanged - reload skipped", filename);
3307 f.open(filename, std::ios::in);
3315 Poco::XML::InputSource xml_src(f);
3316 Poco::XML::DOMParser parser;
3317 Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&xml_src);
3318 Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ELEMENT);
3319 Poco::XML::Node* pNode = it.nextNode();
3322 if (pNode->nodeName() ==
"device")
3324 Poco::XML::NamedNodeMap* attrs = pNode->attributes();
3331 Poco::XML::Node* node = attrs->getNamedItem(
"name");
3334 std::string n = node->nodeValue();
3335 std::replace(n.begin(), n.end(),
' ',
'_');
3339 node = attrs->getNamedItem(
"data_type");
3342 if (node->nodeValue() ==
"int")
3346 else if (node->nodeValue() ==
"float")
3355 node = attrs->getNamedItem(
"raw_units");
3361 node = attrs->getNamedItem(
"scaled_units");
3371 pNode = it.nextNode();
3375 catch (
const Poco::Exception& pex)
3380 catch (
const std::exception& ex)
3388 strncpy(data_dae_table.fname, filename,
sizeof(data_dae_table.fname));
3390 data_dae_table.mod_time = stat_struct.st_mtime;
3391 data_dae_table.file_size = stat_struct.st_size;
3392 memcpy(data_dae_table.checksum, checksum,
sizeof(data_dae_table.checksum));
3398 data_dae_table.file_size = data_dae_table.mod_time = 0;
3399 memset(data_dae_table.checksum, 0,
sizeof(data_dae_table.checksum));
3414 struct stat stat_struct;
3417 boost::array<double*,ISISCRPT_MAX_NTRG> rtcb_file;
3418 rtcb_file.fill(NULL);
3428 "ntgr or ntrc error in tcb");
3431 fs.open(tcr[0].tcb_file.fname, std::ios::in);
3438 rtcb_file[j] =
new double[n];
3441 fs >> rtcb_file[j][i];
3443 tcr[0].
start =
static_cast<float>(rtcb_file[j][0]);
3444 tcr[0].
end =
static_cast<float>(rtcb_file[j][n-1]);
3452 stat(tcr[0].tcb_file.fname, &stat_struct);
3460 "Unable to read TCB file %s", tcr[0].tcb_file.fname);
3461 if (rtcb_file[j] != NULL)
3463 delete[] rtcb_file[j];
3464 rtcb_file[j] = NULL;
3470 if (tcr[0].start < m_crpt->tcb_mintime)
3475 if (tcr[ntcr-1].end < m_crpt->tcb_mintime)
3478 "End channel less than min time (%f < %f)",
3485 "Start channel greater than max time (%f > %f)",
3492 "end channel greater than max time (%f > %f)",
3498 for(i=1; i<ntcr; i++)
3500 if (tcr[i-1].end < 1.0)
3504 if (tcr[i].start < 1.0)
3509 for(i=0; i<ntcr; i++)
3511 if (tcr[i].end < tcr[i].start)
3514 "end channel less than start time (%f < %f)",
3515 tcr[i].end, tcr[i].start);
3520 if ( tcr[i].tcpar[0] > (tcr[i].end - tcr[i].start) )
3523 "channel width too big for section %d (%f)", i,
3530 "channel width too small for section %d (%f)", i,
3537 int clock_delay = 0;
3538 float frame_delay = 0.0;
3547 clock_delay = (int)(min_tcb / 4.0);
3552 frame_delay = 4.0f * clock_delay;
3554 if ( (min_tcb - frame_delay) < 1.4 )
3557 frame_delay = 4.0f * clock_delay;
3560 float first_tcb = min_tcb - frame_delay;
3583 int tcb_trdelay = (int)(tcr[0].start - frame_delay - first_tcb);
3584 if (tcb_trdelay < 0)
3593 "time regimes 1 and %d are incompatible", j+1);
3601 "%d time regimes not allowed on muons",
m_crpt->
ntrg);
3635 double last_time = tcr[0].
start - frame_delay;
3640 double current_time = last_time;
3641 double last_width = 0.0;
3642 int num_iterations = 0;
3650 if ( last_time >= (tcr[i].end - frame_delay) )
3656 current_time = tcr[i].
start - frame_delay;
3668 current_time = rtcb_file[j][nchan] - frame_delay;
3671 current_time = last_time + tcr[i].
tcpar[0];
3674 current_time = last_time + (last_time+frame_delay)*tcr[i].tcpar[0];
3677 current_time = last_time + (last_time+frame_delay)*(last_time+frame_delay)*tcr[i].
tcpar[0];
3681 "unknown time channel mode %d", tcr[i].mode);
3689 if ( current_time > (tcr[i].end - frame_delay) )
3691 current_time = tcr[i].
end - frame_delay;
3692 if ( ((current_time - last_time) < (last_width / 4.0)) ||
3697 last_time = last_time - last_width;
3705 last_width = current_time - last_time;
3706 last_time = current_time;
3716 for(i=0; i<nchan; i++)
3727 for(i=0; i<nchan; i++)
3731 if (rtcb_file[j] != NULL)
3733 delete[] rtcb_file[j];
3758 "invalid range %d", range_number);
3763 tcr.
mode = range_type;
3766 tcr.
tcpar[0] = step;
3784 static unsigned long ncalls = 0;
3785 static unsigned long update_duration_total = 0;
3786 static bool disable_monitoring_in_event_mode =
m_app->config().getBool(
"isisicp.monitoring.disableineventmode",
false);
3790 update_duration_total += poll_time;
3791 struct timeb new_update_time;
3800 ftime(&new_update_time);
3820 int64_t total_counts, total_counts_diff;
3822 if (total_counts < 0)
3835 long integral, max_value;
3836 int period, daq_period;
3843 isisU32_t good_frames, raw_frames, good_frames_diff, raw_frames_diff;
3895 std::map<std::string,double> values;
3902 std::sort(spectra_used.begin(), spectra_used.end());
3903 std::vector<long>::iterator new_end = std::unique(spectra_used.begin(), spectra_used.end());
3911 sprintf(buffer,
"V%d", i+1);
3913 sprintf(buffer,
"_V%d", i+1);
3916 values[
"T"] = tdiff_mon;
3927 double result = 0.0;
3931 std::string sender =
"isisicp@shadow.nd.rl.ac.uk";
3932 std::string alert_sms, line;
3938 std::getline(fs, line,
'\n');
3939 int i = line.find(
'#');
3940 if (i != std::string::npos)
3944 alert_sms.append(
",");
3945 alert_sms.append(line);
3948 alert_sms.erase(std::remove(alert_sms.begin(), alert_sms.end(),
' '), alert_sms.end());
3967 if (newper != -1 && newper != oldper)
4019 if ( !only_refresh_cache && (update_duration_total % 30 == 0) )
4024 if ( only_refresh_cache || (update_duration_total % 15 == 0) )
4038 if (!only_refresh_cache)
4041 bool write_autosave =
false;
4048 write_autosave =
true;
4056 write_autosave =
true;
4064 write_autosave =
true;
4072 write_autosave =
true;
4093 static int nagios_poll =
m_app->config().getInt(
"isisicp.nagios.poll", 60);
4094 static double veto_warn =
m_app->config().getDouble(
"isisicp.nagios.veto.warn", 80.0);
4095 static double veto_critical =
m_app->config().getDouble(
"isisicp.nagios.veto.critical", 90.0);
4096 static double wait_warn =
m_app->config().getDouble(
"isisicp.nagios.wait.warn", 120.0);
4097 static double wait_critical =
m_app->config().getDouble(
"isisicp.nagios.wait.critical", 180.0);
4098 static double shutter_warn =
m_app->config().getDouble(
"isisicp.nagios.shutter.warn", 5.0);
4099 if ( !only_refresh_cache && (update_duration_total % nagios_poll == 0) )
4104 if (raw_frames_diff > 0)
4106 nagios.
veto_percent = 100.0 * (1.0 - (double)good_frames_diff / (
double)raw_frames_diff);
4119 std::string veto_message = Poco::format(
"Vetoing %.1f%% of data;|'veto'=%f%%;%f;%f", nagios.
veto_percent, nagios.
veto_percent, veto_warn, veto_critical);
4146 std::string wait_message = Poco::format(
"Waiting for %.1f minutes;|'data'=%fs;%f;%f", nagios.
wait_mins, nagios.
wait_mins * 60.0, wait_warn * 60.0, wait_critical * 60.0);
4196 std::string shutter_message;
4199 shutter_message = Poco::format(
"KICKER %s COLLECTING %s;|'data'=%d;1:;0:", std::string(
m_crpt->
beamlogger.
muonkicker ?
"ON" :
"OFF"),
4204 shutter_message = Poco::format(
"SHUTTER %s%s;|'data'=%d;1:;0:", std::string(
m_crpt->
beamlogger.
shutter ?
"OPEN" :
"CLOSED"),
4223 static bool write_tdiff_file =
m_app->config().getBool(
"isisicp.logfiles.writetdiff",
false);
4224 bool file_exists =
false;
4225 struct stat stat_struct;
4226 char time_buffer[128];
4227 FILETIME icp_ft, system_ft;
4228 g_icp_clock.get()->getCurrentTimeAsFiletime(icp_ft);
4229 GetSystemTimeAsFileTime(&system_ft);
4230 ISOtime(time(NULL), time_buffer,
sizeof(time_buffer));
4241 if (write_tdiff_file)
4247 std::stringstream f;
4250 f <<
"# iso time, Frame timer drift (icp - dae) ms, System timer drift (icp - system) ms\r\n";
4252 f << time_buffer <<
" " << icp_dae_td <<
" " << icp_sys_td <<
"\r\n";
4259 bool file_exists =
false;
4260 struct stat stat_struct;
4261 char time_buffer[128], buffer[128];
4266 std::stringstream f;
4270 f <<
"# time expression_value";
4285 std::vector<std::string> iso_times;
4286 std::vector<std::string> block_names;
4287 std::vector<std::string> block_values;
4291 sprintf(buffer,
"monitoring_v%d", i+1);
4292 block_names.push_back(buffer);
4294 block_values.push_back(buffer);
4296 block_names.push_back(
"monitoring_expression");
4298 block_values.push_back(buffer);
4299 iso_times.resize(block_names.size());
4300 std::fill(iso_times.begin(), iso_times.end(), time_buffer);
4310 static bool write_status_file =
m_app->config().getBool(
"isisicp.logfiles.writestatus",
false);
4311 bool file_exists =
false;
4312 char time_buffer[128];
4313 struct stat stat_struct;
4314 time_t unix_time = 0;
4319 ISOtime(unix_time, time_buffer,
sizeof(time_buffer));
4329 if (write_status_file)
4335 std::stringstream f;
4338 f <<
"# time period is_running is_waiting good_frames raw_frames good_uamps raw_uamph monitor1_sum dae_beam_current total_counts count_rate np_ratio\r\n";
4340 f << time_buffer <<
" " <<
4360 if (the_icp != NULL)
4407 va_start(ap, event);
4408 int ret =
logEventVaImp(time(NULL), crpt, status, event, ap);
4416 va_start(ap, event);
4425 vsnprintf(buffer,
sizeof(buffer)-1, event, ap);
4427 return logEvent(the_time, crpt, buffer, status);
4432 return logEvent(time(NULL), crpt, event, status);
4437 char time_buffer[128];
4438 std::stringstream s;
4439 ISOtime(the_time, time_buffer,
sizeof(time_buffer));
4440 s << time_buffer <<
' ' <<
event <<
"\r\n";
4443 FILE* f = fopen(m_event_log.c_str(),
"a+t");
4446 fputs(s.str().c_str(), f);
4462 return ISOtime(tb.time, buffer, len);
4467 struct tm *tm_struct;
4469 tm_struct = localtime(&time);
4472 strftime(buffer, len,
"%Y-%m-%dT%H:%M:%S", tm_struct);
4476 strncpy(buffer,
"<UNKNOWN>", len);
4478 buffer[len-1] =
'\0';
4489 struct tm *tm_struct;
4491 tm_struct = localtime(&time);
4494 strftime(buffer, len,
"%a %d-%b-%Y %H:%M:%S", tm_struct);
4498 strncpy(buffer,
"<UNKNOWN>", len);
4500 buffer[len-1] =
'\0';
4534 status.
addInfoVa(
FAC_DAE,
"DAQ period mismatch for period %d: actual %d != CRPT %d", period+1, 1+daq_period, 1+
m_crpt->
period[period].daq_period);
4539 status.
addInfoVa(
FAC_DAE,
"DAQ period OK for period %d (=%d)", period+1, 1+daq_period);
4634 lvxml.
setValue(
"RunNumber", buffer, status);
4664 lvxml.
setValue(
"GoodFramesPeriod", igf, status);
4665 lvxml.
setValue(
"RawFramesPeriod", irf, status);
4668 lvxml.
setValue(
"RunDurationPeriod", this_period.
duration + this_dur, status);
4681 lvxml.
setValue(
"GoodFramesPeriod", igf, status);
4682 lvxml.
setValue(
"RawFramesPeriod", irf, status);
4693 lvxml.
setValue(
"CurrentPeriod", period+1, status);
4695 lvxml.
setValue(
"StartTime", buffer, status);
4708 std::string run_title;
4711 run_title =
"(DAE SIMULATION MODE) ";
4714 lvxml.
setValue(
"RunTitle", run_title.c_str(), status);
4719 lvxml.
setValue(
"DAEMemoryUsed", value32, status);
4721 lvxml.
setValue(
"Last Refresh Time", buffer, status);
4751 bool as_histogram,
bool as_distribution,
long& sum,
DAEstatus& status)
4758 unsigned long* buffer =
new unsigned long[ntc+1];
4763 if (daq_period >= 0)
4776 memset(buffer, 0, (ntc+1) *
sizeof(
unsigned long));
4782 for(i=0; i<ntc+1; i++)
4784 time_array[i] =
m_crpt->
rtcb[tr_index][i] + tr_shift;
4786 for(i=0; i<ntc; i++)
4788 if (as_distribution)
4790 signal_array[i] = (double)buffer[i+1] / (time_array[i+1] - time_array[i]);
4791 error_array[i] = sqrt((
double)buffer[i+1]) / (time_array[i+1] - time_array[i]);
4795 signal_array[i] = (double)buffer[i+1];
4796 error_array[i] = sqrt((
double)buffer[i+1]);
4803 for(i=0; i<ntc; i++)
4806 if (as_distribution)
4808 signal_array[i] = (double)buffer[i+1] / (
m_crpt->
rtcb[tr_index][i+1] -
m_crpt->
rtcb[tr_index][i]);
4809 error_array[i] = sqrt((
double)buffer[i+1]) / (
m_crpt->
rtcb[tr_index][i+1] -
m_crpt->
rtcb[tr_index][i]);
4813 signal_array[i] = buffer[i+1];
4814 error_array[i] = sqrt((
double)buffer[i+1]);
4846 return getSpectrumIntegral(1, &spec_no, period, &t_low, &t_high, &integral, &max_val, status);
4855 float t_high,
long integral[],
long max_val[],
DAEstatus& status)
4858 for(
long i=0; i < nspectra; ++i)
4861 getCRPTSpectrumIntegral(1, &j, period, &t_low, &t_high, integral + i, (max_val != NULL ? max_val + i : &k), status);
4868 const float t_high[],
long integral[],
long max_val[],
DAEstatus& status)
4871 int i, j, ntc, tr_index;
4882 if (t_high[i] > t_low[i])
4890 if (daq_period >= 0)
4893 for(j=0; j<ntc; j++)
4895 float contrib = 0.0;
4896 float width = rtcb[j+1] - rtcb[j];
4901 else if ( (rtcb[j] >= t_low[i]) && (rtcb[j+1] <= t_high[i]) )
4905 else if ( (rtcb[j] < t_low[i]) && (rtcb[j+1] >= t_low[i]) && (rtcb[j+1] <= t_high[i]) )
4907 contrib = (rtcb[j+1] - t_low[i]) / width;
4909 else if ( (rtcb[j] >= t_low[i]) && (rtcb[j] <= t_high[i]) && (rtcb[j+1] > t_high[i]) )
4911 contrib = (t_high[i] - rtcb[j]) / width;
4913 else if ( (rtcb[j] < t_low[i]) && (rtcb[j+1] > t_high[i]) )
4915 contrib = (t_high[i] - t_low[i]) / width;
4919 integral[i] += ( contrib == 1.0 ? raw_base[j+1] : (int)floor(0.5 + contrib * raw_base[j+1]) );
4920 if (raw_base[j+1] > max_val[i])
4922 max_val[i] = raw_base[j+1];
4935 unsigned long* buffer;
4941 for(i=0; i<nspectra; i++)
4944 spec_no = spec_start + i;
4945 if (daq_period >= 0)
4949 integral[i] = spec_integrals[spec_no];
4957 const float t_high[],
long integral[],
long max_val[],
DAEstatus& status)
4960 int i, j, ntc, tr_index;
4961 unsigned long* buffer;
4971 buffer =
new unsigned long[ntc+1];
4974 if (t_high[i] > t_low[i])
4982 if (daq_period >= 0)
4992 for(j=0; j<ntc; j++)
4994 if ( full_range || ((rtcb[j] >= t_low[i]) && (rtcb[j+1] <= t_high[i])) )
4996 integral[i] += buffer[j+1];
4997 if (buffer[j+1] > max_val[i])
4999 max_val[i] = buffer[j+1];
5014 if ((monitor > 0) && (monitor <= m_crpt->nmon))
5017 if (i >=0 && i < m_crpt->ndet)
5066 if ((update_xml.size() == 0) || (lvxml.
loadFromString(update_xml.c_str(), status) != 0))
5103 lvxml.
setValue(
"Calculation Method", 1, status);
5107 lvxml.
setValue(
"Calculation Method", 0, status);
5113 sprintf(buffer,
"TR%d From %d", j+1, i+1);
5115 sprintf(buffer,
"TR%d To %d", j+1, i+1);
5117 sprintf(buffer,
"TR%d In Mode %d", j+1, i+1);
5119 sprintf(buffer,
"TR%d Steps %d", j+1, i+1);
5134 md5sumString((
const unsigned char*)tcb_xml.c_str(), tcb_xml.length(), csum, status);
5154 if ((tcb_xml.size() == 0) || (lvxml.
loadFromString(tcb_xml.c_str(), status) != 0))
5163 lvxml.
getValue(
"Calculation Method", i, status);
5173 sprintf(buffer,
"TR%d From %d", j+1, i+1);
5175 sprintf(buffer,
"TR%d To %d", j+1, i+1);
5177 sprintf(buffer,
"TR%d In Mode %d", j+1, i+1);
5179 sprintf(buffer,
"TR%d Steps %d", j+1, i+1);
5242 lvxml.
setValue(
"Number Of Software Periods", 1, status);
5247 sprintf(name,
"Type %d", i+1);
5249 sprintf(name,
"Frames %d", i+1);
5251 sprintf(name,
"Output %d", i+1);
5253 sprintf(name,
"Label %d", i+1);
5267 int i, daq_period, nperiod;
5274 if ((periods_xml.size() == 0) || (lvxml.
loadFromString(periods_xml.c_str(), status) != 0))
5292 lvxml.
getValue(
"Number Of Software Periods", nperiod, status);
5294 status.
addInfo(
FAC_CRPT,
"Hardware period table ignored as using software periods");
5302 if (periods_info == NULL)
5311 if (!stricmp(name,
"DAQ"))
5315 else if (!stricmp(name,
"DWELL"))
5325 fclose(periods_info);
5331 sprintf(name,
"Type %d", i+1);
5333 sprintf(name,
"Frames %d", i+1);
5335 sprintf(name,
"Output %d", i+1);
5337 sprintf(name,
"Label %d", i+1);
5353 "invalid period type");
5363 if (daq_period <= 0)
5369 status.
addInfoVa(
FAC_CRPT,
"Programmed %d periods (%d DAQ, %d DWELL) for %d sequences from %s",
5427 double fcdelay, fcwidth;
5430 lvxml.
setValue(
"FC Delay", fcdelay, status);
5431 lvxml.
setValue(
"FC Width", fcwidth, status);
5443 md5sumString((
const unsigned char*)dae_xml.c_str(), dae_xml.length(), csum, status);
5458 if ((dae_xml.size() == 0) || (lvxml.
loadFromString(dae_xml.c_str(), status) != 0))
5463 std::string wiring_table, detector_table, spectra_table;
5470 lvxml.
getValue(
"DAETimingSource", tcb_sync, status);
5481 lvxml.
getValue(
"Wiring Table", wiring_table, status);
5482 lvxml.
getValue(
"Detector Table", detector_table, status);
5483 lvxml.
getValue(
"Spectra Table", spectra_table, status);
5487 double fcdelay, fcwidth;
5488 lvxml.
getValue(
"FC Delay", fcdelay, status);
5489 lvxml.
getValue(
"FC Width", fcwidth, status);
5496 readTables(wiring_table.c_str(), detector_table.c_str(), spectra_table.c_str(), status);
5524 std::vector<std::string> table;
5528 table.push_back(buffer);
5530 table.push_back(buffer);
5532 table.push_back(buffer);
5534 lvxml.
setValue(
"Table", table, status);
5549 if ((monitor_xml.size() == 0) || (lvxml.
loadFromString(monitor_xml.c_str(), status) != 0))
5575 fs >> v[i].spectrum >> v[i].t_low >> v[i].t_high;
5582 std::vector<std::string> table;
5584 lvxml.
getValue(
"Table", table, status);
5589 v[i].spectrum = atoi(table[i*3 + 0].c_str());
5590 v[i].t_low = atof(table[i*3 + 1].c_str());
5591 v[i].t_high = atof(table[i*3 + 2].c_str());
5612 mevents = (double)counts / 1.0e6;
5618 long counts = 0, integral, max_val;
5624 mevents = (double)counts / 1.0e6;
5634 for(i=0; i<len; i++)
5664 std::stringstream f;
5666 mess.
print(f,
true,
true);
5674 char time_buffer[128];
5676 ISOtime(time(NULL), time_buffer,
sizeof(time_buffer));
5683 os <<
"ICP status\n";
5706 std::ostringstream oss;
5709 for(i=0; i<num_values; i++)
5711 stat =
VMEReadValue(card_id, card_address + 4*i, sixteen_bit, &(data[i]), status);
5712 oss << Poco::format(
"0x%08lx = 0x%08lx\n", static_cast<unsigned long>(card_address + 4*i), static_cast<unsigned long>(data[i]));
5747 icp_timer.
info(
"VMEWriteArray", status);
5764 icp_timer.
info(
"VMEReadArray", status);
5771 if (message.size() > 0)
5778 "ISISICP.EXE", MB_SERVICE_NOTIFICATION | MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
5790 static bool incrementaleventnexus = Poco::Util::Application::instance().config().getBool(
"isisicp.incrementaleventnexus",
false);
5791 static bool incrementaleventnexustest = Poco::Util::Application::instance().config().getBool(
"isisicp.incrementaleventnexustest",
false);
5793 if ( incrementaleventnexus && events_nxfile.size() > 0 && Poco::File(events_nxfile).exists() )
5795 if (incrementaleventnexustest)
5798 nxwriter.
writeISISNeXus((std::string(filename)+
".incr").c_str(), logs_only, crpt.
CRPT(), crpt.
rawData(), crpt.
rawDataSizeMax(), iraw, blocks, events_nxfile,
m_instrument_xml_file,
m_instrument_parameter_map_file, dstatus);
5802 nxwriter.
writeISISNeXus(filename, logs_only, crpt.
CRPT(), crpt.
rawData(), crpt.
rawDataSizeMax(), iraw, blocks, events_nxfile,
m_instrument_xml_file,
m_instrument_parameter_map_file, dstatus);
5844 crpt(crpt_), filename(filename_), icp(icp_), status(status_) {}
5875 writeMuonFile(filename, crpt, dstatus);
5879 if (const_cast<ISISRAW*>(iraw)->writeToFile(filename) < 0)
5885 timer1.
info(
"Time to write ISISRAW", dstatus);
5892 FILE* input_file = _fsopen(filename,
"r+bN", _SH_DENYWR);
5893 if (input_file != NULL)
5895 iraw->
ioRAW(input_file,
true);
5951 icp_timer.
info(
"refreshCachedValues", status);
5987 std::string sitem_name = item_name;
5988 int spec_from, spec_to;
5989 if (!strncmp(item_name,
"SPECTRUM_", 9))
5991 long spectrum_number = atol(sitem_name.substr(9, 1000).c_str());
5994 else if ( !strncmp(item_name,
"CNT", 3) && (strlen(item_name) >= 5) && (item_name[4] ==
'[') )
5996 long tr = atol(item_name + 3);
6002 else if ( !strncmp(item_name,
"CNT", 3) )
6004 long tr = atol(item_name + 3);
6005 long spec_min, spec_max;
6015 if (!strcmp(item_name,
"SPECTRUM"))
6019 else if ( !strncmp(item_name,
"CNT", 3) )
6021 long tr = atol(item_name + 3);
6022 long spec_min, spec_max;
6037 if (!strcmp(item_name,
"RSPECTRUM") || !strcmp(item_name,
"RSPECERR"))
6046 std::string sitem_name = item_name;
6047 long spectrum_number, sum;
6048 if (!strncmp(item_name,
"RSPECTRUM_", 10))
6050 spectrum_number = atol(sitem_name.substr(10, 1000).c_str());
6052 double* time_array =
new double[ntc+1];
6053 double* error_array =
new double[ntc];
6055 getSpectrum(spectrum_number, 0, time_array, darray, error_array,
6056 true,
true, sum, status);
6057 delete[] time_array;
6058 delete[] error_array;
6061 if (!strncmp(item_name,
"RSPECERR_", 9))
6063 spectrum_number = atol(sitem_name.substr(9, 1000).c_str());
6065 double* time_array =
new double[ntc+1];
6066 double* signal_array =
new double[ntc];
6068 getSpectrum(spectrum_number, 0, time_array, signal_array, darray,
6069 true,
true, sum, status);
6070 delete[] time_array;
6071 delete[] signal_array;
6083 int len, spec, daq_period;
6097 for(i=0; i<nspectra; i++)
6099 spec = spectra_list[i];
6136 for(
int daq_period=0; daq_period <
m_crpt->
nper_daq; ++daq_period)
6171 fs.open(filename, std::ios::in);
6181 for(
int i=0; i<1; i++)
6183 std::fstream::pos_type pt = fs.tellg();
6184 getline(fs, s1, sep);
6218 std::pair<CRPTProxy::parameter_map_t::iterator, bool> insert_ret;
6220 for(
int i=0; i<string_table.size(); i++)
6222 if (string_table[i].size() > 3)
6224 insert_ret = param_map.insert(CRPTProxy::parameter_map_t::value_type(string_table[i][0],
6240 std::string s1, s2, s3, s4;
6242 std::pair<CRPTProxy::parameter_map_t::iterator, bool> insert_ret;
6243 fs.open(filename, std::ios::in);
6246 std::fstream::pos_type pt;
6248 getline(fs, s1, sep);
6249 getline(fs, s2, sep);
6250 getline(fs, s3, sep);
6256 getline(fs, s1, sep);
6257 getline(fs, s2, sep);
6265 getline(fs, s1, sep);
6278 insert_ret = param_map.insert(CRPTProxy::parameter_map_t::value_type(s1,
CRPTProxy::parameter_t(s2, s3, s4)));
6296 int offset, count = 0;
6297 size_t p1, p2, start;
6299 seblock_map_t::const_iterator se_iter;
6300 if (se_blocks == NULL)
6307 p1 = s.find(
"@", start);
6308 if (p1 == std::string::npos)
6312 if (p1 < s.size() && s[p1+1] ==
'!')
6322 p2 = s.find(
"@", p1 + 1);
6323 if (p2 == std::string::npos)
6327 std::string block = s.substr(p1 + offset, p2 - p1 - offset);
6328 if ( (se_iter = se_blocks->find(block)) != se_blocks->end() )
6330 std::string repstr =
"NaN";
6331 if (se_iter->second.is_real)
6333 std::stringstream sstr;
6334 if (setpoint && se_iter->second.fsetpoint_value.size() > 0)
6336 sstr << se_iter->second.fsetpoint_value[0];
6337 repstr = sstr.str();
6339 else if (!setpoint && se_iter->second.fcurrent_value.size() > 0)
6341 sstr << se_iter->second.fcurrent_value[0];
6342 repstr = sstr.str();
6347 if (setpoint && se_iter->second.setpoint_value.size() > 0)
6349 repstr = se_iter->second.setpoint_value[0];
6351 else if (!setpoint && se_iter->second.current_value.size() > 0)
6353 repstr = se_iter->second.current_value[0];
6356 s.replace(p1, p2 - p1 + 1, repstr);
6357 start = p1 + repstr.size();
6372 CRPTProxy::parameter_map_t::const_iterator iter;
6373 if ( (iter = params.find(name)) != params.end() )
6375 std::string s = iter->second.value;
6377 crpt_target = atof(s.c_str());
6387 int size_crpt_target,
bool null_terminate,
DAEstatus& status)
6389 CRPTProxy::parameter_map_t::const_iterator iter;
6390 if ( (iter = params.find(name)) != params.end() )
6392 std::string s = iter->second.value;
6394 strncpy(crpt_target, s.c_str(), size_crpt_target);
6402 crpt_target[size_crpt_target-1] =
'\0';
6410 CRPTProxy::parameter_map_t::const_iterator it;
6414 if (it->second.value.find(
"@") != std::string::npos)
6456 CRPTProxy::parameter_map_t::const_iterator it;
6460 if (it->second.value.find(
"@") != std::string::npos)
6480 setRealParameter(beamline_parameters, se_blocks,
"Primary Flight Path (L1)", crpt->
i_l1, status);
6481 setRealParameter(beamline_parameters, se_blocks,
"Sample Detector Distance", crpt->
sdd, status);
6495 std::string user_names, last_user, user_tmp;
6500 for(
int i=0; i<table.size(); i++)
6502 if (table[i].size() > 0)
6504 last_user = table[i][0];
6505 k = last_user.find(
' ');
6506 if (k != last_user.npos)
6508 user_tmp = last_user.substr(0, k);
6512 user_tmp = last_user;
6516 user_names = user_tmp;
6520 user_names = user_names +
"," + user_tmp;
6526 if (table[i].size() > 1)
6530 if ( table[i].size() > 2 )
6532 std::string role = table[i][2];
6533 std::transform(role.begin(), role.end(), role.begin(), tolower);
6534 if (role.find(
"contact") != role.npos)
6572 static const char*
STR0(
const char* str,
const char* value =
"UNSPECIFIED")
6574 if (str == NULL || str[0] ==
'\0')
6590 XMLJournalHandler(
int& first_run,
int& last_run) : Poco::XML::ContentHandler(), m_first_run(first_run), m_last_run(last_run) { }
6594 m_first_run = m_last_run = 0;
6595 in_run_number =
false;
6600 void startElement(
const Poco::XML::XMLString& uri,
const Poco::XML::XMLString& localName,
const Poco::XML::XMLString& qname,
6601 const Poco::XML::Attributes& attrList)
6603 if (localName ==
"run_number")
6605 in_run_number =
true;
6609 void endElement(
const Poco::XML::XMLString& uri,
const Poco::XML::XMLString& localName,
const Poco::XML::XMLString& qname)
6611 if (localName ==
"run_number")
6613 in_run_number =
false;
6617 void characters(
const Poco::XML::XMLChar ch[],
int start,
int length)
6624 run_number = atoi(std::string(ch+start, length).c_str());
6627 m_last_run = run_number;
6628 if (m_first_run == 0)
6630 m_first_run = m_last_run;
6655 memset(&jl,
' ',
sizeof(jl));
6665 memset(&sl,
' ',
sizeof(sl));
6666 memcpy(&(sl.
jl), &jl,
sizeof(sl.
jl));
6670 fsj.open(
m_data_dir+
"\\journal.txt", std::ios::app);
6673 for(i=0; i<
sizeof(jl); i++)
6675 c = ((
const char*)&jl)[i];
6690 fss.open(
m_data_dir+
"\\summary.txt", std::ios::app);
6693 for(i=0; i<
sizeof(sl); i++)
6695 c = ((
const char*)&sl)[i];
6711 std::stringstream file_buffer;
6717 file_buffer <<
".xml";
6718 std::string file = file_buffer.str();
6719 if (access(file.c_str(), 0) == 0)
6721 nx_mode = NXACC_RDWR;
6725 nx_mode = NXACC_CREATEXML;
6727 long first_run_number;
6730 first_run_number = 0;
6732 std::string measurement_label;
6735 measurement_label =
"";
6737 std::vector<std::string> jblock_list;
6739 const char* block = strtok(tmp_blocks,
" \t,:;");
6740 while(block != NULL)
6742 jblock_list.push_back(block);
6743 block = strtok(NULL,
" \t,:;");
6746 using namespace NeXus;
6747 using namespace NeXus::Stream;
6748 std::string seci_config;
6749 std::stringstream entry_name;
6752 entry_name << crpt->
inst_name << buffer;
6753 std::string temp_file = m_data_dir +
"\\journal_tmp.xml";
6756 if (nx_mode == NXACC_RDWR)
6759 nx_mode = NXACC_CREATEXML;
6761 File journal(file, nx_mode);
6763 journal.putAttr(
"xmlns",
"http://definition.nexusformat.org/schema/3.0");
6764 journal.putAttr(
"xsi:schemaLocation",
"http://definition.nexusformat.org/schema/3.0");
6765 journal.makeGroup(entry_name.str(),
"NXentry",
true);
6772 journal.writeData(
"experiment_identifier",
STR0(buffer));
6773 journal.writeData(
"instrument_name",
STR0(crpt->
inst_name));
6774 journal.writeData(
"run_number", crpt->
run_number);
6776 journal.writeData(
"measurement_first_run", (
int)first_run_number);
6778 journal.writeData(
"measurement_label",
STR0(measurement_label.c_str()));
6782 journal.writeData(
"start_time", buffer);
6784 journal.writeData(
"end_time", buffer);
6785 journal.writeData(
"duration", crpt->
duration);
6786 journal.writeData(
"proton_charge", crpt->
good_uamph);
6788 journal.writeData(
"good_frames", crpt->
good_frames);
6789 journal.writeData(
"number_periods", crpt->
nper);
6791 journal.writeData(
"number_detectors", crpt->
ndet);
6792 journal.writeData(
"number_time_regimes", crpt->
ntrg);
6794 for(i=0; i<crpt->
ntrg; i++)
6797 int ntcr = crpt->
ntcr[i];
6798 sprintf(buffer,
"time_regime_%d", i+1);
6799 journal.makeGroup(buffer,
"IXtime_regime",
true);
6800 journal.writeData(
"number_time_channels", crpt->
ntc[i]);
6802 journal.writeData(
"time_channel_min", tcr[0].start);
6803 journal.writeData(
"time_channel_max", tcr[ntcr-1].end);
6804 journal.closeGroup();
6811 journal.writeData(
"monitor_sum", crpt->
monitor_sum[0]);
6813 journal.writeData(
"comment",
STR0(crpt->
comment));
6822 journal.writeData(
"seci_config",
STR0(seci_config.c_str()));
6824 journal.makeGroup(
"selog",
"IXselog",
true);
6825 for(std::vector<std::string>::const_iterator it = jblock_list.begin(); it != jblock_list.end(); ++it)
6827 seblock_map_t::const_iterator itb;
6828 if ( (Poco::trim(*it)).size() == 0 )
6832 journal.makeGroup(*it,
"IXseblock",
true);
6833 if ( (itb = blocks.find(*it)) != blocks.end() )
6835 const SEBLOCK& block = itb->second;
6845 journal.writeData(
"current_value",
"NaN");
6854 journal.writeData(
"setpoint_value",
"NaN");
6857 journal.writeData(
"average_value",
"NaN");
6867 journal.writeData(
"current_value",
"UNKNOWN");
6875 journal.writeData(
"setpoint_value",
"UNKNOWN");
6877 journal.writeData(
"average_value",
"NaN");
6882 journal.writeData(
"current_value",
"NaN");
6883 journal.writeData(
"setpoint_value",
"NaN");
6884 journal.writeData(
"average_value",
"NaN");
6886 journal.closeGroup();
6888 journal.closeGroup();
6889 journal.closeGroup();
6891 if (file == temp_file)
6893 std::fstream journal_full;
6894 journal_full.open(file.c_str(), std::ios::in);
6895 char big_buffer[10000];
6896 journal_full.getline(big_buffer,
sizeof(big_buffer),
'\0');
6897 journal_full.close();
6898 remove(temp_file.c_str());
6899 std::string xml_entry = big_buffer;
6900 HANDLE h = CreateFile(file_buffer.str().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
6902 if (h != INVALID_HANDLE_VALUE)
6906 SetFilePointerEx(h, li, NULL, FILE_END);
6908 ReadFile(h, buffer, 20, &nread, NULL);
6909 buffer[nread] =
'\0';
6910 const char* pos = strstr(buffer,
"</NXroot>");
6913 int offset = (nread - (pos - buffer));
6914 li.QuadPart = -offset;
6915 SetFilePointerEx(h, li, NULL, FILE_END);
6916 int spos = xml_entry.find(
"<NXentry");
6917 if (spos != std::string::npos)
6919 std::string spos_str = xml_entry.substr(spos);
6921 if ( (WriteFile(h, spos_str.c_str(), spos_str.size(), &nwrite, NULL) == 0) ||
6922 (nwrite != spos_str.size()) )
6933 catch(
const std::exception& ex)
6937 std::vector<std::string> journal_list;
6938 std::string journal_main = m_data_dir +
"\\journal_main.xml";
6939 SetFileAttributes(journal_main.c_str(), FILE_ATTRIBUTE_NORMAL);
6940 remove(journal_main.c_str());
6941 findFiles(m_data_dir.c_str(),
"journal*.xml", journal_list,
false);
6942 std::ofstream jmain;
6945 jmain.open(journal_main);
6946 jmain <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << std::endl;
6947 jmain <<
"<?xml-stylesheet type=\"text/xsl\" href=\"journal.xsl\" ?>" << std::endl;
6948 jmain <<
"<!-- DO NOT EDIT - recreated automatically by ICP at each END of run -->" << std::endl;
6949 jmain <<
"<journal>" << std::endl;
6950 Poco::XML::SAXParser parser;
6951 int first_run, last_run;
6953 parser.setContentHandler(&journal_handler);
6954 for(std::vector<std::string>::const_iterator it = journal_list.begin(); it != journal_list.end(); ++it)
6958 parser.parse(m_data_dir +
"\\" + *it);
6960 catch(
const std::exception& ex)
6962 status.
addWarningVa(
FAC_CRPT,
"Error SAX parsing XML journal file \"%s\" : %s", it->c_str(), ex.what());
6963 first_run = last_run = 0;
6965 jmain <<
" <file name=\"" << *it <<
"\" first_run=\"" << first_run <<
"\" last_run=\"" << last_run <<
"\" />" << std::endl;
6967 jmain <<
"</journal>" << std::endl;
6969 SetFileAttributes(journal_main.c_str(), FILE_ATTRIBUTE_READONLY);
6971 catch(
const std::exception& ex)
7021 unsigned len = permax * nperiod;
7084 Poco::SharedPtr<NeXus::File> nx_file;
7085 std::vector<int32_t> int32_vec;
7096 nx_file =
new NeXus::File(file_name, NXACC_READ);
7097 nx_file->openPath(
"/entry/data");
7098 info = nx_file->getInfo();
7099 nx_file->getData(int32_vec);
7100 nx_file->openPath(
"/entry/good_frames");
7101 nx_file->getData(&good_frames);
7102 nx_file->openPath(
"/entry/proton_charge");
7103 nx_file->getData(&good_uah);
7106 catch(
const std::exception& ex)
7112 if ( info.dims.size() == 2 )
7121 else if ( info.dims.size() == 3 )
7135 if ( info.dims[0+period_offset] !=
m_crpt->
nsp[0] )
7140 if ( info.dims[1+period_offset] !=
m_crpt->
ntc[0] )
7145 int i, j, ndet, card, modn, mpos, nper, spec, spec_len, maxspec, maxcardspec;
7146 std::ostringstream oss;
7147 int maxmod = 16, maxpos = 4096, maxcrate = 16;
7150 int* last_card_spectrum =
new int[maxcrate];
7151 memset(new_poslut, 0, maxcrate * maxmod * maxpos *
sizeof(
isisU32_t));
7152 memset(last_card_spectrum, 0, maxcrate *
sizeof(
int));
7157 int* spec_lookup =
new int[maxspec];
7158 memset(spec_lookup, 0, maxspec *
sizeof(
int));
7159 for(i=0; i < ndet; i++)
7165 if (card >= maxcrate)
7172 j = card * (maxmod * maxpos) + modn * (maxpos) + mpos;
7173 if (spec_lookup[spec] != 0)
7175 new_poslut[j] = spec_lookup[spec];
7179 new_poslut[j] = ++(last_card_spectrum[card]);
7180 spec_lookup[spec] = last_card_spectrum[card];
7184 for(i=0; i < ndet; i++)
7190 maxcardspec = last_card_spectrum[card] + 1;
7191 for(j=0; j<nper; j++)
7194 int array_offset = ((spec - 1) + (maxspec - 1) * j) * (spec_len - 1);
7196 (spec_lookup[spec] + maxcardspec * j) * spec_len * 4 + 1,
7197 spec_len - 1, status);
7201 oss <<
"Loaded " <<
m_crpt->
nsp[0] <<
" spectra, " <<
m_crpt->
ntc[0] <<
" time channels, " <<
m_crpt->
nper <<
" period(s)" << std::endl;
7202 for(i=0; i<maxcrate; i++)
7204 if (last_card_spectrum[i] > 0)
7206 oss <<
"Writing " << last_card_spectrum[i] <<
" spectra to detector card " << i << std::endl;
7212 oss <<
"Set good_frames=" << good_frames <<
" and proton_charge=" << good_uah << std::endl;
7213 delete []new_poslut;
7214 delete []last_card_spectrum;
7215 delete []spec_lookup;
7225 int i, j, ndet, card, modn, mpos, nper, spec, spec_len, maxspec, maxcardspec;
7226 std::ostringstream oss;
7227 int maxmod = 16, maxpos = 4096, maxcrate = 16;
7244 int* last_card_spectrum =
new int[maxcrate];
7245 memset(new_poslut, 0, maxcrate * maxmod * maxpos *
sizeof(
isisU32_t));
7246 memset(last_card_spectrum, 0, maxcrate *
sizeof(
int));
7247 spec_len = ir->
t_ntc1 + 1;
7250 maxspec = (ir->
t_nsp1 + 1);
7251 int* spec_lookup =
new int[maxspec];
7252 memset(spec_lookup, 0, maxspec *
sizeof(
int));
7253 for(i=0; i < ndet; i++)
7259 if (card >= maxcrate)
7266 j = card * (maxmod * maxpos) + modn * (maxpos) + mpos;
7267 if (spec_lookup[spec] != 0)
7269 new_poslut[j] = spec_lookup[spec];
7273 new_poslut[j] = ++(last_card_spectrum[card]);
7274 spec_lookup[spec] = last_card_spectrum[card];
7278 for(i=0; i < ndet; i++)
7284 maxcardspec = last_card_spectrum[card] + 1;
7285 for(j=0; j<nper; j++)
7288 (spec_lookup[spec] + maxcardspec * j) * spec_len * 4,
7293 for(i=0; i<maxcrate; i++)
7295 if (last_card_spectrum[i] > 0)
7297 oss <<
"Writing " << last_card_spectrum[i] <<
" spectra to detector card " << i << std::endl;
7301 delete []new_poslut;
7302 delete []last_card_spectrum;
7303 delete[] spec_lookup;
7312 m_dae->
setVeto(name, (enable != 0 ?
true :
false), status);
7319 if (expression.size() == 0)
7327 std::string sexp(expression);
7329 for(std::map<std::string,double>::iterator it = values.begin(); it != values.end() ; ++it)
7331 p.DefineVar(it->first.c_str(), &(it->second));
7337 catch (Parser::exception_type& e)
7363 int period, daq_period;
7377 good_frames[i] = igf;
7378 raw_frames[i] = irf;
7401 int period, daq_period;
7428 Poco::NotificationCenter& nc = Poco::NotificationCenter::defaultCenter();
7440 Poco::Timespan one_day(1, 0, 0, 0, 0);
7441 std::string form =
m_log_dir+
"\\post_command_%s.log";
7442 Poco::LocalDateTime dateTime;
7443 std::string file = Poco::format(form.c_str(), Poco::DateTimeFormatter::format(dateTime,
"%w"));
7444 dateTime += one_day;
7445 std::string next_file = Poco::format(form.c_str(), Poco::DateTimeFormatter::format(dateTime,
"%w"));
7446 if (_access(next_file.c_str(), 0) == 0)
7448 remove(next_file.c_str());
7462 std::transform(dae2specmap.begin(), dae2specmap.end(),
m_crpt->
dae2cardpos.c_array(), boost::bind(&ISISDAE::dae2spec_map_t::value_type::first, _1));
7463 std::map<int,int>::const_iterator tr_it;
7470 throw std::runtime_error(
"cardpos2index - pos too high");
7473 tr_it = trcn.find(pos);
7474 if (tr_it != trcn.end())
7488 const ISISDAE::dae2spec_map_t::mapped_type& val = dae2specmap.find(pos)->second;
7521 if (tr >= 1 && tr <= m_crpt->ntrg)
boost::array< int, ISISCRPT_MAX_DETECTOR > det_mode
int VMEReadValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long *value, DAEstatus &status)
#define NULL_TERMINATE(__array)
null terminate a char[n] static array
int setSampleParameters(const string_table_t &table, DAEstatus &status)
int(ISISinstrumentControl::* xml_update_func_t)(const std::string &xml, DAEstatus &status)
int updateFunc(int poll_time, bool only_refresh_cache)
int md5sumFile(const char *filename, unsigned char *md5sum, DAEstatus &status)
void endPrefixMapping(const Poco::XML::XMLString &prefix)
char file[ISISCRPT_MAX_LVXML_SIZE]
int getVetoStatus(std::string &veto_text, DAEstatus &status)
int openGroup(const char *group_name, const char *group_class)
int loadFromString(BSTR xml_string, DAEstatus &status)
static void histogramEventsToCRPT(const ISISCRPT_STRUCT *crpt1, const ISISCRPT_STRUCT *crpt2, ISISCRPT_DATA *crpt_data1, ISISCRPT_DATA *crpt_data2, const DAEEventHeader *head, const DetectorEvent32 *ev, int n, int event_source_id)
boost::array< int, ISISCRPT_NUM_FC_VETO > fermi_chopper_delay
in 20ns
int data_type
0=unknown, 1=int, 2=float
int ioRAW(FILE *file, bool from_file)
static void seTransFunction(unsigned int u, EXCEPTION_POINTERS *pExp)
static const char * muon_daes[]
int setPeriodType(ISISDAE::PeriodType type, bool single_daq_period, DAEstatus &status)
int refreshCachedValues(DAEstatus &status)
time_t stop_time
last time period paused
float getCurrentPeriodRawUAmpH(DAEstatus &status)
int setValue(const char *name, const char *value, DAEstatus &status)
bool isMultiplePeriodSequenceComplete(DAEstatus &status)
int loadFromFile(const char *filename, DAEstatus &status)
int timr_crpt[ISISCRPT_MAX_DETECTOR]
int getMEvents(double &mevents, DAEstatus &status)
virtual ~ISISinstrumentControl()
int setVeto(const std::string &name, bool enable, DAEstatus &status)
int listEntries(std::list< std::string > &entries, bool groups_only=false)
int getNumberOfSpectra(DAEstatus &status)
int getHardwarePeriodsXML(const std::string &periods_xml_in, std::string &periods_xml_out, DAEstatus &status)
static int logEventVaImp(time_t the_time, const CRPTProxy &crpt, DAEstatus &status, const char *event, va_list ap)
int getPeriodSize() const
int getNumSpectra(bool include_spectrum_zero=false) const
void zeroCRPTRunRawData()
int getRealArrayItem(const char *item_name, const long *spec_array, int nspec, double *darray, DAEstatus &status) const
long update_period_sequence
float getGoodUAmpH(DAEstatus &status)
int getIntArrayItemSize(const char *item_name, int *dims_array, int &ndims, DAEstatus &status)
float getGoodUAmpHoursPeriod(int period, DAEstatus &status)
int code[ISISCRPT_MAX_DETECTOR]
SELOGGER_API int __stdcall se_log_run(int run_number, const char *source, const char *iso_time, int period, int run_status, int is_running, int is_waiting, int good_frames, int raw_frames, float good_uamph, float raw_uamph, int64_t monitor_sum0, float dae_beam_current, int64_t total_counts, float count_rate, float npratio_current)
static int logEventVa(time_t the_time, const CRPTProxy &crpt, DAEstatus &status, const char *event,...)
ISISCRPT_DATA * crptData()
int readData(const char *data_name, std::string &value)
int write_event_log_t(int sev, const char *message, void *arg)
int setLinearTimeChannelRange(int range_number, float start, float end, float step, DAEstatus &status)
int whichVeto(std::string &veto_text, DAEstatus &status)
int getRealItem(const char *item_name, double &dblVal, DAEstatus &status)
int addVa(int facility, int severity, int errtype, const char *format,...)
int setDAE1Vetos(int vetos[], int n, DAEstatus &status)
int udet[ISISCRPT_MAX_DETECTOR]
int getGoodPPPLower(isisU32_t *value, DAEstatus &status)
int RIO(isis32_t bus_addr, isisU16_t &word, DAEstatus &status)
int getNumberOfPeriods(DAEstatus &status)
int writePOSLUTMemory(int card_id, isisU32_t *buffer, int len, DAEstatus &status)
int getCurrentPeriodRawFrames(DAEstatus &status)
int64_t update_total_counts
static int ISOtime(time_t time, char *buffer, int len)
void stop(bool delete_file=false)
Poco::Net::ServerSocket * m_http_svs
bool m_use_full_inst_name_for_files
int updateCycle(DAEstatus &dstatus)
#define ISISDAE_MAX_DAE2TIMECHAN
std::ostream & printStatus(std::ostream &os, DAEstatus &dstatus)
int writeAutosaveFile(DAEstatus &dstatus)
float getRawUAmpHoursPeriod(int period, DAEstatus &status)
float rtcb[ISISCRPT_MAX_NTRG][ISISCRPT_MAX_TIMECHANB]
void setEventMode(bool value)
ICPEventWriter m_icpwriter
int open(const char *filename, int mode, int type=IXNeXusFile::HDF5)
const std::string & eventLog() const
static void * m_report_arg
int modn[ISISCRPT_MAX_DETECTOR]
int flushCRPT(DAEstatus &status, bool flush_raw_data=false)
int updateFromString(const std::string &xml_string, DAEstatus &status)
ISISinstrumentControl * icp
int getRealArrayItem(const char *item_name, double *darray, DAEstatus &status)
int allReportFuncMain(const DAEstatus_message &mess)
int storeCRPT(DAEstatus &status)
int stopDataCollection(ISISDAE::StopRunMode mode, DAEstatus &status)
int updateUserXML(const std::string &user_xml, DAEstatus &status)
int updateXML(const char *name, xml_update_func_t func, DAEstatus &dstatus)
static write_event_log_t * m_event_func
recovery_map_t m_recovery_map
int updateMonitoringLog()
unsigned total_frames
total up to last pause
int stopRun(StopRunMode mode, DAEstatus &status)
SELOGGER_API int __stdcall se_get_block_values(seblock_map_t &blocks)
static int updateBeamlineParameters(const CRPTProxy::parameter_map_t &beamline_parameters, CRPTProxy &crpt, const seblock_map_t *se_blocks, DAEstatus &status)
int endSEWait(DAEstatus &dstatus)
int readTables(const char *wiring, const char *detector, const char *spectra, DAEstatus &status)
int getGoodPPPUpper(isisU32_t *value, DAEstatus &status)
char label[ISISCRPT_PERIOD_LABEL_LEN]
static bool getBeamlogInt64(Poco::XML::Document *pDoc, const std::string &path, int64_t &value)
bool isFinalSequenceComplete(DAEstatus &status)
void onFinished(Poco::TaskFinishedNotification *pNf)
int readDAE1Spectra(isisU32_t *buffer, int nbuffer, int spec_to_crpt_offset[], int spec_start, int nspec, int period, int persize, DAEstatus &status)
int beginRunEx(bool start_paused, bool delayed_start, long period, DAEstatus &status)
ICPProgressHandler m_task_ph
int makeNewGroup(const char *name, const char *nxclass, bool open_group=true)
write_event_log_t * m_event_log_func
int setDAESpecificParameters()
static int vmstime(char *timbuf, int len, time_t time_value)
int saveCRPTToFile(const CRPTProxy &crpt, const std::string &raw_filename, const std::string &nexus_filename, const seblock_map_t &blocks, const std::string &events_nxfile, DAEstatus &dstatus)
int updateMonitoringXML(const std::string &monitor_xml, DAEstatus &status)
bool compareChecksums(const unsigned char *md5sum1, const unsigned char *md5sum2)
char lvxml_monitoring[ISISCRPT_MAX_LVXML_SIZE]
char lvxml_periods[ISISCRPT_MAX_LVXML_SIZE]
#define ISISCRPT_MAX_NTRG
static std::string getProcessName(DWORD processID)
boost::array< float, ISISCRPT_MAX_TCPAR > tcpar
boost::array< int, ISISCRPT_MAX_NUM_DAE *100 > cardpos2index
reverse of dae2cardpos above - turns position into array index. 100 here is DAE2CardPolicy::CRATE_MOD...
char lvxml_tcb[ISISCRPT_MAX_LVXML_SIZE]
int endRunMain(DAEstatus &status)
int setupDAE(int tables_only, DAEstatus &dstatus)
void clearDCEventMode(DAEstatus &status)
int DAEreport_func_t(const DAEstatus_message &mess, void *arg)
bool m_registersetranslator
int npar
length of tcpar used
Poco::SharedPtr< CRPTProxy > m_crpt_run
used for fast ends
SELOGGER_API int __stdcall se_start_epics_thread(epics_thread_data_t *arg)
char epics_lastread_iso[64]
std::vector< float > fcurrent_spread
per period
void setDCEventMode(unsigned long card_id, bool value, DAEstatus &status)
int writeJournal(const CRPTProxy &crpt, seblock_map_t &blocks, DAEstatus &status)
int getCurrentPeriodGoodFrames(DAEstatus &status)
int whichVeto(std::string &veto_text, DAEstatus &status)
RUNTABLE tcb_file
used if TCBRANGE_FILE
const std::string & statusLog() const
static const char * star_line80
static const int CRATE_MOD
void setDCCardMode(unsigned long card_id, bool neutron_data, DAEstatus &status)
Poco::Path m_inst_settings_dir
int getRawFramesPeriod(isisU32_t *value, int period, DAEstatus &status)
void readBeamloggerBroadcast()
int readFromFile(const char *filename)
int sumAllSpectra(long &counts, long &bin0_counts, DAEstatus &status)
isis32_t open(const char *dae_name, DAEstatus &status)
void characters(const Poco::XML::XMLChar ch[], int start, int length)
int add(DAEstatus &dstatus, bool clear)
int readDetectorTable(const char *filename, DAEstatus &status)
int getCurrentPeriodNumber(int &period, int &daq_period, DAEstatus &status)
struct timeb calc_last_time
#define TCBRANGE_CONST_T
dt=c
bool m_vms_raw_files
produce a VMS raw file
char period_file[ICP_NAME_LEN]
int getCharItem(const char *item_name, std::string &cvalue, DAEstatus &status) const
const std::string & instXMLFileName() const
std::vector< float > fsetpoint_value
per period
int stopEventWriter(bool wait, DAEstatus &status)
int shutter
0 = closed, 1 = open
std::map< std::string, SEBLOCK > seblock_map_t
int changePeriod(int period, DAEstatus &status)
int setBeamlineParameters(const string_table_t &table, DAEstatus &status)
int clearHistogramMemory(DAEstatus &status)
int clearCounters(DAEstatus &status)
int mode
must be a TCBRANGE_* define
#define ISISCRPT_MAX_DETECTOR
int getTotalCounts(int64_t *value, DAEstatus &status)
int fillWithTestPattern(unsigned long pattern, DAEstatus &status)
std::vector< std::vector< std::string > > string_table_t
time_t start_time
first time period started
int updateChecksum(unsigned char *md5sum1, const unsigned char *md5sum2)
int getIntArrayItem(const char *item_name, const long *spec_array, int nspec, long *larray, DAEstatus &status) const
SECURITY_ATTRIBUTES * defaultNoInheritHandles()
int getValue(const char *name, char *value, int max_len, bool write_null, DAEstatus &status)
int getOptions(std::string &options_xml, DAEstatus &status)
int mpos[ISISCRPT_MAX_DETECTOR]
int getDAEsettingsXML(const std::string &dae_xml_in, std::string &dae_xml_out, DAEstatus &status)
static int logEvent(time_t the_time, const CRPTProxy &crpt, const std::string &event, DAEstatus &status)
int printInfo(std::ostream &os)
int getExternalResetCommands(std::list< std::pair< std::string, std::string > > &commands, DAEstatus &status)
std::vector< std::string > setpoint_value
per period
int runPostCommand(const char *property_name, const std::string &arg, DAEstatus &status)
int getGoodFrames(DAEstatus &status)
bool m_shutdown_requested
int muonkicker
0 = off, 1 = on
#define LOGSTR_DEBUG(__arg)
bool isFinalSequenceComplete(DAEstatus &status)
int getRawPPPLower(isisU32_t *value, DAEstatus &status)
char instrument_xml_file[ISISCRPT_MAX_FNAMELEN]
int getSMPVetoedFrames(isisU32_t *value, DAEstatus &status)
boost::array< int, ISISCRPT_MAX_MONITOR > monp
boost::array< int, ISISCRPT_MAX_DC > dae2cardpos
detector card positions, length ndetcard
int importCRPT(const char *filename, DAEstatus &dstatus)
bool hasFileChanged(DAEstatus &status) const
const std::string & debugLog() const
int setReportFunction(DAEreport_func_t *report_func, void *arg)
int spacePadCopyVa(char *output, int output_size, const char *format,...)
static int replaceSEparameters(std::string &s, const seblock_map_t *se_blocks, DAEstatus &status)
int killDatasvr(DAEstatus &dstatus)
#define RUNSTATUS_WAITING
bool beamOn(int minutes=0) const
int tcbcalc(DAEstatus &status)
CRPTProxy m_crpt
pointer to CRPT
static std::string m_icp_service_dir
int fileTR(int tr) const
file_tr same as crpt_tr for now
int dae2specmap[ISISCRPT_MAX_DC][ISISCRPT_MAX_DC_DETECTOR]
give spectrum number from dae2 card and dae2 spec number
#define TCBRANGE_FILE
read from file
double diffFileTimesInMilliSec(const FILETIME &start, const FILETIME &finish)
finish - start in milliseconds
int writeHistogramMemory(int card_id, isisU32_t *buffer, int start, int len, DAEstatus &status)
void startEventBroadcaster(const CRPTProxy &crpt)
int compression_block_size
const std::string & instName() const
static int updateCRPTwithSE(CRPTProxy &crpt, DAEstatus &dstatus)
CRITICAL_SECTION m_crpt_cs
char beamstop_position[16]
int notifyICP(long event_id, const char *param, DAEstatus &status)
int changeNumberOfPeriods(int nperiod, DAEstatus &status)
float beamt
for appropriate target
float getRawUAmpH(DAEstatus &status)
static int writeISISRAW(const CRPTProxy &crpt, const char *filename, DAEstatus &dstatus)
int startDataCollection(bool clear_counters, DAEstatus &status)
SELOGGER_API const char *__stdcall se_get_errmsg()
const std::string & instParameterMapFileName() const
SELOGGER_API int __stdcall se_set_period(int period)
#define LOGSTR_WARNING(__arg)
int timr_dae[ISISCRPT_MAX_DETECTOR]
isisU32_t rawDataSizeMax() const
int getSpectrumIntegral(long spec_no, long period, float t_low, float t_high, long &integral, long &max_val, DAEstatus &status)
static const char * FrameSyncNames[]
void ignorableWhitespace(const Poco::XML::XMLChar ch[], int start, int length)
static void nxErrorFunc(void *arg, char *text)
const std::string & monitoringLog() const
int assignLogFiles(const std::string &prefix)
std::string convertWindows1252ToUTF8(const std::string &win_string)
std::vector< std::string > current_value
per period
int setRunStatusImp(long number, bool is_start, DAEstatus &status)
#define TCBRANGE_SHIFTED
pure shift from an existing range
#define ISISCRPT_MAX_DATADAE
boost::array< int, ISISCRPT_MAX_NTRG > spec_min
range of spectrum numbers in CRPT time regime
float tthe[ISISCRPT_MAX_DETECTOR]
const std::string & instXML() const
static void updateThread(void *arg)
int VMEWriteArray(unsigned long card_id, unsigned long card_address, isisU32_t *values, unsigned long num_values, DAEstatus &status)
int getFramesAllPeriods(long *good_frames, long *raw_frames, int n, DAEstatus &status)
boost::array< VETO, ISISCRPT_NUM_VETOS > vetos
static const char * DAEType_desc[]
int updateCRPTSpectra(int period, long spec_start, int nspectra, DAEstatus &status)
int VMEReadValuesToString(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long num_values, std::string &values, DAEstatus &status)
bool repr_normal
running at 40/50Hz if TS1, or 10Hz or TS2
void appendToFileAsync(HANDLE h, const char *message, bool close_after_write)
char lvxml_dae[ISISCRPT_MAX_LVXML_SIZE]
char institute[ISISCRPT_INSTITUTE_NAME_LEN+1]
#define ISISCRPT_MAX_MONITOR
std::string getPostCommandLogName()
std::string padWithZeros(int number, int len)
int VMEWriteValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long value, unsigned long mode, DAEstatus &status)
static int getAttrIntegerValue(Poco::XML::NamedNodeMap *attrs, const char *name)
isisU32_t update_good_frames_period
int unloadCRPT(bool delete_crpt_file, bool delete_crpt_data_file, DAEstatus &status)
int getExternalVetoedFrames(int veto_number, isisU32_t *value, DAEstatus &status)
int getGoodFramesPeriod(isisU32_t *value, int period, DAEstatus &status)
static const char * hash_line80
static double getAttrFloatValue(Poco::XML::NamedNodeMap *attrs, const char *name)
int repr
for appropriate target
int getCRPTSpectrumIntegral(long spec_no, long period, float t_low, float t_high, long &integral, long &max_val, DAEstatus &status)
int loadDAEWithNeXusData(const std::string &file_name, long options, DAEstatus &status)
data_dae_t data_dae[ISISCRPT_MAX_DATADAE]
int startEventWriter(DAEstatus &status)
void stop(bool immediate)
int readSpectraTable(const char *filename, DAEstatus &status)
void unregisterStructuredExceptionHandler(_se_translator_function old_func)
int exitProgram(const std::string &message, bool prompt)
char temperature_label[256]
int saveRun(DAEstatus &status)
static int stringTableToParameterMap(const string_table_t &string_table, CRPTProxy::parameter_map_t ¶m_map, DAEstatus &status)
int VMEReadArray(unsigned long card_id, unsigned long card_address, isisU32_t *values, unsigned long num_values, DAEstatus &status)
int beginRun(DAEstatus &status)
int resetRunController(DAEstatus &status)
int reportAll(bool reset_overall_severity=true, bool remove_messages=true)
_se_translator_function registerStructuredExceptionHandler()
this needs to be called per thread
void startPrefixMapping(const Poco::XML::XMLString &prefix, const Poco::XML::XMLString &uri)
std::list< boost::signals2::connection > m_crpt_signals
int saveToString(std::string &s, DAEstatus &status)
float delt[ISISCRPT_MAX_DETECTOR]
static int updateSampleParameters(const CRPTProxy::parameter_map_t &sample_parameters, CRPTProxy &crpt, const seblock_map_t *se_blocks, DAEstatus &status)
#define ISISCRPT_NUM_VETOS
max number of vetos
boost::array< int, ISISCRPT_MAX_MONITOR > save_monitor_events
whether to save monitor events in event mode (size NMON)
int getTS2PulseVetoedFrames(isisU32_t *value, DAEstatus &status)
int getRealItem(const char *item_name, double &dblVal, DAEstatus &status) const
int dae_type
time CRPT unloaded (may not be set if program crashed)
int updateCRPTWithDAE(CRPTProxy &crpt, bool pause_collection, DAEstatus &status)
ICPNotificationHandler m_nh
int getSpectrumNumbersForTimeRegime(long tr, long &spec_min, long &spec_max, DAEstatus &status)
char long_title[ISISCRPT_TITLE_LEN+1]
void calculateCRPTOffsets()
std::ostream & print(std::ostream &str, bool format_with_T=false, bool add_cr=false) const
int setDCFrameSyncDelay(int crat, isisU32_t delay, DAEstatus &status)
char measurement_id[ICP_NAME_LEN]
int findFiles(const char *directory, const char *pattern, std::vector< std::string > &list, bool full_path)
static int setRealParameter(const CRPTProxy::parameter_map_t ¶ms, const seblock_map_t *se_blocks, const char *name, float &crpt_target, DAEstatus &status)
static DAEreport_func_t * m_func
int getNumberOfTimeChannels(int spectrum, DAEstatus &status)
boost::array< unsigned, ISISCRPT_MAX_MONITOR > monitor_sum
float getCountRate(DAEstatus &status)
int readRecoveryFile(DAEstatus &dstatus)
LabviewXML * m_icp_config
static int allReportFunc(const DAEstatus_message &mess, void *arg)
static const char * runstatus_names[]
int setTimeChannels(int crat, isisU32_t *tcb, int ntc, DAEstatus &status)
static int loadCRPTWithHistogrammedEvents(CRPTProxy &crpt, DAEstatus &dstatus)
void setDocumentLocator(const Poco::XML::Locator *loc)
int getVetoStatus(std::string &veto_text, DAEstatus &status)
const char *__stdcall se_version()
int pauseRun(DAEstatus &status)
bool isEventTR(int tr) const
isisU32_t update_raw_frames_period
#define TCBRANGE_INC_T
dt/t=c
int getFIFOVetoedFrames(isisU32_t *value, DAEstatus &status)
void clearCallbacks(const std::list< boost::signals2::connection > &callback_list)
static int spawnCommand(const std::string &program, const std::string &args, bool use_cmd_exe, bool console, HANDLE *suspended_thread_handle, const std::string &std_in_file, const std::string &std_out_file, const std::string &std_error_file, int wait_time, DAEstatus &dstatus)
char journal_blocks[ISISCRPT_MAX_LVXML_SIZE]
std::list< boost::signals2::connection > addGoodEventCallback(const EventCallbackSlotType &slot)
void snapshot(const std::string &name)
SELOGGER_API int __stdcall se_get_measurement_label(const char *measurement_id, std::string &res)
int getISIS50HzVetoedFrames(isisU32_t *value, DAEstatus &status)
Poco::Thread m_beamlog_thread
float ut[ISISCRPT_MAX_USER]
#define LOGSTR_INFORMATION(__arg)
void fireOnRunStateChange(const char *state)
void printStatus(std::ostream &os, DAEstatus &status)
int getTCBXML(const std::string &tcb_xml_in, std::string &tcb_xml_out, DAEstatus &status)
void setRunNumberDigits(int digits)
int tcb[ISISCRPT_MAX_NTRG][ISISCRPT_MAX_TIMECHANB]
void endElement(const Poco::XML::XMLString &uri, const Poco::XML::XMLString &localName, const Poco::XML::XMLString &qname)
static void purecallHandler()
int startRun(bool clear_counters, int run_number, time_t &start_time, DAEstatus &status)
int readAllDAE1Spectra(isisU32_t *buffer, int nbuffer, int spec_to_crpt_offset[], int persize, DAEstatus &status)
@ todo specttrum 0 may have differet size for time regimes
void setICPStartTime(time_t t)
#define LOGSTR_ERROR(__arg)
isis32_t openBackplane(const char *dae_name_bp, DAEstatus &status)
Poco::TaskManager m_taskmgr
int VMEReadValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long *value, DAEstatus &status)
isisU32_t * spectrumIntegrals()
int getRawFrames(isisU32_t *value, DAEstatus &status)
SELOGGER_API int __stdcall se_set_run_number(int run_number)
int getRawFrames(DAEstatus &status)
isisU32_t update_good_ppp_high
isisU32_t update_total_ppp_high
static int killProcess(const char *process_name, DAEstatus &dstatus)
int loadDAEWithData(const std::string &file_name, long options, DAEstatus &status)
static int prettyTime(time_t time, char *buffer, int len)
#define SESTATUS_OUTOFRANGE
static bool getBeamlogString(Poco::XML::Document *pDoc, const std::string &path, std::string &value)
int writeWinEventLog(int sev, const std::string &message)
int endRunTask(Poco::SharedPtr< CRPTProxy > crpt, NeXusWriter &nxwriter, bool keep_raw_events, bool keep_crpt, const std::string events_nxfile, DAEstatus &status)
int writeISISRAWasync(const CRPTProxy &crpt, const char *filename, DAEstatus &dstatus)
int updateDAEsettingsXML(const std::string &status_xml, DAEstatus &status)
const std::string & instParameterMap() const
int enableDelayedStart(DAEstatus &status)
unsigned char md5checksum_t[16]
SELOGGER_API int __stdcall se_set_period_async(int period)
boost::array< int, ISISCRPT_MAX_NTRG > tcb_trdelay
boost::signals2::signal< void(BSTR)> m_state_sig
int sendEmail(const std::string &sender, const std::string &recipient, const std::string &subject, const std::string &content, DAEstatus &status)
int spec[ISISCRPT_MAX_DETECTOR]
float chopper_opening_angle
char fname[ISISCRPT_MAX_FNAMELEN]
int readISISRAW(const char *filename, DAEstatus &dstatus)
int updateSampleXML(const std::string &sample_xml, DAEstatus &status)
int addWarning(int facility, const std::string &text)
int startSEWait(DAEstatus &dstatus)
double info(const char *title, std::ostream &os, bool add_nl=true)
SELOGGER_API int __stdcall se_close()
int getIntItem(const char *item_name, long &lVal, DAEstatus &status)
void start(const char *title=NULL)
void startElement(const Poco::XML::XMLString &uri, const Poco::XML::XMLString &localName, const Poco::XML::XMLString &qname, const Poco::XML::Attributes &attrList)
static int updateBeamlineParametersFromFile(const char *filename, DAEstatus &status)
char instrument_parameter_map_file[ISISCRPT_MAX_FNAMELEN]
unsigned epics_lastread_nano
#define ISISCRPT_MAX_DC_DETECTOR
Poco::SingletonHolder< ICPClock > g_icp_clock
boost::array< int, ISISCRPT_MAX_NTRG > ntcr
float update_npratio_current
int addWarningVa(int facility, const char *format,...)
int disablePeriodCard(DAEstatus &status)
int changeNumberOfSoftwarePeriods(long nperiod, DAEstatus &status)
int getRealArrayItemSize(const char *item_name, int *dims_array, int &ndims, DAEstatus &status) const
int writeMuonFile(const char *filename, const ISISCRPT_STRUCT *crpt, const isisU32_t *raw_data, isisU32_t raw_data_size, const seblock_map_t &blocks, const Poco::Path &inst_settings_dir, const std::string &inst_xml_file, const std::string &inst_parameter_map_file, DAEstatus &dstatus)
boost::array< int, ISISCRPT_MAX_MONITOR > mdet
int requestEndRunAfterNextSequenceCompletes(DAEstatus &status)
#define RUNSTATUS_RUNNING
static Poco::Util::Application * m_pApp
char isis_cycle[ISISCRPT_MAX_LVXML_SIZE]
std::vector< float > fcurrent_value
per period
static void deleteOutputFile(int run_number, DAEstatus &status)
int writeISISNeXus(const char *filename, bool logs_only, const ISISCRPT_STRUCT *crpt, const isisU32_t *raw_data, isisU32_t raw_data_size, const ISISRAW *iraw, const seblock_map_t &blocks, const std::string &inst_xml_file, const std::string &inst_parameter_map_file, DAEstatus &dstatus, bool update=false)
double eventModeCardFraction() const
float ts_total
since midnight for appropriate target
SELOGGER_API int __stdcall se_get_seci_config(std::string &seci_config)
parameter_map_t & sampleParameters()
static int updateParametersFromFile(CRPTProxy::parameter_map_t ¶m_map, const char *filename, DAEstatus &status)
volatile LONG m_num_async_requests
const char * runStatusName() const
int disableDelayedStart(DAEstatus &status)
int snapshotCRPT(const char *filename, bool do_update, bool do_pause, DAEstatus &status)
int readWiringTable(const char *filename, DAEstatus &status)
int spectrumCRPTTR(int spec) const
unsigned good_frames
total up to last pause
HANDLE launchDatasvr(DAEstatus &dstatus)
void setParameters(LONGLONG perf_counter, LONGLONG proc_freq, FILETIME filetime)
std::string m_recovery_file
md5checksum_t tcb_xml_checksum
isisU32_t update_good_ppp_low
int getDAQPeriod(int period, DAEstatus &status)
char inst_abrv[ISISCRPT_INST_ABRV_LEN+1]
bool muonKickerOK() const
char icp_version[ICP_NAME_LEN]
md5checksum_t dae_xml_checksum
char comp_name[MAX_COMPUTERNAME_LENGTH+1]
void setUAmpScale(float scale)
int VMEWriteValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long value, unsigned long mode, DAEstatus &status)
int getMonitorIntegral(long monitor, long period, float t_low, float t_high, long &integral, DAEstatus &status)
std::vector< float > fsetpoint_spread
per period
#define MAX_MONITORING_PAR
boost::array< PERIOD, ISISCRPT_MAX_PERIOD > period
int crat[ISISCRPT_MAX_DETECTOR]
void setup(const ISISCRPT_STRUCT *crpt, ISISDAE *dae, int run_number_digits, DAEstatus &status)
int endRun(DAEstatus &status)
SELOGGER_API int __stdcall se_get_measurement_first_run(const char *measurement_id, long &run_number)
int md5sumString(const void *buffer, int len, unsigned char *md5sum, DAEstatus &status)
float good_uamph
total up to last pause
int getUAmpHAllPeriods(float *good_uamph, float *raw_uamph, int n, DAEstatus &status)
int pauseRunMain(bool refresh_cache, DAEstatus &dstatus)
isis32_t check(DAEstatus &status)
float getRawUAmpHours(DAEstatus &status)
int updateCRPTWithSEandSaveToFile(CRPTProxy &crpt, const std::string &raw_filename, const std::string &nexus_filename, DAEstatus &dstatus)
isisraw_async_t(const CRPTProxy &crpt_, const char *filename_, ISISinstrumentControl *icp_, DAEstatus &status_)
static std::string m_instrument_parameter_map_file
void skippedEntity(const Poco::XML::XMLString &name)
SELOGGER_API int __stdcall se_get_blocks(int run_number, time_t ref_time, seblock_map_t &blocks)
float getGoodUAmpHours(DAEstatus &status)
SELOGGER_API int __stdcall se_set_run_state(int run_number, const char *state, int is_start)
int beginRunMain(DAEstatus &status)
int beginRunMainEx(bool start_paused, bool delayed_start, long period, DAEstatus &status)
#define LOG_INFORMATION(__arg)
int timr_file[ISISCRPT_MAX_DETECTOR]
float getBeamCurrent(DAEstatus &status)
boost::signals2::connection registerOnRunStateChange(boost::function< void(BSTR)> func)
#define ISISCRPT_MAX_PERIOD
void reportImmediately(bool value)
float getCurrentPeriodGoodUAmpH(DAEstatus &status)
Poco::Mutex & getDataLockRef()
DAEreport_func_t * m_report_func
int doneAsync()
called by async worker thread when it has completed its work
int changePeriod(int period, int daq_period, DAEstatus &status)
bool isEventSpectrum(int spec) const
char measurement_type[ICP_NAME_LEN]
TCBRANGE tcr[ISISCRPT_MAX_NTRG][ISISCRPT_MAX_TCR]
boost::array< int, ISISCRPT_MAX_NTRG > ntc
number of time channels per CRPT time regime
SELOGGER_API int __stdcall se_clear_values(int run_start, int run_finish)
float monitor_range[ISISCRPT_MAX_MONITOR][2]
int fillWithTestPattern(unsigned long pattern, DAEstatus &status)
bool usingEventMode() const
boost::array< int, ISISCRPT_MAX_DC > dae2highspec
length ndetcard
void handleNotification(ICPNotification *pNf)
int getMEventsPeriod(double &mevents, int period, DAEstatus &status)
int VMEWriteArray(unsigned long card_id, unsigned long card_address, isisU32_t *values, unsigned long num_values, DAEstatus &status)
void beamCurrentTimerCallback(Poco::Timer &t)
int evaluateExpression(std::map< std::string, double > &values, const std::string &expression, double &result, DAEstatus &status)
std::map< std::string, parameter_t > parameter_map_t
char user_name[ISISCRPT_USER_NAME_LEN+1]
int updateUserDetailsFromFile(const char *filename, DAEstatus &status)
boost::array< int, ISISCRPT_MAX_DETECTOR > spec_to_crpt_offset
maps spectrum number to offset in raw data of crpt
char inst_name[ISISCRPT_INST_LEN+1]
void processingInstruction(const Poco::XML::XMLString &target, const Poco::XML::XMLString &data)
static int updateSampleParametersFromFile(const char *filename, DAEstatus &status)
void updateICPTimeDiffLog()
int readDataDaeTable(const char *filename, DAEstatus &status)
void zeroUsedRawData(DAEstatus &status)
#define LV_NUM_TIME_REGIMES
number of time regimes settable in labview DAE control Vi
const std::string & timeDiffLog() const
int ts
1 for ts1, 2 for ts2
boost::array< int, ISISCRPT_MAX_DC > dae2cardmode
-1 unused, 0 histogram, 1 event. length ndetcard
isisU32_t sumAllHistogramMemory(DAEstatus &status)
char lvxml_update[ISISCRPT_MAX_LVXML_SIZE]
void setLoggerName(const std::string &logger_name)
char sample_id[ICP_NAME_LEN]
SELOGGER_API int __stdcall se_log_value_async(long run_number, const char *source, const char *iso_time, const char *block_name, const char *block_value)
char sample_orientation[256]
boost::array< int, ISISCRPT_MAX_DETECTOR > spec_to_index
maps spectrum number to index into spec,udet,timr etc arrays in crpt
int getRawPPPUpper(isisU32_t *value, DAEstatus &status)
int writeData(const char *data_name, const std::vector< T > &value)
int setFrameSync(FrameSync fs, int muon_pulse, DAEstatus &status)
DAEstatus & getStatusReporter()
int changePeriodWhileRunning(int period, bool pause_first, DAEstatus &status)
static const char * STR0(const char *str, const char *value="UNSPECIFIED")
bool m_nexus_files
produce a nexus file. If m_vms_raw_files is true, it is log only. If false, it has data too ...
static std::string m_instrument_xml_file
static int writeISISNeXus(NeXusWriter &nxwriter, const CRPTProxy &crpt, const char *filename, bool logs_only, const seblock_map_t &blocks, const std::string &events_nxfile, DAEstatus &dstatus)
int updateHardwarePeriodsXML(const std::string &periods_xml, DAEstatus &status)
int RCretry(const char *name, boost::function< int(ISISinstrumentControl *, DAEstatus &)> func, DAEstatus &status)
int requestEndRunAfterNextSequenceCompletes(DAEstatus &status)
this must have NO VIRTUAL FUNCTIONS as it is embedded inside the CRPT
void closeEventFiles(DAEstatus &status)
#define VMS_RUN_MASK
need to wrap VMS run numbers to fit into 5 digits
int changeUpdateSettingsXML(const std::string &update_xml, DAEstatus &status)
void getCurrentTimeAsFiletime(FILETIME &ft)
int programDAE1POSLUT(int crat[], int maxcrate, int modn[], int mpos[], int spec[], int ndet, int nper_daq, DAEstatus &status)
void setInstName(const std::string &comp_name)
parameter_map_t & beamlineParameters()
int sendNagios(int status, const std::string &service, const std::string &message, DAEstatus &dstatus)
#define ISISCRPT_MAX_TIMECHANB
char measurement_subid[ICP_NAME_LEN]
void zeroEventRawData(DAEstatus &status)
float update_npratio_average
char local_contact[ISISCRPT_USER_NAME_LEN+1]
int readDAE1Spectrum(int dae1_spectrum, isisU32_t *buffer, int nbuffer, DAEstatus &status)
long update_duration_period
int programPeriodCard(PeriodType period_type, int nper, int nperseq_request, isisU32_t *outputs, isisU16_t *dwell_flags, isisU16_t *frames, int period_output_delay, DAEstatus &status)
isisU32_t update_total_ppp_low
int flushCRPT(DAEstatus &status, bool flush_raw_data=false)
int getNPRatio(float *current, float *average, DAEstatus &status)
char instrument_geometry[5]
float total_uamph
total up to last pause
int addInfo(int facility, const std::string &text)
int setFrameSyncDelay(isisU32_t delay, DAEstatus &status)
int abortRun(DAEstatus &status)
int createLastrunFile(const CRPTProxy &crpt, DAEstatus &status)
static DWORD __stdcall writeISISRAWthread(void *arg)
HANDLE m_async_complete_event
int parseSpectraRange(const std::string &spec_range, int &spec_from, int &spec_to)
int getHighestSpectrumNumber() const
int resetSeverityToAtMost(int severity)
std::string m_icp_service_dir
float len2[ISISCRPT_MAX_DETECTOR]
epics_thread_data_t m_epics_data
int setOptions(const std::string &options_xml, DAEstatus &status)
static int sqliteReportFunction(const DAEstatus_message &mess, void *arg)
int setBlockTable(const string_table_t &table, DAEstatus &status)
int getIntItem(const char *item_name, long &lVal, DAEstatus &status) const
float ut[ISISCRPT_MAX_USER *ISISCRPT_MAX_DETECTOR]
void onProgress(Poco::TaskProgressNotification *pNf)
int getRealArrayItemSize(const char *item_name, int *dims_array, int &ndims, DAEstatus &status)
int setLogTimeChannelRange(int range_number, float start, float end, float step, DAEstatus &status)
#define ISISCRPT_MAX_USER
int setUserParameters(long rbno, const string_table_t &table, DAEstatus &status)
int spectrumNTC(int spec) const
int getIntArrayItemSize(const char *item_name, int *dims_array, int &ndims, DAEstatus &status) const
void addFileInputSource(int run_number, FileEventSourceInfo &info)
struct ISISCRPT_STRUCT::@9 icp_clock
int checkTestPattern(unsigned long pattern, DAEstatus &status)
int sendSMS(const std::string &phone, const std::string &message, DAEstatus &status)
std::map< int, std::vector< int > > dae2spec_map_t
Poco::Util::Application * m_app
int addInfoVa(int facility, const char *format,...)
int setTimeChannelRange(int range_number, int range_type, float start, float end, float step, DAEstatus &status)
uint32_t spectrumCRPTOffset(int spec, int daq_period) const
char expression[ISISCRPT_MAX_LVXML_SIZE]
time_t duration
total data collection time in periods (seconds)
static int setStringParameter(const CRPTProxy::parameter_map_t ¶ms, const seblock_map_t *se_blocks, const char *name, char *crpt_target, int size_crpt_target, bool null_terminate, DAEstatus &status)
int checkTestPatternAsync(unsigned long pattern, DAEstatus &status)
int getCurrentPeriodSequence(isisU32_t *period_sequence, DAEstatus &status)
const dae2spec_map_t & getDAE2Specmap() const
double frameTimerDrift(DAEstatus &status)
frame timer drift (icp - dae)
int sumAllHistogramMemory(long &counts, DAEstatus &status)
int loadOrCreateCRPT(const std::string &crpt_file, const std::string &crpt_name, const std::string &crpt_data_file, const std::string &crpt_data_name, int crpt_data_size, ISISDAE::DAEType dae_type, const std::string &comp_name, boost::function< int(DAEstatus &)> readRecoveryFile, DAEstatus &status)
int VMEReadArray(unsigned long card_id, unsigned long card_address, isisU32_t *values, unsigned long num_values, DAEstatus &status)
int updateTCBXML(const std::string &status_xml, DAEstatus &status)
int getSpectrum(long spectrum_number, long period, double *time_array, double *signal_array, double *error_array, bool as_histogram, bool as_distribution, long &sum, DAEstatus &status)
int checkForNoncountingDetectors(const CRPTProxy &crpt, DAEstatus &dstatus)
the idea here is to look for any module (dim) that has no counts
boost::array< int, ISISCRPT_MAX_NTRG > nsp
number of spectra per CRPT time regime
#define TCBRANGE_INC_T_2
dt/t^c=c
int getCurrentHardwarePeriod(isisU32_t *period, DAEstatus &status)
int getCurrentDAQHardwarePeriod(isisU32_t *period, DAEstatus &status)
std::list< boost::signals2::connection > addGoodEventCallback(const EventCallbackSlotType &slot)
char script_name[ICP_NAME_LEN]
boost::array< int, ISISCRPT_MAX_DETECTOR > det_group
0 = monitor, else logical det number
static int debugReportFunction(const DAEstatus_message &mess, void *arg)
static bool getBeamlogInt(Poco::XML::Document *pDoc, const std::string &path, int &value)
int getUpdateSettingsXML(const std::string &update_xml_in, std::string &update_xml_out, DAEstatus &status)
static bool getBeamlogFloat(Poco::XML::Document *pDoc, const std::string &path, float &value)
boost::array< int, ISISCRPT_MAX_NTRG > spec_max
range of spectrum numbers in CRPT time regime
int updateCRPTSpectraAllPeriods(long spec_start, int nspectra, DAEstatus &status)
int setVeto(const std::string &name, long enable, DAEstatus &status)
static int getSE(const CRPTProxy &crpt, seblock_map_t &blocks, DAEstatus &dstatus)
int getCharItem(const char *item_name, std::string &cvalue, DAEstatus &status)
void printComputerMemoryStats(DAEstatus &status)
int spacePadCopy(char *output, const char *input, int output_size)
boost::array< int, ISISCRPT_NUM_FC_VETO > fermi_chopper_width
in 20ns
boost::array< int, ISISCRPT_MAX_DC > dae2cardtr
detector card DAE time regime (-1 if card not used), length ndetcard - individual spectra on card may...
int getMSModeVetoedFrames(isisU32_t *value, DAEstatus &status)
Poco::Net::HTTPServer * m_http_server
XMLJournalHandler(int &first_run, int &last_run)
int writeRecoveryFile(DAEstatus &dstatus)
int getMonitoringXML(const std::string &monitor_xml_in, std::string &monitor_xml_out, DAEstatus &status)
int updateStatusXML(std::string &status_xml, DAEstatus &status)
int getTotalCounts(int64_t &counts, DAEstatus &status)
int getIntArrayItem(const char *item_name, long *larray, DAEstatus &status)
int getGoodFrames(isisU32_t *value, DAEstatus &status)
int updateSpecmapsFromDAE(const std::map< int, int > &trcn, DAEstatus &status)
SELOGGER_API int __stdcall se_log_values_async(long run_number, const char *source, const std::vector< std::string > &iso_times, const std::vector< std::string > &block_names, const std::vector< std::string > &block_values)
boost::array< monitoring_par, MAX_MONITORING_PAR > par_type
int fullTR(int index) const
ISISDAE::DAEType m_dae_type
int resumeRun(DAEstatus &status)