...
This commit is contained in:
parent
9cde583688
commit
ff42a30717
@ -52,10 +52,16 @@ public:
|
|||||||
|
|
||||||
/* PUBLIC METHODS */
|
/* PUBLIC METHODS */
|
||||||
|
|
||||||
IdentT ident() const { return ident; }
|
ident_t ident() const
|
||||||
|
{
|
||||||
|
return _ident;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void operator()() { _execFunc(); }
|
void operator()()
|
||||||
|
{
|
||||||
|
_execFunc();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -108,9 +108,10 @@ namespace adc
|
|||||||
|
|
||||||
class AdcDeviceNetServer : public AdcGenericNetServer
|
class AdcDeviceNetServer : public AdcGenericNetServer
|
||||||
{
|
{
|
||||||
protected:
|
public:
|
||||||
typedef std::vector<char> serialized_t;
|
typedef std::vector<char> serialized_t;
|
||||||
|
|
||||||
|
protected:
|
||||||
class DeviceWrapper
|
class DeviceWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -134,8 +135,8 @@ protected:
|
|||||||
DeviceWrapper() : _id()
|
DeviceWrapper() : _id()
|
||||||
{
|
{
|
||||||
// null device
|
// null device
|
||||||
std::string_view is{"NULL-DEVICE"};
|
std::string_view id{"NULL-DEVICE"};
|
||||||
std::ranges::copy(_id, std::back_inserter(_id));
|
std::ranges::copy(id, std::back_inserter(_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
template <interfaces::adc_device_c DeviceT,
|
template <interfaces::adc_device_c DeviceT,
|
||||||
@ -375,7 +376,7 @@ public:
|
|||||||
virtual ~AdcDeviceNetServer() = default;
|
virtual ~AdcDeviceNetServer() = default;
|
||||||
|
|
||||||
template <interfaces::adc_device_c DeviceT,
|
template <interfaces::adc_device_c DeviceT,
|
||||||
typename IdSerialT = traits::adc_char_identity<typename DeviceT::ident_t>,
|
typename IdSerialT = traits::adc_char_identity<serialized_t>,
|
||||||
typename AttrIdDeserialT = traits::adc_char_identity<typename DeviceT::attr_ident_t>,
|
typename AttrIdDeserialT = traits::adc_char_identity<typename DeviceT::attr_ident_t>,
|
||||||
typename CmdIdDeserialT = traits::adc_char_identity<typename DeviceT::cmd_ident_t>>
|
typename CmdIdDeserialT = traits::adc_char_identity<typename DeviceT::cmd_ident_t>>
|
||||||
AdcDeviceNetServer& addDevice(DeviceT* dev_ptr,
|
AdcDeviceNetServer& addDevice(DeviceT* dev_ptr,
|
||||||
|
|||||||
@ -78,7 +78,7 @@ int main(int argc, char* argv[])
|
|||||||
// read-only attr
|
// read-only attr
|
||||||
dev2.addAttribute({0x1, [&dev1_val1]() { return dev1_val1; }});
|
dev2.addAttribute({0x1, [&dev1_val1]() { return dev1_val1; }});
|
||||||
// write-only
|
// write-only
|
||||||
dev2.addAttribute({0x2, [&dev1_val1](const int& v) { dev1_val1 = v; }});
|
dev2.addAttribute({0xff, [&dev1_val1](const int& v) { dev1_val1 = v; }});
|
||||||
|
|
||||||
|
|
||||||
/* COMMANDLINE OPTS */
|
/* COMMANDLINE OPTS */
|
||||||
@ -116,12 +116,15 @@ int main(int argc, char* argv[])
|
|||||||
asio::signal_set signals(io_ctx, SIGINT, SIGTERM);
|
asio::signal_set signals(io_ctx, SIGINT, SIGTERM);
|
||||||
signals.async_wait([&](std::error_code, int) { io_ctx.stop(); });
|
signals.async_wait([&](std::error_code, int) { io_ctx.stop(); });
|
||||||
|
|
||||||
|
using server_t = adc::impl::AdcDeviceNetServerASIO;
|
||||||
adc::impl::AdcDeviceNetServerASIO server("TEST SRV", io_ctx);
|
adc::impl::AdcDeviceNetServerASIO server("TEST SRV", io_ctx);
|
||||||
server.setupSignals();
|
server.setupSignals();
|
||||||
|
|
||||||
server.addDevice(&dev1);
|
server.addDevice(&dev1);
|
||||||
server.addDevice(&dev2, adc::traits::adc_char_identity<std::string>{},
|
server.addDevice(
|
||||||
adc::utils::AdcDefaultValueConverter<>::serialize<std::string, Device2::attr_ident_t>);
|
&dev2, {},
|
||||||
|
// adc::traits::adc_char_identity<server_t::serialized_t>{},
|
||||||
|
adc::utils::AdcDefaultValueConverter<>::deserialize<Device2::attr_ident_t, server_t::serialized_t>);
|
||||||
|
|
||||||
auto epnt = opt_result["endpoints"].as<std::vector<std::string>>();
|
auto epnt = opt_result["endpoints"].as<std::vector<std::string>>();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user