ICP  1
dae.h
Go to the documentation of this file.
1 // dae.h : Declaration of the Cdae
2 
3 #pragma once
4 #include "resource.h" // main symbols
5 
6 
7 
8 #include "isisicp_i.h"
9 #include "_IdaeEvents_CP.h"
10 
11 
12 class DAEstatus;
14 
15 using namespace ATL;
16 
17 
18 // Cdae
19 
20 class ATL_NO_VTABLE Cdae :
21  public CComObjectRootEx<CComMultiThreadModel>,
22  public CComCoClass<Cdae, &CLSID_dae>,
23  public ISupportErrorInfo,
24  public IConnectionPointContainerImpl<Cdae>,
25  public CProxy_IdaeEvents<Cdae>,
26  public IDispatchImpl<Idae, &IID_Idae, &LIBID_isisicpLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
27 {
28 public:
29  Cdae()
30  {
31  }
32 
33 DECLARE_REGISTRY_RESOURCEID(IDR_DAE)
34 
35 BEGIN_COM_MAP(Cdae)
36  COM_INTERFACE_ENTRY(Idae)
37  COM_INTERFACE_ENTRY(IDispatch)
38  COM_INTERFACE_ENTRY(ISupportErrorInfo)
39  COM_INTERFACE_ENTRY(IConnectionPointContainer)
40 END_COM_MAP()
41 
42 BEGIN_CONNECTION_POINT_MAP(Cdae)
43  CONNECTION_POINT_ENTRY(__uuidof(_IdaeEvents))
44 END_CONNECTION_POINT_MAP()
45 // ISupportsErrorInfo
46  STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
47 
48 
49  DECLARE_PROTECT_FINAL_CONSTRUCT()
50 
51  HRESULT FinalConstruct()
52  {
53  if (m_critical == NULL)
54  {
55  m_critical = new CRITICAL_SECTION;
56  InitializeCriticalSection(m_critical);
57  }
58  registerICPCallbacks();
59  return S_OK;
60  }
61 
62  void FinalRelease()
63  {
64 // This is now shared, so we cannot remove it without reference counting
65 // if (m_critical != NULL)
66 // {
67 // DeleteCriticalSection(m_critical);
68 // delete m_critical;
69 // m_critical = NULL;
70 // }
71  unregisterICPCallbacks();
72  }
73 
74  static CRITICAL_SECTION* m_critical;
75  std::list<boost::signals2::connection> m_connection;
76 
77 protected:
78 
79  template <typename T> HRESULT callICP(BSTR* messages, T& result, boost::function<T(ISISinstrumentControl*, DAEstatus&)> func);
80  template <typename T> HRESULT callICP(BSTR* messages, boost::function<T(ISISinstrumentControl*, DAEstatus&)> func);
81 
82  HRESULT makeResult(DAEstatus& status, BSTR* messages, bool force_success_result = false);
83  int getValueMain(ISISinstrumentControl* the_icp, const char* item_name, VARIANT* result, DAEstatus& status);
84  int getArrayValueMain(ISISinstrumentControl* the_icp, const char* item_name, long args[], int nargs, VARIANT* result, DAEstatus& status);
85  int reallocBSTR(BSTR* bstr, const char* str);
86 
87  typedef int (ISISinstrumentControl::*xml_get_func_t)(const std::string& xml_in, std::string& xml_out, DAEstatus& status);
88  typedef int (ISISinstrumentControl::*xml_set_func_t)(const std::string& xml_in, DAEstatus& status);
89  HRESULT getSettings(BSTR xml_in, BSTR* xml_out, BSTR* messages, xml_get_func_t func);
90  HRESULT updateSettings(BSTR xml_in, BSTR* messages, xml_set_func_t func);
91 
92  typedef int (ISISinstrumentControl::*spec_int_func_t)(long n, const long spec_no[], long period, const float t_low[], const float t_high[], long integral[], long max_val[], DAEstatus& status);
93  HRESULT getSpectraIntegralHelper(spec_int_func_t func, VARIANT spectrum_numbers, LONG period, VARIANT time_low, VARIANT time_high, VARIANT* counts, BSTR* messages);
94 
95 public:
96 
97  void registerICPCallbacks();
98  void unregisterICPCallbacks();
99 
100 
101  static BSTR makeBSTR(const char* str);
102 
103  STDMETHOD(updateStatusXML)(BSTR* cluster_xml, BSTR* messages);
104  STDMETHOD(beginRun)(BSTR* messages);
105  STDMETHOD(endRun)(BSTR* messages);
106  STDMETHOD(pauseRun)(BSTR* messages);
107  STDMETHOD(resumeRun)(BSTR* messages);
108  STDMETHOD(saveRun)(BSTR* messages);
109  STDMETHOD(abortRun)(BSTR* messages);
110  STDMETHOD(startSEWait)(BSTR* messages);
111  STDMETHOD(endSEWait)(BSTR* messages);
112  STDMETHOD(getSpectrum)(LONG spectrum_number, LONG period, VARIANT* time_channels, VARIANT* signal, LONG as_histogram, LONG as_distribution, LONG* sum, BSTR* messages);
113  STDMETHOD(changeTCB)(BSTR tcb_xml, BSTR* messages);
114  STDMETHOD(changeDAEsettings)(BSTR dae_xml, BSTR* messages);
115  STDMETHOD(getSpectrumIntegral)(LONG spectrum_number, LONG period, FLOAT time_low, FLOAT time_high, LONG* counts, BSTR* messages);
116  STDMETHOD(getSpectraIntegral)(VARIANT spectrum_numbers, LONG period, VARIANT time_low, VARIANT time_high, VARIANT* counts, BSTR* messages);
117  STDMETHOD(getsect)(LONG start, LONG length, VARIANT* values, BSTR* messages);
118  STDMETHOD(rio)(LONG address, LONG* value, BSTR* messages);
119  STDMETHOD(getValue)(BSTR name, BSTR* messages, VARIANT* result);
120  STDMETHOD(getRawFramesTotal)(BSTR* messages, LONG* value);
121  STDMETHOD(getGoodFramesTotal)(BSTR* messages, LONG* value);
122  STDMETHOD(getGoodUAmpH)(BSTR* messages, DOUBLE* value);
123  STDMETHOD(getSpectraSum)(LONG period, LONG first_spec, LONG num_spec, LONG spec_type, DOUBLE time_low, DOUBLE time_high, VARIANT* sums, VARIANT* max_vals, VARIANT* spec_nums, BSTR* messages);
124  STDMETHOD(changeSample)(BSTR sample_xml, BSTR* messages);
125  STDMETHOD(changeUser)(BSTR user_xml, BSTR* messages);
126  STDMETHOD(changeHardwarePeriods)(BSTR periods_xml, BSTR* messages);
127  STDMETHOD(changePeriod)(LONG period_number, BSTR* messages);
128  STDMETHOD(dumpDebugInfo)(BSTR* messages);
129  STDMETHOD(VMEWriteValue)(ULONG card_id, ULONG card_address, ULONG word_size, ULONG value, ULONG mode, BSTR* messages);
130  STDMETHOD(VMEReadValue)(ULONG card_id, ULONG card_address, ULONG word_size, ULONG* value, BSTR* messages);
131  STDMETHOD(sumAllSpectra)(LONG* counts, LONG* bin0_counts, BSTR* messages);
132  STDMETHOD(sumAllHistogramMemory)(LONG* counts, BSTR* messages);
133  STDMETHOD(VMEReadArray)(ULONG card_id, ULONG card_address, VARIANT* values, ULONG num_values, BSTR* messages);
134  STDMETHOD(VMEWriteArray)(ULONG card_id, ULONG card_address, VARIANT values, BSTR* messages);
135  STDMETHOD(VMEReadValuesToString)(ULONG card_id, ULONG card_address, ULONG word_size, ULONG num_values, BSTR* values, BSTR* messages);
136  STDMETHOD(refreshCachedValues)(BSTR* messages);
137  STDMETHOD(setOptions)(BSTR options_xml, BSTR* messages);
138  STDMETHOD(getOptions)(BSTR* options_xml, BSTR* messages);
139  STDMETHOD(getArrayValue)(BSTR name, VARIANT arg, BSTR* messages, VARIANT* result);
140  STDMETHOD(updateCRPT)(BSTR* messages);
141  STDMETHOD(storeCRPT)(BSTR* messages);
142  STDMETHOD(setICPValueLong)(BSTR name, LONG value, BSTR* messages);
143  STDMETHOD(notifyICP)(LONG event_id, BSTR param, BSTR* messages);
144  STDMETHOD(setBlocksTable)(VARIANT table, BSTR* messages);
145  STDMETHOD(setSampleParameters)(VARIANT table, BSTR* messages);
146  STDMETHOD(setBeamlineParameters)(VARIANT table, BSTR* messages);
147  STDMETHOD(setUserParameters)(LONG rbno, VARIANT table, BSTR* messages);
148  STDMETHOD(areYouThere)(void);
149  STDMETHOD(changeUpdateSettings)(BSTR update_xml, BSTR* messages);
150  STDMETHOD(getNPRatio)(FLOAT* current, FLOAT* average, BSTR* messages);
151  STDMETHOD(getTotalCounts)(BSTR* messages, LONG* counts);
152  STDMETHOD(getMEvents)(BSTR* messages, DOUBLE* mevents);
153  STDMETHOD(getCurrentPeriodNumber)(LONG* period, LONG* daq_period, BSTR* messages);
154  STDMETHOD(snapshotCRPT)(BSTR filename, LONG do_update, LONG do_pause, BSTR* messages);
155  STDMETHOD(changePeriodWhileRunning)(LONG period, LONG pause_first, BSTR* messages);
156  STDMETHOD(getDAEsettings)(BSTR dae_xml_in, BSTR* dae_xml_out, BSTR* messages);
157  STDMETHOD(getHardwarePeriods)(BSTR periods_xml_in, BSTR* periods_xml_out, BSTR* messages);
158  STDMETHOD(getTCB)(BSTR tcb_xml_in, BSTR* tcb_xml_out, BSTR* messages);
159  STDMETHOD(getUpdateSettings)(BSTR update_xml_in, BSTR* update_xml_out, BSTR* messages);
160  STDMETHOD(changeNumberOfSoftwarePeriods)(LONG nperiod, BSTR* messages);
161  STDMETHOD(getRunState)(BSTR* messages, LONG* state);
162  STDMETHOD(beginRunEx)(LONG options, LONG period, BSTR* messages);
163  STDMETHOD(fillWithTestPattern)(ULONG pattern, BSTR* messages);
164  STDMETHOD(getVetoStatus)(BSTR* veto_status, BSTR* messages);
165  STDMETHOD(loadDAEWithData)(BSTR file_name, LONG options, BSTR* messages);
166  STDMETHOD(setVeto)(BSTR name, LONG enable, BSTR* messages);
167  STDMETHOD(checkTestPattern)(ULONG pattern, BSTR* messages);
168  STDMETHOD(getRunNumber)(BSTR* messages, LONG* run_number);
169  STDMETHOD(changeMonitoringSettings)(BSTR monitor_xml, BSTR* messages);
170  STDMETHOD(getMonitoringSettings)(BSTR monitor_xml_in, BSTR* monitor_xml_out, BSTR* messages);
171  STDMETHOD(getStatusMessages)(LONG stream, VARIANT* messages);
172  STDMETHOD(getGoodFramesPeriod)(BSTR* messages, LONG* value);
173  STDMETHOD(getGoodUAmpHPeriod)(BSTR* messages, DOUBLE* value);
174  STDMETHOD(getFramesAllPeriods)(VARIANT* good_frames, VARIANT* raw_frames, BSTR* messages);
175  STDMETHOD(getUAmpHAllPeriods)(VARIANT* good_uamph, VARIANT* raw_uamph, BSTR* messages);
176  STDMETHOD(getMEventsPeriod)(LONG period, BSTR* messages, DOUBLE* mevents);
177  STDMETHOD(updateCRPTSpectra)(LONG period, LONG spec_start, LONG nspec, BSTR* messages);
178  STDMETHOD(getCRPTSpectraIntegral)(VARIANT spectrum_numbers, LONG period, VARIANT time_low, VARIANT time_high, VARIANT* counts, BSTR* messages);
179  STDMETHOD(quit)(BSTR* messages);
180  STDMETHOD(requestEndRunAfterNextSequenceCompletes)(BSTR* messages);
181  STDMETHOD(isFinalSequenceComplete)(BSTR* messages, LONG* complete);
182  STDMETHOD(getSpectrumNumbersForTR)(LONG time_regime, LONG* spec_min, LONG* spec_max, BSTR* messages);
183  STDMETHOD(getSpectraIntegral2)(LONG spec_start, LONG nspectra, LONG period, FLOAT time_low, FLOAT time_high, VARIANT* counts, BSTR* messages);
184  STDMETHOD(getNumberOfPeriods)(BSTR* messages, LONG* nperiod);
185  STDMETHOD(updateStatusXML2)(BSTR status_xml_in, BSTR* status_xml_out, BSTR* messages);
186 };
187 
188 OBJECT_ENTRY_AUTO(__uuidof(dae), Cdae)
std::list< boost::signals2::connection > m_connection
Definition: dae.h:75
static ISISDAE * dae
Definition: daeset.cpp:7
void FinalRelease()
Definition: dae.h:62
#define IDR_DAE
Definition: Resource.h:7
static CRITICAL_SECTION * m_critical
Definition: dae.h:74
Cdae()
Definition: dae.h:29
Definition: dae.h:20