38namespace etsi_its_rtcmem_ts_msgs {
42#include <etsi_its_msgs_utils/impl/asn1_primitives/asn1_primitives_setters.h>
52 throwIfOutOfRange(value, ItsPduHeader::PROTOCOL_VERSION_MIN, ItsPduHeader::PROTOCOL_VERSION_MAX,
53 "ItsPduHeader.protocol_version");
54 header.protocol_version = value;
63 inline void setMessageID(ItsPduHeader& header,
const uint8_t value) {
64 throwIfOutOfRange(value, ItsPduHeader::MESSAGE_ID_MIN, ItsPduHeader::MESSAGE_ID_MAX,
65 "ItsPduHeader.message_id");
66 header.message_id = value;
75 header.message_id = ItsPduHeader::MESSAGE_ID_RTCMEM;
84 inline void setStationID(StationID& station_id,
const uint32_t value) {
86 station_id.value = value;
95 inline void setStationID(ItsPduHeader& header,
const uint32_t value) {
105 inline void setHeader(RTCMEM& rtcmem,
const ItsPduHeader& header) {
106 rtcmem.header = header;
166 msg_cnt.value = value;
175 inline void setMsgCount(RTCMcorrections& rtcm,
const uint8_t value) {
196 throwIfOutOfRange(value, RTCMRevision::UNKNOWN, RTCMRevision::RESERVED,
"RTCMRevision");
227 throwIfOutOfRange(value, MinuteOfTheYear::MIN, MinuteOfTheYear::MAX,
"MinuteOfTheYear");
239 rtcm.time_stamp_is_present =
true;
258 rtcm.time_stamp_is_present =
false;
276 inline void setAnchorPoint(RTCMcorrections& rtcm,
const FullPositionVector& anchor) {
277 rtcm.anchor_point = anchor;
278 rtcm.anchor_point_is_present =
true;
297 rtcm.anchor_point_is_present =
false;
315 inline void setRTCMHeader(RTCMcorrections& rtcm,
const RTCMheader& header) {
316 rtcm.rtcm_header = header;
317 rtcm.rtcm_header_is_present =
true;
336 rtcm.rtcm_header_is_present =
false;
356 static_cast<std::size_t
>(RTCMmessage::MIN_SIZE),
357 static_cast<std::size_t
>(RTCMmessage::MAX_SIZE),
358 "RTCMmessage length");
380 static_cast<std::size_t
>(RTCMmessageList::MIN_SIZE),
381 static_cast<std::size_t
>(RTCMmessageList::MAX_SIZE),
382 "RTCMmessageList size");
414 static_cast<std::size_t
>(RTCMmessageList::MIN_SIZE),
415 static_cast<std::size_t
>(RTCMmessageList::MAX_SIZE),
416 "RTCMmessageList size");
417 msgs.array.emplace_back();
418 return msgs.array.back();
448 inline RTCMmessage&
addRTCMmessage(RTCMmessageList& msgs,
const std::vector<uint8_t>& data) {
461 inline RTCMmessage&
addRTCMmessage(RTCMcorrections& rtcm,
const std::vector<uint8_t>& data) {
472 inline RTCMmessage&
addRTCMmessage(RTCMEM& rtcmem,
const std::vector<uint8_t>& data) {
510 header.status = status;
519 inline void setGNSSstatus(RTCMheader& header,
const std::vector<bool>& status_bits) {
530 header.offset_set = offset_set;
539 if (status.value.size() < 1) {
540 status.value.resize(1, 0u);
541 status.bits_unused = 0;
552 inline void setGNSSstatusBit(GNSSstatus& status,
const uint8_t bit_index,
const bool value) {
553 throwIfOutOfRange(bit_index,
static_cast<uint8_t
>(0),
static_cast<uint8_t
>(GNSSstatus::SIZE_BITS - 1),
"GNSSstatus bit index");
556 const uint8_t mask =
static_cast<uint8_t
>(1u << bit_index);
559 status.value[0] =
static_cast<uint8_t
>(status.value[0] | mask);
561 status.value[0] =
static_cast<uint8_t
>(status.value[0] & ~mask);
632 setGNSSstatusBit(status, GNSSstatus::BIT_INDEX_LOCAL_CORRECTIONS_PRESENT, value);
642 setGNSSstatusBit(status, GNSSstatus::BIT_INDEX_NETWORK_CORRECTIONS_PRESENT, value);
716 longitude.value = value;
726 int64_t longitude_value =
static_cast<int64_t
>(std::round(value * 1e7));
728 longitude.value = longitude_value;
737 inline void setLatitude(Latitude& latitude,
const int32_t value) {
739 latitude.value = value;
749 int64_t latitude_value =
static_cast<int64_t
>(std::round(value * 1e7));
751 latitude.value = latitude_value;
762 elevation.value = value;
772 int64_t elevation_value =
static_cast<int64_t
>(std::round(value * 1e1));
774 elevation.value = elevation_value;
783 inline void setHeading(HeadingDSRC& heading,
const uint16_t value) {
785 heading.value = value;
794 inline void setUTCTime(FullPositionVector& pos,
const DDateTime& utc_time) {
795 pos.utc_time = utc_time;
796 pos.utc_time_is_present =
true;
805 pos.utc_time_is_present =
false;
814 inline void setLongitude(FullPositionVector& pos,
const int32_t value) {
824 inline void setLongitude(FullPositionVector& pos,
const double value) {
834 inline void setLatitude(FullPositionVector& pos,
const int32_t value) {
844 inline void setLatitude(FullPositionVector& pos,
const double value) {
854 inline void setElevation(FullPositionVector& pos,
const Elevation& elevation) {
855 pos.elevation = elevation;
856 pos.elevation_is_present =
true;
865 inline void setElevation(FullPositionVector& pos,
const int32_t value) {
867 pos.elevation_is_present =
true;
876 inline void setElevation(FullPositionVector& pos,
const double value) {
878 pos.elevation_is_present =
true;
887 pos.elevation_is_present =
false;
896 inline void setHeading(FullPositionVector& pos,
const HeadingDSRC& heading) {
897 pos.heading = heading;
898 pos.heading_is_present =
true;
907 inline void setHeading(FullPositionVector& pos,
const uint16_t value) {
909 pos.heading_is_present =
true;
918 pos.heading_is_present =
false;
927 inline void setSpeed(FullPositionVector& pos,
const TransmissionAndSpeed& speed) {
929 pos.speed_is_present =
true;
938 pos.speed_is_present =
false;
948 pos.pos_accuracy = accuracy;
949 pos.pos_accuracy_is_present =
true;
958 pos.pos_accuracy_is_present =
false;
968 throwIfOutOfRange(value, TimeConfidence::UNAVAILABLE, TimeConfidence::TIME_000_000_000_01,
970 time_confidence.value = value;
980 pos.time_confidence = time_confidence;
981 pos.time_confidence_is_present =
true;
992 pos.time_confidence_is_present =
true;
1001 pos.time_confidence_is_present =
false;
1011 pos.pos_confidence = confidence;
1012 pos.pos_confidence_is_present =
true;
1021 pos.pos_confidence_is_present =
false;
1031 const SpeedandHeadingandThrottleConfidence& confidence) {
1032 pos.speed_confidence = confidence;
1033 pos.speed_confidence_is_present =
true;
1042 pos.speed_confidence_is_present =
false;
1052 throwIfOutOfRange(value, TransmissionState::NEUTRAL, TransmissionState::UNAVAILABLE,
"TransmissionState");
1053 transmission_state.value = value;
1074 velocity.value = value;
1083 inline void setVelocity(TransmissionAndSpeed& speed,
const uint16_t value) {
1095 const uint16_t velocity) {
1107 throwIfOutOfRange(value, SemiMajorAxisAccuracy::MIN, SemiMajorAxisAccuracy::MAX,
"SemiMajorAxisAccuracy");
1108 accuracy.value = value;
1128 throwIfOutOfRange(value, SemiMinorAxisAccuracy::MIN, SemiMinorAxisAccuracy::MAX,
"SemiMinorAxisAccuracy");
1129 accuracy.value = value;
1149 throwIfOutOfRange(value, SemiMajorAxisOrientation::MIN, SemiMajorAxisOrientation::MAX,
1150 "SemiMajorAxisOrientation");
1151 orientation.value = value;
1171 throwIfOutOfRange(value, PositionConfidence::UNAVAILABLE, PositionConfidence::A1CM,
"PositionConfidence");
1172 confidence.value = value;
1192 throwIfOutOfRange(value, ElevationConfidence::UNAVAILABLE, ElevationConfidence::ELEV_000_01,
1193 "ElevationConfidence");
1194 confidence.value = value;
1214 throwIfOutOfRange(value, HeadingConfidenceDSRC::UNAVAILABLE, HeadingConfidenceDSRC::PREC0_0125DEG,
1215 "HeadingConfidenceDSRC");
1216 confidence.value = value;
1236 throwIfOutOfRange(value, SpeedConfidenceDSRC::UNAVAILABLE, SpeedConfidenceDSRC::PREC0_01MS,
1237 "SpeedConfidenceDSRC");
1238 confidence.value = value;
1258 throwIfOutOfRange(value, ThrottleConfidence::UNAVAILABLE, ThrottleConfidence::PREC0_5PERCENT,
1259 "ThrottleConfidence");
1260 confidence.value = value;
1279 inline void setYear(DYear& year,
const uint16_t value) {
1290 inline void setYear(DDateTime& date_time,
const uint16_t value) {
1291 setYear(date_time.year, value);
1292 date_time.year_is_present =
true;
1301 date_time.year_is_present =
false;
1310 inline void setMonth(DMonth& month,
const uint8_t value) {
1312 month.value = value;
1321 inline void setMonth(DDateTime& date_time,
const uint8_t value) {
1323 date_time.month_is_present =
true;
1332 date_time.month_is_present =
false;
1341 inline void setDay(DDay& day,
const uint8_t value) {
1352 inline void setDay(DDateTime& date_time,
const uint8_t value) {
1353 setDay(date_time.day, value);
1354 date_time.day_is_present =
true;
1363 date_time.day_is_present =
false;
1372 inline void setHour(DHour& hour,
const uint8_t value) {
1383 inline void setHour(DDateTime& date_time,
const uint8_t value) {
1384 setHour(date_time.hour, value);
1385 date_time.hour_is_present =
true;
1394 date_time.hour_is_present =
false;
1403 inline void setMinute(DMinute& minute,
const uint8_t value) {
1405 minute.value = value;
1414 inline void setMinute(DDateTime& date_time,
const uint8_t value) {
1416 date_time.minute_is_present =
true;
1425 date_time.minute_is_present =
false;
1434 inline void setSecond(DSecond& second,
const uint16_t value) {
1436 second.value = value;
1445 inline void setSecond(DSecond& second,
const double value) {
1446 setSecond(second,
static_cast<uint16_t
>(std::round(value * 1e3)));
1455 inline void setSecond(DDateTime& date_time,
const uint16_t value) {
1457 date_time.second_is_present =
true;
1466 inline void setSecond(DDateTime& date_time,
const double value) {
1468 date_time.second_is_present =
true;
1477 date_time.second_is_present =
false;
1486 inline void setOffset(DOffset& offset,
const int16_t value) {
1488 offset.value = value;
1497 inline void setOffset(DDateTime& date_time,
const int16_t value) {
1499 date_time.offset_is_present =
true;
1508 date_time.offset_is_present =
false;
Sanity-check functions etc.
void throwIfOutOfRange(const T1 &val, const T2 &min, const T2 &max, const std::string val_desc)
Throws an exception if a given value is out of a defined range.
void setMonth(DMonth &month, const uint8_t value)
Set the DMonth value.
void setUnavailableFlag(GNSSstatus &status, const bool value)
Set the unavailable flag of a GNSSstatus object.
void clearRTCMmessages(RTCMmessageList &msgs)
Clear all RTCM messages from a RTCMmessageList object.
void clearMonth(DDateTime &date_time)
Clear the optional month of a DDateTime object.
void setStationID(StationID &station_id, const uint32_t value)
Set the StationID object.
void setAntennaOffsetZ(OffsetB10 &field, const int16_t value)
Set the z antenna offset object.
void setIsMonitoredFlag(GNSSstatus &status, const bool value)
Set the isMonitored flag of a GNSSstatus object.
void setHour(DHour &hour, const uint8_t value)
Set the DHour value.
void clearUTCTime(FullPositionVector &pos)
Clear the optional utcTime of a FullPositionVector object.
void clearMinuteOfTheYear(RTCMcorrections &rtcm)
Clear the optional MinuteOfTheYear of a RTCMcorrections object.
void setRTCMmessageData(RTCMmessage &msg, const std::vector< uint8_t > &data)
Set the raw bytes of a RTCMmessage object.
void setPositionConfidence(FullPositionVector &pos, const PositionConfidenceSet &confidence)
Set the position confidence of a FullPositionVector object.
void clearHour(DDateTime &date_time)
Clear the optional hour of a DDateTime object.
void setSemiMajorAxisAccuracy(SemiMajorAxisAccuracy &accuracy, const uint8_t value)
Set the semi-major axis accuracy value.
RTCMmessage & addRTCMmessage(RTCMmessageList &msgs)
Add a new default-constructed RTCMmessage to a RTCMmessageList object.
void clearRTCMHeader(RTCMcorrections &rtcm)
Clear the optional RTCMheader of a RTCMcorrections object.
void setLatitude(Latitude &latitude, const int32_t value)
Set the raw latitude value of a Latitude object.
void setLongitude(Longitude &longitude, const int32_t value)
Set the raw longitude value of a Longitude object.
void setTransmissionAndSpeed(TransmissionAndSpeed &speed, const uint8_t transmission_state, const uint16_t velocity)
Set the transmission state and velocity of a TransmissionAndSpeed object.
void clearElevation(FullPositionVector &pos)
Clear the optional elevation of a FullPositionVector object.
void setBaseStationTypeFlag(GNSSstatus &status, const bool value)
Set the baseStationType flag of a GNSSstatus object.
void clearTimeConfidence(FullPositionVector &pos)
Clear the optional time confidence of a FullPositionVector object.
void clearOffset(DDateTime &date_time)
Clear the optional offset of a DDateTime object.
void setAntennaOffsetX(OffsetB12 &field, const int16_t value)
Set the x antenna offset object.
void setGNSSstatus(RTCMheader &header, const GNSSstatus &status)
Set the GNSSstatus object of a RTCMheader object.
void setSemiMajorAxisOrientation(SemiMajorAxisOrientation &orientation, const uint16_t value)
Set the semi-major axis orientation value.
void setInViewOfUnder5Flag(GNSSstatus &status, const bool value)
Set the inViewOfUnder5 flag of a GNSSstatus object.
void setRTCMHeader(RTCMcorrections &rtcm, const RTCMheader &header)
Set the RTCMheader of a RTCMcorrections object.
void setThrottleConfidence(ThrottleConfidence &confidence, const uint8_t value)
Set the throttle confidence value.
void setOffset(DOffset &offset, const int16_t value)
Set the DOffset value.
void setRTCMcorrections(RTCMEM &rtcmem, const RTCMcorrections &rtcm)
Set the RTCMcorrections container of a RTCMEM object.
void setMessageIDToRTCMEM(ItsPduHeader &header)
Set the message ID of an ItsPduHeader object to RTCMEM.
void clearSpeed(FullPositionVector &pos)
Clear the optional speed of a FullPositionVector object.
void clearYear(DDateTime &date_time)
Clear the optional year of a DDateTime object.
void setHeader(RTCMEM &rtcmem, const ItsPduHeader &header)
Set the ItsPduHeader of a RTCMEM object.
void setAntennaOffsetSet(RTCMheader &header, const AntennaOffsetSet &offset_set)
Set the AntennaOffsetSet object of a RTCMheader object.
void setBitString(T &bitstring, const std::vector< bool > &bits)
Set a Bit String by a vector of bools.
void setRTCMRevision(RTCMRevision &rev, const uint8_t value)
Set the RTCMRevision value.
void setNetworkCorrectionsPresentFlag(GNSSstatus &status, const bool value)
Set the networkCorrectionsPresent flag of a GNSSstatus object.
void setLocalCorrectionsPresentFlag(GNSSstatus &status, const bool value)
Set the localCorrectionsPresent flag of a GNSSstatus object.
void setProtocolVersion(ItsPduHeader &header, const uint8_t value)
Set the protocol version of an ItsPduHeader object.
void setSemiMinorAxisAccuracy(SemiMinorAxisAccuracy &accuracy, const uint8_t value)
Set the semi-minor axis accuracy value.
void ensureGNSSstatusStorage(GNSSstatus &status)
Ensure storage for a GNSSstatus object.
void clearMinute(DDateTime &date_time)
Clear the optional minute of a DDateTime object.
void setAnchorPoint(RTCMcorrections &rtcm, const FullPositionVector &anchor)
Set the anchor point of a RTCMcorrections object.
void setMinuteOfTheYear(MinuteOfTheYear &moy, const uint32_t value)
Set the MinuteOfTheYear object.
void setUTCTime(FullPositionVector &pos, const DDateTime &utc_time)
Set the utcTime of a FullPositionVector object.
void setRTCMmessageList(RTCMmessageList &msgs, const std::vector< RTCMmessage > &values)
Set the RTCMmessageList object.
void setIsHealthyFlag(GNSSstatus &status, const bool value)
Set the isHealthy flag of a GNSSstatus object.
void setSpeed(FullPositionVector &pos, const TransmissionAndSpeed &speed)
Set the speed of a FullPositionVector object.
void setElevationConfidence(ElevationConfidence &confidence, const uint8_t value)
Set the elevation confidence value.
void clearPositionConfidence(FullPositionVector &pos)
Clear the optional position confidence of a FullPositionVector object.
void clearSecond(DDateTime &date_time)
Clear the optional second of a DDateTime object.
void setSecond(DSecond &second, const uint16_t value)
Set the DSecond value.
void clearHeading(FullPositionVector &pos)
Clear the optional heading of a FullPositionVector object.
void setTimeConfidence(TimeConfidence &time_confidence, const uint8_t value)
Set the time confidence value.
void setElevation(Elevation &elevation, const int32_t value)
Set the raw elevation value of an Elevation object.
void setMessageID(ItsPduHeader &header, const uint8_t value)
Set the message ID of an ItsPduHeader object.
void clearDay(DDateTime &date_time)
Clear the optional day of a DDateTime object.
void clearAnchorPoint(RTCMcorrections &rtcm)
Clear the optional anchor point of a RTCMcorrections object.
void setAntennaOffsetY(OffsetB09 &field, const int16_t value)
Set the y antenna offset object.
void setYear(DYear &year, const uint16_t value)
Set the DYear value.
void setSpeedConfidence(FullPositionVector &pos, const SpeedandHeadingandThrottleConfidence &confidence)
Set the speed confidence of a FullPositionVector object.
void setMsgCount(MsgCount &msg_cnt, const uint8_t value)
Set the MsgCount object.
void setAPDOPofUnder5Flag(GNSSstatus &status, const bool value)
Set the aPDOPofUnder5 flag of a GNSSstatus object.
void setVelocity(Velocity &velocity, const uint16_t value)
Set the velocity value.
void clearSpeedConfidence(FullPositionVector &pos)
Clear the optional speed confidence of a FullPositionVector object.
void setHeadingConfidence(HeadingConfidenceDSRC &confidence, const uint8_t value)
Set the heading confidence value.
void setPositionalAccuracy(FullPositionVector &pos, const PositionalAccuracy &accuracy)
Set the positional accuracy of a FullPositionVector object.
void setRTCMmessageValue(RTCMmessage &msg, const std::vector< uint8_t > &data)
Set the raw bytes of a RTCMmessage object.
void setMinute(DMinute &minute, const uint8_t value)
Set the DMinute value.
void setHeading(HeadingDSRC &heading, const uint16_t value)
Set the heading of a HeadingDSRC object.
void setGNSSstatusBit(GNSSstatus &status, const uint8_t bit_index, const bool value)
Set a single GNSSstatus bit.
void setTransmissionState(TransmissionState &transmission_state, const uint8_t value)
Set the transmission state value.
void setDay(DDay &day, const uint8_t value)
Set the DDay value.
void clearPositionalAccuracy(FullPositionVector &pos)
Clear the optional positional accuracy of a FullPositionVector object.