Commit 9cd243b8 authored by Florian Raeth's avatar Florian Raeth
Browse files

add N, Z, B test

parent 80f4b94e
......@@ -36,8 +36,14 @@ public class AdapterGenerationTest extends AbstractSymtabTest {
// Connect component's ports to topics
componentInstanceSymbol.getPortInstance("in1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(11,12,13/*,14,15*/));
componentInstanceSymbol.getPortInstance("in2").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(21,22,23/*,24,25*/));
componentInstanceSymbol.getPortInstance("in3").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(31,32,33/*,34,35*/));
componentInstanceSymbol.getPortInstance("in4").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(41,42,43/*,44,45*/));
componentInstanceSymbol.getPortInstance("in5").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(51,52,53/*,54,55*/));
componentInstanceSymbol.getPortInstance("out1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(111,112,113/*,114,115*/));
componentInstanceSymbol.getPortInstance("out2").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(121,122,123/*,124,125*/));
componentInstanceSymbol.getPortInstance("out3").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(131,132,133/*,134,135*/));
componentInstanceSymbol.getPortInstance("out4").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(141,142,143/*,144,145*/));
componentInstanceSymbol.getPortInstance("out5").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(151,152,153/*,154,155*/));
List<File> files = generatorSomeIP.generateSomeIPAdapter(componentInstanceSymbol);
......
......@@ -34,7 +34,16 @@ public class PrettyPrintGenerationTest extends AbstractSymtabTest {
generatorSomeIP.setGenerationTargetPath("./target/generated-sources/");
// Connect component's ports to topics
componentInstanceSymbol.getPortInstance("in1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(1,2,3));
componentInstanceSymbol.getPortInstance("in1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(11,12,13/*,14,15*/));
componentInstanceSymbol.getPortInstance("in2").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(21,22,23/*,24,25*/));
componentInstanceSymbol.getPortInstance("in3").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(31,32,33/*,34,35*/));
componentInstanceSymbol.getPortInstance("in4").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(41,42,43/*,44,45*/));
componentInstanceSymbol.getPortInstance("in5").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(51,52,53/*,54,55*/));
componentInstanceSymbol.getPortInstance("out1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(111,112,113/*,114,115*/));
componentInstanceSymbol.getPortInstance("out2").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(121,122,123/*,124,125*/));
componentInstanceSymbol.getPortInstance("out3").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(131,132,133/*,134,135*/));
componentInstanceSymbol.getPortInstance("out4").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(141,142,143/*,144,145*/));
componentInstanceSymbol.getPortInstance("out5").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(151,152,153/*,154,155*/));
List<File> files = generatorSomeIP.generatePrettyPrint(componentInstanceSymbol);
......
......@@ -3,7 +3,13 @@ Component name: tests.a.compA
Ports:
in1 : incoming (someip, serviceID: 1 instanceID: 2 eventgroupID: 3)
in2 : incoming (unknown symbol)
out1 : outgoing (unknown symbol)
out2 : outgoing (unknown symbol)
in1 : incoming (someip, serviceID: 11 instanceID: 12 eventgroupID: 13)
in2 : incoming (someip, serviceID: 21 instanceID: 22 eventgroupID: 23)
in3 : incoming (someip, serviceID: 31 instanceID: 32 eventgroupID: 33)
in4 : incoming (someip, serviceID: 41 instanceID: 42 eventgroupID: 43)
in5 : incoming (someip, serviceID: 51 instanceID: 52 eventgroupID: 53)
out1 : outgoing (someip, serviceID: 111 instanceID: 112 eventgroupID: 113)
out2 : outgoing (someip, serviceID: 121 instanceID: 122 eventgroupID: 123)
out3 : outgoing (someip, serviceID: 131 instanceID: 132 eventgroupID: 133)
out4 : outgoing (someip, serviceID: 141 instanceID: 142 eventgroupID: 143)
out5 : outgoing (someip, serviceID: 151 instanceID: 152 eventgroupID: 153)
......@@ -33,6 +33,39 @@ void SomeIPAdapter_tests_a_compA::init(tests_a_compA *comp) {
std::thread sender_in2(std::bind(&SomeIPAdapter_tests_a_compA::run_in2, this));
in2_Subscriber->start();
in3_Subscriber = vsomeip::runtime::get()->create_application("Subscriber in3");
if (!in3_Subscriber->init()) {
std::cerr << "Couldn't initialize Subscriber in3" << std::endl;
}
in3_Subscriber->register_availability_handler(31, 32, std::bind(&SomeIPAdapter_tests_a_compA::on_availability_in3, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
in3_Subscriber->request_service(31, 32);
in3_Subscriber->register_message_handler(31, 32, 0, std::bind(&SomeIPAdapter_tests_a_compA::on_message_in3, this, std::placeholders::_1));
std::thread sender_in3(std::bind(&SomeIPAdapter_tests_a_compA::run_in3, this));
in3_Subscriber->start();
in4_Subscriber = vsomeip::runtime::get()->create_application("Subscriber in4");
if (!in4_Subscriber->init()) {
std::cerr << "Couldn't initialize Subscriber in4" << std::endl;
}
in4_Subscriber->register_availability_handler(41, 42, std::bind(&SomeIPAdapter_tests_a_compA::on_availability_in4, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
in4_Subscriber->request_service(41, 42);
in4_Subscriber->register_message_handler(41, 42, 0, std::bind(&SomeIPAdapter_tests_a_compA::on_message_in4, this, std::placeholders::_1));
std::thread sender_in4(std::bind(&SomeIPAdapter_tests_a_compA::run_in4, this));
in4_Subscriber->start();
in5_Subscriber = vsomeip::runtime::get()->create_application("Subscriber in5");
if (!in5_Subscriber->init()) {
std::cerr << "Couldn't initialize Subscriber in5" << std::endl;
}
in5_Subscriber->register_availability_handler(51, 52, std::bind(&SomeIPAdapter_tests_a_compA::on_availability_in5, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
in5_Subscriber->request_service(51, 52);
in5_Subscriber->register_message_handler(51, 52, 0, std::bind(&SomeIPAdapter_tests_a_compA::on_message_in5, this, std::placeholders::_1));
std::thread sender_in5(std::bind(&SomeIPAdapter_tests_a_compA::run_in5, this));
in5_Subscriber->start();
// Intitialize Publisher
......@@ -48,6 +81,24 @@ void SomeIPAdapter_tests_a_compA::init(tests_a_compA *comp) {
}
out2_Publisher->offer_service(121, 122);
out2_Publisher->start();
out3_Publisher = vsomeip::runtime::get()->create_application("Publisher out3");
if (!out3_Publisher->init()) {
std::cerr << "Couldn't initialize Publisher out3" << std::endl;
}
out3_Publisher->offer_service(131, 132);
out3_Publisher->start();
out4_Publisher = vsomeip::runtime::get()->create_application("Publisher out4");
if (!out4_Publisher->init()) {
std::cerr << "Couldn't initialize Publisher out4" << std::endl;
}
out4_Publisher->offer_service(141, 142);
out4_Publisher->start();
out5_Publisher = vsomeip::runtime::get()->create_application("Publisher out5");
if (!out5_Publisher->init()) {
std::cerr << "Couldn't initialize Publisher out5" << std::endl;
}
out5_Publisher->offer_service(151, 152);
out5_Publisher->start();
}
void SomeIPAdapter_tests_a_compA::run_in1() {
......@@ -65,7 +116,10 @@ void SomeIPAdapter_tests_a_compA::on_message_in1(const std::shared_ptr<vsomeip::
std::shared_ptr<vsomeip::payload> its_payload = _message->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
// double
component->in1 = dataFromMessage;
//print data to std out
std::cout << "SERVICE in1: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _message->get_client() << "/"
......@@ -96,7 +150,10 @@ void SomeIPAdapter_tests_a_compA::on_message_in2(const std::shared_ptr<vsomeip::
std::shared_ptr<vsomeip::payload> its_payload = _message->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
// double
component->in2 = dataFromMessage;
//print data to std out
std::cout << "SERVICE in2: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _message->get_client() << "/"
......@@ -112,11 +169,114 @@ void SomeIPAdapter_tests_a_compA::on_availability_in2(vsomeip::service_t _servic
<< std::endl;
condition_in2.notify_one();
}
void SomeIPAdapter_tests_a_compA::run_in3() {
std::unique_lock<std::mutex> its_lock(mutex_in3);
condition_in3.wait(its_lock);
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(33);
in3_Subscriber->request_event(31, 32, 0, event_group, true);
in3_Subscriber->subscribe(31, 32, 33);
}
void SomeIPAdapter_tests_a_compA::on_message_in3(const std::shared_ptr<vsomeip::message> &_message) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _message->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
//int
component->in3 = (int) round(dataFromMessage);
//print data to std out
std::cout << "SERVICE in3: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _message->get_client() << "/"
<< std::setw(4) << std::setfill('0') << std::hex << _message->get_session() << "]: "
<< dataFromMessage << std::endl;
}
void SomeIPAdapter_tests_a_compA::on_availability_in3(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) {
std::cout << "Service ["
<< std::setw(4) << std::setfill('0') << std::hex << _service << "." << _instance
<< "] is "
<< (_is_available ? "available." : "NOT available.")
<< std::endl;
condition_in3.notify_one();
}
void SomeIPAdapter_tests_a_compA::run_in4() {
std::unique_lock<std::mutex> its_lock(mutex_in4);
condition_in4.wait(its_lock);
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(43);
in4_Subscriber->request_event(41, 42, 0, event_group, true);
in4_Subscriber->subscribe(41, 42, 43);
}
void SomeIPAdapter_tests_a_compA::on_message_in4(const std::shared_ptr<vsomeip::message> &_message) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _message->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
//int
component->in4 = (int) round(dataFromMessage);
//print data to std out
std::cout << "SERVICE in4: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _message->get_client() << "/"
<< std::setw(4) << std::setfill('0') << std::hex << _message->get_session() << "]: "
<< dataFromMessage << std::endl;
}
void SomeIPAdapter_tests_a_compA::on_availability_in4(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) {
std::cout << "Service ["
<< std::setw(4) << std::setfill('0') << std::hex << _service << "." << _instance
<< "] is "
<< (_is_available ? "available." : "NOT available.")
<< std::endl;
condition_in4.notify_one();
}
void SomeIPAdapter_tests_a_compA::run_in5() {
std::unique_lock<std::mutex> its_lock(mutex_in5);
condition_in5.wait(its_lock);
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(53);
in5_Subscriber->request_event(51, 52, 0, event_group, true);
in5_Subscriber->subscribe(51, 52, 53);
}
void SomeIPAdapter_tests_a_compA::on_message_in5(const std::shared_ptr<vsomeip::message> &_message) {
//read received message
std::shared_ptr<vsomeip::payload> its_payload = _message->get_payload();
vsomeip::length_t l = its_payload->get_length();
double dataFromMessage = *((double*)its_payload->get_data());
//bool
component->in5 = (dataFromMessage > 1.0e-10);
//print data to std out
std::cout << "SERVICE in5: Received message from ["
<< std::setw(4) << std::setfill('0') << std::hex << _message->get_client() << "/"
<< std::setw(4) << std::setfill('0') << std::hex << _message->get_session() << "]: "
<< dataFromMessage << std::endl;
}
void SomeIPAdapter_tests_a_compA::on_availability_in5(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) {
std::cout << "Service ["
<< std::setw(4) << std::setfill('0') << std::hex << _service << "." << _instance
<< "] is "
<< (_is_available ? "available." : "NOT available.")
<< std::endl;
condition_in5.notify_one();
}
void SomeIPAdapter_tests_a_compA::publishout1_Publisher()
{
//Read data from component
// double
double d = component->out1;
const vsomeip::byte_t its_data[] = { (uint8_t) d };
......@@ -132,6 +292,7 @@ void SomeIPAdapter_tests_a_compA::publishout1_Publisher()
void SomeIPAdapter_tests_a_compA::publishout2_Publisher()
{
//Read data from component
// double
double d = component->out2;
const vsomeip::byte_t its_data[] = { (uint8_t) d };
......@@ -144,10 +305,61 @@ void SomeIPAdapter_tests_a_compA::publishout2_Publisher()
out2_Publisher->offer_event(121, 122, 0, event_group, true);
out2_Publisher->notify(121, 122, 0, payload);
}
void SomeIPAdapter_tests_a_compA::publishout3_Publisher()
{
//Read data from component
//int
double d = 1.0 * component->out3;
const vsomeip::byte_t its_data[] = { (uint8_t) d };
std::shared_ptr<vsomeip::payload> payload = vsomeip::runtime::get()->create_payload();
payload->set_data(its_data, sizeof(its_data));
//Publish
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(133);
out3_Publisher->offer_event(131, 132, 0, event_group, true);
out3_Publisher->notify(131, 132, 0, payload);
}
void SomeIPAdapter_tests_a_compA::publishout4_Publisher()
{
//Read data from component
//int
double d = 1.0 * component->out4;
const vsomeip::byte_t its_data[] = { (uint8_t) d };
std::shared_ptr<vsomeip::payload> payload = vsomeip::runtime::get()->create_payload();
payload->set_data(its_data, sizeof(its_data));
//Publish
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(143);
out4_Publisher->offer_event(141, 142, 0, event_group, true);
out4_Publisher->notify(141, 142, 0, payload);
}
void SomeIPAdapter_tests_a_compA::publishout5_Publisher()
{
//Read data from component
//bool
double d = component->out5 ? 1.0 : 0.0;
const vsomeip::byte_t its_data[] = { (uint8_t) d };
std::shared_ptr<vsomeip::payload> payload = vsomeip::runtime::get()->create_payload();
payload->set_data(its_data, sizeof(its_data));
//Publish
std::set<vsomeip::eventgroup_t> event_group;
event_group.insert(153);
out5_Publisher->offer_event(151, 152, 0, event_group, true);
out5_Publisher->notify(151, 152, 0, payload);
}
void SomeIPAdapter_tests_a_compA::tick()
{
publishout1_Publisher();
publishout2_Publisher();
publishout3_Publisher();
publishout4_Publisher();
publishout5_Publisher();
}
......@@ -43,6 +43,27 @@ private:
void run_in2();
void on_message_in2(const std::shared_ptr<vsomeip::message> &_message);
void on_availability_in2(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available);
std::shared_ptr<vsomeip::application> in3_Subscriber;
std::mutex mutex_in3;
std::condition_variable condition_in3;
void run_in3();
void on_message_in3(const std::shared_ptr<vsomeip::message> &_message);
void on_availability_in3(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available);
std::shared_ptr<vsomeip::application> in4_Subscriber;
std::mutex mutex_in4;
std::condition_variable condition_in4;
void run_in4();
void on_message_in4(const std::shared_ptr<vsomeip::message> &_message);
void on_availability_in4(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available);
std::shared_ptr<vsomeip::application> in5_Subscriber;
std::mutex mutex_in5;
std::condition_variable condition_in5;
void run_in5();
void on_message_in5(const std::shared_ptr<vsomeip::message> &_message);
void on_availability_in5(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available);
std::shared_ptr<vsomeip::application> out1_Publisher;
......@@ -50,4 +71,13 @@ private:
std::shared_ptr<vsomeip::application> out2_Publisher;
void publishout2_Publisher();
std::shared_ptr<vsomeip::application> out3_Publisher;
void publishout3_Publisher();
std::shared_ptr<vsomeip::application> out4_Publisher;
void publishout4_Publisher();
std::shared_ptr<vsomeip::application> out5_Publisher;
void publishout5_Publisher();
};
......@@ -4,6 +4,12 @@ package tests.a;
component CompA{
port in Q in1;
port in Q in2;
port in N in3;
port in Z in4;
port in B in5;
port out Q out1;
port out Q out2;
port out N out3;
port out Z out4;
port out B out5;
}
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