39 Scheduler{id,pPlatformServiceProvider,pSchedulerUser},
40 bWaitingFirstTxSlotInfoRequest_{},
41 pNumScheduleRejectSlotIndexOutOfRange_{},
42 pNumScheduleRejectFrameIndexOutOfRange_{},
43 pNumScheduleRejectUpdateBeforeFull_{},
44 pNumScheduleRejectOther_{},
45 pNumScheduleFullAccept_{},
46 pNumScheduleUpdateAccept_{}
56 "MACI %03hu TDMA::EventScheduler::%s",
64 pNumScheduleRejectSlotIndexOutOfRange_ =
65 statisticRegistrar.registerNumeric<std::uint64_t>(
"scheduler.scheduleRejectSlotIndexRange",
67 "Number of schedules rejected" 68 " due to out of range slot index.");
70 pNumScheduleRejectFrameIndexOutOfRange_ =
71 statisticRegistrar.registerNumeric<std::uint64_t>(
"scheduler.scheduleRejectFrameIndexRange",
73 "Number of schedules rejected" 74 " due to out of range frame index.");
76 pNumScheduleRejectUpdateBeforeFull_ =
77 statisticRegistrar.registerNumeric<std::uint64_t>(
"scheduler.scheduleRejectUpdateBeforeFull",
79 "Number of schedules rejected" 80 " due to an update before full schedule.");
82 pNumScheduleRejectOther_ =
83 statisticRegistrar.registerNumeric<std::uint64_t>(
"scheduler.scheduleRejectOther",
85 "Number of schedules rejected" 86 " due to other reasons.");
88 pNumScheduleFullAccept_ =
89 statisticRegistrar.registerNumeric<std::uint64_t>(
"scheduler.scheduleAcceptFull",
91 "Number of full schedules accepted.");
93 pNumScheduleUpdateAccept_ =
94 statisticRegistrar.registerNumeric<std::uint64_t>(
"scheduler.scheduleAcceptUpdate",
96 "Number of update schedules accepted.");
107 "MACI %03hu TDMA::EventScheduler::%s",
116 "MACI %03hu TDMA::EventScheduler::%s",
125 "MACI %03hu TDMA::EventScheduler::%s",
134 "MACI %03hu TDMA::EventScheduler::%s",
143 "MACI %03hu TDMA::EventScheduler::%s",
153 "MACI %03hu TDMA::EventScheduler::%s",
163 bool bHasStructure{};
166 std::tie(structure,bHasStructure) =
event.getSlotStructure();
172 "MACI %03hu TDMA::EventScheduler::%s full" 181 structure_ = structure;
185 frequencies_.clear();
188 slotInfos_ =
event.getSlotInfos();
193 else if(slotInfos_.empty())
199 "MACI %03hu TDMA::EventScheduler::%s schedule" 200 " rejected update received before full schedule",
204 ++*pNumScheduleRejectUpdateBeforeFull_;
211 const auto & slotInfos =
event.getSlotInfos();
213 std::vector<int> indexes{};
214 indexes.reserve(slotInfos.size());
216 for(
const auto & slotInfo : slotInfos)
218 if(slotInfo.getFrameIndex() < framesPerMultiFrame)
220 if(slotInfo.getSlotIndex() < slotsPerFrame)
222 indexes.push_back(slotInfo.getFrameIndex() *
224 slotInfo.getSlotIndex());
230 "MACI %03hu TDMA::EventScheduler::%s schedule" 231 " rejected update slot index %u out of range",
234 slotInfo.getSlotIndex());
236 ++*pNumScheduleRejectSlotIndexOutOfRange_;
247 "MACI %03hu TDMA::EventScheduler::%s schedule" 248 " rejected update frame index %u out of range",
251 slotInfo.getFrameIndex());
253 ++*pNumScheduleRejectFrameIndexOutOfRange_;
262 if(indexes.size() == slotInfos.size())
264 auto indexIter = indexes.begin();
265 auto slotInfoIter = slotInfos.begin();
267 for(;indexIter != indexes.end(); ++indexIter, ++slotInfoIter)
269 slotInfos_[*indexIter] = *slotInfoIter;
281 ++*pNumScheduleFullAccept_;
283 eventTablePublisher_.
replace(event.getSlotInfos(),structure_);
287 ++*pNumScheduleUpdateAccept_;
289 eventTablePublisher_.
update(event.getSlotInfos());
292 bWaitingFirstTxSlotInfoRequest_ =
true;
298 const auto & eventFrequencies =
event.getFrequencies();
300 frequencies_.insert(eventFrequencies.begin(),
301 eventFrequencies.end());
315 "MACI %03hu TDMA::EventScheduler::%s schedule" 321 ++*pNumScheduleRejectOther_;
327 void EMANE::Models::TDMA::EventScheduler::flushSchedule()
336 frequencies_.clear();
339 eventTablePublisher_.
clear();
342 slotter_.
reset(Microseconds::zero(),0,0);
352 if(slotInfos_.empty())
357 std::uint32_t u32RelativeSlotIndex{};
358 std::uint32_t u32RelativeFrameIndex{};
360 std::tie(u32RelativeSlotIndex,
361 u32RelativeFrameIndex) =
364 auto index = u32RelativeFrameIndex * structure_.
getSlotsPerFrame() + u32RelativeSlotIndex;
366 const auto & info = slotInfos_[index];
368 return {u64AbsoluteSlotIndex,
370 u32RelativeSlotIndex,
371 u32RelativeFrameIndex,
382 if(slotInfos_.empty())
387 std::uint64_t u64AbsoluteSlotIndex{};
388 std::uint64_t u64AbsoluteFrameIndex{};
389 std::uint64_t u64AbsoluteMultiFrameIndex{};
391 std::tie(u64AbsoluteSlotIndex,
392 u64AbsoluteFrameIndex,
398 std::pair<EMANE::Models::TDMA::RxSlotInfo,bool>
403 "MACI %03hu TDMA::EventScheduler::%s",
408 if(slotInfos_.empty())
410 return {{0,0,0,0,EMANE::TimePoint::min(),0},
false};
413 std::uint64_t u64AbsoluteSlotIndex{};
414 std::uint64_t u64AbsoluteFrameIndex{};
415 std::uint64_t u64AbsoluteMultiFrameIndex{};
417 std::tie(u64AbsoluteSlotIndex,
418 u64AbsoluteFrameIndex,
421 std::uint32_t u32RelativeSlotIndex{};
422 std::uint32_t u32RelativeFrameIndex{};
424 std::tie(u32RelativeSlotIndex,
425 u32RelativeFrameIndex) =
428 auto index = u32RelativeFrameIndex * structure_.
getSlotsPerFrame() + u32RelativeSlotIndex;
431 const auto & info = slotInfos_[index];
435 u32RelativeSlotIndex,
436 u32RelativeFrameIndex,
438 info.getFrequency()};
443 std::pair<EMANE::Models::TDMA::TxSlotInfos,EMANE::TimePoint>
445 int multiframes)
const 448 if(slotInfos_.empty())
450 return {{},EMANE::TimePoint::min()};
455 if(bWaitingFirstTxSlotInfoRequest_)
462 bWaitingFirstTxSlotInfoRequest_ =
false;
465 std::uint64_t u64AbsoluteSlotIndex{};
466 std::uint64_t u64AbsoluteFrameIndex{};
467 std::uint64_t u64AbsoluteMultiFrameIndex{};
469 std::tie(u64AbsoluteSlotIndex,
470 u64AbsoluteFrameIndex,
473 std::uint32_t u32RelativeSlotIndex{};
474 std::uint32_t u32RelativeFrameIndex{};
476 std::tie(u32RelativeSlotIndex,
477 u32RelativeFrameIndex) =
480 auto index = u32RelativeFrameIndex * structure_.
getSlotsPerFrame() + u32RelativeSlotIndex;
484 for(
int i = 0; i < multiframes; ++i)
486 while(index < slotInfos_.size())
488 const auto & info = slotInfos_[index];
492 txSlotInfos.push_back({u64AbsoluteSlotIndex,
495 info.getFrameIndex(),
499 info.getServiceClass(),
501 info.getDestination()});
504 ++u64AbsoluteSlotIndex;
511 return {txSlotInfos,slotter_.
getMultiFrameTime(u64AbsoluteMultiFrameIndex + multiframes)};
519 "MACI %03hu TDMA::EventScheduler::%s",
528 "MACI %03hu TDMA::EventScheduler::%s",
void configure(const ConfigurationUpdate &update) override
std::pair< TxSlotInfos, TimePoint > getTxSlotInfo(const TimePoint &timePoint, int multiframes) const override
std::string Serialization
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
The Registrar interface provides access to all of the emulator registrars.
std::pair< RxSlotInfo, bool > getRxSlotInfo(const TimePoint &timePoint) const override
SlotInfo getSlotInfo(std::uint64_t u64AbsoluteSlotIndex) const override
SerializationException is thrown when an exception occurs during serialization or deserialization of ...
void processEvent(const EventId &eventId, const Serialization &serialization) override
TimePoint getMultiFrameTime(std::uint64_t u64MultiFrameIndex) const
void processSchedulerPacket(UpstreamPacket &pkt, const PacketMetaInfo &packetMetaInfo) override
void replace(const Events::SlotInfos &slotInfos, const Events::SlotStructure &structure)
virtual StatisticRegistrar & statisticRegistrar()=0
std::uint32_t getFramesPerMultiFrame() const
void processPacketMetaInfo(const PacketMetaInfo &packetMetaInfo) override
void initialize(Registrar ®istrar) override
std::tuple< std::uint32_t, std::uint32_t > getRelativeIndex(std::uint64_t u64SlotIndex) const
virtual EventRegistrar & eventRegistrar()=0
EventScheduler(NEMId id, PlatformServiceProvider *pPlatformServiceProvider, SchedulerUser *pSchedulerUser)
const char * what() const
Current slot information.
std::uint64_t getBandwidth() const
TimePoint getSlotTime(std::uint64_t u64SlotIndex) const
Receive slot information.
void reset(const EMANE::Microseconds &slotSizeMicroseconds, std::uint64_t u32SlotsPerFrame, std::uint64_t u32FramesPerMultiFrame)
void registerStatistics(StatisticRegistrar ®istrar)
std::uint32_t getSlotsPerFrame() const
Interface used by a scheduler module to communicate information with BaseModel.
Scheduler interface used by BaseModel to communicate with a scheduler module.
const Microseconds & getSlotOverhead() const
virtual void notifyScheduleChange(const Frequencies &frequencies, std::uint64_t u64BandwidthHz, const Microseconds &slotDuration, const Microseconds &slotOverhead)=0
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
virtual void registerEvent(EventId eventId)=0
std::tuple< std::uint64_t, std::uint64_t, std::uint64_t > getAbsoluteIndex(const EMANE::TimePoint &timePoint) const
void postStart() override
Clock::time_point TimePoint
std::list< TxSlotInfo > TxSlotInfos
#define LOGGER_STANDARD_LOGGING(logger, level, fmt, args...)
void update(const Events::SlotInfos &slotInfos)
SchedulerUser * pSchedulerUser_
const Microseconds & getSlotDuration() const