Commit 86174607 authored by Alexander David Hellwig's avatar Alexander David Hellwig

Merge branch '18-fix-subscribers-publishers-someip-2' into 'master'

Resolve "Fix Subscribers/Publishers(SomeIP)"

Closes #18

See merge request !7
parents 00c16ca6 abafe36a
Pipeline #188875 passed with stages
in 1 minute and 49 seconds
......@@ -49,6 +49,66 @@ public class SomeIPAdapterModel {
outgoing = outgoing.stream().filter(fc -> fc.isSomeIPPort()).filter(fc -> fc.isOutgoing()).collect(Collectors.toList());
}
public int getServiceId(EMAPortInstanceSymbol p)
{
Optional<MiddlewareSymbol> symbol = p.getMiddlewareSymbol();
if(symbol.isPresent() && symbol.get().isKindOf(SomeIPConnectionKind.INSTANCE))
{
SomeIPConnectionSymbol sym = (SomeIPConnectionSymbol) symbol.get();
int serviceID = sym.getserviceID().isPresent()?sym.getserviceID().get():-1;
return serviceID;
}
return -1;
}
public int getInstanceId(EMAPortInstanceSymbol p)
{
Optional<MiddlewareSymbol> symbol = p.getMiddlewareSymbol();
if(symbol.isPresent() && symbol.get().isKindOf(SomeIPConnectionKind.INSTANCE))
{
SomeIPConnectionSymbol sym = (SomeIPConnectionSymbol) symbol.get();
int instanceID = sym.getinstanceID().isPresent()?sym.getinstanceID().get():-1;
return instanceID;
}
return -1;
}
public int getEventGroupId(EMAPortInstanceSymbol p)
{
Optional<MiddlewareSymbol> symbol = p.getMiddlewareSymbol();
if(symbol.isPresent() && symbol.get().isKindOf(SomeIPConnectionKind.INSTANCE))
{
SomeIPConnectionSymbol sym = (SomeIPConnectionSymbol) symbol.get();
int eventgroupID = sym.geteventgroupID().isPresent()?sym.geteventgroupID().get():-1;
return eventgroupID;
}
return -1;
}
public int getEventId(EMAPortInstanceSymbol p)
{
Optional<MiddlewareSymbol> symbol = p.getMiddlewareSymbol();
if(symbol.isPresent() && symbol.get().isKindOf(SomeIPConnectionKind.INSTANCE))
{
SomeIPConnectionSymbol sym = (SomeIPConnectionSymbol) symbol.get();
int eventID = 0;//sym.geteventID().isPresent()?sym.geteventID().get():-1;
return eventID;
}
return -1;
}
public int getMethodId(EMAPortInstanceSymbol p)
{
Optional<MiddlewareSymbol> symbol = p.getMiddlewareSymbol();
if(symbol.isPresent() && symbol.get().isKindOf(SomeIPConnectionKind.INSTANCE))
{
SomeIPConnectionSymbol sym = (SomeIPConnectionSymbol) symbol.get();
int methodID = 0;//sym.getmethodID().isPresent()?sym.getmethodID().get():-1;
return methodID;
}
return -1;
}
// Parse through component to find information about its ports
public void addPortsDesc(Collection<EMAPortInstanceSymbol> ports)
{
......
......@@ -3,7 +3,6 @@
#pragma once
#include "${model.getEscapedCompName()}.h"
#include "IAdapter_${model.getEscapedCompName()}.h"
#include <iomanip>
#include <iostream>
#include <sstream>
......@@ -12,6 +11,7 @@
#include <thread>
#include <vsomeip/vsomeip.hpp>
#include <math.h>
using namespace std;
......@@ -23,14 +23,6 @@ public:
void init(${model.getEscapedCompName()} *comp);
void on_message_in1(const std::shared_ptr<vsomeip::message> &_request);
void on_message_in2(const std::shared_ptr<vsomeip::message> &_request);
void publishout1_Publisher();
void publishout2_Publisher();
void tick();
......@@ -38,35 +30,19 @@ private:
${model.getEscapedCompName()}* component = nullptr;
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;
<#list model.getIncomingPorts() as sub>
std::shared_ptr<vsomeip::application> ${sub.getName()}_Subscriber;
std::mutex mutex_${sub.getName()};
std::condition_variable condition_${sub.getName()};
int in2_service_id;
int in2_instance_id;
int in2_method_id;
int in2_event_id;
int in2_eventgroup_id;
void run_${sub.getName()}();
void on_message_${sub.getName()}(const std::shared_ptr<vsomeip::message> &_message);
void on_availability_${sub.getName()}(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available);
</#list>
int out1_service_id;
int out1_instance_id;
int out1_method_id;
int out1_event_id;
int out1_eventgroup_id;
<#list model.getOutgoingPorts() as pub>
std::shared_ptr<vsomeip::application> ${pub.getName()}_Publisher;
int out2_service_id;
int out2_instance_id;
int out2_method_id;
int out2_event_id;
int out2_eventgroup_id;
void publish${pub.getName()}_Publisher();
</#list>
};
......@@ -34,7 +34,10 @@ public class AdapterGenerationTest 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("out1").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(111,112,113/*,114,115*/));
componentInstanceSymbol.getPortInstance("out2").orElse(null).setMiddlewareSymbol(new SomeIPConnectionSymbol(121,122,123/*,124,125*/));
List<File> files = generatorSomeIP.generateSomeIPAdapter(componentInstanceSymbol);
......
......@@ -10,6 +10,7 @@
#include <thread>
#include <vsomeip/vsomeip.hpp>
#include <math.h>
using namespace std;
......@@ -21,14 +22,6 @@ public:
void init(tests_a_compA *comp);
void on_message_in1(const std::shared_ptr<vsomeip::message> &_request);
void on_message_in2(const std::shared_ptr<vsomeip::message> &_request);
void publishout1_Publisher();
void publishout2_Publisher();
void tick();
......@@ -36,35 +29,25 @@ private:
tests_a_compA* component = nullptr;
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> in1_Subscriber;
std::mutex mutex_in1;
std::condition_variable condition_in1;
std::shared_ptr<vsomeip::application> out2_Publisher;
void run_in1();
void on_message_in1(const std::shared_ptr<vsomeip::message> &_message);
void on_availability_in1(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available);
std::shared_ptr<vsomeip::application> in2_Subscriber;
std::mutex mutex_in2;
std::condition_variable condition_in2;
int in1_service_id;
int in1_instance_id;
int in1_method_id;
int in1_event_id;
int in1_eventgroup_id;
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);
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> out1_Publisher;
int out1_service_id;
int out1_instance_id;
int out1_method_id;
int out1_event_id;
int out1_eventgroup_id;
void publishout1_Publisher();
std::shared_ptr<vsomeip::application> out2_Publisher;
int out2_service_id;
int out2_instance_id;
int out2_method_id;
int out2_event_id;
int out2_eventgroup_id;
void publishout2_Publisher();
};
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