10 #include "../selogger/selogger.h"
11 #include "../comutils/variant_utils.h"
17 #import "..\\isisicp\\isisicp.tlb" named_guids
18 #import "..\\tlb\\Seci.tlb" named_guids
19 #import "..\\tlb\\LabVIEW.tlb" named_guids
42 COAUTHIDENTITY* pidentity =
new COAUTHIDENTITY;
43 pidentity->Domain = (USHORT*)strdup(domain.c_str());
44 pidentity->DomainLength = strlen((
const char*)pidentity->Domain);
45 pidentity->Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
46 pidentity->Password = (USHORT*)strdup(pass.c_str());
47 pidentity->PasswordLength = strlen((
const char*)pidentity->Password);
48 pidentity->User = (USHORT*)strdup(user.c_str());
49 pidentity->UserLength = strlen((
const char*)pidentity->User);
56 if (pidentity != NULL)
58 hr = CoSetProxyBlanket(pUnk, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
59 RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, pidentity, EOAC_NONE);
76 CComPtr<isisicpLib::Idae> icp;
77 COSERVERINFO server_info;
78 memset(&server_info, 0,
sizeof(server_info));
80 memset(multi_qi, 0,
sizeof(multi_qi));
81 server_info.pwszName = L
"ndxtest";
82 COAUTHIDENTITY* pidentity =
createIdentity(
"spudulike",
"ndxtest",
"reliablebeam");
83 COAUTHINFO* pauth =
new COAUTHINFO;
84 pauth->dwAuthnSvc = RPC_C_AUTHN_WINNT;
85 pauth->dwAuthnLevel = RPC_C_AUTHN_LEVEL_DEFAULT;
86 pauth->dwAuthzSvc = RPC_C_AUTHZ_NONE;
87 pauth->dwCapabilities = EOAC_NONE;
88 pauth->dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
89 pauth->pAuthIdentityData = pidentity;
90 pauth->pwszServerPrincName = NULL;
91 server_info.pAuthInfo = pauth;
93 multi_qi[0].pIID = &isisicpLib::IID_Idae;
94 HRESULT hr = ::CoCreateInstanceEx(isisicpLib::CLSID_dae, NULL, CLSCTX_ALL,
95 &server_info, (
sizeof(multi_qi) /
sizeof(MULTI_QI)), multi_qi);
101 if (FAILED(multi_qi[0].hr))
104 return multi_qi[0].hr;
107 icp.Attach(reinterpret_cast<isisicpLib::Idae*>(multi_qi[0].pItf));
108 hr = icp->areYouThere();
124 CComPtr<isisicpLib::Idae> icp;
125 HRESULT hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
133 hr = icp->areYouThere();
150 CComPtr<LabVIEW::_Application> lv;
151 HRESULT hr = lv.CoCreateInstance(LabVIEW::CLSID_Application, 0, CLSCTX_LOCAL_SERVER);
159 CComBSTR ccombstr((
char *)lv->GetVersion());
161 if (ccombstr.Length() == 0)
173 CComPtr<isisicpLib::Idae> icp;
175 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
180 static int junk(
const std::string& hostname, GUID C, GUID G)
184 COSERVERINFO server_info;
185 memset(&server_info, 0,
sizeof(server_info));
186 MULTI_QI multi_qi[1];
187 memset(multi_qi, 0,
sizeof(multi_qi));
188 server_info.pwszName = hostname;
189 COAUTHIDENTITY* pidentity = createIdentity(
"spudulike",
"ndxtest",
"reliablebeam");
190 COAUTHINFO* pauth =
new COAUTHINFO;
191 pauth->dwAuthnSvc = RPC_C_AUTHN_WINNT;
192 pauth->dwAuthnLevel = RPC_C_AUTHN_LEVEL_DEFAULT;
193 pauth->dwAuthzSvc = RPC_C_AUTHZ_NONE;
194 pauth->dwCapabilities = EOAC_NONE;
195 pauth->dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
196 pauth->pAuthIdentityData = pidentity;
197 pauth->pwszServerPrincName = NULL;
198 server_info.pAuthInfo = pauth;
200 multi_qi[0].pIID = &G;
201 HRESULT hr = ::CoCreateInstanceEx(C, NULL, CLSCTX_ALL,
202 &server_info, (
sizeof(multi_qi) /
sizeof(MULTI_QI)), multi_qi);
208 if (FAILED(multi_qi[0].hr))
211 return multi_qi[0].hr;
213 setIdentity(pidentity, multi_qi[0].pItf);
214 icp.Attach(reinterpret_cast<OBJ*>(multi_qi[0].pItf));
221 void InstAPILib::getMessages(ULONG session_id, LONG start_index, BSTR min_severity, VARIANT* times, VARIANT* severities, VARIANT* messages, LONG* end_index)
227 UINT len = SysStringLen(vi_name);
228 std::wstring ws(vi_name, SysStringLen(vi_name));
230 vi_map_t::iterator it =
m_vimap.find(ws);
235 vi = it->second.vi_ref;
252 std::wstring ws(vi_name, SysStringLen(vi_name));
254 CComPtr<LabVIEW::_Application> lv;
255 HRESULT hr = lv.CoCreateInstance(LabVIEW::CLSID_Application, 0, CLSCTX_LOCAL_SERVER);
259 throw std::runtime_error(
"getViRef failed (could not connect to LabVIEW)");
264 vi = lv->GetVIReference(vi_name,
"", 1, 8);
269 vi = lv->GetVIReference(vi_name,
"", 0, 0);
272 vi = lv->GetVIReference(vi_name,
"", 1, 8);
287 LabVIEW::VirtualInstrumentPtr vi;
290 *value = vi->GetControlValue(control_name).Detach();
301 results->vt = VT_EMPTY;
302 setBlockSetpoint(session_id, block_name, setpoint_value, push_button, use_external, results);
309 CComSafeArray<BSTR> sab;
310 sab.CopyFrom(names.parray);
312 UINT d = sab.GetDimensions();
316 throw std::runtime_error(
"getBlockNames returned an array of the wrong dimensions");
319 LONG numPars = sab.GetUpperBound(0);
322 std::vector<std::string> blocknames;
323 std::vector<std::string> blockvalues;
324 std::vector<std::string> times;
330 int len = (int) SysStringLen(source);
331 char* char_source = (
char *) malloc(1+len);
332 WideCharToMultiByte( CP_ACP, 0, source, -1, char_source, len, NULL, NULL );
333 char_source[len] =
'\0';
335 for (UINT i = 0; i <= numPars; ++i)
339 sab.MultiDimGetAt(aIndex, bname.GetBSTR());
342 UINT len = SysStringLen(bname);
343 std::wstring ws_name(bname, len);
345 s_name.assign(ws_name.begin(), ws_name.end());
346 blocknames.push_back(s_name);
351 currVal.ChangeType(VT_BSTR);
353 currVal.CopyTo(&(bstrVal.GetBSTR()));
354 std::wstring ws_curr(bstrVal, SysStringLen(bstrVal));
356 s_curr.assign(ws_curr.begin(), ws_curr.end());
357 blockvalues.push_back(s_curr);
361 struct tm * timeinfo;
363 timeinfo = localtime ( &rawtime );
364 int year = timeinfo->tm_year + 1900;
365 int month = timeinfo->tm_mon + 1;
367 sprintf (buffer,
"%d-%02d-%02dT%02d:%02d:%02d", year, month, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
368 times.push_back(buffer);
387 _bstr_t vi(details.
vi_name().c_str());
407 VARIANT* pushResults =
new VARIANT;
409 _variant_t button(
true);
413 pushResults->vt = VT_EMPTY;
425 VariantChangeType(&v, &setpoint_value, 0, VT_BSTR);
436 LabVIEW::VirtualInstrumentPtr vi;
438 hr = vi->SetControlValue(control_name, value);
448 throw std::runtime_error(
"SetLabviewValue failed");
454 _bstr_t path(L
"C:\\LabVIEW Modules\\Common\\External Interface\\External Interface.llb\\External Interface - Set Value.vi");
456 CComSafeArray<BSTR> names(6);
457 names[0].AssignBSTR(_bstr_t(L
"VI Name"));
458 names[1].AssignBSTR(_bstr_t(L
"Control Name"));
459 names[2].AssignBSTR(_bstr_t(L
"String Control Value"));
460 names[3].AssignBSTR(_bstr_t(L
"Variant Control Value"));
461 names[4].AssignBSTR(_bstr_t(L
"Machine Name"));
462 names[5].AssignBSTR(_bstr_t(L
"Return Message"));
465 n.vt = VT_ARRAY | VT_BSTR;
466 n.parray = names.Detach();
468 CComSafeArray<VARIANT> values(6);
470 values[1] = control_name;
477 v.vt = VT_ARRAY | VT_VARIANT;
478 v.parray = values.Detach();
481 callLabview(session_id, path, n, v,
true, results);
484 void InstAPILib::callLabview(ULONG session_id, BSTR vi_name, VARIANT names, VARIANT values, VARIANT_BOOL reentrant, VARIANT* results)
490 LabVIEW::VirtualInstrumentPtr vi;
501 hr = vi->Call(&names, &values);
504 CComVariant var(values);
514 throw std::runtime_error(
"CallLabviewValue failed");
520 results =
new VARIANT;
521 results->vt = VT_EMPTY;
529 _bstr_t vi(details.
vi_name().c_str());
534 _variant_t button(
true);
553 LabVIEW::VirtualInstrumentPtr vi;
555 vi->FPWinOpen = show;
565 throw std::runtime_error(
"toggleViVisibility failed");
575 LabVIEW::VirtualInstrumentPtr vi;
578 wrapper.ChangeType(VT_INT);
579 wrapper.Detach(value);
580 value->intVal = vi->ExecState;
590 throw std::runtime_error(
"GetViState failed");
600 LabVIEW::VirtualInstrumentPtr vi;
603 if (vi->ExecState == 1)
616 throw std::runtime_error(
"StartVi failed");
626 LabVIEW::VirtualInstrumentPtr vi;
630 if (vi->ExecState == 1 || vi->ExecState == 2)
643 throw std::runtime_error(
"StopVi failed");
653 LabVIEW::VirtualInstrumentPtr vi;
655 hr = vi->CloseFrontPanel();
665 throw std::runtime_error(
"CloseViFrontPanel failed");
671 CComPtr<Seci::IComInterface> seci;
672 HRESULT hr = seci.CoCreateInstance(Seci::CLSID_ComInterface, 0, CLSCTX_LOCAL_SERVER);
676 throw std::runtime_error(
"GetViNames failed (could not connect to SECI)");
681 SAFEARRAY* temp = seci->GetVIsFullpath();
682 CComSafeArray<BSTR> saBstr(temp);
683 CComVariant varArrayWrapper (saBstr);
684 varArrayWrapper.Detach(names);
693 throw std::runtime_error(
"GetViNames failed");
705 _bstr_t vi(details.
vi_name().c_str());
725 _bstr_t vi(details.
vi_name().c_str());
748 CComBSTR path(L
"C:\\Labview modules\\dae\\monitor\\dae_monitor.vi");
749 CComBSTR control(L
"Parameter details");
755 CComSafeArray<BSTR> sab;
756 sab.CopyFrom(val.parray);
757 UINT d = sab.GetDimensions();
758 LONG numPars = sab.GetUpperBound(0);
762 for (UINT i = 0; i <= numPars; ++i)
766 sab.MultiDimGetAt(aIndex, bname.GetBSTR());
768 if (wcscmp(bname, block_name) == 0)
778 sab.MultiDimSetAt(aIndex, bnew);
783 sab.MultiDimSetAt(aIndex, bnew);
785 CComVariant vnew(sab);
793 sab.MultiDimGetAt(aIndex, bvalue.GetBSTR());
795 if (wcscmp(bvalue, L
"1") == 0)
812 CComBSTR path(L
"C:\\Labview modules\\dae\\monitor\\dae_monitor.vi");
813 CComBSTR control(L
"Parameter details");
819 CComSafeArray<BSTR> sab;
820 sab.CopyFrom(val.parray);
821 UINT d = sab.GetDimensions();
822 LONG numPars = sab.GetUpperBound(0);
826 for (UINT i = 0; i <= numPars; ++i)
830 sab.MultiDimGetAt(aIndex, bname.GetBSTR());
832 if (wcscmp(bname, block_name) == 0)
836 CComVariant vWrapper(new_value);
837 vWrapper.ChangeType(VT_BSTR);
843 bstr_t bnew(vWrapper.bstrVal);
844 sab.MultiDimSetAt(aIndex, bnew);
850 bstr_t bnew(vWrapper.bstrVal);
851 sab.MultiDimSetAt(aIndex, bnew);
853 CComVariant vnew(sab);
862 sab.MultiDimGetAt(aIndex, *value);
867 sab.MultiDimGetAt(aIndex, *value);
878 VARIANT null = VARIANT();
880 null.scode = DISP_E_PARAMNOTFOUND;
883 accessLimits(session_id, block_name, null, &result,
false, low);
885 CComVariant wrapper = CComVariant(result);
888 HRESULT hr = wrapper.ChangeType(VT_R8);
893 wrapper.ChangeType(VT_BSTR);
896 wrapper.Detach(limit_value);
901 accessLimits(session_id, block_name, new_value, NULL,
true, low);
906 CComPtr<isisicpLib::Idae> icp;
908 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
912 throw std::runtime_error(
"Could not connect to icp");
915 *status = icp->getRunState(messages);
918 void InstAPILib::beginRun(ULONG session_id, LONG period, VARIANT_BOOL wait, VARIANT_BOOL quiet, VARIANT_BOOL paused, BSTR* messages)
921 CComPtr<isisicpLib::Idae> icp;
923 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
927 throw std::runtime_error(
"Could not connect to icp");
931 if (paused) options += 1;
932 if (wait) options += 2;
934 icp->beginRunEx(options, period, messages);
939 CComPtr<isisicpLib::Idae> icp;
941 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
945 throw std::runtime_error(
"Could not connect to icp");
948 icp->abortRun(messages);
953 CComPtr<isisicpLib::Idae> icp;
955 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
959 throw std::runtime_error(
"Could not connect to icp");
962 icp->endRun(messages);
967 CComPtr<isisicpLib::Idae> icp;
969 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
973 throw std::runtime_error(
"Could not connect to icp");
976 icp->pauseRun(messages);
981 CComPtr<isisicpLib::Idae> icp;
983 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
987 throw std::runtime_error(
"Could not connect to icp");
990 icp->resumeRun(messages);
995 CComPtr<isisicpLib::Idae> icp;
997 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1001 throw std::runtime_error(
"Could not connect to icp");
1004 icp->setICPValueLong(L
"RUN_STATUS", 3, messages);
1009 CComPtr<isisicpLib::Idae> icp;
1011 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1015 throw std::runtime_error(
"Could not connect to icp");
1018 icp->saveRun(messages);
1023 CComPtr<isisicpLib::Idae> icp;
1025 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1029 throw std::runtime_error(
"Could not connect to icp");
1032 icp->updateCRPT(messages);
1037 CComPtr<isisicpLib::Idae> icp;
1039 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1043 throw std::runtime_error(
"Could not connect to icp");
1046 icp->storeCRPT(messages);
1051 CComPtr<isisicpLib::Idae> icp;
1053 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1057 throw std::runtime_error(
"Could not connect to icp");
1062 *frames = icp->getGoodFramesPeriod(messages);
1066 *frames = icp->getGoodFramesTotal(messages);
1072 CComPtr<isisicpLib::Idae> icp;
1074 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1078 throw std::runtime_error(
"Could not connect to icp");
1083 *uamps = icp->getGoodUAmpHPeriod(messages);
1087 *uamps = icp->getGoodUAmpH(messages);
1093 CComPtr<isisicpLib::Idae> icp;
1095 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1099 throw std::runtime_error(
"Could not connect to icp");
1102 *mev = icp->getMEvents(messages);
1107 CComPtr<isisicpLib::Idae> icp;
1109 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1113 throw std::runtime_error(
"Could not connect to icp");
1116 hr = icp->getCurrentPeriodNumber(period, daq_period, messages);
1121 CComPtr<isisicpLib::Idae> icp;
1123 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1127 throw std::runtime_error(
"Could not connect to icp");
1130 *run_no = icp->getRunNumber(messages);
1135 CComPtr<isisicpLib::Idae> icp;
1137 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1141 throw std::runtime_error(
"Could not connect to icp");
1144 *counts = icp->getTotalCounts(messages);
1149 CComPtr<isisicpLib::Idae> icp;
1151 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1155 throw std::runtime_error(
"Could not connect to icp");
1158 hr = icp->snapshotCRPT(filename, do_update, do_pause, messages);
1163 CComPtr<isisicpLib::Idae> icp;
1165 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1169 throw std::runtime_error(
"Could not connect to icp");
1172 hr = icp->sumAllHistogramMemory(counts, messages);
1177 CComPtr<isisicpLib::Idae> icp;
1179 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1183 throw std::runtime_error(
"Could not connect to icp");
1189 hr = icp->sumAllSpectra(counts, bin_counts, messages);
1198 _bstr_t path(L
"C:\\Labview modules\\Common\\User Details\\User Details.vi");
1199 _bstr_t control(L
"RB Number");
1206 _bstr_t path(L
"C:\\Labview modules\\Common\\User Details\\User Details.vi");
1207 _bstr_t control(L
"RB Number");
1214 CComPtr<isisicpLib::Idae> icp;
1216 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1220 throw std::runtime_error(
"Could not connect to icp");
1226 hr = icp->changePeriod(period_number, messages);
1230 CComBSTR tmpbstr(L
"Could not change period - is the number entered valid?");
1231 tmpbstr.CopyTo(messages);
1237 _bstr_t path(L
"C:\\Labview modules\\dae\\DAE Control.vi");
1238 _bstr_t title_control(L
"New Run Title");
1239 _bstr_t button_control(L
"Set Title");
1244 _variant_t ans(
true);
1248 void InstAPILib::getSpectrum(ULONG session_id, LONG spectrum_no, LONG period, VARIANT_BOOL as_dist, VARIANT* time_channels, VARIANT* signal, LONG* sum, BSTR* messages)
1250 CComPtr<isisicpLib::Idae> icp;
1252 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1256 throw std::runtime_error(
"Could not connect to icp");
1262 hr = icp->getSpectrum(spectrum_no, period, time_channels, signal, 0, 1, sum, messages);
1266 hr = icp->getSpectrum(spectrum_no, period, time_channels, signal, 1, 0, sum, messages);
1272 CComPtr<isisicpLib::Idae> icp;
1274 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1278 throw std::runtime_error(
"Could not connect to icp");
1283 hr = icp->changeNumberOfSoftwarePeriods(num_periods, messages);
1287 CComBSTR tmpbstr(L
"Could not change number of software periods - is the DAE set to use software periods?");
1288 tmpbstr.CopyTo(messages);
1294 CComPtr<isisicpLib::Idae> icp;
1296 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1300 throw std::runtime_error(
"Could not connect to icp");
1303 *num_periods = icp->getNumberOfPeriods(messages);
1308 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Beamline Parameters.vi");
1309 _bstr_t name_ctrl(L
"Custom Parameter Name");
1310 _bstr_t value_ctrl(L
"Custom Parameter Value");
1311 _bstr_t units_ctrl(L
"Custom Parameter Units ");
1312 _bstr_t set_ctrl(L
"Add Custom parameter");
1318 _variant_t ans(
true);
1324 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Beamline Parameters.vi");
1325 _bstr_t name_ctrl(L
"Custom Parameter Name");
1326 _bstr_t set_ctrl(L
"Remove Custom Parameter");
1330 _variant_t ans(
true);
1336 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Beamline Parameters.vi");
1337 _bstr_t del_ctrl(L
"Clear Parameters");
1338 _variant_t ans(
true);
1344 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Beamline Parameters.vi");
1345 _bstr_t name_ctrl(L
"Additional Parameters");
1356 bool changed =
false;
1358 HRESULT hr = SafeArrayAccessData(val.parray, (
void HUGEP**)&pbstr);
1365 CComSafeArray<BSTR> saBstr(dims[0], 0);
1368 for (
int x = 0; x < dims[0]; ++x)
1373 HRESULT hr = saBstr.MultiDimSetAt(index, pbstr[x]);
1376 CComVariant varArrayWrapper(saBstr);
1377 varArrayWrapper.Detach(names);
1379 SafeArrayUnaccessData(val.parray);
1384 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Beamline Parameters.vi");
1385 _bstr_t name_ctrl(L
"Additional Parameters");
1390 CComSafeArray<BSTR> sab;
1391 sab.CopyFrom(val.parray);
1392 UINT d = sab.GetDimensions();
1393 LONG numPars = sab.GetUpperBound(0);
1398 for (LONG i = 0; i <= numPars; ++i)
1402 sab.MultiDimGetAt(aIndex, bname.GetBSTR());
1404 if (wcscmp(bname, name) == 0)
1407 sab.MultiDimGetAt(aIndex, *value);
1409 sab.MultiDimGetAt(aIndex, *units);
1411 sab.MultiDimGetAt(aIndex, *type);
1419 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Sample Parameters.vi");
1420 _bstr_t name_ctrl(L
"Custom Parameter Name");
1421 _bstr_t value_ctrl(L
"Custom Parameter Value");
1422 _bstr_t units_ctrl(L
"Custom Parameter Units ");
1423 _bstr_t set_ctrl(L
"Add Custom parameter");
1429 _variant_t ans(
true);
1435 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Sample Parameters.vi");
1436 _bstr_t name_ctrl(L
"Custom Parameter Name");
1437 _bstr_t set_ctrl(L
"Remove Custom Parameter");
1441 _variant_t ans(
true);
1447 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Sample Parameters.vi");
1448 _bstr_t del_ctrl(L
"Clear Parameters");
1449 _variant_t ans(
true);
1455 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Sample Parameters.vi");
1456 _bstr_t name_ctrl(L
"Additional Parameters");
1467 bool changed =
false;
1469 HRESULT hr = SafeArrayAccessData(val.parray, (
void HUGEP**)&pbstr);
1476 CComSafeArray<BSTR> saBstr(dims[0], 0);
1479 for (
int x = 0; x < dims[0]; ++x)
1484 HRESULT hr = saBstr.MultiDimSetAt(index, pbstr[x]);
1487 CComVariant varArrayWrapper (saBstr);
1488 varArrayWrapper.Detach(names);
1490 SafeArrayUnaccessData(val.parray);
1495 _bstr_t path(L
"C:\\Labview modules\\Common\\Experiment Parameters\\Sample Parameters.vi");
1496 _bstr_t name_ctrl(L
"Additional Parameters");
1501 CComSafeArray<BSTR> sab;
1502 sab.CopyFrom(val.parray);
1503 UINT d = sab.GetDimensions();
1504 LONG numPars = sab.GetUpperBound(0);
1509 for (LONG i = 0; i <= numPars; ++i)
1513 sab.MultiDimGetAt(aIndex, bname.GetBSTR());
1515 if (wcscmp(bname, name) == 0)
1518 sab.MultiDimGetAt(aIndex, *value);
1520 sab.MultiDimGetAt(aIndex, *units);
1522 sab.MultiDimGetAt(aIndex, *type);
1528 void InstAPILib::vmeWriteValue(ULONG session_id, ULONG card_id, ULONG card_address, ULONG word_size, ULONG value, ULONG mode, BSTR* messages)
1530 CComPtr<isisicpLib::Idae> icp;
1532 hr = icp.CoCreateInstance(isisicpLib::CLSID_dae, 0, CLSCTX_LOCAL_SERVER);
1536 throw std::runtime_error(
"Could not connect to icp");
1539 hr = icp->VMEWriteValue(card_id, card_address, word_size, value, mode, messages);
1543 throw std::runtime_error(
"Problem writing value to VME");
1549 std::string config =
"";
1551 CComBSTR tmpbstr(config.c_str());
1552 tmpbstr.CopyTo(name);
1564 std::string dir(myb);
1566 Poco::File logDir(dir);
1568 std::string s = boost::lexical_cast<std::string>(run_num);
1570 std::string nameformat(
"^[a-z]+\\w*[a-z]+0*" + s +
"(_(\\w|_)+.txt|.log)");
1572 if (logDir.exists() && logDir.isDirectory())
1574 Poco::RegularExpression re(nameformat, Poco::RegularExpression::RE_CASELESS);
1576 std::vector<std::string> files;
1578 std::vector<std::string>::iterator it = files.begin();
1579 for (; it != files.end(); ++it)
1584 std::string fullname(dir +
"\\" + *it);
1585 Poco::File temp(fullname);
1595 const size_t newsize = (temp.length()+1)*2;
1596 char *nstring =
new char[newsize];
1597 strcpy_s(nstring, newsize, (
char *)temp);
1600 *label = CComBSTR(ans.c_str()).Detach();
1606 size_t newsize = (b_id.length()+1)*2;
1607 char *id_string =
new char[newsize];
1608 strcpy_s(id_string, newsize, (
char *)b_id);
1610 _bstr_t b_label(label);
1611 newsize = (b_label.length()+1)*2;
1612 char *label_string =
new char[newsize];
1613 strcpy_s(label_string, newsize, (
char *)b_label);
1620 _bstr_t temp(label);
1621 const size_t newsize = (temp.length()+1)*2;
1622 char *nstring =
new char[newsize];
1623 strcpy_s(nstring, newsize, (
char *)temp);
1635 *
id = CComBSTR(ans.c_str()).Detach();
1641 CComPtr<Seci::IComInterface> seci;
1642 HRESULT hr = seci.CoCreateInstance(Seci::CLSID_ComInterface, 0, CLSCTX_LOCAL_SERVER);
1646 throw std::runtime_error(
"Could not connect to Seci");
1649 block_names->vt = VT_ARRAY | VT_BSTR;
1650 block_names->parray = seci->GetBlockNames(
true);
1655 CComPtr<Seci::IComInterface> seci;
1656 HRESULT hr = seci.CoCreateInstance(Seci::CLSID_ComInterface, 0, CLSCTX_LOCAL_SERVER);
1660 throw std::runtime_error(
"Could not connect to Seci");
1663 seci->ClearGraphs();
1668 CComPtr<Seci::IComInterface> seci;
1669 HRESULT hr = seci.CoCreateInstance(Seci::CLSID_ComInterface, 0, CLSCTX_LOCAL_SERVER);
1673 throw std::runtime_error(
"Could not connect to Seci");
1676 *result = seci->ChangeConfiguration(name);
1681 CComPtr<Seci::IComInterface> seci;
1682 HRESULT hr = seci.CoCreateInstance(Seci::CLSID_ComInterface, 0, CLSCTX_LOCAL_SERVER);
1686 throw std::runtime_error(
"Could not connect to Seci");
1689 *result = seci->IsSeciBusy();
void beginRun(ULONG session_id, LONG period, VARIANT_BOOL wait, VARIANT_BOOL quiet, VARIANT_BOOL paused, BSTR *messages)
void sumAllSpectra(ULONG session_id, BSTR *messages, LONG *counts, LONG *bin_counts)
void changeSeciConfiguration(ULONG session_id, BSTR name, VARIANT_BOOL *result)
void clearDatabaseLogs(ULONG session_id, int run_num)
void createSession(BSTR instrument, BSTR user_name, BSTR password, ULONG *session_id)
void isSeciBusy(ULONG session_id, VARIANT_BOOL *result)
void deleteSession(ULONG session_id)
void getRunState(ULONG session_id, BSTR *messages, LONG *status)
void pushBlockButton(ULONG session_id, BSTR block_name, bool use_external, VARIANT *results)
void getMEvents(ULONG session_id, BSTR *messages, DOUBLE *mev)
void createViRef(BSTR vi_name, bool reentrant, LabVIEW::VirtualInstrumentPtr &vi)
void getSeciConfig(ULONG session_id, BSTR *name)
SELOGGER_API int __stdcall se_new_measurement(const char *label, std::string &res)
SELOGGER_API int __stdcall se_get_measurement_id(const char *label, std::string &measurement_id)
void snapshotCRPT(ULONG session_id, BSTR filename, LONG do_update, LONG do_pause, BSTR *messages)
void abortRun(ULONG session_id, BSTR *messages)
void startVi(ULONG session_id, BSTR vi_name)
void toggleViVisibility(ULONG session_id, BSTR vi_name, VARIANT_BOOL show)
void setRole(ULONG session_id, BSTR role)
void saveRun(ULONG session_id, BSTR *messages)
void recoverRun(ULONG session_id, BSTR *messages)
void setLabviewValueExt(ULONG session_id, BSTR vi_name, BSTR control_name, VARIANT value, VARIANT *results)
void getRunControl(ULONG session_id, BSTR block_name, VARIANT_BOOL *rc_value)
void getGoodFrames(ULONG session_id, VARIANT_BOOL curr_period, BSTR *messages, LONG *frames)
void setMeasurementLabel(ULONG session_id, BSTR id, BSTR label)
void getBlockNames(ULONG session_id, VARIANT *block_names)
void logBlocksNow(ULONG session_id, BSTR source)
void getSpectrum(ULONG session_id, LONG spectrum_no, LONG period, VARIANT_BOOL as_dist, VARIANT *time_channels, VARIANT *signal, LONG *sum, BSTR *messages)
static COAUTHIDENTITY * createIdentity(const std::string &user, const std::string &domain, const std::string &pass)
void pauseRun(ULONG session_id, BSTR *messages)
void vmeWriteValue(ULONG session_id, ULONG card_id, ULONG card_address, ULONG word_size, ULONG value, ULONG mode, BSTR *messages)
void setPeriod(ULONG session_id, LONG period_number, BSTR *messages)
SELOGGER_API const char *__stdcall se_get_errmsg()
void getBeamlineParameterNames(ULONG session_id, VARIANT *names)
void getRunNumber(ULONG session_id, BSTR *messages, LONG *run_no)
std::string & set_control()
void setBlockSetpoint(ULONG session_id, BSTR block_name, VARIANT setpoint_value, bool push_button, bool use_external, VARIANT *results)
void deleteAllBeamlineParameters(ULONG session_id)
void setRunControl(ULONG session_id, BSTR block_name, VARIANT_BOOL rc_value)
void getBlockSetpoint(ULONG session_id, BSTR block_name, VARIANT *setpoint_value)
void callLabview(ULONG session_id, BSTR vi_name, VARIANT names, VARIANT values, VARIANT_BOOL reentrant, VARIANT *results)
void clearSeciGraphs(ULONG session_id)
void getRunControlLimit(ULONG session_id, BSTR block_name, VARIANT *limit_value, bool low)
void getMeasurementLabel(ULONG session_id, BSTR id, BSTR *label)
void getMessages(ULONG session_id, LONG start_index, BSTR min_severity, VARIANT *times, VARIANT *severities, VARIANT *messages, LONG *end_index)
void getBlockValue(ULONG session_id, BSTR block_name, VARIANT *block_value)
void updateCRPT(ULONG session_id, BSTR *messages)
void setRunControlLimit(ULONG session_id, BSTR block_name, VARIANT new_value, bool low)
void closeViFrontPanel(ULONG session_id, BSTR vi_name)
void changeNumberOfSoftwarePeriods(ULONG session_id, LONG num_periods, BSTR *messages)
void getSampleParameterNames(ULONG session_id, VARIANT *names)
SELOGGER_API int __stdcall se_get_block_details(const char *block_name, SEBLOCK_DETAILS &block)
SELOGGER_API int __stdcall se_get_measurement_label(const char *measurement_id, std::string &res)
void deleteAllSampleParameters(ULONG session_id)
void getNumberOfPeriods(ULONG session_id, BSTR *messages, LONG *num_periods)
void setSampleParameter(ULONG session_id, VARIANT name, VARIANT value, VARIANT units)
void accessRuncontrol(ULONG session_id, BSTR block_name, VARIANT_BOOL new_value, VARIANT_BOOL *value, bool setvalue)
void getCurrentPeriod(ULONG session_id, BSTR *messages, LONG *period, LONG *daq_period)
void setBeamlineParameter(ULONG session_id, VARIANT name, VARIANT value, VARIANT units)
SELOGGER_API int __stdcall se_get_seci_config(std::string &seci_config)
void stopVi(ULONG session_id, BSTR vi_name)
static HRESULT setIdentity(COAUTHIDENTITY *pidentity, IUnknown *pUnk)
void endRun(ULONG session_id, BSTR *messages)
void sendBlockSetpoint(ULONG session_id, BSTR block_name, VARIANT setpoint_value, bool push_button, bool use_external, VARIANT *results)
void setRbNumber(ULONG session_id, VARIANT rb_no)
void getUamps(ULONG session_id, VARIANT_BOOL curr_period, BSTR *messages, DOUBLE *uamps)
void putMessage(ULONG session_id, BSTR time, BSTR severity, BSTR message)
void setTitle(ULONG session_id, VARIANT title)
SELOGGER_API int __stdcall se_clear_values(int run_start, int run_finish)
void getViState(ULONG session_id, BSTR vi_name, VARIANT *value)
SELOGGER_API int __stdcall se_set_block_value(const char *block_name, const char *block_value)
std::string & read_control()
static int junk(const std::string &hostname, GUID C, GUID G)
SELOGGER_API int __stdcall se_set_measurement_label(const char *measurement_id, const char *label)
std::string & button_control()
void accessLimits(ULONG session_id, BSTR block_name, VARIANT new_value, BSTR *value, bool setvalue, bool low)
void resumeRun(ULONG session_id, BSTR *messages)
void getRbNumber(ULONG session_id, VARIANT *rb_no)
void getViRef(BSTR vi_name, bool reentrant, LabVIEW::VirtualInstrumentPtr &vi)
void getSampleParameter(ULONG session_id, BSTR name, BSTR *value, BSTR *units, BSTR *type)
void storeCRPT(ULONG session_id, BSTR *messages)
void getMeasurementId(ULONG session_id, BSTR label, VARIANT_BOOL newId, BSTR *id)
void getLabviewValue(ULONG session_id, BSTR vi_name, BSTR control_name, VARIANT *value)
void clearLogFiles(ULONG session_id, int run_num, BSTR path)
LabVIEW::VirtualInstrumentPtr vi_ref
void getBeamlineParameter(ULONG session_id, BSTR name, BSTR *value, BSTR *units, BSTR *type)
void getTotalCounts(ULONG session_id, BSTR *messages, LONG *counts)
void sumAllHistogramMemory(ULONG session_id, BSTR *messages, LONG *counts)
void setLabviewValue(ULONG session_id, BSTR vi_name, BSTR control_name, VARIANT value)
void deleteBeamlineParameter(ULONG session_id, VARIANT name)
int arrayVariantDimensions(VARIANT *v, int dims_array[], int &ndims)
void getRole(ULONG session_id, BSTR *role)
void deleteSampleParameter(ULONG session_id, VARIANT name)
void getViNames(ULONG session_id, VARIANT *names)
SELOGGER_API int __stdcall se_log_values_async(long run_number, const char *source, const std::vector< std::string > &iso_times, const std::vector< std::string > &block_names, const std::vector< std::string > &block_values)