ICP  1
block.cpp
Go to the documentation of this file.
1 // block.cpp : Implementation of Cblock
2 
3 #include "stdafx.h"
4 #include "block.h"
5 
6 #include "instapi_utils.h"
7 
8 
9 // Cblock
10 
11 STDMETHODIMP Cblock::InterfaceSupportsErrorInfo(REFIID riid)
12 {
13  static const IID* const arr[] =
14  {
15  &IID_Iblock
16  };
17 
18  for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
19  {
20  if (InlineIsEqualGUID(*arr[i],riid))
21  return S_OK;
22  }
23  return S_FALSE;
24 }
25 
26 
27 STDMETHODIMP Cblock::get_setpoint(VARIANT* pVal)
28 {
29  return callInstAPILib(this, boost::bind(&InstAPILib::getBlockSetpoint, _1, m_session_id, m_name, pVal));
30 }
31 
32 
33 STDMETHODIMP Cblock::put_setpoint(VARIANT newVal)
34 {
35  VARIANT* results = new VARIANT;
36  return callInstAPILib(this, boost::bind(&InstAPILib::sendBlockSetpoint, _1, m_session_id, m_name, newVal, true, true, results));
37 }
38 
39 
40 STDMETHODIMP Cblock::get_value(VARIANT* pVal)
41 {
42  return callInstAPILib(this, boost::bind(&InstAPILib::getBlockValue, _1, m_session_id, m_name, pVal));
43 }
44 
45 
46 STDMETHODIMP Cblock::getLogValues(BSTR start_time, BSTR end_time, BSTR output_time_format, VARIANT* times, VARIANT* values)
47 {
48  // TODO: Add your implementation code here
49 
50  return S_OK;
51 }
52 
53 
54 STDMETHODIMP Cblock::logValues(BSTR time_format, VARIANT times, VARIANT values)
55 {
56  // TODO: Add your implementation code here
57 
58  return S_OK;
59 }
60 
61 
62 STDMETHODIMP Cblock::getSetpoint(VARIANT* value, BSTR* time)
63 {
64  return callInstAPILib(this, boost::bind(&InstAPILib::getBlockSetpoint, _1, m_session_id, m_name, value));
65 }
66 
67 
68 STDMETHODIMP Cblock::getValue(VARIANT* value, BSTR* time)
69 {
70  return callInstAPILib(this, boost::bind(&InstAPILib::getBlockValue, _1, m_session_id, m_name, value));
71 }
72 
73 
74 STDMETHODIMP Cblock::get_name(BSTR* pVal)
75 {
76  m_name.CopyTo(pVal);
77  return S_OK;
78 }
79 
80 
81 STDMETHODIMP Cblock::put_name(BSTR newVal)
82 {
83  m_name = newVal;
84  return S_OK;
85 }
86 
87 
88 STDMETHODIMP Cblock::get_runcontrol(VARIANT_BOOL* pVal)
89 {
90  callInstAPILib(this, boost::bind(&InstAPILib::getRunControl, _1, m_session_id, m_name, pVal));
91  return S_OK;
92 }
93 
94 
95 STDMETHODIMP Cblock::put_runcontrol(VARIANT_BOOL newVal)
96 {
97  callInstAPILib(this, boost::bind(&InstAPILib::setRunControl, _1, m_session_id, m_name, newVal));
98  return S_OK;
99 }
100 
101 STDMETHODIMP Cblock::get_lowlimit(VARIANT* pVal)
102 {
103  callInstAPILib(this, boost::bind(&InstAPILib::getRunControlLimit, _1, m_session_id, m_name, pVal, true));
104  return S_OK;
105 }
106 
107 
108 STDMETHODIMP Cblock::put_lowlimit(VARIANT newVal)
109 {
110  callInstAPILib(this, boost::bind(&InstAPILib::setRunControlLimit, _1, m_session_id, m_name, newVal, true));
111  return S_OK;
112 }
113 
114 STDMETHODIMP Cblock::get_highlimit(VARIANT* pVal)
115 {
116  callInstAPILib(this, boost::bind(&InstAPILib::getRunControlLimit, _1, m_session_id, m_name, pVal, false));
117  return S_OK;
118 }
119 
120 STDMETHODIMP Cblock::put_highlimit(VARIANT newVal)
121 {
122  callInstAPILib(this, boost::bind(&InstAPILib::setRunControlLimit, _1, m_session_id, m_name, newVal, false));
123  return S_OK;
124 }
125 
126 STDMETHODIMP Cblock::enterSetpointOnly(VARIANT newVal)
127 {
128  VARIANT* results = new VARIANT;
129  return callInstAPILib(this, boost::bind(&InstAPILib::sendBlockSetpoint, _1, m_session_id, m_name, newVal, false, false, results));
130 }
131 
132 STDMETHODIMP Cblock::enterSetpointOnlyExt(VARIANT newVal, VARIANT* results)
133 {
134  return callInstAPILib(this, boost::bind(&InstAPILib::sendBlockSetpoint, _1, m_session_id, m_name, newVal, false, true, results));
135 }
136 
137 STDMETHODIMP Cblock::pushSetButton()
138 {
139  VARIANT* results = new VARIANT;
140  return callInstAPILib(this, boost::bind(&InstAPILib::pushBlockButton, _1, m_session_id, m_name, false, results));
141 }
142 
143 STDMETHODIMP Cblock::pushSetButtonExt(VARIANT* results)
144 {
145  return callInstAPILib(this, boost::bind(&InstAPILib::pushBlockButton, _1, m_session_id, m_name, true, results));
146 }
147 
148 STDMETHODIMP Cblock::setValue(VARIANT newVal)
149 {
150  VARIANT* results = new VARIANT;
151  return callInstAPILib(this, boost::bind(&InstAPILib::sendBlockSetpoint, _1, m_session_id, m_name, newVal, true, false, results));
152 }
153 
154 STDMETHODIMP Cblock::setValueExt(VARIANT newVal, VARIANT* results)
155 {
156  return callInstAPILib(this, boost::bind(&InstAPILib::sendBlockSetpoint, _1, m_session_id, m_name, newVal, true, true, results));
157 }
HRESULT enterSetpointOnly(VARIANT newVal)
Definition: block.cpp:126
HRESULT pushSetButton()
Definition: block.cpp:137
void pushBlockButton(ULONG session_id, BSTR block_name, bool use_external, VARIANT *results)
HRESULT setValue(VARIANT newVal)
Definition: block.cpp:148
HRESULT put_runcontrol(VARIANT_BOOL pVal)
Definition: block.cpp:95
HRESULT get_value(VARIANT *pVal)
Definition: block.cpp:40
HRESULT get_highlimit(VARIANT *pVal)
Definition: block.cpp:114
void getRunControl(ULONG session_id, BSTR block_name, VARIANT_BOOL *rc_value)
HRESULT enterSetpointOnlyExt(VARIANT newVal, VARIANT *results)
Definition: block.cpp:132
HRESULT getLogValues(BSTR start_time, BSTR end_time, BSTR output_time_format, VARIANT *times, VARIANT *values)
Definition: block.cpp:46
HRESULT InterfaceSupportsErrorInfo(REFIID riid)
Definition: block.cpp:11
HRESULT getValue(VARIANT *value, BSTR *time)
Definition: block.cpp:68
void setRunControl(ULONG session_id, BSTR block_name, VARIANT_BOOL rc_value)
void getBlockSetpoint(ULONG session_id, BSTR block_name, VARIANT *setpoint_value)
void getRunControlLimit(ULONG session_id, BSTR block_name, VARIANT *limit_value, bool low)
HRESULT callInstAPILib(T *obj, instapi_lib_call_t func)
Definition: instapi_utils.h:25
void getBlockValue(ULONG session_id, BSTR block_name, VARIANT *block_value)
void setRunControlLimit(ULONG session_id, BSTR block_name, VARIANT new_value, bool low)
HRESULT getSetpoint(VARIANT *value, BSTR *time)
Definition: block.cpp:62
HRESULT put_setpoint(VARIANT newVal)
Definition: block.cpp:33
HRESULT put_highlimit(VARIANT pVal)
Definition: block.cpp:120
HRESULT get_runcontrol(VARIANT_BOOL *pVal)
Definition: block.cpp:88
HRESULT get_lowlimit(VARIANT *pVal)
Definition: block.cpp:101
HRESULT logValues(BSTR time_format, VARIANT times, VARIANT values)
Definition: block.cpp:54
HRESULT pushSetButtonExt(VARIANT *results)
Definition: block.cpp:143
HRESULT get_setpoint(VARIANT *pVal)
Definition: block.cpp:27
void sendBlockSetpoint(ULONG session_id, BSTR block_name, VARIANT setpoint_value, bool push_button, bool use_external, VARIANT *results)
unsigned long m_session_id
0 is an invalid session
Definition: block.h:33
CComBSTR m_name
Definition: block.h:31
HRESULT get_name(BSTR *pVal)
Definition: block.cpp:74
HRESULT put_lowlimit(VARIANT pVal)
Definition: block.cpp:108
HRESULT put_name(BSTR pVal)
Definition: block.cpp:81
HRESULT setValueExt(VARIANT newVal, VARIANT *results)
Definition: block.cpp:154