Commit d6abc440 authored by Mike Grüne's avatar Mike Grüne

Fix Issue with Ports

parent 2e80f928
Pipeline #165569 passed with stages
in 1 minute and 9 seconds
......@@ -19,12 +19,12 @@ void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::init(${model.getEscaped
// Intitialize callbacks, subscribers and publishers
<#list model.getIncomingPorts() as sub>
_sub_${sub.getName()} = new client(SERVER_ADDRESS, ${sub.getName()});
_callback_${sub.getName()} = new Callback(*_sub_${sub.getName()}, component->${sub.getName()});
_sub_${sub.getName()} = new client(SERVER_ADDRESS, "${sub.getName()}");
_callback_${sub.getName()} = new Callback(*_sub_${sub.getName()}, &(component->${sub.getName()}));
</#list>
<#list model.getOutgoingPorts() as pub>
_pub_${pub.getName()} = new client(SERVER_ADDRESS, ${pub.getName()});
_pub_${pub.getName()} = new client(SERVER_ADDRESS, "${pub.getName()}");
</#list>
// Connect subscribers, publishers and subscribe to the topics
......
......@@ -2,7 +2,7 @@
#include "Callback.hpp"
Callback::Callback(client& cli, double port) : callback(), cli_(cli)
Callback::Callback(client& cli, double* port) : callback(), cli_(cli)
{
port_ = port;
}
......@@ -27,5 +27,5 @@ void Callback::message_arrived(const_message_ptr msg)
cout << "Message received "<< msg->get_topic() << ": " << msg->get_payload_str() << endl;
string::size_type sz;
double value = std::stod (msg->get_payload_str(),&sz);
port_ = value;
*port_ = value;
}
......@@ -13,7 +13,7 @@ class Callback : public virtual callback
client& cli_;
public:
Callback(client& cli, double port);
Callback(client& cli, double* port);
void connected(const string& cause);
......@@ -22,7 +22,7 @@ public:
void message_arrived(const_message_ptr msg);
private:
double port_;
double* port_;
};
#endif /* Callback_hpp */
#include "Callback.hpp"
Callback::Callback(client& cli, double port) : callback(), cli_(cli)
Callback::Callback(client& cli, double* port) : callback(), cli_(cli)
{
port_ = port;
}
......@@ -26,5 +26,5 @@ void Callback::message_arrived(const_message_ptr msg)
cout << "Message received "<< msg->get_topic() << ": " << msg->get_payload_str() << endl;
string::size_type sz;
double value = std::stod (msg->get_payload_str(),&sz);
port_ = value;
*port_ = value;
}
......@@ -12,7 +12,7 @@ class Callback : public virtual callback
client& cli_;
public:
Callback(client& cli, double port);
Callback(client& cli, double* port);
void connected(const string& cause);
......@@ -21,7 +21,7 @@ public:
void message_arrived(const_message_ptr msg);
private:
double port_;
double* port_;
};
#endif /* Callback_hpp */
......@@ -17,13 +17,13 @@ void MqttAdapter_tests_a_compA::init(tests_a_compA *comp)
connOpts.set_clean_session(true);
// Intitialize callbacks, subscribers and publishers
_sub_portA = new client(SERVER_ADDRESS, portA);
_callback_portA = new Callback(*_sub_portA, component->portA);
_sub_portB = new client(SERVER_ADDRESS, portB);
_callback_portB = new Callback(*_sub_portB, component->portB);
_sub_portA = new client(SERVER_ADDRESS, "portA");
_callback_portA = new Callback(*_sub_portA, &(component->portA));
_sub_portB = new client(SERVER_ADDRESS, "portB");
_callback_portB = new Callback(*_sub_portB, &(component->portB));
_pub_portC = new client(SERVER_ADDRESS, portC);
_pub_portD = new client(SERVER_ADDRESS, portD);
_pub_portC = new client(SERVER_ADDRESS, "portC");
_pub_portD = new client(SERVER_ADDRESS, "portD");
// Connect subscribers, publishers and subscribe to the topics
try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment