Newer
Older
#include "ConfigRsuSimulatorPort.hh"
#include "ConfigRsuSimulatorLayerFactory.hh"
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "loggers.hh"
namespace ItsRSUsSimulator__TestSystem {
ConfigRsuSimulatorPort::ConfigRsuSimulatorPort(const char *par_port_name)
: ConfigRsuSimulatorPort_BASE(par_port_name), _cfg_params(), _layer_params(), _layer(nullptr), _time_key("ConfigRsuSimulatorPort::outgoing_send") {
// Nothing to do
} // End of constructor
ConfigRsuSimulatorPort::~ConfigRsuSimulatorPort()
{
loggers::get_instance().log(">>> ConfigRsuSimulatorPort::~ConfigRsuSimulatorPort");
if (_layer != nullptr) {
delete _layer;
}
} // End of destructor
void ConfigRsuSimulatorPort::set_parameter(const char * parameter_name, const char * parameter_value)
{
loggers::get_instance().log("ConfigRsuSimulatorPort::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 ConfigRsuSimulatorPort::Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error) {}*/
void ConfigRsuSimulatorPort::Handle_Fd_Event_Error(int /*fd*/)
{
}
void ConfigRsuSimulatorPort::Handle_Fd_Event_Writable(int /*fd*/)
{
}
void ConfigRsuSimulatorPort::Handle_Fd_Event_Readable(int /*fd*/)
{
}
/*void ConfigRsuSimulatorPort::Handle_Timeout(double time_since_last_call) {}*/
void ConfigRsuSimulatorPort::user_map(const char * system_port)
{
loggers::get_instance().log(">>> ConfigRsuSimulatorPort::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("ConfigRsuSimulatorPort::user_map: %s", it->second.c_str());
// Setup parameters
Params::convert(_layer_params, it->second); // TODO This _layer_params seems to be useless
// Create layer
_layer = LayerStackBuilder::GetInstance()->createLayerStack(it->second.c_str());
if (static_cast<ConfigRsuSimulatorLayer*>(_layer) == nullptr) {
loggers::get_instance().error("ConfigRsuSimulatorPort::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<ConfigRsuSimulatorLayer*>(_layer)->addUpperPort(this);
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
} else {
loggers::get_instance().error("ConfigRsuSimulatorPort::user_map: No layers defined in configuration file");
}
} // End of user_map method
void ConfigRsuSimulatorPort::user_unmap(const char * system_port)
{
loggers::get_instance().log(">>> ConfigRsuSimulatorPort::user_unmap: %s", system_port);
// Reset layers
if (_layer != nullptr) {
delete _layer;
_layer = nullptr;
}
} // End of user_unmap method
void ConfigRsuSimulatorPort::user_start()
{
loggers::get_instance().log(">>> ConfigRsuSimulatorPort::user_start");
} // End of user_start method
void ConfigRsuSimulatorPort::user_stop()
{
loggers::get_instance().log(">>> ConfigRsuSimulatorPort::user_stop");
} // End of user_stop method
void ConfigRsuSimulatorPort::outgoing_send(const CfInitialize& send_par)
{
loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
/*float duration;
loggers::get_instance().set_start_time(_time_key);
Params params;
static_cast<ConfigRsuSimulatorLayer *>(_layer)->sendMsg(send_par, params);
loggers::get_instance().set_stop_time(_time_key, duration);*/
}
void ConfigRsuSimulatorPort::outgoing_send(const BOOLEAN& send_par)
{
loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
}
void ConfigRsuSimulatorPort::outgoing_send(const LibItsGeoNetworking__TypesAndValues::UtGnResults& send_par)
{
loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
}
void ConfigRsuSimulatorPort::receiveMsg (const BOOLEAN& p_ind, const Params& p_params) {
loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::receive_msg: ", p_ind);
// Sanity check
if (!p_ind.is_bound()) {
return;
}
//incoming_message(p_ind);
}
void ConfigRsuSimulatorPort::receiveMsg (const LibItsGeoNetworking__TypesAndValues::UtGnInitialize& p_ind, const Params& p_params) {
loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::receive_msg: ", p_ind);
// Sanity check
if (!p_ind.is_bound()) {
return;
}
incoming_message(p_ind);
}
} /* end of namespace */