Skip to content
Snippets Groups Projects
Commit 097b165e authored by Guillaume Communie's avatar Guillaume Communie
Browse files

Merge branch 'bug_att_event' into 'main'

Bug with event subscription

Closes #4

See merge request !21
parents b52f3dd3 af616875
No related branches found
No related tags found
1 merge request!21Bug with event subscription
...@@ -63,6 +63,8 @@ class attribute ...@@ -63,6 +63,8 @@ class attribute
attribute(const std::string &attr_name, const std::string host, unsigned int port); attribute(const std::string &attr_name, const std::string host, unsigned int port);
attribute(const std::string &dev_name, const std::string &attr_name, const std::string host, unsigned int port); attribute(const std::string &dev_name, const std::string &attr_name, const std::string host, unsigned int port);
std::string get_fqdn() const;
const std::type_info &get_type() const; const std::type_info &get_type() const;
attribute_value get_value() const; attribute_value get_value() const;
......
...@@ -410,7 +410,7 @@ int eventAttribute(std::span<std::string> args, const mj::options &options) ...@@ -410,7 +410,7 @@ int eventAttribute(std::span<std::string> args, const mj::options &options)
} }
std::string deviceName{""}; std::string deviceName{""};
if(args.size() == 4) if(args.size() == 5)
{ {
if(std::string{"device"}.starts_with(args[3])) if(std::string{"device"}.starts_with(args[3]))
{ {
...@@ -429,8 +429,7 @@ int eventAttribute(std::span<std::string> args, const mj::options &options) ...@@ -429,8 +429,7 @@ int eventAttribute(std::span<std::string> args, const mj::options &options)
auto attribute = details::create_attribute(deviceName, attName, options); auto attribute = details::create_attribute(deviceName, attName, options);
// event subscription // event subscription
std::cerr << "Subscription to event of type \"" << EVENT_NAMES[evType] << "\" " std::cerr << "Subscription to event of type \"" << EVENT_NAMES[evType] << "\" "
<< "of \"" << attName << "\" " << "of \"" << attribute.get_fqdn() << "\" " << std::endl;
<< "on \"" << deviceName << "\"" << std::endl;
std::cerr << "Ctrl-C to stop" << std::endl; std::cerr << "Ctrl-C to stop" << std::endl;
auto t0 = std::chrono::steady_clock::now(); auto t0 = std::chrono::steady_clock::now();
......
...@@ -75,6 +75,11 @@ attribute::attribute(const std::string &dev_name, ...@@ -75,6 +75,11 @@ attribute::attribute(const std::string &dev_name,
{ {
} }
std::string attribute::get_fqdn() const
{
return fqdn_name;
}
std::string attribute::get_name() const std::string attribute::get_name() const
{ {
if(ptr_attr) if(ptr_attr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment