Files
salmanoff/stimBuffApis/livoxGen1/livoxGen1Proto1CpsBridge.cpp
T
hayodea fc5ebb72b9 LivoxGen1: Port to coros
No longer uses CPS. We also found and documented a potential bug in
the way we deal with disablePcloudData during detachDeviceReq.
2026-05-28 15:17:50 -04:00

90 lines
2.8 KiB
C++

#include "livoxGen1Proto1CpsBridge.h"
#include <stdexcept>
namespace smo::stim_buff {
sscl::co::ViralNonPostingInvoker<adapters::smo::GetOrCreateDeviceResult>
coAwaitGetOrCreateDevice(
const std::shared_ptr<sscl::ComponentThread> &componentThread,
const std::string &deviceIdentifier,
const LivoxProviderParams &params)
{
if (!livoxProto1.livoxProto1_getOrCreateDeviceReq) {
throw std::runtime_error("coAwaitGetOrCreateDevice: proto1 function missing");
}
auto result = co_await adapters::smo::getGetOrCreateDeviceReqAReqAwaiter(
componentThread->getIoService(),
livoxProto1.livoxProto1_getOrCreateDeviceReq,
deviceIdentifier,
componentThread,
params.commandTimeoutMs,
params.retryDelayMs,
params.smoIp,
params.smoSubnetNbits,
params.dataPort,
params.cmdPort,
params.imuPort);
co_return result;
}
sscl::co::ViralNonPostingInvoker<adapters::smo::GetReturnModeResult>
coAwaitGetReturnMode(
const std::shared_ptr<sscl::ComponentThread> &componentThread,
const std::shared_ptr<livoxProto1::Device> &device)
{
if (!livoxProto1.livoxProto1_device_getReturnModeReq) {
throw std::runtime_error("coAwaitGetReturnMode: proto1 function missing");
}
co_return co_await adapters::smo::getDeviceGetReturnModeReqAReqAwaiter(
componentThread->getIoService(),
livoxProto1.livoxProto1_device_getReturnModeReq,
device);
}
sscl::co::ViralNonPostingInvoker<bool> coAwaitEnablePcloudData(
const std::shared_ptr<sscl::ComponentThread> &componentThread,
const std::shared_ptr<livoxProto1::Device> &device)
{
if (!livoxProto1.livoxProto1_device_enablePcloudDataReq) {
throw std::runtime_error("coAwaitEnablePcloudData: proto1 function missing");
}
co_return co_await adapters::smo::getDeviceEnablePcloudDataReqAReqAwaiter(
componentThread->getIoService(),
livoxProto1.livoxProto1_device_enablePcloudDataReq,
device);
}
sscl::co::ViralNonPostingInvoker<bool> coAwaitDisablePcloudData(
const std::shared_ptr<sscl::ComponentThread> &componentThread,
const std::shared_ptr<livoxProto1::Device> &device)
{
if (!livoxProto1.livoxProto1_device_disablePcloudDataReq) {
throw std::runtime_error("coAwaitDisablePcloudData: proto1 function missing");
}
co_return co_await adapters::smo::getDeviceDisablePcloudDataReqAReqAwaiter(
componentThread->getIoService(),
livoxProto1.livoxProto1_device_disablePcloudDataReq,
device);
}
sscl::co::ViralNonPostingInvoker<bool> coAwaitDestroyDevice(
const std::shared_ptr<sscl::ComponentThread> &componentThread,
const std::shared_ptr<livoxProto1::Device> &device)
{
if (!livoxProto1.livoxProto1_destroyDeviceReq) {
throw std::runtime_error("coAwaitDestroyDevice: proto1 function missing");
}
co_return co_await adapters::smo::getDestroyDeviceReqAReqAwaiter(
componentThread->getIoService(),
livoxProto1.livoxProto1_destroyDeviceReq,
device);
}
} // namespace smo::stim_buff