3e19d39853
SenseApiDesc's exported API now uses coro pointers instead of CPS fn pointers. * Do not build this version of SMO with the Livox drivers enabled, because SMO has been changed at the smocore level to use coros when calling into stimbuffAPI libs. But the Livox drivers haven't yet been ported from CPS to coros. xcbWindow has been ported to expose coros to SMO in its senseApiDesc exported iface.
110 lines
2.8 KiB
C++
110 lines
2.8 KiB
C++
#ifndef DEVICEMANAGER_H
|
|
#define DEVICEMANAGER_H
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <opts.h>
|
|
#include <utility>
|
|
#include <iostream>
|
|
#include <user/senseApiDesc.h>
|
|
#include <user/deviceAttachmentSpec.h>
|
|
#include <deviceManager/device.h>
|
|
#include <deviceManager/deviceRole.h>
|
|
#include <deviceManager/deviceReattacher.h>
|
|
#include <marionette/marionetteThread.h>
|
|
#include <spinscale/co/coQutex.h>
|
|
#include <spinscale/multiOperationResultSet.h>
|
|
#include <spinscale/sharedResourceGroup.h>
|
|
|
|
namespace smo {
|
|
namespace device {
|
|
|
|
class DeviceReattacher;
|
|
|
|
class DeviceManager
|
|
{
|
|
public:
|
|
struct DeviceAttachmentIndResult
|
|
{
|
|
bool success = false;
|
|
std::shared_ptr<DeviceRole> deviceRole;
|
|
std::shared_ptr<DeviceAttachmentSpec> deviceSpec;
|
|
};
|
|
|
|
static DeviceManager& getInstance()
|
|
{
|
|
static DeviceManager instance;
|
|
return instance;
|
|
}
|
|
|
|
void initialize(void)
|
|
{};
|
|
void finalize(void)
|
|
{};
|
|
|
|
void initializeDeviceReattacher();
|
|
void finalizeDeviceReattacher();
|
|
|
|
std::string readDapSpecFile(const std::string& filename);
|
|
void collateAllDapSpecs(void);
|
|
void parseAllDapSpecs(void);
|
|
|
|
static const std::string stringifyDeviceSpecs(void);
|
|
|
|
mrntt::MrnttViralPostingInvoker<DeviceAttachmentIndResult>
|
|
newDeviceAttachmentSpecIndCReq(const DeviceAttachmentSpec &spec);
|
|
|
|
mrntt::MrnttViralPostingInvoker<DeviceAttachmentIndResult>
|
|
removeDeviceAttachmentSpecCReq(const DeviceAttachmentSpec &spec);
|
|
|
|
mrntt::MrnttViralPostingInvoker<stim_buff::StimBuffDeviceOpResult>
|
|
attachStimBuffDeviceCReq(
|
|
const std::shared_ptr<DeviceAttachmentSpec>& spec);
|
|
|
|
mrntt::MrnttViralPostingInvoker<stim_buff::StimBuffDeviceOpResult>
|
|
detachStimBuffDeviceCReq(
|
|
const std::shared_ptr<DeviceAttachmentSpec>& spec);
|
|
|
|
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSet>
|
|
attachAllUnattachedDevicesFromCReq(
|
|
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs);
|
|
|
|
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSet>
|
|
attachAllUnattachedDevicesFromKnownListCReq();
|
|
|
|
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSet>
|
|
attachAllUnattachedDevicesFromCmdlineCReq();
|
|
|
|
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSet>
|
|
detachAllAttachedDeviceRolesCReq();
|
|
|
|
private:
|
|
DeviceManager()
|
|
: s("DeviceManager")
|
|
{}
|
|
|
|
~DeviceManager();
|
|
DeviceManager(const DeviceManager&) = delete;
|
|
DeviceManager& operator=(const DeviceManager&) = delete;
|
|
|
|
public:
|
|
struct Resources
|
|
{
|
|
std::vector<std::shared_ptr<DeviceAttachmentSpec>> deviceAttachmentSpecs;
|
|
std::vector<std::shared_ptr<Device>> devices;
|
|
std::vector<std::shared_ptr<DeviceRole>> attachedDeviceRoles;
|
|
std::vector<DeviceAttachmentSpec> commandLineDASpecs;
|
|
std::string allDapSpecs;
|
|
};
|
|
sscl::SharedResourceGroup<sscl::co::CoQutex, Resources> s;
|
|
|
|
private:
|
|
std::unique_ptr<DeviceReattacher> deviceReattacher;
|
|
};
|
|
|
|
} // namespace device
|
|
} // namespace smo
|
|
|
|
#endif // DEVICEMANAGER_H
|