changes according to new naming scheme of the snippets-library
new naming scheme (delete "adclib_" prefixes)
This commit is contained in:
@@ -9,7 +9,7 @@ using namespace adc;
|
||||
template <typename ID_T, typename VT>
|
||||
void add_attr_mark(ID_T id, VT const& val, std::string_view acc = "RW")
|
||||
{
|
||||
auto tp = snplib::snplib_get_type_name<VT>();
|
||||
auto tp = snplib::type_name_as_string<VT>();
|
||||
|
||||
std::println("add {}-attr with ID='{}' of type '{}'", acc, id, tp);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ void add_attr_mark(ID_T id, VT const& val, std::string_view acc = "RW")
|
||||
template <typename DEV_T, typename VT>
|
||||
void set_attr(DEV_T& dev, typename DEV_T::attr_id_t id, VT const& val)
|
||||
{
|
||||
auto tp = snplib::snplib_get_type_name<VT>();
|
||||
auto tp = snplib::type_name_as_string<VT>();
|
||||
|
||||
std::print("set '{}'-attr value to {} of type '{}':\t", id, val, tp);
|
||||
|
||||
@@ -30,11 +30,11 @@ void set_attr(DEV_T& dev, typename DEV_T::attr_id_t id, VT const& val)
|
||||
}
|
||||
|
||||
template <typename DEV_T, typename VT>
|
||||
void get_attr(DEV_T& dev, typename DEV_T::attr_id_t id, adc_result_t<VT>& val)
|
||||
void get_attr(DEV_T& dev, typename DEV_T::attr_id_t id, ret_result_t<VT>& val)
|
||||
{
|
||||
std::string tp;
|
||||
|
||||
[&tp]<typename T>(T v) { tp = snplib::snplib_get_type_name<T>(); }(val.value());
|
||||
[&tp]<typename T>(T v) { tp = snplib::type_name_as_string<T>(); }(val.value());
|
||||
|
||||
std::print("get '{}'-attr value as one of type '{}':\t", id, tp);
|
||||
|
||||
@@ -59,7 +59,7 @@ int main()
|
||||
|
||||
std::println("add arith RW-attr with id='{}' (val={})", id1, i);
|
||||
dev.addArithAttr(
|
||||
id1, [&i]() -> adc_result_t<int> { return i; },
|
||||
id1, [&i]() -> ret_result_t<int> { return i; },
|
||||
[&i](int const& ii) -> adc_error_t {
|
||||
i = ii;
|
||||
return AdcDeviceErrorCode::ERROR_OK;
|
||||
@@ -74,7 +74,7 @@ int main()
|
||||
// std::tuple<double, int, long>{});
|
||||
|
||||
std::println("add RO-attr with id='{}' (val={})", id2, d);
|
||||
dev.addAttr(id2, [&d]() -> adc_result_t<double> { return d; }, nullptr);
|
||||
dev.addAttr(id2, [&d]() -> ret_result_t<double> { return d; }, nullptr);
|
||||
|
||||
// std::println("add RW-attr with id='{}' (val={})", id3, s);
|
||||
// dev.addAttr(
|
||||
@@ -95,7 +95,7 @@ int main()
|
||||
|
||||
std::println("add RW-attr with id='{}' (val={})", id3, s);
|
||||
dev.addCharRangeAttr(
|
||||
id3, [&s]() -> adc_result_t<std::string> { return s; },
|
||||
id3, [&s]() -> ret_result_t<std::string> { return s; },
|
||||
[&s](std::string const& sv) -> adc_error_t {
|
||||
s = sv;
|
||||
return {};
|
||||
@@ -104,14 +104,14 @@ int main()
|
||||
// std::println("add RW-attr with id='{}' (val={})", id4, pt.native());
|
||||
add_attr_mark(id4, pt);
|
||||
dev.addFSPathAttr(
|
||||
id4, [&pt]() -> adc_result_t<std::filesystem::path> { return pt; },
|
||||
id4, [&pt]() -> ret_result_t<std::filesystem::path> { return pt; },
|
||||
[&pt](std::filesystem::path const& p) -> adc_error_t {
|
||||
pt = p;
|
||||
return {};
|
||||
});
|
||||
|
||||
std::print("get '{}'-attr value as native int:\t", id1);
|
||||
adc_result_t<int> ri = dev[id1];
|
||||
ret_result_t<int> ri = dev[id1];
|
||||
if (ri) {
|
||||
std::println("dev[{}] = {}", id1, ri.value());
|
||||
} else {
|
||||
@@ -128,7 +128,7 @@ int main()
|
||||
}
|
||||
|
||||
std::print("get '{}'-attr value as double:\t", id1);
|
||||
adc_result_t<double> rd = dev[id1];
|
||||
ret_result_t<double> rd = dev[id1];
|
||||
if (rd) {
|
||||
std::println("dev[{}] = {}", id1, rd.value());
|
||||
} else {
|
||||
@@ -160,7 +160,7 @@ int main()
|
||||
std::println("\n");
|
||||
|
||||
std::print("get '{}'-attr value as native string:\t", id3);
|
||||
adc_result_t<std::string> rs = dev[id3];
|
||||
ret_result_t<std::string> rs = dev[id3];
|
||||
if (rs) {
|
||||
std::println("dev[{}] = {}", id3, rs.value());
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
|
||||
std::println("is ACK: {}", msg.isACK());
|
||||
|
||||
msg.createSET("ATTR1", snplib::snplib_serialization_params_t{}, 10, std::vector<char>{'V', 'A', 'L'});
|
||||
msg.createSET("ATTR1", snplib::serialization_params_t{}, 10, std::vector<char>{'V', 'A', 'L'});
|
||||
|
||||
std::println("KEY: <{}>", msg.key());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user