Commit ab777484 authored by Stefan Dähling's avatar Stefan Dähling

added connection time to ensure message

parent a563df10
......@@ -51,7 +51,8 @@ public:
int64_t *n; //!< set point for tap position
double *v; //!< voltage measurement value
double *SOC; //!< SOC measurement
bool *connected; //!< connection statuss
bool *connected; //!< connection status
int64_t *t_connected; //!< time until disconnection in seconds
static std::vector<Meta_infos> ensure_msg_meta;
static bool meta_initialized;
......@@ -64,6 +65,6 @@ public:
private:
void init_message(int _performative, int _agent_id, double _P,
double _Q, int _n, double _v, double _SOC, bool _conn);
double _Q, int _n, double _v, double _SOC, bool _conn, int _t_conn);
};
#endif //DISTAIX_ENSURE_MESSAGE_H
......@@ -36,8 +36,9 @@ Ensure_msg::Ensure_msg() : Villas_message() {
v = nullptr;
SOC = nullptr;
connected = nullptr;
t_connected = nullptr;
init_message(0, 0, 0, 0.0, 0, 0.0, 0.0, false);
init_message(0, 0, 0, 0.0, 0, 0.0, 0.0, false, 0);
}
......@@ -57,8 +58,9 @@ Ensure_msg::Ensure_msg(int _performative, int _agent_id) {
v = nullptr;
SOC = nullptr;
connected = nullptr;
t_connected = nullptr;
init_message(_performative, _agent_id, 0, 0.0, 0, 0.0, 0.0, false);
init_message(_performative, _agent_id, 0, 0.0, 0, 0.0, 0.0, false, 0);
}
void Ensure_msg::set_pointers() {
......@@ -73,9 +75,10 @@ void Ensure_msg::set_pointers() {
v = &(data[5].f);
SOC = &(data[6].f);
connected = &(data[7].b);
t_connected = &(data[8].i);
}
void Ensure_msg::init_message(int _performative, int _agent_id, double _P, double _Q, int _n, double _v, double _SOC, bool _conn) {
void Ensure_msg::init_message(int _performative, int _agent_id, double _P, double _Q, int _n, double _v, double _SOC, bool _conn, int _t_conn) {
//add all data and meta elements of this message type
Data_element perf_data;
......@@ -110,6 +113,10 @@ void Ensure_msg::init_message(int _performative, int _agent_id, double _P, doubl
conn_data.b = _conn;
add_element(conn_data, VILLAS_DATA_TYPE_BOOLEAN);
Data_element t_conn_data;
t_conn_data.i = _t_conn;
add_element(t_conn_data, VILLAS_DATA_TYPE_INT64);
//set the pointers of the message to the corresponding fields in data
set_pointers();
}
......@@ -169,6 +176,12 @@ void Ensure_msg::init_meta() {
conn_meta.unit = "boolean";
conn_meta.type = VILLAS_DATA_TYPE_BOOLEAN;
Ensure_msg::ensure_msg_meta.push_back(conn_meta);
Meta_infos t_conn_meta;
t_conn_meta.name = "t_connected";
t_conn_meta.unit = "s";
t_conn_meta.type = VILLAS_DATA_TYPE_INT64;
Ensure_msg::ensure_msg_meta.push_back(t_conn_meta);
}
}
......@@ -190,7 +203,8 @@ std::string Ensure_msg::get_message_output()
<< " n: " << *n
<< " v: " << *v
<< " SOC: " << *SOC
<< " connected: " << *connected;
<< " connected: " << *connected
<< " t_connected: " << *t_connected;
output = temp.str();
return output;
......
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