Commit 2be9885e authored by Markus Georg Bendel's avatar Markus Georg Bendel

Fix Subscribers/Publishers

parent 2f5a8d9a
Pipeline #165559 passed with stages
in 1 minute and 36 seconds
......@@ -2,51 +2,82 @@
SomeIPAdapter_tests_a_compA::SomeIPAdapter_tests_a_compA() {
//choose random ids
service_id = 1;
instance_id = 2;
method_id = 3;
event_id = 4;
eventgroup_id = 5;
}
in1_service_id = 11;
in1_instance_id = 12;
in1_method_id = 13;
in1_event_id = 14;
in1_eventgroup_id = 15;
in2_service_id = 21;
in2_instance_id = 22;
in2_method_id = 23;
in2_event_id = 24;
in2_eventgroup_id = 25;
out1_service_id = 111;
out1_instance_id = 112;
out1_method_id = 113;
out1_event_id = 114;
out1_eventgroup_id = 115;
SomeIPAdapter_tests_a_compA::SomeIPAdapter_tests_a_compA(int service_id, int instance_id, int method_id, int event_id, int eventgroup_id) {
this->service_id = service_id;
this->instance_id = instance_id;
this->method_id = method_id;
this->event_id = event_id;
this->eventgroup_id = eventgroup_id;
out2_service_id = 121;
out2_instance_id = 122;
out2_method_id = 123;
out2_event_id = 124;
out2_eventgroup_id = 125;
}
void SomeIPAdapter_tests_a_compA::init(tests_a_compA *comp) {
// Initialize component
// Initialize component
this->component = comp;
// Intitialize subscriber
_clockSubscriber = vsomeip::runtime::get()->create_application("Subscriber");
_clockSubscriber->init();
_clockSubscriber->request_service(service_id, instance_id);
_clockSubscriber->register_message_handler(service_id, instance_id, method_id, std::bind(&SomeIPAdapter_tests_a_compA::on_message, this, std::placeholders::_1));
// Intitialize subscriber for in1
in1_Subscriber = vsomeip::runtime::get()->create_application("Subscriber");
in1_Subscriber->init();
in1_Subscriber->request_service(in1_service_id, in1_instance_id);
in1_Subscriber->register_message_handler(in1_service_id, in1_instance_id, in1_method_id, std::bind(&SomeIPAdapter_tests_a_compA::on_message_in1, this, std::placeholders::_1));
// Subscribe
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(eventgroup_id);
_clockSubscriber->request_event(service_id, instance_id, event_id, event_group, true);
_clockSubscriber->subscribe(service_id, instance_id, eventgroup_id);
_clockSubscriber->start();
// Intitialize Publisher
_echoPublisher = vsomeip::runtime::get()->create_application("Publisher");
_echoPublisher->init();
_echoPublisher->offer_service(service_id, instance_id);
_echoPublisher->start();
std::set<vsomeip::eventgroup_t> in1_event_group;
in1_event_group.insert(in1_eventgroup_id);
in1_Subscriber->request_event(in1_service_id, in1_instance_id, in1_event_id, in1_event_group, true);
in1_Subscriber->subscribe(in1_service_id, in1_instance_id, in1_eventgroup_id);
in1_Subscriber->start();
// Intitialize subscriber for in2
in2_Subscriber = vsomeip::runtime::get()->create_application("Subscriber");
in2_Subscriber->init();
in2_Subscriber->request_service(in2_service_id, in2_instance_id);
in2_Subscriber->register_message_handler(in2_service_id, in2_instance_id, in2_method_id, std::bind(&SomeIPAdapter_tests_a_compA::on_message_in2, this, std::placeholders::_1));
// Subscribe
std::set<vsomeip::eventgroup_t> in2_event_group;
in2_event_group.insert(in2_eventgroup_id);
in2_Subscriber->request_event(in2_service_id, in2_instance_id, in2_event_id, in2_event_group, true);
in2_Subscriber->subscribe(in2_service_id, in2_instance_id, in2_eventgroup_id);
in2_Subscriber->start();
// Intitialize Publisher for out1
out1_Publisher = vsomeip::runtime::get()->create_application("Publisher");
out1_Publisher->init();
out1_Publisher->offer_service(out1_service_id, out1_instance_id);
out1_Publisher->start();
// Intitialize Publisher for out2
out2_Publisher = vsomeip::runtime::get()->create_application("Publisher");
out2_Publisher->init();
out2_Publisher->offer_service(out2_service_id, out2_instance_id);
out2_Publisher->start();
}
void SomeIPAdapter_tests_a_compA::on_message(const std::shared_ptr<vsomeip::message> &_request) {
void SomeIPAdapter_tests_a_compA::on_message_in1(const std::shared_ptr<vsomeip::message> &_request) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _request->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
component->someIPIn = dataFromMessage;
component->in1 = dataFromMessage;
//print data to std out
std::cout << "SERVICE: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_client() << "/"
......@@ -54,10 +85,41 @@ void SomeIPAdapter_tests_a_compA::on_message(const std::shared_ptr<vsomeip::mess
<< dataFromMessage << std::endl;
}
void SomeIPAdapter_tests_a_compA::publish_echoPublisher()
void SomeIPAdapter_tests_a_compA::on_message_in2(const std::shared_ptr<vsomeip::message> &_request) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _request->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
component->in2 = dataFromMessage;
//print data to std out
std::cout << "SERVICE: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_client() << "/"
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_session() << "]: "
<< dataFromMessage << std::endl;
}
void SomeIPAdapter_tests_a_compA::publishout1_Publisher()
{
//Read data from component
double d = component->out1;
//Create message
uint8_t *byteArray = (uint8_t*)&d;
vsomeip::byte_t *p;
p = byteArray;
std::shared_ptr< vsomeip::payload > payload = vsomeip::runtime::get()->create_payload(p,8);
//Publish
std::set<vsomeip::eventgroup_t> out1_event_group;
out1_event_group.insert(out1_eventgroup_id);
out1_Publisher->offer_event(out1_service_id, out1_instance_id, out1_event_id, out1_event_group, true);
out1_Publisher->notify(out1_service_id, out1_instance_id, out1_event_id, payload);
}
void SomeIPAdapter_tests_a_compA::publishout2_Publisher()
{
//Read data from component
double d = component->someIPOut;
double d = component->out2;
//Create message
uint8_t *byteArray = (uint8_t*)&d;
......@@ -66,13 +128,15 @@ void SomeIPAdapter_tests_a_compA::publish_echoPublisher()
std::shared_ptr< vsomeip::payload > payload = vsomeip::runtime::get()->create_payload(p,8);
//Publish
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(eventgroup_id);
_echoPublisher->offer_event(service_id, instance_id, event_id, event_group, true);
_echoPublisher->notify(service_id, instance_id, event_id, payload);
std::set<vsomeip::eventgroup_t> out2_event_group;
out2_event_group.insert(out2_eventgroup_id);
out2_Publisher->offer_event(out2_service_id, out2_instance_id, out2_event_id, out2_event_group, true);
out2_Publisher->notify(out2_service_id, out2_instance_id, out2_event_id, payload);
}
void SomeIPAdapter_tests_a_compA::tick()
{
publish_echoPublisher();
publishout1_Publisher();
publishout2_Publisher();
}
......@@ -17,27 +17,52 @@ public:
SomeIPAdapter_tests_a_compA();
SomeIPAdapter_tests_a_compA(int service_id, int instance_id, int method_id, int event_id, int eventgroup_id);
void init(tests_a_compA *comp);
void init(tests_a_compA* comp);
void on_message_in1(const std::shared_ptr<vsomeip::message> &_request);
void publish_echoPublisher();
void on_message_in2(const std::shared_ptr<vsomeip::message> &_request);
void publishout1_Publisher();
void publishout2_Publisher();
void tick();
void on_message(const std::shared_ptr<vsomeip::message> &_response);
private:
tests_a_compA* component = nullptr;
std::shared_ptr<vsomeip::application> _clockSubscriber;
std::shared_ptr<vsomeip::application> in1_Subscriber;
std::shared_ptr<vsomeip::application> in2_Subscriber;
std::shared_ptr<vsomeip::application> out1_Publisher;
std::shared_ptr<vsomeip::application> out2_Publisher;
int in1_service_id;
int in1_instance_id;
int in1_method_id;
int in1_event_id;
int in1_eventgroup_id;
int in2_service_id;
int in2_instance_id;
int in2_method_id;
int in2_event_id;
int in2_eventgroup_id;
std::shared_ptr<vsomeip::application> _echoPublisher;
int out1_service_id;
int out1_instance_id;
int out1_method_id;
int out1_event_id;
int out1_eventgroup_id;
int service_id;
int instance_id;
int method_id;
int event_id;
int eventgroup_id;
int out2_service_id;
int out2_instance_id;
int out2_method_id;
int out2_event_id;
int out2_eventgroup_id;
};
#include <stdio.h>
#include "tests_a_compA.h"
tests_a_compA::tests_a_compA(double value)
testComp::tests_a_compA(double out1_value, double out2_value)
{
someIPOut = value;
out1 = out1_value;
out2 = out2_value;
}
......@@ -9,8 +9,10 @@ class tests_a_compA {
public:
tests_a_compA(double value);
double someIPIn = 2.5;
double someIPOut = 3.14;
double in1 = 1.5;
double in2 = 2.5;
double out1 = 0.1;
double out2 = 0.2;
};
#endif /* tests_a_compA_h */
......@@ -3,51 +3,95 @@
<@m.mwIdent/>Adapter_${model.getEscapedCompName()}::<@m.mwIdent/>Adapter_${model.getEscapedCompName()}() {
//choose random ids
service_id = 1;
instance_id = 2;
method_id = 3;
event_id = 4;
eventgroup_id = 5;
}
in1_service_id = 11;
in1_instance_id = 12;
in1_method_id = 13;
in1_event_id = 14;
in1_eventgroup_id = 15;
in2_service_id = 21;
in2_instance_id = 22;
in2_method_id = 23;
in2_event_id = 24;
in2_eventgroup_id = 25;
<@m.mwIdent/>Adapter_${model.getEscapedCompName()}::<@m.mwIdent/>Adapter_${model.getEscapedCompName()}(int service_id, int instance_id, int method_id, int event_id, int eventgroup_id) {
this->service_id = service_id;
this->instance_id = instance_id;
this->method_id = method_id;
this->event_id = event_id;
this->eventgroup_id = eventgroup_id;
out1_service_id = 111;
out1_instance_id = 112;
out1_method_id = 113;
out1_event_id = 114;
out1_eventgroup_id = 115;
out2_service_id = 121;
out2_instance_id = 122;
out2_method_id = 123;
out2_event_id = 124;
out2_eventgroup_id = 125;
}
void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::init(${model.getEscapedCompName()} *comp) {
// Initialize component
this->component = comp;
// Intitialize subscriber
_clockSubscriber = vsomeip::runtime::get()->create_application("Subscriber");
_clockSubscriber->init();
_clockSubscriber->request_service(service_id, instance_id);
_clockSubscriber->register_message_handler(service_id, instance_id, method_id, std::bind(&SomeIPAdapter_tests_a_compA::on_message, this, std::placeholders::_1));
// Intitialize subscriber for in1
in1_Subscriber = vsomeip::runtime::get()->create_application("Subscriber");
in1_Subscriber->init();
in1_Subscriber->request_service(in1_service_id, in1_instance_id);
in1_Subscriber->register_message_handler(in1_service_id, in1_instance_id, in1_method_id, std::bind(&SomeIPAdapter_${model.getEscapedCompName()}::on_message_in1, this, std::placeholders::_1));
// Subscribe
std::set<vsomeip::eventgroup_t> in1_event_group;
in1_event_group.insert(in1_eventgroup_id);
in1_Subscriber->request_event(in1_service_id, in1_instance_id, in1_event_id, in1_event_group, true);
in1_Subscriber->subscribe(in1_service_id, in1_instance_id, in1_eventgroup_id);
in1_Subscriber->start();
// Intitialize subscriber for in2
in2_Subscriber = vsomeip::runtime::get()->create_application("Subscriber");
in2_Subscriber->init();
in2_Subscriber->request_service(in2_service_id, in2_instance_id);
in2_Subscriber->register_message_handler(in2_service_id, in2_instance_id, in2_method_id, std::bind(&SomeIPAdapter_${model.getEscapedCompName()}::on_message_in2, this, std::placeholders::_1));
// Subscribe
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(eventgroup_id);
_clockSubscriber->request_event(service_id, instance_id, event_id, event_group, true);
_clockSubscriber->subscribe(service_id, instance_id, eventgroup_id);
_clockSubscriber->start();
// Intitialize Publisher
_echoPublisher = vsomeip::runtime::get()->create_application("Publisher");
_echoPublisher->init();
_echoPublisher->offer_service(service_id, instance_id);
_echoPublisher->start();
std::set<vsomeip::eventgroup_t> in2_event_group;
in2_event_group.insert(in2_eventgroup_id);
in2_Subscriber->request_event(in2_service_id, in2_instance_id, in2_event_id, in2_event_group, true);
in2_Subscriber->subscribe(in2_service_id, in2_instance_id, in2_eventgroup_id);
in2_Subscriber->start();
// Intitialize Publisher for out1
out1_Publisher = vsomeip::runtime::get()->create_application("Publisher");
out1_Publisher->init();
out1_Publisher->offer_service(out1_service_id, out1_instance_id);
out1_Publisher->start();
// Intitialize Publisher for out2
out2_Publisher = vsomeip::runtime::get()->create_application("Publisher");
out2_Publisher->init();
out2_Publisher->offer_service(out2_service_id, out2_instance_id);
out2_Publisher->start();
}
void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::on_message_in1(const std::shared_ptr<vsomeip::message> &_request) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _request->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
component->in1 = dataFromMessage;
//print data to std out
std::cout << "SERVICE: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_client() << "/"
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_session() << "]: "
<< dataFromMessage << std::endl;
}
void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::on_message(const std::shared_ptr<vsomeip::message> &_request) {
void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::on_message_in2(const std::shared_ptr<vsomeip::message> &_request) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _request->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
component->someIPIn = dataFromMessage;
component->in2 = dataFromMessage;
//print data to std out
std::cout << "SERVICE: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_client() << "/"
......@@ -55,10 +99,28 @@ void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::on_message(const std::s
<< dataFromMessage << std::endl;
}
void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::publish_echoPublisher()
void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::publishout1_Publisher()
{
//Read data from component
double d = component->out1;
//Create message
uint8_t *byteArray = (uint8_t*)&d;
vsomeip::byte_t *p;
p = byteArray;
std::shared_ptr< vsomeip::payload > payload = vsomeip::runtime::get()->create_payload(p,8);
//Publish
std::set<vsomeip::eventgroup_t> out1_event_group;
out1_event_group.insert(out1_eventgroup_id);
out1_Publisher->offer_event(out1_service_id, out1_instance_id, out1_event_id, out1_event_group, true);
out1_Publisher->notify(out1_service_id, out1_instance_id, out1_event_id, payload);
}
void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::publishout2_Publisher()
{
//Read data from component
double d = component->someIPOut;
double d = component->out2;
//Create message
uint8_t *byteArray = (uint8_t*)&d;
......@@ -67,13 +129,14 @@ void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::publish_echoPublisher()
std::shared_ptr< vsomeip::payload > payload = vsomeip::runtime::get()->create_payload(p,8);
//Publish
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(eventgroup_id);
_echoPublisher->offer_event(service_id, instance_id, event_id, event_group, true);
_echoPublisher->notify(service_id, instance_id, event_id, payload);
std::set<vsomeip::eventgroup_t> out2_event_group;
out2_event_group.insert(out2_eventgroup_id);
out2_Publisher->offer_event(out2_service_id, out2_instance_id, out2_event_id, out2_event_group, true);
out2_Publisher->notify(out2_service_id, out2_instance_id, out2_event_id, payload);
}
void <@m.mwIdent/>Adapter_${model.getEscapedCompName()}::tick()
{
publish_echoPublisher();
publishout1_Publisher();
publishout2_Publisher();
}
......@@ -18,27 +18,52 @@ public:
<@m.mwIdent/>Adapter_${model.getEscapedCompName()}();
<@m.mwIdent/>Adapter_${model.getEscapedCompName()}(int service_id, int instance_id, int method_id, int event_id, int eventgroup_id);
void init(${model.getEscapedCompName()} *comp);
void init(${model.getEscapedCompName()}* comp);
void on_message_in1(const std::shared_ptr<vsomeip::message> &_request);
void publish_echoPublisher();
void on_message_in2(const std::shared_ptr<vsomeip::message> &_request);
void publishout1_Publisher();
void publishout2_Publisher();
void tick();
void on_message(const std::shared_ptr<vsomeip::message> &_response);
private:
${model.getEscapedCompName()}* component = nullptr;
std::shared_ptr<vsomeip::application> _clockSubscriber;
std::shared_ptr<vsomeip::application> in1_Subscriber;
std::shared_ptr<vsomeip::application> in2_Subscriber;
std::shared_ptr<vsomeip::application> out1_Publisher;
std::shared_ptr<vsomeip::application> out2_Publisher;
int in1_service_id;
int in1_instance_id;
int in1_method_id;
int in1_event_id;
int in1_eventgroup_id;
int in2_service_id;
int in2_instance_id;
int in2_method_id;
int in2_event_id;
int in2_eventgroup_id;
std::shared_ptr<vsomeip::application> _echoPublisher;
int out1_service_id;
int out1_instance_id;
int out1_method_id;
int out1_event_id;
int out1_eventgroup_id;
int service_id;
int instance_id;
int method_id;
int event_id;
int eventgroup_id;
int out2_service_id;
int out2_instance_id;
int out2_method_id;
int out2_event_id;
int out2_eventgroup_id;
};
......@@ -31,7 +31,7 @@ public class AdapterGenerationTest extends AbstractSymtabTest {
GeneratorSomeIP generatorSomeIP = new GeneratorSomeIP();
// Connect component's ports to topics
componentInstanceSymbol.getPortInstance("portA").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(1,2,3));
componentInstanceSymbol.getPortInstance("in1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(1,2,3));
List<File> files = generatorSomeIP.generateSomeIPAdapter(componentInstanceSymbol);
......
......@@ -32,7 +32,7 @@ public class CMakeGenerationTest extends AbstractSymtabTest {
GeneratorSomeIP generatorSomeIP = new GeneratorSomeIP();
// Connect component's ports to topics
componentInstanceSymbol.getPortInstance("portA").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(1,2,3));
componentInstanceSymbol.getPortInstance("in1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(1,2,3));
List<File> files = new ArrayList<>();
......
......@@ -31,7 +31,7 @@ public class PrettyPrintGenerationTest extends AbstractSymtabTest {
GeneratorSomeIP generatorSomeIP = new GeneratorSomeIP();
// Connect component's ports to topics
componentInstanceSymbol.getPortInstance("portA").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(1,2,3));
componentInstanceSymbol.getPortInstance("in1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(1,2,3));
List<File> files = generatorSomeIP.generatePrettyPrint(componentInstanceSymbol);
......
......@@ -3,7 +3,7 @@ Component name: tests.a.compA
Ports:
portA : incoming (someip, serviceID: 1 instanceID: 2 eventgroupID: 3)
portB : incoming (unknown symbol)
portC : outgoing (unknown symbol)
portD : outgoing (unknown symbol)
in1 : incoming (someip, serviceID: 1 instanceID: 2 eventgroupID: 3)
in2 : incoming (unknown symbol)
out1 : outgoing (unknown symbol)
out2 : outgoing (unknown symbol)
......@@ -2,51 +2,82 @@
SomeIPAdapter_tests_a_compA::SomeIPAdapter_tests_a_compA() {
//choose random ids
service_id = 1;
instance_id = 2;
method_id = 3;
event_id = 4;
eventgroup_id = 5;
}
in1_service_id = 11;
in1_instance_id = 12;
in1_method_id = 13;
in1_event_id = 14;
in1_eventgroup_id = 15;
in2_service_id = 21;
in2_instance_id = 22;
in2_method_id = 23;
in2_event_id = 24;
in2_eventgroup_id = 25;
out1_service_id = 111;
out1_instance_id = 112;
out1_method_id = 113;
out1_event_id = 114;
out1_eventgroup_id = 115;
SomeIPAdapter_tests_a_compA::SomeIPAdapter_tests_a_compA(int service_id, int instance_id, int method_id, int event_id, int eventgroup_id) {
this->service_id = service_id;
this->instance_id = instance_id;
this->method_id = method_id;
this->event_id = event_id;
this->eventgroup_id = eventgroup_id;
out2_service_id = 121;
out2_instance_id = 122;
out2_method_id = 123;
out2_event_id = 124;
out2_eventgroup_id = 125;
}
void SomeIPAdapter_tests_a_compA::init(tests_a_compA *comp) {
// Initialize component
// Initialize component
this->component = comp;
// Intitialize subscriber
_clockSubscriber = vsomeip::runtime::get()->create_application("Subscriber");
_clockSubscriber->init();
_clockSubscriber->request_service(service_id, instance_id);
_clockSubscriber->register_message_handler(service_id, instance_id, method_id, std::bind(&SomeIPAdapter_tests_a_compA::on_message, this, std::placeholders::_1));
// Intitialize subscriber for in1
in1_Subscriber = vsomeip::runtime::get()->create_application("Subscriber");
in1_Subscriber->init();
in1_Subscriber->request_service(in1_service_id, in1_instance_id);
in1_Subscriber->register_message_handler(in1_service_id, in1_instance_id, in1_method_id, std::bind(&SomeIPAdapter_tests_a_compA::on_message_in1, this, std::placeholders::_1));
// Subscribe
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(eventgroup_id);
_clockSubscriber->request_event(service_id, instance_id, event_id, event_group, true);
_clockSubscriber->subscribe(service_id, instance_id, eventgroup_id);
_clockSubscriber->start();
// Intitialize Publisher
_echoPublisher = vsomeip::runtime::get()->create_application("Publisher");
_echoPublisher->init();
_echoPublisher->offer_service(service_id, instance_id);
_echoPublisher->start();
std::set<vsomeip::eventgroup_t> in1_event_group;
in1_event_group.insert(in1_eventgroup_id);
in1_Subscriber->request_event(in1_service_id, in1_instance_id, in1_event_id, in1_event_group, true);
in1_Subscriber->subscribe(in1_service_id, in1_instance_id, in1_eventgroup_id);
in1_Subscriber->start();
// Intitialize subscriber for in2
in2_Subscriber = vsomeip::runtime::get()->create_application("Subscriber");
in2_Subscriber->init();
in2_Subscriber->request_service(in2_service_id, in2_instance_id);
in2_Subscriber->register_message_handler(in2_service_id, in2_instance_id, in2_method_id, std::bind(&SomeIPAdapter_tests_a_compA::on_message_in2, this, std::placeholders::_1));
// Subscribe
std::set<vsomeip::eventgroup_t> in2_event_group;
in2_event_group.insert(in2_eventgroup_id);
in2_Subscriber->request_event(in2_service_id, in2_instance_id, in2_event_id, in2_event_group, true);
in2_Subscriber->subscribe(in2_service_id, in2_instance_id, in2_eventgroup_id);
in2_Subscriber->start();
// Intitialize Publisher for out1
out1_Publisher = vsomeip::runtime::get()->create_application("Publisher");
out1_Publisher->init();
out1_Publisher->offer_service(out1_service_id, out1_instance_id);
out1_Publisher->start();
// Intitialize Publisher for out2
out2_Publisher = vsomeip::runtime::get()->create_application("Publisher");
out2_Publisher->init();
out2_Publisher->offer_service(out2_service_id, out2_instance_id);
out2_Publisher->start();
}
void SomeIPAdapter_tests_a_compA::on_message(const std::shared_ptr<vsomeip::message> &_request) {
void SomeIPAdapter_tests_a_compA::on_message_in1(const std::shared_ptr<vsomeip::message> &_request) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _request->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
component->someIPIn = dataFromMessage;
component->in1 = dataFromMessage;
//print data to std out
std::cout << "SERVICE: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_client() << "/"
......@@ -54,10 +85,41 @@ void SomeIPAdapter_tests_a_compA::on_message(const std::shared_ptr<vsomeip::mess
<< dataFromMessage << std::endl;
}
void SomeIPAdapter_tests_a_compA::publish_echoPublisher()
void SomeIPAdapter_tests_a_compA::on_message_in2(const std::shared_ptr<vsomeip::message> &_request) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _request->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
component->in2 = dataFromMessage;
//print data to std out
std::cout << "SERVICE: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_client() << "/"
<< std::setw(4) << std::setfill('0') << std::hex << _request->get_session() << "]: "
<< dataFromMessage << std::endl;
}