Commit 6139193d authored by Mike Grüne's avatar Mike Grüne

Minor changes

parent 7998bb07
Pipeline #165393 passed with stages
in 3 minutes and 18 seconds
......@@ -20,7 +20,7 @@ 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()}, comp, ${sub.getName()});
_callback_${sub.getName()} = new Callback(*_sub_${sub.getName()}, comp, component->getIncomingPorts().get(component->getIncomingPorts().indexOf(${sub.getName()})));
</#list>
<#list model.getOutgoingPorts() as pub>
......
......@@ -9,32 +9,32 @@ using namespace std;
using namespace <@m.smallIdent/>;
class <@m.mwIdent/>Adapter_${model.getEscapedCompName()} {
public:
<@m.mwIdent/>Adapter_${model.getEscapedCompName()}();
void init(${model.getEscapedCompName()}* comp);
<#list model.getOutgoingPorts() as pub>
void publish_echo_${pub.getName()}();
</#list>
void tick();
private:
const string SERVER_ADDRESS = "tcp://localhost:1883";
${model.getEscapedCompName()}* component = nullptr;
// Callbacks, subscribers
<#list model.getIncomingPorts() as sub>
Callback* _callback_${sub.getName()} = nullptr;
client* _sub_${sub.getName()} = nullptr;
client* _sub_${sub.getName()} = nullptr;
</#list>
// Publishers
<#list model.getOutgoingPorts() as pub>
client* _pub_${pub.getName()} = nullptr;
client* _pub_${pub.getName()} = nullptr;
</#list>
};
......@@ -28,5 +28,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);
comp_->port_ = value;
comp_->port_.toString() = value;
}
......@@ -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);
comp_->port_ = value;
comp_->port_.toString() = value;
}
......@@ -18,7 +18,7 @@ void MqttAdapter_tests_a_compA::init(tests_a_compA *comp)
// Intitialize callbacks, subscribers and publishers
_sub_portA = new client(SERVER_ADDRESS, portA);
_callback_portA = new Callback(*_sub_portA, comp, portA);
_callback_portA = new Callback(*_sub_portA, comp, component->getIncomingPorts().get(component->getIncomingPorts().indexOf(portA)));
_pub_portC = new client(SERVER_ADDRESS, portC);
......
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