2025-01-05 14:19:53 -04:00
|
|
|
#ifndef DEVICEMANAGER_H
|
|
|
|
|
#define DEVICEMANAGER_H
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
2025-01-08 06:23:34 -04:00
|
|
|
#include <memory>
|
2025-01-05 14:19:53 -04:00
|
|
|
#include <opts.h>
|
2025-01-07 14:11:51 -04:00
|
|
|
#include <utility>
|
|
|
|
|
#include <iostream>
|
2025-09-27 23:16:46 -04:00
|
|
|
#include <user/senseApiDesc.h>
|
2025-08-29 15:16:11 -04:00
|
|
|
#include <user/deviceAttachmentSpec.h>
|
2025-08-29 17:42:13 -04:00
|
|
|
#include <deviceManager/device.h>
|
2025-09-28 00:50:05 -04:00
|
|
|
#include <deviceManager/deviceRole.h>
|
2025-09-29 01:07:32 -04:00
|
|
|
#include <deviceManager/deviceReattacher.h>
|
2026-05-24 16:12:29 -04:00
|
|
|
#include <marionette/marionetteThread.h>
|
|
|
|
|
#include <spinscale/multiOperationResultSet.h>
|
2026-06-07 19:37:50 -04:00
|
|
|
#include <spinscale/co/coQutex.h>
|
2026-05-24 16:12:29 -04:00
|
|
|
#include <spinscale/sharedResourceGroup.h>
|
2025-01-05 14:19:53 -04:00
|
|
|
|
2025-07-22 06:48:04 -04:00
|
|
|
namespace smo {
|
2025-01-13 21:57:11 -04:00
|
|
|
namespace device {
|
|
|
|
|
|
2025-09-29 01:07:32 -04:00
|
|
|
class DeviceReattacher;
|
|
|
|
|
|
2025-01-05 14:19:53 -04:00
|
|
|
class DeviceManager
|
|
|
|
|
{
|
|
|
|
|
public:
|
2026-05-24 16:12:29 -04:00
|
|
|
static DeviceManager& getInstance()
|
|
|
|
|
{
|
|
|
|
|
static DeviceManager instance;
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
2025-01-05 14:19:53 -04:00
|
|
|
|
2025-09-12 16:09:26 -04:00
|
|
|
void initialize(void)
|
|
|
|
|
{};
|
|
|
|
|
void finalize(void)
|
|
|
|
|
{};
|
|
|
|
|
|
2025-09-29 01:07:32 -04:00
|
|
|
void initializeDeviceReattacher();
|
|
|
|
|
void finalizeDeviceReattacher();
|
|
|
|
|
|
2026-05-24 16:12:29 -04:00
|
|
|
std::string readDapSpecFile(const std::string& filename);
|
|
|
|
|
void collateAllDapSpecs(void);
|
|
|
|
|
void parseAllDapSpecs(void);
|
|
|
|
|
|
|
|
|
|
static const std::string stringifyDeviceSpecs(void);
|
|
|
|
|
|
2026-06-07 19:37:50 -04:00
|
|
|
mrntt::MrnttViralPostingInvoker<std::shared_ptr<DeviceRole>>
|
2026-05-24 16:12:29 -04:00
|
|
|
newDeviceAttachmentSpecIndCReq(const DeviceAttachmentSpec &spec);
|
|
|
|
|
|
2026-06-07 19:37:50 -04:00
|
|
|
mrntt::MrnttViralPostingInvoker<void>
|
2026-05-24 16:12:29 -04:00
|
|
|
removeDeviceAttachmentSpecCReq(const DeviceAttachmentSpec &spec);
|
|
|
|
|
|
2026-06-07 19:37:50 -04:00
|
|
|
mrntt::MrnttViralPostingInvoker<void>
|
2026-05-24 16:12:29 -04:00
|
|
|
attachStimBuffDeviceCReq(
|
|
|
|
|
const std::shared_ptr<DeviceAttachmentSpec>& spec);
|
|
|
|
|
|
2026-06-07 19:37:50 -04:00
|
|
|
mrntt::MrnttViralPostingInvoker<void>
|
2026-05-24 16:12:29 -04:00
|
|
|
detachStimBuffDeviceCReq(
|
|
|
|
|
const std::shared_ptr<DeviceAttachmentSpec>& spec);
|
|
|
|
|
|
2026-06-07 19:37:50 -04:00
|
|
|
mrntt::MrnttViralPostingInvoker<void>
|
2026-05-24 16:12:29 -04:00
|
|
|
attachAllUnattachedDevicesFromKnownListCReq();
|
|
|
|
|
|
2026-06-07 19:37:50 -04:00
|
|
|
mrntt::MrnttViralPostingInvoker<void>
|
2026-05-24 16:12:29 -04:00
|
|
|
attachAllUnattachedDevicesFromCmdlineCReq();
|
|
|
|
|
|
2026-06-07 19:37:50 -04:00
|
|
|
mrntt::MrnttViralPostingInvoker<void>
|
2026-05-24 16:12:29 -04:00
|
|
|
detachAllAttachedDeviceRolesCReq();
|
2025-09-27 23:16:46 -04:00
|
|
|
|
2025-01-05 14:19:53 -04:00
|
|
|
private:
|
2026-05-24 16:12:29 -04:00
|
|
|
DeviceManager()
|
|
|
|
|
: s("DeviceManager")
|
2025-09-28 01:27:32 -04:00
|
|
|
{}
|
2026-05-24 16:12:29 -04:00
|
|
|
|
|
|
|
|
~DeviceManager();
|
|
|
|
|
DeviceManager(const DeviceManager&) = delete;
|
|
|
|
|
DeviceManager& operator=(const DeviceManager&) = delete;
|
2025-01-07 14:11:51 -04:00
|
|
|
|
2026-06-07 19:37:50 -04:00
|
|
|
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSetWithException>
|
|
|
|
|
attachAllUnattachedDevicesFromCReq(
|
|
|
|
|
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs);
|
|
|
|
|
|
2025-01-07 14:11:51 -04:00
|
|
|
public:
|
2026-05-24 16:12:29 -04:00
|
|
|
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;
|
2025-09-15 14:20:08 -04:00
|
|
|
|
|
|
|
|
private:
|
2025-09-29 01:07:32 -04:00
|
|
|
std::unique_ptr<DeviceReattacher> deviceReattacher;
|
2025-01-05 14:19:53 -04:00
|
|
|
};
|
|
|
|
|
|
2025-01-13 21:57:11 -04:00
|
|
|
} // namespace device
|
2025-07-22 06:48:04 -04:00
|
|
|
} // namespace smo
|
2025-01-13 21:57:11 -04:00
|
|
|
|
2025-01-05 14:19:53 -04:00
|
|
|
#endif // DEVICEMANAGER_H
|