ICP  1
ISISinstrumentControl.h
Go to the documentation of this file.
1 #ifndef ISISINSTRUMENTCONTROL_H
2 #define ISISINSTRUMENTCONTROL_H
3 
4 #ifdef _DEBUG
5 #define CONFIG_NAME "Debug"
6 #else
7 #define CONFIG_NAME "Release"
8 #endif /* _DEBUG */
9 #ifdef _WIN64
10 #define PLATFORM_NAME "x64"
11 #else
12 #define PLATFORM_NAME "Win32"
13 #endif /* _WIN64 */
14 
15 #define PLATFORM_SUFFIX PLATFORM_NAME "\\" CONFIG_NAME
16 
17 #include "IsisBase.h"
18 
19 #include "DAEstatus.h"
20 #include "isisdae.h"
21 #include "CRPTProxy.h"
22 #include "selogger.h"
23 #include "nexuswriter.h"
24 #include "NeXusEventWriter.h"
25 
26 //#include "../isisutils/Logger.h"
27 
29 {
30  std::string filename;
32 };
33 
35 {
36 
37 public:
39 
40  void onProgress(Poco::TaskProgressNotification* pNf)
41  {
42  pNf->release();
43  }
44 
45  void onFinished(Poco::TaskFinishedNotification* pNf)
46  {
47  pNf->task()->name();
48  pNf->release();
49  }
50 
51 };
52 
53 typedef std::vector< std::vector<std::string> > string_table_t;
54 
55 class LabviewXML;
56 typedef int write_event_log_t(int sev, const char* message, void* arg);
57 
58 #include "icp_notifications.h"
59 
61 {
62  protected:
64  Poco::SharedPtr<CRPTProxy> m_crpt_run;
65  std::list<boost::signals2::connection> m_crpt_signals;
72  CRITICAL_SECTION m_crpt_cs;
73  std::string m_comp_name;
74  std::string m_recovery_file;
75  Poco::Timer m_beam_current_timer;
76 // std::string m_crpt_file;
77 // std::string m_crpt_name; ///< name of memory section
78 // std::string m_crpt_data_file;
79 // std::string m_crpt_data_name; ///< name of memory section
80 // isisU32_t m_crpt_data_size; ///< in words
83  volatile LONG m_num_async_requests;
85  Poco::Path m_inst_settings_dir;
86  Poco::Util::Application* m_app;
87  Poco::TaskManager m_taskmgr;
89  Poco::Thread m_beamlog_thread;
90 
92 
94 // NeXusEventWriter m_nxeventwriter;
96 
97  boost::signals2::signal<void(BSTR)> m_state_sig;
98 
100 
101  std::string m_icp_dir;
102  std::string m_icp_service_dir;
103  std::string m_data_dir; // for raw files etc usually c:\data
104  std::string m_log_dir; // for log files etc usually c:\data\log
105 
108 
111  typedef std::map<std::string, std::string> recovery_map_t;
116  bool m_use_full_inst_name_for_files; // otherwise use inst_abrv
117 
119  unsigned m_icp_options;
120 
121  Poco::Net::HTTPServer* m_http_server;
122  Poco::Net::ServerSocket* m_http_svs;
123 
124  int RCretry(const char* name, boost::function<int(ISISinstrumentControl*, DAEstatus&)> func, DAEstatus& status);
125  typedef int (ISISinstrumentControl::*xml_update_func_t)(const std::string& xml, DAEstatus& status);
126  int updateXML(const char* name, xml_update_func_t func, DAEstatus& dstatus);
128 
129  int writeWinEventLog(int sev, const std::string& message);
130  int allReportFuncMain(const DAEstatus_message& mess);
131  static DWORD __stdcall writeISISRAWthread(void* arg);
132 
133  public:
135  int createLastrunFile(const CRPTProxy& crpt, DAEstatus& status);
136  int writeISISRAWasync(const CRPTProxy& crpt, const char* filename, DAEstatus& dstatus);
137  int waitForAsync();
138  int doneAsync();
139  static int allReportFunc(const DAEstatus_message& mess, void* arg);
140 // control functions
141  int beginRun(DAEstatus& status);
142  int beginRunEx(bool start_paused, bool delayed_start, long period, DAEstatus& status);
143  int endRun(DAEstatus& status);
145  bool isFinalSequenceComplete(DAEstatus& status);
146  int pauseRun(DAEstatus& status);
147  int resumeRun(DAEstatus& status);
148  int abortRun(DAEstatus& status);
149  int saveRun(DAEstatus& status);
150  int updateCRPTWithDAE(CRPTProxy& crpt, bool pause_collection, DAEstatus& status);
151  int updateCRPTWithDAE(bool pause_collection, DAEstatus& status);
152  int storeCRPT(DAEstatus& status);
153  int storeCRPT(CRPTProxy& crpt, DAEstatus& status);
154  int snapshotCRPT(const char* filename, bool do_update, bool do_pause, DAEstatus& status);
155  static int updateCRPTwithSE(CRPTProxy& crpt, DAEstatus& dstatus);
156  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);
157  int updateCRPTWithSEandSaveToFile(CRPTProxy& crpt, const std::string& raw_filename, const std::string& nexus_filename, DAEstatus& dstatus);
158  static int getSE(const CRPTProxy& crpt, seblock_map_t& blocks, DAEstatus& dstatus);
159  static int updateCRPTwithSE(CRPTProxy& crpt, const seblock_map_t& blocks, DAEstatus& dstatus);
160  int startSEWait(DAEstatus& dstatus);
161  int endSEWait(DAEstatus& dstatus);
162 
163  int changePeriod(int period, DAEstatus& status);
164  int changePeriodWhileRunning(int period, bool pause_first, DAEstatus& status);
165  int readTables(const char* wiring, const char* detector, const char* spectra, DAEstatus& status);
166 
167  int setLinearTimeChannelRange(int range_number, float start, float end, float step, DAEstatus& status);
168  int setLogTimeChannelRange(int range_number, float start, float end, float step, DAEstatus& status);
169 
170  int setVeto(const std::string& name, long enable, DAEstatus& status);
171 // information retrieval functions
172  bool isRunning();
173  bool isWaiting();
174  int getRunState();
175  int getRunNumber();
176  int getSpectrum(long spectrum_number, long period, double* time_array, double* signal_array, double* error_array,
177  bool as_histogram, bool as_distribution, long& sum, DAEstatus& status);
178  int getSpectrumIntegral(long spec_no, long period, float t_low, float t_high, long& integral, long& max_val, DAEstatus& status);
179  int getMonitorIntegral(long monitor, long period, float t_low, float t_high, long& integral, DAEstatus& status);
180  int getSpectrumIntegral(long n, const long spec_no[], long period, const float t_low[], const float t_high[], long integral[], long max_val[], DAEstatus& status);
181  int getMonitorIntegral(long n, const long monitor[], long period, const float t_low[], const float t_high[], long integral[], DAEstatus& status);
182  int getTotalCounts(int64_t& counts, DAEstatus& status);
183  int getMEvents(double& mevents, DAEstatus& status);
184  int getMEventsPeriod(double& mevents, int period, DAEstatus& status);
185  float getCountRate(DAEstatus& status);
186  int getCRPTSpectrumIntegral(long spec_no, long period, float t_low, float t_high, long& integral,
187  long& max_val, DAEstatus& status);
188  int getCRPTSpectrumIntegral(long n, const long spec_no[], long period, const float t_low[],
189  const float t_high[], long integral[], long max_val[], DAEstatus& status);
190  int getCRPTSpectrumIntegral(long spec_start, int nspectra, long period, float t_low,
191  float t_high, long integral[], long max_val[], DAEstatus& status);
192  int getCRPTSpectrumIntegral(long spec_start, int nspectra, long period, long integral[], DAEstatus& status);
193 
194  float getBeamCurrent(DAEstatus& status);
195  int getCurrentPeriodNumber(int& period, int& daq_period, DAEstatus& status);
196  float getGoodUAmpH(DAEstatus& status);
197  float getRawUAmpH(DAEstatus& status);
198  float getCurrentPeriodGoodUAmpH(DAEstatus& status);
199  float getCurrentPeriodRawUAmpH(DAEstatus& status);
200  float getDuration(DAEstatus& status);
201  int getFramesAllPeriods(long* good_frames, long* raw_frames, int n, DAEstatus& status);
202  int getUAmpHAllPeriods(float* good_uamph, float* raw_uamph, int n, DAEstatus& status);
203  int getNumberOfTimeChannels(int spectrum, DAEstatus& status);
204  int getNumberOfSpectra(DAEstatus& status);
205  int getSpectrumNumbersForTimeRegime(long tr, long& spec_min, long& spec_max, DAEstatus& status);
206  int getNumberOfPeriods(DAEstatus& status);
207  float getPeriodDuration(DAEstatus& status);
208  int getRawFrames(DAEstatus& status);
210  int getGoodFrames(DAEstatus& status);
212  int RIO(isis32_t bus_addr, isisU16_t& word, DAEstatus& status);
213 // XML routines
214  int updateStatusXML(std::string& status_xml, DAEstatus& status);
215  int updateTCBXML(const std::string& status_xml, DAEstatus& status);
216  int updateDAEsettingsXML(const std::string& status_xml, DAEstatus& status);
217  int updateSampleXML(const std::string& sample_xml, DAEstatus& status);
218  int updateUserXML(const std::string& user_xml, DAEstatus& status);
219  int updateHardwarePeriodsXML(const std::string& periods_xml, DAEstatus& status);
220  int changeUpdateSettingsXML(const std::string& update_xml, DAEstatus& status);
221  int updateMonitoringXML(const std::string& monitor_xml, DAEstatus& status);
222  int getDAEsettingsXML(const std::string& dae_xml_in, std::string& dae_xml_out, DAEstatus& status);
223  int getHardwarePeriodsXML(const std::string& periods_xml_in, std::string& periods_xml_out, DAEstatus& status);
224  int getTCBXML(const std::string& tcb_xml_in, std::string& tcb_xml_out, DAEstatus& status);
225  int getUpdateSettingsXML(const std::string& update_xml_in, std::string& update_xml_out, DAEstatus& status);
226  int getMonitoringXML(const std::string& monitor_xml_in, std::string& monitor_xml_out, DAEstatus& status);
227 
228  ISISinstrumentControl(Poco::Util::Application* pApp, const std::string& icp_service_dir, DAEreport_func_t* func = &DAEstatus::ostreamReportFunction,
229  write_event_log_t* event_func = NULL, void* report_arg = &std::cerr);
230  virtual ~ISISinstrumentControl();
231 // int logStatus(DAEstatus& status);
232  int setRunNumber(long number, DAEstatus& status) { ICPCritical cs(&m_crpt_cs); m_crpt->run_number = number; logEvent(m_crpt, "SET_RUN_NUMBER", status); return DAEstatus::Success; }
233  int setRunStatus(long number, DAEstatus& status) { ICPCritical cs(&m_crpt_cs); logEvent(m_crpt, "SET_RUN_STATUS", status); return setRunStatusImp(number, false, status); }
234 
235 // other
237  std::ostream& printStatus(std::ostream& os, DAEstatus& dstatus);
238  static int debugReportFunction(const DAEstatus_message& mess, void* arg);
239  static int sqliteReportFunction(const DAEstatus_message& mess, void* arg);
240  int VMEReadValuesToString(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long num_values, std::string& values, DAEstatus& status);
241  int VMEWriteValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long value, unsigned long mode, DAEstatus& status);
242  int VMEReadValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long *value, DAEstatus& status);
243  int VMEWriteArray(unsigned long card_id, unsigned long card_address, isisU32_t* values, unsigned long num_values, DAEstatus& status);
244  int VMEReadArray(unsigned long card_id, unsigned long card_address, isisU32_t* values, unsigned long num_values, DAEstatus& status);
245 
246  int sumAllSpectra(long& counts, long& bin0_counts, DAEstatus& status);
247  int sumAllHistogramMemory(long& counts, DAEstatus& status);
248 
249  int importCRPT(const char* filename, DAEstatus& dstatus);
250 
251  int readISISRAW(const char* filename, DAEstatus& dstatus);
252  static int writeISISRAW(const CRPTProxy& crpt, const char* filename, DAEstatus& dstatus);
253  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);
254 
255  int getOptions(std::string& options_xml, DAEstatus& status);
256  int setOptions(const std::string& options_xml, DAEstatus& status);
257  int refreshCachedValues(DAEstatus& status);
258  int getPollTime() const { return m_crpt->update_poll_time; }
259 
260  int getCharItem(const char* item_name, std::string& cvalue, DAEstatus& status);
261  int getIntItem(const char* item_name, long& lVal, DAEstatus& status);
262  int getRealItem(const char* item_name, double& dblVal, DAEstatus& status);
263  int getIntArrayItemSize(const char* item_name, int* dims_array, int& ndims, DAEstatus& status);
264  int getIntArrayItem(const char* item_name, long* larray, DAEstatus& status);
265  int getRealArrayItemSize(const char* item_name, int* dims_array, int& ndims, DAEstatus& status);
266  int getRealArrayItem(const char* item_name, double* darray, DAEstatus& status);
267 
268  int getIntItem(const char* item_name, long* spec_array, int nspec, long* lVal, DAEstatus& status);
269  int getRealItem(const char* item_name, long* spec_array, int nspec, double* dblVal, DAEstatus& status);
270  int getIntArrayItem(const char* item_name, long* spec_array, int nspec, long* larray, DAEstatus& status);
271  int getRealArrayItem(const char* item_name, long* spec_array, int nspec, double* darray, DAEstatus& status);
272 
273  int notifyICP(long event_id, const char* param, DAEstatus& status);
274  int setSampleParameters(const string_table_t& table, DAEstatus& status);
275  int setBeamlineParameters(const string_table_t& table, DAEstatus& status);
276  static int updateSampleParameters(const CRPTProxy::parameter_map_t& sample_parameters, CRPTProxy& crpt, const seblock_map_t* se_blocks, DAEstatus& status);
277  static int updateBeamlineParameters(const CRPTProxy::parameter_map_t& beamline_parameters, CRPTProxy& crpt, const seblock_map_t* se_blocks, DAEstatus& status);
278  int setBlockTable(const string_table_t& table, DAEstatus& status);
279  int setUserParameters(long rbno, const string_table_t& table, DAEstatus& status);
280  int getNPRatio(float* current, float* average, DAEstatus& status);
281  void zeroCRPTRawData();
282  void zeroCRPTRunRawData();
283  //static void zeroCRPTRawData(void* arg); // used by thread to call member zeroCRPTRawData
284 
285  int changeNumberOfSoftwarePeriods(long nperiod, DAEstatus& status);
286  int fillWithTestPattern(unsigned long pattern, DAEstatus& status);
287  int checkTestPattern(unsigned long pattern, DAEstatus& status);
288  int getVetoStatus(std::string& veto_text, DAEstatus& status);
289  int whichVeto(std::string& veto_text, DAEstatus& status);
290  int loadDAEWithData(const std::string& file_name, long options, DAEstatus& status);
291 
292  int updateCRPTSpectra(int period, long spec_start, int nspectra, DAEstatus& status);
293  int updateCRPTSpectraAllPeriods(long spec_start, int nspectra, DAEstatus& status);
294  int exitProgram(const std::string& message, bool prompt);
295 
296 // event callbacks
297  boost::signals2::connection registerOnRunStateChange(boost::function<void(BSTR)> func);
298  void fireOnRunStateChange(const char* state);
299 
300  static int ISOtime(time_t time, char* buffer, int len);
301  static int ISOtime(const struct timeb& tb, char* buffer, int len);
302  static int prettyTime(time_t time, char* buffer, int len);
303  static int prettyTime(const struct timeb& tb, char* buffer, int len);
304  _se_translator_function registerStructuredExceptionHandler();
305  void unregisterStructuredExceptionHandler(_se_translator_function old_func);
306 
307 
308 protected:
309  int checkForNoncountingDetectors(const CRPTProxy& crpt, DAEstatus& dstatus);
310  void rerunFailedEnds();
311  int startEventWriter(DAEstatus& status);
312  int stopEventWriter(bool wait, DAEstatus& status);
313  int updateSpecmapsFromDAE(const std::map<int,int>& trcn, DAEstatus& status);
314  int beginRunMain(DAEstatus& status);
315  int beginRunMainEx(bool start_paused, bool delayed_start, long period, DAEstatus& status);
316  int endRunMain(DAEstatus& status);
317  int endRunTask(Poco::SharedPtr<CRPTProxy> crpt, NeXusWriter& nxwriter, bool keep_raw_events, bool keep_crpt, const std::string events_nxfile, DAEstatus& status);
318  int pauseRunMain(bool refresh_cache, DAEstatus& dstatus);
319  int readWiringTable(const char* filename, DAEstatus& status);
320  int readDetectorTable(const char* filename, DAEstatus& status);
321  int readSpectraTable(const char* filename, DAEstatus& status);
322  int tcbcalc(DAEstatus& status);
323  int pausePeriod(PERIOD* p);
324  int setupDAE(int tables_only, DAEstatus& dstatus);
325  static void updateThread(void* arg);
326  int updateFunc(int poll_time, bool only_refresh_cache);
327  static int replaceSEparameters(std::string& s, const seblock_map_t* se_blocks, DAEstatus& status);
328  static int setRealParameter(const CRPTProxy::parameter_map_t& params, const seblock_map_t* se_blocks, const char* name, float& crpt_target, DAEstatus& status);
329  static int setStringParameter(const CRPTProxy::parameter_map_t& params, const seblock_map_t* se_blocks, const char* name, char* crpt_target, int size_crpt_target,
330  bool null_terminate, DAEstatus& status);
331 
332  int setTimeChannelRange(int range_number, int range_type, float start, float end, float step, DAEstatus& status);
333  int updateStatusLog();
334  int updateMonitoringLog();
335  static int logEvent(time_t the_time, const CRPTProxy& crpt, const std::string& event, DAEstatus& status);
336  static int logEvent(const CRPTProxy& crpt, const std::string& event, DAEstatus& status);
337  static int logEventVa(time_t the_time, const CRPTProxy& crpt, DAEstatus& status, const char* event, ... );
338  static int logEventVaImp(time_t the_time, const CRPTProxy& crpt, DAEstatus& status, const char* event, va_list ap);
339  static int logEventVa(const CRPTProxy& crpt, DAEstatus& status, const char* event, ... );
340  int loadCRPT();
341  int flushCRPT(DAEstatus& status, bool flush_raw_data = false);
342  int startDataCollection(bool clear_counters, DAEstatus& status);
344  static int spawnCommand(const std::string& program, const std::string& args, bool use_cmd_exe, bool console, HANDLE* suspended_thread_handle,
345  const std::string& std_in_file, const std::string& std_out_file, const std::string& std_error_file, int wait_time, DAEstatus& dstatus);
346  int readRecoveryFile(DAEstatus& dstatus);
347  int writeRecoveryFile(DAEstatus& dstatus);
348  int readLogFile(const char* filename);
349  int writeAutosaveFile(DAEstatus& dstatus);
350  int getDAQPeriod(int period, DAEstatus& status);
351  int updateCRPTSpectra(int period, long* spectra_list, int nspectra, DAEstatus& status);
352  int updateUserDetailsFromFile(const char* filename, DAEstatus& status);
353  static int updateSampleParametersFromFile(const char* filename, DAEstatus& status);
354  static int updateBeamlineParametersFromFile(const char* filename, DAEstatus& status);
355  static int updateParametersFromFile(CRPTProxy::parameter_map_t& param_map, const char* filename, DAEstatus& status);
356  static int stringTableToParameterMap(const string_table_t& string_table, CRPTProxy::parameter_map_t& param_map, DAEstatus& status);
357  int writeJournal(const CRPTProxy& crpt, seblock_map_t& blocks, DAEstatus& status);
358  HANDLE launchDatasvr(DAEstatus& dstatus);
359  int killDatasvr(DAEstatus& dstatus);
360  static int killProcess(const char* process_name, DAEstatus& dstatus);
361  static std::string getProcessName(DWORD processID);
362  int updateCycle(DAEstatus& dstatus);
363  int evaluateExpression(std::map<std::string,double>& values, const std::string& expression, double& result, DAEstatus& status);
364  std::string getPostCommandLogName();
365  int runPostCommand(const char* property_name, const std::string& arg, DAEstatus& status);
366  static int loadCRPTWithHistogrammedEvents(CRPTProxy& crpt, DAEstatus& dstatus);
367  void beamCurrentTimerCallback(Poco::Timer& t);
368  void updateICPTimeDiffLog();
369  int setRunStatusImp(long number, bool is_start, DAEstatus& status);
370  static std::string m_instrument_xml_file;
372  static void purecallHandler();
373  static void seTransFunction(unsigned int u, EXCEPTION_POINTERS* pExp);
374  int loadDAEWithNeXusData(const std::string& file_name, long options, DAEstatus& status);
375  int readDataDaeTable(const char* filename, DAEstatus& status);
376  int sendNagios(int status, const std::string& service, const std::string& message, DAEstatus& dstatus);
378  bool beamOn(int minutes = 0) const;
379  bool muonKickerOK() const;
380 
381  private:
383 };
384 
386 {
387 private:
388  static Poco::Util::Application* m_pApp;
389  static std::string m_icp_service_dir;
392  static void* m_report_arg;
393 public:
394  static void setDefaultArgs(Poco::Util::Application* pApp, const std::string& icp_service_dir, DAEreport_func_t* func = &DAEstatus::ostreamReportFunction,
395  write_event_log_t* event_func = NULL, void* report_arg = &std::cerr)
396  {
397  m_pApp = pApp;
398  m_icp_service_dir = icp_service_dir;
399  m_func = func;
400  m_event_func = event_func;
401  m_report_arg = report_arg;
402  }
404  {
405  if (m_pApp == NULL)
406  {
407  throw("Did not create InstrumentControlHolder properly");
408  }
409  }
410 };
411 
412 
413 #endif /* ISIS_CRPT_H */
int VMEReadValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long *value, DAEstatus &status)
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)
static void seTransFunction(unsigned int u, EXCEPTION_POINTERS *pExp)
int refreshCachedValues(DAEstatus &status)
float getCurrentPeriodRawUAmpH(DAEstatus &status)
int readLogFile(const char *filename)
int getMEvents(double &mevents, DAEstatus &status)
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)
float getGoodUAmpH(DAEstatus &status)
int getIntArrayItemSize(const char *item_name, int *dims_array, int &ndims, DAEstatus &status)
static int logEventVa(time_t the_time, const CRPTProxy &crpt, DAEstatus &status, const char *event,...)
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 getRealItem(const char *item_name, double &dblVal, DAEstatus &status)
int RIO(isis32_t bus_addr, isisU16_t &word, DAEstatus &status)
int getNumberOfPeriods(DAEstatus &status)
int getCurrentPeriodRawFrames(DAEstatus &status)
static int ISOtime(time_t time, char *buffer, int len)
Poco::Net::ServerSocket * m_http_svs
int updateCycle(DAEstatus &dstatus)
int writeAutosaveFile(DAEstatus &dstatus)
std::ostream & printStatus(std::ostream &os, DAEstatus &dstatus)
int flushCRPT(DAEstatus &status, bool flush_raw_data=false)
int getRealArrayItem(const char *item_name, double *darray, DAEstatus &status)
int storeCRPT(DAEstatus &status)
int allReportFuncMain(const DAEstatus_message &mess)
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
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)
float getDuration(DAEstatus &status)
StopRunMode
Definition: isisdae.h:154
void onFinished(Poco::TaskFinishedNotification *pNf)
int beginRunEx(bool start_paused, bool delayed_start, long period, DAEstatus &status)
ICPProgressHandler m_task_ph
int setRunStatus(long number, DAEstatus &status)
write_event_log_t * m_event_log_func
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)
static std::string getProcessName(DWORD processID)
int endRunMain(DAEstatus &status)
int setupDAE(int tables_only, DAEstatus &dstatus)
int DAEreport_func_t(const DAEstatus_message &mess, void *arg)
Definition: DAEstatus.h:119
Poco::SharedPtr< CRPTProxy > m_crpt_run
used for fast ends
int writeJournal(const CRPTProxy &crpt, seblock_map_t &blocks, DAEstatus &status)
int getCurrentPeriodGoodFrames(DAEstatus &status)
int whichVeto(std::string &veto_text, DAEstatus &status)
unsigned long isisU32_t
Definition: isisvme_types.h:8
int sumAllSpectra(long &counts, long &bin0_counts, DAEstatus &status)
int readDetectorTable(const char *filename, DAEstatus &status)
int getCurrentPeriodNumber(int &period, int &daq_period, DAEstatus &status)
bool m_vms_raw_files
produce a VMS raw file
int stopEventWriter(bool wait, DAEstatus &status)
std::map< std::string, SEBLOCK > seblock_map_t
Definition: selogger.h:128
int changePeriod(int period, DAEstatus &status)
int setBeamlineParameters(const string_table_t &table, DAEstatus &status)
int fillWithTestPattern(unsigned long pattern, DAEstatus &status)
std::vector< std::vector< std::string > > string_table_t
int getOptions(std::string &options_xml, DAEstatus &status)
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 runPostCommand(const char *property_name, const std::string &arg, DAEstatus &status)
static const int Success
Definition: DAEstatus.h:140
int getGoodFrames(DAEstatus &status)
bool isFinalSequenceComplete(DAEstatus &status)
int importCRPT(const char *filename, DAEstatus &dstatus)
static int replaceSEparameters(std::string &s, const seblock_map_t *se_blocks, DAEstatus &status)
int killDatasvr(DAEstatus &dstatus)
bool beamOn(int minutes=0) const
int tcbcalc(DAEstatus &status)
CRPTProxy m_crpt
pointer to CRPT
static std::string m_icp_service_dir
int setRunNumber(long number, DAEstatus &status)
static int updateCRPTwithSE(CRPTProxy &crpt, DAEstatus &dstatus)
int notifyICP(long event_id, const char *param, DAEstatus &status)
float getRawUAmpH(DAEstatus &status)
static int writeISISRAW(const CRPTProxy &crpt, const char *filename, DAEstatus &dstatus)
int startDataCollection(bool clear_counters, DAEstatus &status)
int getSpectrumIntegral(long spec_no, long period, float t_low, float t_high, long &integral, long &max_val, DAEstatus &status)
int setRunStatusImp(long number, bool is_start, DAEstatus &status)
static void updateThread(void *arg)
int getFramesAllPeriods(long *good_frames, long *raw_frames, int n, DAEstatus &status)
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)
int VMEWriteValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long value, unsigned long mode, DAEstatus &status)
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)
int startEventWriter(DAEstatus &status)
int readSpectraTable(const char *filename, DAEstatus &status)
void unregisterStructuredExceptionHandler(_se_translator_function old_func)
int exitProgram(const std::string &message, bool prompt)
int saveRun(DAEstatus &status)
static int stringTableToParameterMap(const string_table_t &string_table, CRPTProxy::parameter_map_t &param_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)
_se_translator_function registerStructuredExceptionHandler()
this needs to be called per thread
std::list< boost::signals2::connection > m_crpt_signals
static int updateSampleParameters(const CRPTProxy::parameter_map_t &sample_parameters, CRPTProxy &crpt, const seblock_map_t *se_blocks, DAEstatus &status)
int updateCRPTWithDAE(CRPTProxy &crpt, bool pause_collection, DAEstatus &status)
ICPNotificationHandler m_nh
int getSpectrumNumbersForTimeRegime(long tr, long &spec_min, long &spec_max, DAEstatus &status)
static int setRealParameter(const CRPTProxy::parameter_map_t &params, 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)
std::map< std::string, std::string > recovery_map_t
float getCountRate(DAEstatus &status)
int readRecoveryFile(DAEstatus &dstatus)
int pausePeriod(PERIOD *p)
static int allReportFunc(const DAEstatus_message &mess, void *arg)
static int loadCRPTWithHistogrammedEvents(CRPTProxy &crpt, DAEstatus &dstatus)
int getVetoStatus(std::string &veto_text, DAEstatus &status)
int pauseRun(DAEstatus &status)
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)
void fireOnRunStateChange(const char *state)
int getTCBXML(const std::string &tcb_xml_in, std::string &tcb_xml_out, DAEstatus &status)
float getPeriodDuration(DAEstatus &status)
Poco::TaskManager m_taskmgr
unsigned short isisU16_t
Definition: isisvme_types.h:7
int getRawFrames(DAEstatus &status)
static int killProcess(const char *process_name, DAEstatus &dstatus)
static int prettyTime(time_t time, char *buffer, int len)
int loadDAEWithData(const std::string &file_name, long options, DAEstatus &status)
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)
boost::signals2::signal< void(BSTR)> m_state_sig
int readISISRAW(const char *filename, DAEstatus &dstatus)
int updateSampleXML(const std::string &sample_xml, DAEstatus &status)
int startSEWait(DAEstatus &dstatus)
int getIntItem(const char *item_name, long &lVal, DAEstatus &status)
static int updateBeamlineParametersFromFile(const char *filename, DAEstatus &status)
int changeNumberOfSoftwarePeriods(long nperiod, DAEstatus &status)
int requestEndRunAfterNextSequenceCompletes(DAEstatus &status)
static Poco::Util::Application * m_pApp
static int updateParametersFromFile(CRPTProxy::parameter_map_t &param_map, const char *filename, DAEstatus &status)
volatile LONG m_num_async_requests
int snapshotCRPT(const char *filename, bool do_update, bool do_pause, DAEstatus &status)
int readWiringTable(const char *filename, DAEstatus &status)
int update_poll_time
Definition: isiscrpt.h:366
HANDLE launchDatasvr(DAEstatus &dstatus)
int getDAQPeriod(int period, DAEstatus &status)
int getMonitorIntegral(long monitor, long period, float t_low, float t_high, long &integral, DAEstatus &status)
int endRun(DAEstatus &status)
int getUAmpHAllPeriods(float *good_uamph, float *raw_uamph, int n, DAEstatus &status)
int pauseRunMain(bool refresh_cache, DAEstatus &dstatus)
int updateCRPTWithSEandSaveToFile(CRPTProxy &crpt, const std::string &raw_filename, const std::string &nexus_filename, DAEstatus &dstatus)
static std::string m_instrument_parameter_map_file
int beginRunMain(DAEstatus &status)
int beginRunMainEx(bool start_paused, bool delayed_start, long period, DAEstatus &status)
float getBeamCurrent(DAEstatus &status)
boost::signals2::connection registerOnRunStateChange(boost::function< void(BSTR)> func)
float getCurrentPeriodGoodUAmpH(DAEstatus &status)
DAEreport_func_t * m_report_func
int doneAsync()
called by async worker thread when it has completed its work
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
Definition: CRPTProxy.h:248
int updateUserDetailsFromFile(const char *filename, DAEstatus &status)
static int updateSampleParametersFromFile(const char *filename, DAEstatus &status)
int readDataDaeTable(const char *filename, DAEstatus &status)
int changePeriodWhileRunning(int period, bool pause_first, DAEstatus &status)
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 changeUpdateSettingsXML(const std::string &update_xml, DAEstatus &status)
int sendNagios(int status, const std::string &service, const std::string &message, DAEstatus &dstatus)
int getNPRatio(float *current, float *average, DAEstatus &status)
int abortRun(DAEstatus &status)
int createLastrunFile(const CRPTProxy &crpt, DAEstatus &status)
static DWORD __stdcall writeISISRAWthread(void *arg)
static int ostreamReportFunction(const DAEstatus_message &mess, void *arg)
Definition: DAEstatus.h:192
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)
long isis32_t
Definition: isisvme_types.h:14
void onProgress(Poco::TaskProgressNotification *pNf)
int getRealArrayItemSize(const char *item_name, int *dims_array, int &ndims, DAEstatus &status)
static void setDefaultArgs(Poco::Util::Application *pApp, const std::string &icp_service_dir, DAEreport_func_t *func=&DAEstatus::ostreamReportFunction, write_event_log_t *event_func=NULL, void *report_arg=&std::cerr)
int setLogTimeChannelRange(int range_number, float start, float end, float step, DAEstatus &status)
int setUserParameters(long rbno, const string_table_t &table, DAEstatus &status)
int checkTestPattern(unsigned long pattern, DAEstatus &status)
Poco::Util::Application * m_app
int setTimeChannelRange(int range_number, int range_type, float start, float end, float step, DAEstatus &status)
static int setStringParameter(const CRPTProxy::parameter_map_t &params, const seblock_map_t *se_blocks, const char *name, char *crpt_target, int size_crpt_target, bool null_terminate, DAEstatus &status)
int sumAllHistogramMemory(long &counts, 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
static int debugReportFunction(const DAEstatus_message &mess, void *arg)
int getUpdateSettingsXML(const std::string &update_xml_in, std::string &update_xml_out, DAEstatus &status)
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)
Poco::Net::HTTPServer * m_http_server
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 updateSpecmapsFromDAE(const std::map< int, int > &trcn, DAEstatus &status)
int resumeRun(DAEstatus &status)
DAEType
Definition: isisdae.h:63