ICP  1
session.h
Go to the documentation of this file.
1 // session.h : Declaration of the Csession
2 
3 #pragma once
4 #include "resource.h" // main symbols
5 
6 
7 
8 #include "instapi_i.h"
9 #include "_IsessionEvents_CP.h"
10 
11 #include "instapi_utils.h"
12 
13 
14 #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
15 #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
16 #endif
17 
18 using namespace ATL;
19 
20 class InstAPILib;
21 
22 // Csession
23 
24 class ATL_NO_VTABLE Csession :
25  public CComObjectRootEx<CComMultiThreadModel>,
26  public CComCoClass<Csession, &CLSID_session>,
27  public ISupportErrorInfo,
28  public IConnectionPointContainerImpl<Csession>,
29  public CProxy_IsessionEvents<Csession>,
30  public IDispatchImpl<Isession, &IID_Isession, &LIBID_instapiLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
31 {
32 private:
33  unsigned long m_session_id;
34 // static Poco::Logger& g_log; // caused problems with static poco library
35 
36 public:
37  Csession() : m_session_id(0)
38  {
39  }
40 
41 DECLARE_REGISTRY_RESOURCEID(IDR_SESSION)
42 
43 
44 BEGIN_COM_MAP(Csession)
45  COM_INTERFACE_ENTRY(Isession)
46  COM_INTERFACE_ENTRY(IDispatch)
47  COM_INTERFACE_ENTRY(ISupportErrorInfo)
48  COM_INTERFACE_ENTRY(IConnectionPointContainer)
49 END_COM_MAP()
50 
51 BEGIN_CONNECTION_POINT_MAP(Csession)
52  CONNECTION_POINT_ENTRY(__uuidof(_IsessionEvents))
53 END_CONNECTION_POINT_MAP()
54 // ISupportsErrorInfo
55  STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
56 
57 
58  DECLARE_PROTECT_FINAL_CONSTRUCT()
59 
60  HRESULT FinalConstruct()
61  {
62  return S_OK;
63  }
64 
65  void FinalRelease()
66  {
67  callInstAPILib(this, boost::bind(&InstAPILib::deleteSession, _1, m_session_id));
68  }
69 
70 public:
71 
72  STDMETHOD(get_role)(BSTR* pVal);
73  STDMETHOD(put_role)(BSTR newVal);
74  STDMETHOD(getMessages)(LONG start_index, BSTR min_severity, VARIANT* times, VARIANT* severities, VARIANT* messages, LONG* end_index);
75  STDMETHOD(putMessage)(BSTR time, BSTR severity, BSTR message);
76  STDMETHOD(getBlock)(BSTR block_name, Iblock** block);
77  STDMETHOD(getBlockNames)(VARIANT* block_names);
78  STDMETHOD(get_session_id)(ULONG* pVal);
79  STDMETHOD(put_session_id)(ULONG newVal);
80  STDMETHOD(getLabviewVar)(BSTR vi_name, BSTR control_name, VARIANT* value);
81  STDMETHOD(setLabviewVar)(BSTR vi_name, BSTR control_name, VARIANT new_value);
82  STDMETHOD(setLabviewVarExt)(BSTR vi_name, BSTR control_name, VARIANT new_value, VARIANT* results);
83  STDMETHOD(callLabview)(BSTR vi_name, VARIANT names, VARIANT values, VARIANT_BOOL reentrant, VARIANT* results);
84  STDMETHOD(toggleViVisibility)(BSTR vi_name, VARIANT_BOOL show);
85  STDMETHOD(getViState)(BSTR vi_name, VARIANT* value);
86  STDMETHOD(startVi)(BSTR vi_name);
87  STDMETHOD(stopVi)(BSTR vi_name);
88  STDMETHOD(closeViFrontPanel)(BSTR vi_name);
89  STDMETHOD(beginRun)(LONG period, VARIANT_BOOL wait, VARIANT_BOOL quiet, VARIANT_BOOL paused, BSTR* messages);
90  STDMETHOD(abortRun)(BSTR* messages);
91  STDMETHOD(endRun)(BSTR* messages);
92  STDMETHOD(getRunState)(BSTR* messages, LONG* status);
93  STDMETHOD(pauseRun)(BSTR* messages);
94  STDMETHOD(resumeRun)(BSTR* messages);
95  STDMETHOD(recoverRun)(BSTR* messages);
96  STDMETHOD(saveRun)(BSTR* messages);
97  STDMETHOD(updateCRPT)(BSTR* messages);
98  STDMETHOD(storeCRPT)(BSTR* messages);
99  STDMETHOD(getGoodFrames)(VARIANT_BOOL curr_period, BSTR* messages, LONG* frames);
100  STDMETHOD(getUamps)(VARIANT_BOOL curr_period, BSTR* messages, DOUBLE* uamps);
101  STDMETHOD(getMEvents)(BSTR* messages, DOUBLE* mev);
102  STDMETHOD(getCurrentPeriod)(LONG* daq_period, BSTR* messages, LONG *period);
103  STDMETHOD(getRunNumber)(BSTR* messages, LONG* run_no);
104  STDMETHOD(getTotalCounts)(BSTR* messages, LONG* counts);
105  STDMETHOD(snapshotCRPT)(BSTR filename, LONG do_update, LONG do_pause, BSTR* messages);
106  STDMETHOD(sumAllHistogramMemory)(BSTR* messages, LONG* counts);
107  STDMETHOD(sumAllSpectra)(LONG* bin_counts, BSTR* messages, LONG* counts);
108  STDMETHOD(setRBNumber)(VARIANT rb_no);
109  STDMETHOD(getRBNumber)(VARIANT* rb_no);
110  STDMETHOD(setPeriod)(LONG period_number, BSTR* messages);
111  STDMETHOD(setTitle)(VARIANT title);
112  STDMETHOD(getSpectrum)(LONG spectrum_no, LONG period, VARIANT_BOOL as_dist, VARIANT* time_channels, VARIANT* signal, LONG* sum, BSTR* messages);
113  STDMETHOD(changeNumberOfSoftwarePeriods)(LONG num_periods, BSTR* messages);
114  STDMETHOD(getNumberOfPeriods)(BSTR* messages, LONG* num_periods);
115  STDMETHOD(setBeamlineParameter)(VARIANT name, VARIANT value, VARIANT units);
116  STDMETHOD(deleteBeamlineParameter)(VARIANT name);
117  STDMETHOD(getBeamlineParameter)(BSTR name, BSTR* units, BSTR* type, BSTR* value);
118  STDMETHOD(getBeamlineParameterNames)(VARIANT* names);
119  STDMETHOD(vmeWriteValue)(ULONG card_id, ULONG card_address, ULONG word_size, ULONG value, ULONG mode, BSTR* messages);
120  STDMETHOD(setSampleParameter)(VARIANT name, VARIANT value, VARIANT units);
121  STDMETHOD(deleteSampleParameter)(VARIANT name);
122  STDMETHOD(getSampleParameter)(BSTR name, BSTR* units, BSTR* type, BSTR* value);
123  STDMETHOD(getSampleParameterNames)(VARIANT* names);
124  STDMETHOD(deleteAllBeamlineParameters)();
125  STDMETHOD(deleteAllSampleParameters)();
126  STDMETHOD(getSeciConfig)(BSTR* name);
127  STDMETHOD(clearSeciGraphs)();
128  STDMETHOD(clearDatabaseLogs)(int run_number);
129  STDMETHOD(clearLogFiles)(int run_number, BSTR path);
130  STDMETHOD(getMeasurementLabel)(BSTR id, BSTR* label);
131  STDMETHOD(setMeasurementLabel)(BSTR id, BSTR label);
132  STDMETHOD(getMeasurementId)(BSTR label, VARIANT_BOOL newId, BSTR* id);
133  STDMETHOD(getViNames)(VARIANT* names);
134  STDMETHOD(logBlocksNow)(BSTR source);
135  STDMETHOD(changeSeciConfiguration)(BSTR vi_name, VARIANT_BOOL* result);
136  STDMETHOD(isSeciBusy)(VARIANT_BOOL* result);
137 };
138 
139 OBJECT_ENTRY_AUTO(__uuidof(session), Csession)
void deleteSession(ULONG session_id)
Definition: instapi_lib.cpp:27
#define IDR_SESSION
Definition: resource.h:9
void FinalRelease()
Definition: session.h:65
unsigned long m_session_id
0 is an invalid session
Definition: session.h:33
HRESULT callInstAPILib(T *obj, instapi_lib_call_t func)
Definition: instapi_utils.h:25
Csession()
Definition: session.h:37