Commit a683b98a authored by Yann Garcia's avatar Yann Garcia
Browse files

Add GPC Codec/Test Adapter

parent a5509b3a
......@@ -9,6 +9,7 @@
#include "IVIM_ports/AdapterControlPort_IVIM.partC"
#include "MapemSpatem_ports/AdapterControlPort_MapemSpatem.partC"
#include "SremSsem_ports/AdapterControlPort_SremSsem.partC"
#include "Rtcmem_ports/AdapterControlPort_Rtcmem.partC"
//#include "V2G_ports/AdapterControlPort_V2G.partC"
#else //_NO_SOFTLINKS_
......@@ -18,6 +19,7 @@
#include "AdapterControlPort_IVIM.partC"
#include "AdapterControlPort_MapemSpatem.partC"
#include "AdapterControlPort_SremSsem.partC"
#include "AdapterControlPort_Rtcmem.partC"
#include "AdapterControlPort_GN.partC"
/*
#include "AdapterControlPort_IVIM.partC"
......
......@@ -12,6 +12,7 @@
#include "IVIM_ports/AdapterControlPort_IVIM.partH"
#include "MapemSpatem_ports/AdapterControlPort_MapemSpatem.partH"
#include "SremSsem_ports/AdapterControlPort_SremSsem.partH"
#include "Rtcmem_ports/AdapterControlPort_Rtcmem.partH"
//#include "V2G_ports/AdapterControlPort_V2G.partH"
#else //_NO_SOFTLINKS_
......@@ -21,6 +22,7 @@
#include "AdapterControlPort_IVIM.partH"
#include "AdapterControlPort_MapemSpatem.partH"
#include "AdapterControlPort_SremSsem.partH"
#include "AdapterControlPort_Rtcmem.partH"
#include "AdapterControlPort_GN.partH"
/*
#include "AdapterControlPort_IVIM.partH"
......
//=============================================================================
namespace LibItsRtcmem__TestSystem {
AdapterControlPort::AdapterControlPort(const char *par_port_name)
: AdapterControlPort_BASE(par_port_name)
{
}
AdapterControlPort::~AdapterControlPort()
{
}
void AdapterControlPort::set_parameter(const char * /*parameter_name*/,
const char * /*parameter_value*/)
{
}
/*void AdapterControlPort::Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error) {}*/
void AdapterControlPort::Handle_Fd_Event_Error(int /*fd*/)
{
}
void AdapterControlPort::Handle_Fd_Event_Writable(int /*fd*/)
{
}
void AdapterControlPort::Handle_Fd_Event_Readable(int /*fd*/)
{
}
/*void AdapterControlPort::Handle_Timeout(double time_since_last_call) {}*/
void AdapterControlPort::user_map(const char * /*system_port*/)
{
}
void AdapterControlPort::user_unmap(const char * /*system_port*/)
{
}
void AdapterControlPort::user_start()
{
}
void AdapterControlPort::user_stop()
{
}
void AdapterControlPort::outgoing_send(const LibItsCommon__TypesAndValues::AcSecPrimitive& /*send_par*/)
{
}
} /* end of namespace */
//=============================================================================
#include "LibItsRtcmem_TestSystem.hh"
namespace LibItsRtcmem__TestSystem {
class AdapterControlPort : public AdapterControlPort_BASE {
public:
AdapterControlPort(const char *par_port_name = NULL);
~AdapterControlPort();
void set_parameter(const char *parameter_name,
const char *parameter_value);
private:
/* void Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error); */
void Handle_Fd_Event_Error(int fd);
void Handle_Fd_Event_Writable(int fd);
void Handle_Fd_Event_Readable(int fd);
/* void Handle_Timeout(double time_since_last_call); */
protected:
void user_map(const char *system_port);
void user_unmap(const char *system_port);
void user_start();
void user_stop();
void outgoing_send(const LibItsCommon__TypesAndValues::AcSecPrimitive& send_par);
};
} // end of namespace
// This Test Port skeleton source file was generated by the
// TTCN-3 Compiler of the TTCN-3 Test Executor version CRL 113 200/5 R3A
// for U-ERICSSON\ethgry (ethgry@HU00078339) on Fri Aug 14 16:32:05 2015
// Copyright Ericsson Telecom AB 2000-2014
// You may modify this file. Complete the body of empty functions and
// add your member functions here.
#include "RtcmemPort.hh"
#include "RtcmemLayerFactory.hh"
#include "loggers.hh"
namespace LibItsRtcmem__TestSystem {
RtcmemPort::RtcmemPort(const char *par_port_name) : RtcmemPort_BASE(par_port_name), _cfg_params(), _layer_params(), _layer(NULL), _time_key("RtcmemPort::outgoing_send") {
}
RtcmemPort::~RtcmemPort()
{
if (_layer != NULL) {
delete _layer;
}
}
void RtcmemPort::set_parameter(const char * parameter_name, const char * parameter_value)
{
loggers::get_instance().log("RtcmemPort::set_parameter: %s=%s", parameter_name, parameter_value);
_cfg_params.insert(std::pair<std::string, std::string>(std::string(parameter_name), std::string(parameter_value)));
}
/*void RtcmemPort::Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error) {}*/
void RtcmemPort::Handle_Fd_Event_Error(int /*fd*/)
{
}
void RtcmemPort::Handle_Fd_Event_Writable(int /*fd*/)
{
}
void RtcmemPort::Handle_Fd_Event_Readable(int /*fd*/)
{
}
/*void RtcmemPort::Handle_Timeout(double time_since_last_call) {}*/
void RtcmemPort::user_map(const char * system_port)
{
loggers::get_instance().log(">>> RtcmemPort::user_map: %s", system_port);
// Build layer stack
params::iterator it = _cfg_params.find(std::string("params"));
if (it != _cfg_params.end()) {
loggers::get_instance().log("RtcmemPort::user_map: %s", it->second.c_str());
_layer = layer_stack_builder::get_instance()->create_layer_stack(it->second.c_str());
if (static_cast<RtcmemLayer *>(_layer) == NULL) {
loggers::get_instance().error("RtcmemPort::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<RtcmemLayer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("RtcmemPort::user_map: No layers defined in configuration file");
}
}
void RtcmemPort::user_unmap(const char * system_port)
{
loggers::get_instance().log(">>> RtcmemPort::user_unmap: %s", system_port);
if (_layer != NULL) {
delete _layer;
_layer = NULL;
}
}
void RtcmemPort::user_start()
{
}
void RtcmemPort::user_stop()
{
}
void RtcmemPort::outgoing_send(const RtcmemReq& send_par)
{
loggers::get_instance().log_msg(">>> RtcmemPort::outgoing_send: payload=", send_par);
float duration;
loggers::get_instance().set_start_time(_time_key);
params params;
static_cast<RtcmemLayer *>(_layer)->sendMsg(send_par, params);
loggers::get_instance().set_stop_time(_time_key, duration);
}
void RtcmemPort::receiveMsg(const LibItsRtcmem__TestSystem::RtcmemInd& p_ind, const params& p_params) {
loggers::get_instance().log_msg(">>> RtcmemPort::receive_msg: ", p_ind);
incoming_message(p_ind);
}
} /* end of namespace */
// This Test Port skeleton header file was generated by the
// TTCN-3 Compiler of the TTCN-3 Test Executor version CRL 113 200/5 R3A
// for U-ERICSSON\ethgry (ethgry@HU00078339) on Fri Aug 14 21:19:06 2015
// Copyright Ericsson Telecom AB 2000-2014
// You may modify this file. Add your attributes and prototypes of your
// member functions here.
#ifndef RTCMEMPORT_HH
#define RTCMEMPORT_HH
#include "LibItsRtcmem_TestSystem.hh"
namespace LibItsRtcmem__TestSystem {
class RtcmemPort : public RtcmemPort_BASE {
params _cfg_params;
params _layer_params;
layer* _layer;
std::string _time_key;
public:
RtcmemPort(const char *par_port_name = NULL);
~RtcmemPort();
void set_parameter(const char *parameter_name,
const char *parameter_value);
void receiveMsg (const LibItsRtcmem__TestSystem::RtcmemInd&, const params&);
private:
/* void Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error); */
void Handle_Fd_Event_Error(int fd);
void Handle_Fd_Event_Writable(int fd);
void Handle_Fd_Event_Readable(int fd);
/* void Handle_Timeout(double time_since_last_call); */
protected:
void user_map(const char *system_port);
void user_unmap(const char *system_port);
void user_start();
void user_stop();
void outgoing_send(const RtcmemReq& send_par);
};
} /* end of namespace */
#endif
#include "UpperTesterRtcmemFactory.hh"
#include "loggers.hh"
//=============================================================================
namespace LibItsRtcmem__TestSystem {
UpperTesterPort::UpperTesterPort(const char *par_port_name)
: UpperTesterPort_BASE(par_port_name), _cfg_params(), _layer_params(), _layer(NULL), _time_key("UpperTesterPort_Rtcmem::outgoing_send")
{
loggers::get_instance().log("UpperTesterPort_Rtcmem::UpperTesterPort_Rtcmem");
}
UpperTesterPort::~UpperTesterPort()
{
if (_layer != NULL) {
delete _layer;
}
}
void UpperTesterPort::set_parameter(const char * parameter_name, const char * parameter_value)
{
loggers::get_instance().log("UpperTesterPort_Rtcmem::set_parameter: %s=%s", parameter_name, parameter_value);
_cfg_params.insert(std::pair<std::string, std::string>(std::string(parameter_name), std::string(parameter_value)));
_cfg_params.log();
}
/*void UpperTesterPort::Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error) {}*/
void UpperTesterPort::Handle_Fd_Event_Error(int /*fd*/)
{
}
void UpperTesterPort::Handle_Fd_Event_Writable(int /*fd*/)
{
}
void UpperTesterPort::Handle_Fd_Event_Readable(int /*fd*/)
{
}
/*void UpperTesterPort::Handle_Timeout(double time_since_last_call) {}*/
void UpperTesterPort::user_map(const char * system_port)
{
loggers::get_instance().log(">>> UpperTesterPort_Rtcmem::user_map: %s", system_port);
// Build layer stack
params::iterator it = _cfg_params.find(std::string("params"));
if (it != _cfg_params.end()) {
loggers::get_instance().log("UpperTesterPort_Rtcmem::user_map: %s", it->second.c_str());
_layer = layer_stack_builder::get_instance()->create_layer_stack(it->second.c_str());
if (static_cast<UpperTesterRtcmemLayer *>(_layer) == NULL) {
loggers::get_instance().error("UpperTesterPort_Rtcmem::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<UpperTesterRtcmemLayer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("UpperTesterPort_Rtcmem::user_map: No layers defined in configuration file");
}
}
void UpperTesterPort::user_unmap(const char * system_port)
{
loggers::get_instance().log(">>> UpperTesterPort_Rtcmem::user_unmap: %s", system_port);
if (_layer != NULL) {
delete _layer;
_layer = NULL;
}
}
void UpperTesterPort::user_start()
{
}
void UpperTesterPort::user_stop()
{
}
void UpperTesterPort::outgoing_send(const LibItsRtcmem__TypesAndValues::UtRtcmemInitialize& send_par)
{
loggers::get_instance().log_msg(">>> UppertesterPort::outgoing_send: ", send_par);
float duration;
loggers::get_instance().set_start_time(_time_key);
static_cast<UpperTesterRtcmemLayer *>(_layer)->sendMsg(send_par, _layer_params);
loggers::get_instance().set_stop_time(_time_key, duration);
}
void UpperTesterPort::outgoing_send(const LibItsRtcmem__TypesAndValues::UtRtcmemTrigger& send_par)
{
loggers::get_instance().log_msg(">>> UppertesterPort::outgoing_send: ", send_par);
float duration;
loggers::get_instance().set_start_time(_time_key);
static_cast<UpperTesterRtcmemLayer *>(_layer)->sendMsg(send_par, _layer_params);
loggers::get_instance().set_stop_time(_time_key, duration);
}
void UpperTesterPort::outgoing_send(const LibItsRtcmem__TypesAndValues::UtRtcmemUpdate& send_par)
{
loggers::get_instance().log_msg(">>> UppertesterPort::outgoing_send: ", send_par);
float duration;
loggers::get_instance().set_start_time(_time_key);
static_cast<UpperTesterRtcmemLayer *>(_layer)->sendMsg(send_par, _layer_params);
loggers::get_instance().set_stop_time(_time_key, duration);
}
void UpperTesterPort::receiveMsg (const Base_Type& p_ind, const params& p_params) {
loggers::get_instance().log_msg(">>> UpperTesterPort_Rtcmem::receive_msg: ", p_ind);
// Sanity check
if (!p_ind.is_bound()) {
return;
}
loggers::get_instance().log("UpperTesterPort_Rtcmem::receive_msg: %s", p_ind.get_descriptor()->name);
if (std::string(p_ind.get_descriptor()->name).compare("@LibItsRtcmem_TypesAndValues.UtRtcmemResults") == 0) { // TODO To be refined
incoming_message((LibItsRtcmem__TypesAndValues::UtRtcmemResults&)p_ind);
} // TODO Implement UtRtcmemEventInd part
}
} /* end of namespace */
//=============================================================================
#include "LibItsRtcmem_TestSystem.hh"
namespace LibItsRtcmem__TestSystem {
class UpperTesterPort : public UpperTesterPort_BASE {
params _cfg_params;
params _layer_params;
layer* _layer;
std::string _time_key;
public:
UpperTesterPort(const char *par_port_name = NULL);
~UpperTesterPort();
void set_parameter(const char *parameter_name,
const char *parameter_value);
void receiveMsg (const Base_Type&, const params&);
private:
/* void Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error); */
void Handle_Fd_Event_Error(int fd);
void Handle_Fd_Event_Writable(int fd);
void Handle_Fd_Event_Readable(int fd);
/* void Handle_Timeout(double time_since_last_call); */
protected:
void user_map(const char *system_port);
void user_unmap(const char *system_port);
void user_start();
void user_stop();
void outgoing_send(const LibItsRtcmem__TypesAndValues::UtRtcmemInitialize& send_par);
void outgoing_send(const LibItsRtcmem__TypesAndValues::UtRtcmemTrigger& send_par);
void outgoing_send(const LibItsRtcmem__TypesAndValues::UtRtcmemUpdate& send_par);
};
} /* end of namespace */
......@@ -9,6 +9,7 @@
#include "IVIM_ports/UpperTesterPort_IVIM.partC"
#include "MapemSpatem_ports/UpperTesterPort_MapemSpatem.partC"
#include "SremSsem_ports/UpperTesterPort_SremSsem.partC"
#include "Rtcmem_ports/UpperTesterPort_Rtcmem.partC"
//#include "Pki_ports/UpperTesterPort_Pki.partC"
//#include "V2G_ports/UpperTesterPort_V2G.partC"
......@@ -20,6 +21,7 @@
#include "UpperTesterPort_IVIM.partC"
#include "UpperTesterPort_MapemSpatem.partC"
#include "UpperTesterPort_SremSsem.partC"
#include "UpperTesterPort_Rtcmem.partC"
#include "UpperTesterPort_GN.partC"
//#include "UpperTesterPort_Pki.partC"
/*
......
......@@ -13,6 +13,7 @@
#include "IVIM_ports/UpperTesterPort_IVIM.partH"
#include "MapemSpatem_ports/UpperTesterPort_MapemSpatem.partH"
#include "SremSsem_ports/UpperTesterPort_SremSsem.partH"
#include "Rtcmem_ports/UpperTesterPort_Rtcmem.partH"
//#include "Pki_ports/UpperTesterPort_Pki.partH"
//#include "V2G_ports/UpperTesterPort_V2G.partH"
......@@ -25,6 +26,7 @@
#include "UpperTesterPort_MapemSpatem.partH"
#include "UpperTesterPort_SremSsem.partH"
#include "UpperTesterPort_GN.partH"
#include "UpperTesterPort_Rtcmem.partH"
//#include "UpperTesterPort_Pki.partH"
/*
#include "UpperTesterPort_IVIM.partH"
......
......@@ -56,7 +56,6 @@ void cam_layer::receive_data(OCTETSTRING& data, params& params)
return;
} // else, continue
// Process lower layer data
// gnNextHeader
params::const_iterator it = params.find(params::gn_next_header);
......@@ -122,7 +121,7 @@ void cam_layer::receive_data(OCTETSTRING& data, params& params)
p.its__aid().set_to_omit();
}
// Pass it to the ports if amy
// Pass it to the ports if any
to_all_upper_ports(p, params);
}
......
......@@ -24,7 +24,7 @@ void denm_layer::sendMsg(const LibItsDenm__TestSystem::DenmReq& p, params& param
// Encode DENM PDU
OCTETSTRING data;
if (_codec.encode(p.msgOut(), data) == -1) {
loggers::get_instance().warning("denm_layer::sendMsg: Encodeing failure");
loggers::get_instance().warning("denm_layer::sendMsg: Encoding failure");
return;
}
......@@ -121,7 +121,7 @@ void denm_layer::receive_data(OCTETSTRING& data, params& params)
p.its__aid().set_to_omit();
}
// Pass it to the ports if amy
// Pass it to the ports if any
to_all_upper_ports(p, params);
}
......
......@@ -16,7 +16,7 @@ void ivim_layer::sendMsg(const LibItsIvim__TestSystem::IvimReq& p, params& param
// Encode IVIM PDU
OCTETSTRING data;
if (_codec.encode(p.msgOut(), data) == -1) {
loggers::get_instance().warning("ivim_layer::sendMsg: Encodeing failure");
loggers::get_instance().warning("ivim_layer::sendMsg: Encoding failure");
return;
}
send_data(data, params);
......@@ -113,7 +113,7 @@ void ivim_layer::receive_data(OCTETSTRING& data, params& params)
p.its__aid().set_to_omit();
}
// Pass it to the ports if amy
// Pass it to the ports if any
to_all_upper_ports(p, params);
}
......
......@@ -16,7 +16,7 @@ void mapem_spatem_layer::sendMsg(const LibItsMapemSpatem__TestSystem::MapemReq&
// Encode mapem PDU
OCTETSTRING data;
if (_mapem_codec.encode(p.msgOut(), data) == -1) {
loggers::get_instance().warning("mapem_spatem_layer::sendMsg: Encodeing failure");
loggers::get_instance().warning("mapem_spatem_layer::sendMsg: Encoding failure");
return;
}
// Update parameters
......@@ -29,7 +29,7 @@ void mapem_spatem_layer::sendMsg(const LibItsMapemSpatem__TestSystem::SpatemReq&
// Encode spatem PDU
OCTETSTRING data;
if (_spatem_codec.encode(p.msgOut(), data) == -1) {
loggers::get_instance().warning("mapem_spatem_layer::sendMsg: Encodeing failure");
loggers::get_instance().warning("mapem_spatem_layer::sendMsg: Encoding failure");
return;
}
send_data(data, params);
......@@ -134,7 +134,7 @@ void mapem_spatem_layer::receive_data(OCTETSTRING& data, params& params)
p.its__aid().set_to_omit();
}
// Pass it to the ports if amy
// Pass it to the ports if any
to_all_upper_ports(p, params);*/
}
......
#include "LibItsRtcmem_TestSystem.hh"
#include "RtcmemCodec.hh"
#include "asn1/asn_application.h" // from asn1c
#include "loggers.hh"
int RtcmemCodec::encode (const RTCMEM__PDU__Descriptions::RTCMEM& rtcmem, OCTETSTRING& data)
{
loggers::get_instance().log(">>> RtcmemCodec::encode");
BITSTRING b;
int rc = asn_codec.encode(rtcmem, b);
if(rc){
data = bit2oct(b);
loggers::get_instance().log_msg("RtcmemCodec::encode: ", data);
}
return rc;
}
int RtcmemCodec::decode (const OCTETSTRING& data, RTCMEM__PDU__Descriptions::RTCMEM& p_rtcmem, params* params)
{
loggers::get_instance().log_msg(">>> RtcmemCodec::decode: ", data);
int rc = asn_codec.decode(oct2bit(data), p_rtcmem);
loggers::get_instance().log("RtcmemCodec::decode: ASN.1 codec returned %d", rc);
if(rc) {
loggers::get_instance().log_msg("RtcmemCodec::decode: ", p_rtcmem);
}
return rc;