pacemaker 3.0.3
COM automation for people with deadlines and a hatred of GUIs
 
Loading...
Searching...
No Matches
IncaOnlineExperimentProxy.hpp
Go to the documentation of this file.
1#ifndef PACEMAKER_INCA_COM_INCAONLINEEXPERIMENTPROXY_HPP_
2#define PACEMAKER_INCA_COM_INCAONLINEEXPERIMENTPROXY_HPP_
3
4#include <stdexcept>
5#include <string>
6#include <vector>
7
11
14
16{
30 {
45 [[nodiscard]] auto GetAllDevices() -> std::vector<ExperimentDeviceProxy>
46 {
47 _variant_t device_list = ::IncaOnlineExperiment_Dispatch::GetAllDevices();
48 if (device_list.vt != (VT_ARRAY | VT_VARIANT))
49 throw std::runtime_error("GetAllDevices returned an unexpected type.");
50
51 SAFEARRAY *psa = V_ARRAY(&device_list);
52 long lLower{}, lUpper{};
53 SafeArrayGetLBound(psa, 1, &lLower);
54 SafeArrayGetUBound(psa, 1, &lUpper);
55
56 std::vector<ExperimentDeviceProxy> out{};
57 out.reserve(static_cast<std::size_t>(lUpper - lLower + 1));
58 for (long i{lLower}; i <= lUpper; ++i)
59 {
60 _variant_t device;
61 if (FAILED(SafeArrayGetElement(psa, &i, &device)))
62 throw std::runtime_error("GetAllDevices: SafeArrayGetElement failed");
63
64 if (device.vt != VT_DISPATCH)
65 throw std::runtime_error("GetAllDevices: device element is not VT_DISPATCH");
66
67 auto idispatch = (IDispatch *)(device);
68 out.emplace_back(idispatch);
69 }
70 return out;
71 }
72
86 [[nodiscard]] auto GetCalibrationValueInDevice(const std::string &name, ::ExperimentDevice_Dispatch *const device) -> CalibrationScalarDataProxy
87 {
88 ::IDispatch *raw = ::IncaOnlineExperiment_Dispatch::GetCalibrationValueInDevice(name.c_str(), device).Detach();
89 if (raw == nullptr)
90 throw std::runtime_error("GetCalibrationValueInDevice: parameter not found " + name);
92 }
93 };
94
117} // namespace pacemaker::inca::com
118#endif // PACEMAKER_INCA_COM_INCAONLINEEXPERIMENTPROXY_HPP_
Owning smart-pointer base class for COM dispatch proxy objects.
Definition COMProxy.hpp:58
pacemaker::inca::detail::COMProxy< CalibrationScalarData_DispatchWrapper > CalibrationScalarDataProxy
Owning smart-pointer proxy for an INCA calibration scalar data COM object.
DispatchWrapper for the IncaOnlineExperiment_Dispatch COM interface.
auto GetCalibrationValueInDevice(const std::string &name, ::ExperimentDevice_Dispatch *const device) -> CalibrationScalarDataProxy
Retrieves a calibration scalar data item by name from a specific device.
auto GetAllDevices() -> std::vector< ExperimentDeviceProxy >
Returns all ECU devices associated with the open experiment.
Helper struct for standardize interface retrieval.