working tests/adc_asio_netserver_test.cpp
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#include "../net/asio/adc_device_netserver_asio.h"
|
||||
|
||||
typedef adc::impl::AdcDeviceNetServerASIO server_t;
|
||||
|
||||
typedef adc::AdcDeviceAttribute<std::string, server_t::serialized_t> attr_t;
|
||||
|
||||
class Device1 : public adc::AdcGenericDevice<std::string,
|
||||
adc::AdcDeviceAttribute<std::string, server_t::serialized_t>,
|
||||
@@ -66,8 +66,10 @@ int main(int argc, char* argv[])
|
||||
|
||||
// device#1
|
||||
dev1.addCommand("DEV1::COM1", []() { std::cout << "EXEC DEV1::COM1\n"; });
|
||||
dev1.addAttribute(
|
||||
"DEV1::ATTR1", [&dev1_val1]() { return dev1_val1; }, [&dev1_val1](const int& v) { dev1_val1 = v; });
|
||||
// dev1.addAttribute(
|
||||
// "DEV1::ATTR1", [&dev1_val1]() { return dev1_val1; }, [&dev1_val1](const int& v) { dev1_val1 = v; });
|
||||
dev1.addAttribute(Device1::attribute_t::makeArithAttr(
|
||||
"DEV1::ATTR1", [&dev1_val1]() { return dev1_val1; }, [&dev1_val1](const int& v) { dev1_val1 = v; }));
|
||||
|
||||
dev1.addAttribute("DEV1::ATTR2", gt, st);
|
||||
|
||||
@@ -75,7 +77,24 @@ int main(int argc, char* argv[])
|
||||
// read-only attr
|
||||
dev2.addAttribute(0x1ul, [&dev1_val1]() { return dev1_val1; });
|
||||
// write-only
|
||||
dev2.addAttribute(0xfful, [&dev1_val1](const int& v) { dev1_val1 = v; });
|
||||
// dev2.addAttribute(0xfful, [&dev1_val1](const int& v) { dev1_val1 = v; });
|
||||
dev2.addAttribute(Device2::attribute_t::makeArithAttr(0xfful, [&dev1_val1](const int& v) { dev1_val1 = v; }));
|
||||
|
||||
|
||||
double f = 7.7;
|
||||
std::cout << "SET DEV1['DEV1::ATTR1'] to " << f;
|
||||
dev1["DEV1::ATTR1"] = f;
|
||||
std::cout << "\tRESULT ( " << dev1_val1 << " )\n";
|
||||
|
||||
dev1_val1 = 111;
|
||||
std::cout << "GET DEV1['DEV1::ATTR1']";
|
||||
float fl = dev1["DEV1::ATTR1"];
|
||||
std::cout << "\tRESULT ( " << fl << " )\n";
|
||||
|
||||
f *= 3.3;
|
||||
std::cout << "SET DEV2['0xff'] to " << f;
|
||||
dev2[0xff] = f;
|
||||
std::cout << "\tRESULT ( " << dev1_val1 << " )\n";
|
||||
|
||||
|
||||
/* COMMANDLINE OPTS */
|
||||
|
||||
@@ -66,7 +66,7 @@ TEST_CASE("[ADC DEVICE ATTRIBUTE]")
|
||||
auto ar1 = ar;
|
||||
std::cout << "ATTR1_RO = " << (double)ar1 << "\n";
|
||||
|
||||
auto ar2(ar1);
|
||||
auto ar2(std::move(ar1));
|
||||
std::cout << "ATTR2_RO = " << (double)ar2 << "\n";
|
||||
|
||||
std::cout << "ATTR2_RO_SER = " << ar2.serialize() << "\n";
|
||||
|
||||
Reference in New Issue
Block a user