CVB++ 15.0
detail_device_control.hpp
1#pragma once
2
3#include <vector>
4
5#include "../../global.hpp"
6
7#include "../../_decl/decl_device.hpp"
8
9#include "../_decl/decl_device_control.hpp"
10
11namespace Cvb
12{
13
14 CVB_BEGIN_INLINE_NS
15
16 namespace Driver
17 {
18
20 {
21 std::string cvalue(Internal::CastToAscii(value));
22 std::size_t outputStringSize = 0;
23 auto resultQuery = CExports::DCStrCommand(parent_->Handle(),
24 static_cast<CExports::DEVICECTRL_CMD>(static_cast<uint32_t>(command)),
25 cvalue.c_str(), cvalue.size(), nullptr, outputStringSize);
26 if (resultQuery < 0)
28 CvbException::FromCvbResult(resultQuery, "failed to query buffer size with DCStrCommand"));
29
30 std::vector<char> buffer(outputStringSize + 1);
31 auto resultExec = CExports::DCStrCommand(parent_->Handle(),
32 static_cast<CExports::DEVICECTRL_CMD>(static_cast<uint32_t>(command)),
33 cvalue.c_str(), cvalue.size(), &buffer[0], outputStringSize);
34 if (resultExec < 0)
35 std::rethrow_exception(CvbException::FromCvbResult(resultExec, "failed to execute DCStrCommand"));
36
37 std::string cresult(&buffer[0]);
38 String result(cresult.begin(), cresult.end());
39 return result;
40 }
41
42 inline void DeviceControl::SendCommand(DeviceControlCommand command, void *inputBuffer, std::size_t inputBufferSize,
43 void *outputBuffer, std::size_t &outputBufferSize)
44 {
45 auto result = CExports::DCBinaryCommand(parent_->Handle(),
46 static_cast<CExports::DEVICECTRL_CMD>(static_cast<uint32_t>(command)),
47 inputBuffer, inputBufferSize, outputBuffer, outputBufferSize);
48 if (result < 0)
49 std::rethrow_exception(CvbException::FromCvbResult(result, "failed to execute binary command"));
50 }
51
52 } // namespace Driver
53
54 CVB_END_INLINE_NS
55
56} // namespace Cvb
A specific command to send to the driver.
Definition decl_device_control.hpp:19
String SendStringCommand(DeviceControlCommand command, const String &value)
Sends the given command value to the driver.
Definition detail_device_control.hpp:19
void SendCommand(DeviceControlCommand command, IN_TYPE value, OUT_TYPE &result)
Sends the given command value to the driver.
Definition decl_device_control.hpp:128
Namespace for driver or device related operations.
Definition decl_composite.hpp:28
@ String
String value.
Definition driver.hpp:366
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
T rethrow_exception(T... args)