-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCameraPowerController.h
More file actions
50 lines (44 loc) · 1.28 KB
/
CameraPowerController.h
File metadata and controls
50 lines (44 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <memory>
#include <filesystem>
#include "ProductVariant.h"
template<typename SerialPortManager>
class CameraPowerController
{
public:
CameraPowerController(ProductVariant productVariant)
{
switch (productVariant)
{
case ProductVariant::A:
{
const std::filesystem::path kSerialDevicePathForVariantA{
"/dev/CoolCompanyDevice"};
const auto kBaudRateForVariantA = 9600;
mSerialPortManager = std::make_unique<SerialPortManager>(
kSerialDevicePathForVariantA, kBaudRateForVariantA);
}
return;
case ProductVariant::B:
{
const std::filesystem::path kSerialDevicePathForVariantB{"COM3"};
const auto kBaudRateForVariantB = 115200;
mSerialPortManager = std::make_unique<SerialPortManager>(
kSerialDevicePathForVariantB, kBaudRateForVariantB);
}
return;
default:
throw std::logic_error("Unknown variant");
}
}
void turnOnCamera()
{
mSerialPortManager->asioWrite("ON");
}
void turnOffCamera()
{
mSerialPortManager->asioWrite("OFF");
}
private:
std::unique_ptr<SerialPortManager> mSerialPortManager;
};