Commit ce6f2ac5 authored by Markus Georg Bendel's avatar Markus Georg Bendel

Update Dockerfile

parent 61dc8887
Pipeline #159026 passed with stages
in 1 minute and 49 seconds
# Use an official Python runtime as a parent image
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get -y install build-essential
RUN apt-get -y install cmake
RUN apt-get -y install libboost-system1.58-dev libboost-thread1.58-dev libboost-log1.58-dev
RUN apt-get update \
&& apt-get -y install openjdk-8-jdk \
&& rm -rf /var/lib/apt/lists/*
......@@ -17,25 +9,20 @@ ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
ENV PATH $JAVA_HOME/bin:$PATH
RUN apt-get update
RUN apt-get -y install maven
RUN apt-get -y install git
RUN mkdir /usr/src/emam2someip
RUN apt-get update && apt-get -y install \
build-essential \
cmake \
libboost-system1.58-dev libboost-thread1.58-dev libboost-log1.58-dev \
maven \
git
WORKDIR /usr/src/emam2someip
#clone and build vsomeip
RUN git clone https://github.com/GENIVI/vsomeip.git
#copy example
COPY . /usr/src/emam2someip
WORKDIR /usr/src/emam2someip/vsomeip
RUN mkdir /usr/src/emam2someip/vsomeip/build
WORKDIR /usr/src/emam2someip/vsomeip/build
RUN cmake ..
......@@ -48,10 +35,14 @@ WORKDIR /usr/src/emam2someip/vsomeip
RUN rm -rf build
#copy example and adapter
COPY . /usr/src/emam2someip
#build example
WORKDIR /usr/src/emam2someip/example/build
RUN cmake ..
RUN make
WORKDIR /usr/src/emam2someip/
# Setting cmake version
cmake_minimum_required (VERSION 2.8)
# Using C++ version 11 with threads for compiling
set (CMAKE_CXX_FLAGS "-g -std=c++0x")
# Find packages and include directories
find_package (vsomeip 2.10.0 REQUIRED)
find_package( Boost 1.55 COMPONENTS system thread log REQUIRED )
include_directories (
${Boost_INCLUDE_DIR}
${VSOMEIP_INCLUDE_DIRS}
)
# Linking libraries to target
add_library(SomeipAdapter_tests_a_compA SomeipAdapter_tests_a_compA.cpp)
target_link_libraries(SomeipAdapter_tests_a_compA vsomeip ${Boost_LIBRARIES})
# Export target to a cmake module file for outside usage
export(TARGETS SomeipAdapter_tests_a_compA FILE SomeipAdapter_tests_a_compA.cmake)
#include "SomeipAdapter_tests_a_compA.h"
#define SAMPLE_SERVICE_ID 0x1234
#define SAMPLE_INSTANCE_ID 0x5678
#define SAMPLE_METHOD_ID 0x0421
#define SAMPLE_EVENT_ID 0x2345
#define SAMPLE_EVENTGROUP_ID 0x1456
tests_a_compA* component;
std::shared_ptr<vsomeip::application> _clockSubscriber;
std::shared_ptr<vsomeip::application> _echoPublisher;
SomeipAdapter_tests_a_compA::SomeipAdapter_tests_a_compA() {}
void SomeipAdapter_tests_a_compA::init(tests_a_compA *comp)
{
this->component = comp;
_clockSubscriber = vsomeip::runtime::get()->create_application("Subscriber");
_clockSubscriber->init();
//_clockSubscriber->register_availability_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, on_availability);
_clockSubscriber->request_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
_clockSubscriber->register_message_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_METHOD_ID, std::bind(&SomeipAdapter_tests_a_compA::on_message, this, std::placeholders::_1));
//_clockSubscriber->register_message_handler(vsomeip::ANY_SERVICE, vsomeip::ANY_INSTANCE, vsomeip::ANY_METHOD, std::bind(&SomeipAdapter_tests_a_compA::on_message, this, std::placeholders::_1));
std::set<vsomeip::eventgroup_t> its_groups;
its_groups.insert(SAMPLE_EVENTGROUP_ID);
_clockSubscriber->request_event(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENT_ID, its_groups, true);
_clockSubscriber->subscribe(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENTGROUP_ID);
_clockSubscriber->start();
_echoPublisher = vsomeip::runtime::get()->create_application("Publisher");
_echoPublisher->init();
//_echoPublisher->register_message_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_METHOD_ID, on_message);
_echoPublisher->offer_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
_echoPublisher->start();
}
void SomeipAdapter_tests_a_compA::on_message(const std::shared_ptr<vsomeip::message> &_request) {
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->rosIn = dataFromMessage;
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::publish_echoPublisher()
{
double d = component->rosOut;
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);
//const vsomeip::byte_t its_data[] = component->rosOut; //component->rosOut
//std::shared_ptr< vsomeip::payload > payload = vsomeip::runtime::get()->create_payload();
//payload->set_data(its_data, sizeof(its_data));
std::set<vsomeip::eventgroup_t> its_groups;
its_groups.insert(SAMPLE_EVENTGROUP_ID);
_echoPublisher->offer_event(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENT_ID, its_groups, true);
_echoPublisher->notify(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENT_ID, payload);
}
void SomeipAdapter_tests_a_compA::tick()
{
publish_echoPublisher();
}
#pragma once
#include "tests_a_compA.h"
#include <iomanip>
#include <iostream>
#include <sstream>
#include <condition_variable>
#include <thread>
#include <vsomeip/vsomeip.hpp>
using namespace std;
class SomeipAdapter_tests_a_compA {
public:
SomeipAdapter_tests_a_compA();
void init(tests_a_compA* comp);
void publish_echoPublisher();
void tick();
void on_message(const std::shared_ptr<vsomeip::message> &_response);
private:
tests_a_compA* component = nullptr;
};
#ifndef tests_a_compA_h
#define tests_a_compA_h
#include <iostream>
using namespace std;
class tests_a_compA {
public:
double rosIn = 2.5;
double rosOut = 3.14;
};
#endif /* tests_a_compA_h */
# Setting cmake version
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 2.8)
# Using C++ version 11 with threads for compiling
set (CMAKE_CXX_FLAGS "-g -std=c++0x")
# Setting project name and description
project(SomeipAdapter VERSION 1.0
DESCRIPTION "Someip adapter"
LANGUAGES CXX)
# Find packages and include directories
find_package (vsomeip 2.10.0 REQUIRED)
find_package( Boost 1.55 COMPONENTS system thread log REQUIRED )
......
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