LivoxProto1: port to sscl::co framework
Code now actually looks a lot cleaner, tbh.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <spinscale/cps/callback.h>
|
||||
#include <spinscale/co/invokers.h>
|
||||
#include <boost/asio/posix/stream_descriptor.hpp>
|
||||
|
||||
// Forward declarations
|
||||
@@ -23,6 +23,18 @@ namespace livoxProto1 {
|
||||
class Device;
|
||||
}
|
||||
|
||||
struct LivoxProto1GetOrCreateDeviceResult
|
||||
{
|
||||
bool success = false;
|
||||
std::shared_ptr<livoxProto1::Device> device;
|
||||
};
|
||||
|
||||
struct LivoxProto1GetReturnModeResult
|
||||
{
|
||||
bool success = false;
|
||||
uint8_t returnMode = 0;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -52,54 +64,43 @@ typedef void livoxProto1_exitFn(void);
|
||||
* @param dataPort Data port for point cloud (default: 56000)
|
||||
* @param cmdPort Command port (default: 56001)
|
||||
* @param imuPort IMU port (default: 56002)
|
||||
* @return Device pointer on success, nullptr on failure
|
||||
* @return LivoxProto1GetOrCreateDeviceResult (success + device on success,
|
||||
* null device on failure)
|
||||
*/
|
||||
typedef std::function<
|
||||
void(bool success, std::shared_ptr<livoxProto1::Device> device)>
|
||||
livoxProto1_getOrCreateDeviceReqCbFn;
|
||||
|
||||
typedef void livoxProto1_getOrCreateDeviceReqFn(
|
||||
typedef sscl::co::ViralNonPostingInvoker<LivoxProto1GetOrCreateDeviceResult>
|
||||
livoxProto1_getOrCreateDeviceCReqFn(
|
||||
const std::string& deviceIdentifier,
|
||||
const std::shared_ptr<sscl::ComponentThread>& componentThread,
|
||||
int commandTimeoutMs, int retryDelayMs,
|
||||
const std::string& smoIp, uint8_t smoSubnetNbits,
|
||||
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort,
|
||||
sscl::cps::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback);
|
||||
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort);
|
||||
|
||||
typedef std::function<void(bool success)> livoxProto1_destroyDeviceReqCbFn;
|
||||
typedef void livoxProto1_destroyDeviceReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
sscl::cps::Callback<livoxProto1_destroyDeviceReqCbFn> callback);
|
||||
typedef sscl::co::ViralNonPostingInvoker<bool> livoxProto1_destroyDeviceCReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device);
|
||||
|
||||
typedef std::function<void(bool success)>
|
||||
livoxProto1_device_enablePcloudDataReqCbFn;
|
||||
typedef void livoxProto1_device_enablePcloudDataReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
sscl::cps::Callback<livoxProto1_device_enablePcloudDataReqCbFn> callback);
|
||||
typedef sscl::co::ViralNonPostingInvoker<bool>
|
||||
livoxProto1_device_enablePcloudDataCReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device);
|
||||
|
||||
typedef std::function<void(bool success)>
|
||||
livoxProto1_device_disablePcloudDataReqCbFn;
|
||||
typedef void livoxProto1_device_disablePcloudDataReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
sscl::cps::Callback<livoxProto1_device_disablePcloudDataReqCbFn> callback);
|
||||
typedef sscl::co::ViralNonPostingInvoker<bool>
|
||||
livoxProto1_device_disablePcloudDataCReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device);
|
||||
|
||||
typedef std::function<void(bool success, uint8_t returnMode)>
|
||||
livoxProto1_device_getReturnModeReqCbFn;
|
||||
typedef void livoxProto1_device_getReturnModeReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
sscl::cps::Callback<livoxProto1_device_getReturnModeReqCbFn> callback);
|
||||
typedef sscl::co::ViralNonPostingInvoker<LivoxProto1GetReturnModeResult>
|
||||
livoxProto1_device_getReturnModeCReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device);
|
||||
|
||||
typedef std::shared_ptr<boost::asio::posix::stream_descriptor>
|
||||
livoxProto1_getPcloudDataFdDescFn(void);
|
||||
|
||||
livoxProto1_mainFn livoxProto1_main;
|
||||
livoxProto1_exitFn livoxProto1_exit;
|
||||
livoxProto1_getOrCreateDeviceReqFn livoxProto1_getOrCreateDeviceReq;
|
||||
livoxProto1_destroyDeviceReqFn livoxProto1_destroyDeviceReq;
|
||||
livoxProto1_device_enablePcloudDataReqFn livoxProto1_device_enablePcloudDataReq;
|
||||
livoxProto1_device_disablePcloudDataReqFn
|
||||
livoxProto1_device_disablePcloudDataReq;
|
||||
livoxProto1_device_getReturnModeReqFn livoxProto1_device_getReturnModeReq;
|
||||
livoxProto1_getOrCreateDeviceCReqFn livoxProto1_getOrCreateDeviceCReq;
|
||||
livoxProto1_destroyDeviceCReqFn livoxProto1_destroyDeviceCReq;
|
||||
livoxProto1_device_enablePcloudDataCReqFn livoxProto1_device_enablePcloudDataCReq;
|
||||
livoxProto1_device_disablePcloudDataCReqFn
|
||||
livoxProto1_device_disablePcloudDataCReq;
|
||||
livoxProto1_device_getReturnModeCReqFn livoxProto1_device_getReturnModeCReq;
|
||||
livoxProto1_getPcloudDataFdDescFn livoxProto1_getPcloudDataFdDesc;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user