33 #include "tdmabasemodelmessage.pb.h" 37 u64AbsoluteSlotIndex_{},
42 std::uint64_t u64DataRatebps,
44 u64AbsoluteSlotIndex_{u64AbsoluteSlotIndex},
45 u64DataRatebps_{u64DataRatebps},
46 messages_{std::move(messages)}{}
51 EMANEMessage::TDMABaseModelMessage message;
53 if(!message.ParseFromArray(p, len))
58 u64AbsoluteSlotIndex_ = message.absslotindex();
59 u64DataRatebps_ = message.dataratebps();
61 for(
const auto & msg : message.messages())
67 case EMANEMessage::TDMABaseModelMessage::Message::DATA:
70 case EMANEMessage::TDMABaseModelMessage::Message::CONTROL:
77 if(msg.has_fragment())
79 const auto & fragment = msg.fragment();
81 messages_.push_back({type,
82 static_cast<NEMId>(msg.destination()),
83 static_cast<Priority>(msg.priority()),
93 messages_.push_back({type,
94 static_cast<NEMId>(msg.destination()),
95 static_cast<Priority>(msg.priority()),
97 msg.data().size())}});
112 return u64AbsoluteSlotIndex_;
118 return u64DataRatebps_;
126 EMANEMessage::TDMABaseModelMessage baseModelMessage{};
128 baseModelMessage.set_absslotindex(u64AbsoluteSlotIndex_);
129 baseModelMessage.set_dataratebps(u64DataRatebps_);
131 for(
const auto & message : messages_)
133 auto pMessage = baseModelMessage.add_messages();
135 pMessage->set_destination(message.getDestination());
136 pMessage->set_priority(message.getPriority());
138 switch(message.getType())
141 pMessage->set_type(EMANEMessage::TDMABaseModelMessage::Message::DATA);
144 pMessage->set_type(EMANEMessage::TDMABaseModelMessage::Message::CONTROL);
150 auto const & data = message.getData();
152 pMessage->set_data(std::string(reinterpret_cast<const char *>(&data[0]),data.size()));
154 if(message.isFragment())
156 auto pFragement = pMessage->mutable_fragment();
158 pFragement->set_index(message.getFragmentIndex());
159 pFragement->set_offset(message.getFragmentOffset());
160 pFragement->set_more(message.isMoreFragments());
161 pFragement->set_sequence(message.getFragmentSequence());
165 if(!baseModelMessage.SerializeToString(&serialization))
171 return serialization;
std::string Serialization
SerializationException is thrown when an exception occurs during serialization or deserialization of ...
iovec make_iovec(void *base, std::size_t len)
std::list< MessageComponent > MessageComponents
const MessageComponents & getMessages() const
Serialization serialize() const override
std::uint64_t getDataRate() const
std::uint64_t getAbsoluteSlotIndex() const