1 #ifndef ISISINSTRUMENTCONTROL_H
2 #define ISISINSTRUMENTCONTROL_H
5 #define CONFIG_NAME "Debug"
7 #define CONFIG_NAME "Release"
10 #define PLATFORM_NAME "x64"
12 #define PLATFORM_NAME "Win32"
15 #define PLATFORM_SUFFIX PLATFORM_NAME "\\" CONFIG_NAME
165 int readTables(
const char* wiring,
const char* detector,
const char* spectra,
DAEstatus& status);
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);
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);
189 const float t_high[],
long integral[],
long max_val[],
DAEstatus& status);
191 float t_high,
long integral[],
long max_val[],
DAEstatus& status);
224 int getTCBXML(
const std::string& tcb_xml_in, std::string& tcb_xml_out,
DAEstatus& status);
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);
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);
294 int exitProgram(
const std::string& message,
bool prompt);
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);
317 int endRunTask(Poco::SharedPtr<CRPTProxy> crpt,
NeXusWriter& nxwriter,
bool keep_raw_events,
bool keep_crpt,
const std::string events_nxfile,
DAEstatus& status);
326 int updateFunc(
int poll_time,
bool only_refresh_cache);
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);
376 int sendNagios(
int status,
const std::string& service,
const std::string& message,
DAEstatus& dstatus);
378 bool beamOn(
int minutes = 0)
const;
407 throw(
"Did not create InstrumentControlHolder properly");
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)
virtual ~ISISinstrumentControl()
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)
void zeroCRPTRunRawData()
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
bool m_use_full_inst_name_for_files
int updateCycle(DAEstatus &dstatus)
int writeAutosaveFile(DAEstatus &dstatus)
std::ostream & printStatus(std::ostream &os, DAEstatus &dstatus)
ICPEventWriter m_icpwriter
static void * m_report_arg
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
recovery_map_t m_recovery_map
int updateMonitoringLog()
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)
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)
bool m_registersetranslator
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)
Poco::Path m_inst_settings_dir
void readBeamloggerBroadcast()
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
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)
int getGoodFrames(DAEstatus &status)
bool m_shutdown_requested
Poco::Timer m_beam_current_timer
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)
CRITICAL_SECTION m_crpt_cs
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)
std::string getPostCommandLogName()
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 ¶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)
_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 ¶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)
std::map< std::string, std::string > recovery_map_t
float getCountRate(DAEstatus &status)
int readRecoveryFile(DAEstatus &dstatus)
int pausePeriod(PERIOD *p)
LabviewXML * m_icp_config
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)
Poco::Thread m_beamlog_thread
void fireOnRunStateChange(const char *state)
int getTCBXML(const std::string &tcb_xml_in, std::string &tcb_xml_out, DAEstatus &status)
static void purecallHandler()
float getPeriodDuration(DAEstatus &status)
Poco::TaskManager m_taskmgr
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 ¶m_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)
HANDLE launchDatasvr(DAEstatus &dstatus)
std::string m_recovery_file
int getDAQPeriod(int period, DAEstatus &status)
bool muonKickerOK() const
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
int updateUserDetailsFromFile(const char *filename, DAEstatus &status)
static int updateSampleParametersFromFile(const char *filename, DAEstatus &status)
void updateICPTimeDiffLog()
int readDataDaeTable(const char *filename, DAEstatus &status)
InstrumentControlHolder()
DAEstatus & getStatusReporter()
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)
HANDLE m_async_complete_event
static int ostreamReportFunction(const DAEstatus_message &mess, void *arg)
std::string m_icp_service_dir
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)
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 ¶ms, 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)
ISISDAE::DAEType m_dae_type
int resumeRun(DAEstatus &status)