36namespace etsi_its_spatem_ts_msgs {
40 const std::array<float, 4> color_grey {0.5, 0.5, 0.5, 1.0};
41 const std::array<float, 4> color_green {0.18, 0.79, 0.21, 1.0};
42 const std::array<float, 4> color_orange {0.9, 0.7, 0.09, 1.0};
43 const std::array<float, 4> color_red {0.8, 0.2, 0.2, 1.0};
45 enum time_mark_value_interpretation { normal, undefined, over_an_hour, leap_second };
56 time_t ts =
static_cast<time_t
>(unixSecond);
59 timeinfo = gmtime(&ts);
64 timeinfo->tm_hour = 0;
65 timeinfo->tm_mday = 1;
68 return timegm(timeinfo);
89 float probability = 0;
91 switch (encoded_probability)
154 std::array<float, 4> color;
158 case MovementPhaseState::UNAVAILABLE:
162 case MovementPhaseState::DARK:
165 case MovementPhaseState::STOP_THEN_PROCEED:
168 case MovementPhaseState::STOP_AND_REMAIN:
171 case MovementPhaseState::PRE_MOVEMENT:
172 color = color_orange;
174 case MovementPhaseState::PERMISSIVE_MOVEMENT_ALLOWED:
177 case MovementPhaseState::PROTECTED_MOVEMENT_ALLOWED:
180 case MovementPhaseState::PERMISSIVE_CLEARANCE:
181 color = color_orange;
183 case MovementPhaseState::PROTECTED_CLEARANCE:
184 color = color_orange;
186 case MovementPhaseState::CAUTION_CONFLICTING_TRAFFIC:
187 color = color_orange;
204 time_mark_value_interpretation type;
208 type = time_mark_value_interpretation::undefined;
209 }
else if (time == 36000) {
211 type = time_mark_value_interpretation::over_an_hour;
212 }
else if (time >= 35991 && time <= 35999) {
214 type = time_mark_value_interpretation::leap_second;
216 type = time_mark_value_interpretation::normal;
232 float abs_time_hour = ((int)(seconds)) % 3600 + (
float)nanosec * 1e-9;
233 float rel_time_until_change = (float)time * 0.1f - abs_time_hour;
235 return rel_time_until_change;
250 std::string text_content;
253 case time_mark_value_interpretation::undefined:
254 text_content =
"undefined";
256 case time_mark_value_interpretation::over_an_hour:
257 text_content =
">36000s";
259 case time_mark_value_interpretation::leap_second:
260 text_content =
"leap second";
262 case time_mark_value_interpretation::normal:
266 std::stringstream ss;
267 ss << std::fixed << std::setprecision(1) << rel_time_until_change <<
"s";
268 text_content = ss.str();
uint64_t getUnixSecondsOfYear(const uint64_t unixSecond)
Get the unix seconds of the beginning of a year that corresponds to a given unix timestamp.
std::array< float, 4 > interpretMovementPhaseStateAsColor(const uint8_t value)
Interprets the MovementPhaseState type as a color (see etsi definition)
uint64_t getUnixNanosecondsFromMinuteOfTheYear(const MinuteOfTheYear &moy, const uint64_t unix_nanoseconds_estimate)
Get the unix nanoseconds from MinuteOfTheYear object.
float interpretTimeMarkValueAsSeconds(const uint16_t time, const int32_t seconds, const uint32_t nanosec)
Calculate the amount of seconds until the given time is reached.
time_mark_value_interpretation interpretTimeMarkValueType(const uint16_t time)
Interprets the type of a TimeMark message See etsi ASNI1 - IS TS 103 301 documentation for for the en...
std::string parseTimeMarkValueToString(const uint16_t time, const int32_t seconds, const uint32_t nanosec)
Converts a value from message type TimeMarkValue into a string representation.
float interpretTimeIntervalConfidenceAsFloat(const uint16_t encoded_probability)
Interprets the TimeIntervalConfidence type as a float value (see etsi definition)