Capsule API Example

Loading...
Searching...
No Matches
Device.hpp
Go to the documentation of this file.
1// Copyright. 2019 - 2024 PSBD. All rights reserved.
2
3#pragma once
4
5#include "CDefinesPrivate.h"
6
7#include <Devices/DeviceTypes.hpp>
8#include <Utils/Time.hpp>
9
10#include <string>
11
12 namespace capsule::client {
13 class ClientPrivate;
14 class Device;
15 class DevicePrivate;
16 class DeviceLocatorPrivate;
17
23 class CL_DLL DeviceLocator final {
24 friend ClientPrivate;
25 friend Device;
26 friend DevicePrivate;
27 friend DeviceLocatorPrivate;
28
29 public:
30 explicit DeviceLocator(const std::optional<fs::path>& logDirectory = std::nullopt);
31 DeviceLocator(const DeviceLocator&) = delete;
32 DeviceLocator& operator=(const DeviceLocator&) = delete;
33 DeviceLocator(DeviceLocator&& rhd) noexcept;
34 DeviceLocator& operator=(DeviceLocator&& rhd) noexcept;
35 ~DeviceLocator();
43 void RequestDevices(device::DeviceType deviceType, core::SecondsI searchTime);
50 Device CreateDevice(const std::string& deviceSerial) &;
51
52 void SetOnDevicesEvent(std::function<void(DeviceLocator&, const device::DeviceListExpected&)>&& callback);
53
54 static void SetSingleThreaded(bool singleThreaded);
55 void Update();
56
57 bool IsValid() const noexcept;
58 void ResetDevice();
59
60 private:
61 void CheckValid() const;
62
63 std::unique_ptr<DeviceLocatorPrivate> m_pimpl;
64};
65
71class CL_DLL Device final {
72 friend DeviceLocator;
73 friend DeviceLocatorPrivate;
74 friend ClientPrivate;
75 friend DevicePrivate;
76
77 public:
78 Device(const Device&) = delete;
79 Device& operator=(const Device&) = delete;
80 Device(Device&& rhd) noexcept;
81 Device& operator=(Device&& rhd) noexcept;
82 ~Device() = default;
86 bool IsConnected() const;
91 const device::DeviceInfo& GetInfo() &;
92 float GetEEGSampleRate() const;
93 float GetPPGSampleRate() const;
94 float GetMEMSSampleRate() const;
95 int GetPPGIrAmplitude() const;
96 int GetPPGRedAmplitude() const;
97
98 void SetOnConnectionStateChangedEvent(std::function<void(Device&, device::DeviceConnectionStatus)>&& callback);
99 void SetOnResistanceUpdateEvent(std::function<void(Device&, device::Resistances&&)>&& callback);
100 void SetOnBatteryChargeUpdateEvent(std::function<void(Device&, device::DeviceBatteryCharge)>&& callback);
101 void SetOnEEGDataEvent(std::function<void(Device&, device::EEGTimedData&&)>&& callback);
102 void SetOnErrorEvent(std::function<void(Device&, std::string&&)>&& callback);
103 void SetOnModeSwitchedEvent(std::function<void(Device&, device::DeviceMode)>&& callback);
104 void SetOnPSDDataEvent(std::function<void(Device&, device::PSDData&&)>&& callback);
105 void SetOnEEGArtifactsEvent(std::function<void(Device&, device::EEGArtifacts&&)>&& callback);
106
111 void Connect(bool bipolarChannels);
116 void Disconnect();
117 void Start();
118 bool Stop();
119
120 device::DeviceBatteryCharge GetBatteryCharge() const;
121 device::DeviceChannelNames GetChannelNames() const;
122 device::DeviceMode GetMode() const;
123
124 bool IsValid() const noexcept;
125
126 private:
127 void CheckValid() const;
128 Device() = default;
129
130 DevicePrivate* m_pimpl = nullptr;
131};
132
133} // namespace capsule::client
CDefinesPrivate.h
CL_DLL
#define CL_DLL
Definition CDefinesPrivate.h:51
capsule::client::Device
Device.
Definition Device.hpp:71
capsule::client::Device::~Device
~Device()=default
capsule::client::Device::SetOnEEGArtifactsEvent
void SetOnEEGArtifactsEvent(std::function< void(Device &, device::EEGArtifacts &&)> &&callback)
capsule::client::Device::Connect
void Connect(bool bipolarChannels)
capsule::client::Device::GetPPGSampleRate
float GetPPGSampleRate() const
capsule::client::Device::Stop
bool Stop()
capsule::client::Device::GetMEMSSampleRate
float GetMEMSSampleRate() const
capsule::client::Device::GetMode
device::DeviceMode GetMode() const
capsule::client::Device::operator=
Device & operator=(const Device &)=delete
capsule::client::Device::Disconnect
void Disconnect()
capsule::client::Device::IsValid
bool IsValid() const noexcept
capsule::client::Device::SetOnConnectionStateChangedEvent
void SetOnConnectionStateChangedEvent(std::function< void(Device &, device::DeviceConnectionStatus)> &&callback)
capsule::client::Device::GetPPGRedAmplitude
int GetPPGRedAmplitude() const
capsule::client::Device::Device
Device(Device &&rhd) noexcept
capsule::client::Device::Device
Device(const Device &)=delete
capsule::client::Device::SetOnBatteryChargeUpdateEvent
void SetOnBatteryChargeUpdateEvent(std::function< void(Device &, device::DeviceBatteryCharge)> &&callback)
capsule::client::Device::SetOnEEGDataEvent
void SetOnEEGDataEvent(std::function< void(Device &, device::EEGTimedData &&)> &&callback)
capsule::client::Device::IsConnected
bool IsConnected() const
capsule::client::Device::GetBatteryCharge
device::DeviceBatteryCharge GetBatteryCharge() const
capsule::client::Device::SetOnPSDDataEvent
void SetOnPSDDataEvent(std::function< void(Device &, device::PSDData &&)> &&callback)
capsule::client::Device::GetInfo
const device::DeviceInfo & GetInfo() &
capsule::client::Device::SetOnErrorEvent
void SetOnErrorEvent(std::function< void(Device &, std::string &&)> &&callback)
capsule::client::Device::SetOnModeSwitchedEvent
void SetOnModeSwitchedEvent(std::function< void(Device &, device::DeviceMode)> &&callback)
capsule::client::Device::GetChannelNames
device::DeviceChannelNames GetChannelNames() const
capsule::client::Device::GetEEGSampleRate
float GetEEGSampleRate() const
capsule::client::Device::Start
void Start()
capsule::client::Device::SetOnResistanceUpdateEvent
void SetOnResistanceUpdateEvent(std::function< void(Device &, device::Resistances &&)> &&callback)
capsule::client::Device::operator=
Device & operator=(Device &&rhd) noexcept
capsule::client::Device::GetPPGIrAmplitude
int GetPPGIrAmplitude() const
capsule::client::DeviceLocator
Device locator.
Definition Device.hpp:23
capsule::client::DeviceLocator::DeviceLocator
DeviceLocator(const DeviceLocator &)=delete
capsule::client::DeviceLocator::DeviceLocator
DeviceLocator(const std::optional< fs::path > &logDirectory=std::nullopt)
capsule::client::DeviceLocator::IsValid
bool IsValid() const noexcept
capsule::client::DeviceLocator::operator=
DeviceLocator & operator=(DeviceLocator &&rhd) noexcept
capsule::client::DeviceLocator::SetSingleThreaded
static void SetSingleThreaded(bool singleThreaded)
capsule::client::DeviceLocator::CreateDevice
Device CreateDevice(const std::string &deviceSerial) &
capsule::client::DeviceLocator::Update
void Update()
capsule::client::DeviceLocator::DeviceLocator
DeviceLocator(DeviceLocator &&rhd) noexcept
capsule::client::DeviceLocator::~DeviceLocator
~DeviceLocator()
capsule::client::DeviceLocator::SetOnDevicesEvent
void SetOnDevicesEvent(std::function< void(DeviceLocator &, const device::DeviceListExpected &)> &&callback)
capsule::client::DeviceLocator::operator=
DeviceLocator & operator=(const DeviceLocator &)=delete
capsule::client::DeviceLocator::RequestDevices
void RequestDevices(device::DeviceType deviceType, core::SecondsI searchTime)
Find available devices. Search time is in seconds. Non-blocking - OnDevices event is fired when timeo...
capsule::client
Definition Classification.hpp:7