59 void connect(
const ns3::InetSocketAddress &endpoint);
66 using state_type = OrderStates;
70 ns3::Ptr<ns3::Socket> socket_;
72 void sendVehicleStatusUpdateNs3(
bool force);
74 void sendOrderUpdateNs3();
76 void readSocket(ns3::Ptr<ns3::Socket> socket);
78 void sendDescriptionNs3();
79 void scheduleVehicleStatusUpdateNs3();
80 void startVehicleStatusUpdates();
81 void stopVehicleStatusUpdatesNs3()
const;
82 ns3::EventId next_update_event_;
84 void processMessageOrderInfo(
const AmrOrderInfo &order_info);
86 util::Position getPosition()
const;
89 std::deque<FunctionalityVariant> functionality_queue_;
90 util::Position last_sent_position_;
91 AmrState amr_state_ = AmrState::kIdle;
94 void executeFrontFunctionality();
95 bool holdsMoveType(
const FunctionalityVariant &f)
const;
98 template <
typename T>
void charge(
const T &t);
99 template <
typename T>
void execute(
const T &t);
100 template <
typename T>
void finish(
const T &t);
102#define MAKE_SKIP_HANDLE_FUNC_PAIR(FCLASS) \
103 void handleSkip##FCLASS(const FCLASS &) { \
104 process_event(FCLASS()); \
105 sendOrderUpdateNs3(); \
108 void skip(const FCLASS &t) { \
109 ns3::Simulator::Schedule(ns3::Seconds(0), &AmrPhysicalAsset::handleSkip##FCLASS, this, t); \
117 template <
typename T>
bool isMoveToLoad(
const T &t)
const;
118 template <
typename T>
bool isMoveToUnload(
const T &t)
const;
119 template <
typename T>
bool isMoveToCharge(
const T &t)
const;
120 template <
typename T>
bool isMove(
const T &t)
const;
121 template <
typename T>
bool isLoad(
const T &t)
const;
122 template <
typename T>
bool isUnload(
const T &t)
const;
123 template <
typename T>
bool isCharge(
const T &t)
const;
124 template <
typename T>
bool isFinish(
const T &t)
const;
128 using s = OrderStates;
130 using transition_table = table<
132 mem_fn_row<s::kFinished, ReceivedOrder, s::kStarted, &m::skip>,
134 mem_fn_row<s::kStarted, ReceivedOrder, s::kGoToPickUpLocation, &m::execute, &m::isMoveToLoad>,
136 mem_fn_row<s::kGoToPickUpLocation, ReachedTarget, s::kReachedPickUpLocation, &m::skip>,
138 mem_fn_row<s::kReachedPickUpLocation, ReachedTarget, s::kLoad, &m::execute, &m::isLoad>,
140 mem_fn_row<s::kGoToDeliveryLocation, ReachedTarget, s::kReachedDeliveryLocation, &m::skip>,
142 mem_fn_row<s::kReachedDeliveryLocation, ReachedTarget, s::kUnload, &m::execute, &m::isUnload>,
144 mem_fn_row<s::kLoad, LoadedPayload, s::kLoaded, &m::skip>,
146 mem_fn_row<s::kLoaded, LoadedPayload, s::kGoToPickUpLocation, &m::execute, &m::isMoveToLoad>,
147 mem_fn_row<s::kLoaded,
LoadedPayload, s::kGoToDeliveryLocation, &m::execute,
149 mem_fn_row<s::kLoaded, LoadedPayload, s::kFinished, &m::finish, &m::isFinish>,
151 mem_fn_row<s::kUnload, UnloadedPayload, s::kUnloaded, &m::skip>,
153 mem_fn_row<s::kUnloaded,
UnloadedPayload, s::kGoToPickUpLocation, &m::execute,
155 mem_fn_row<s::kUnloaded, UnloadedPayload, s::kFinished, &m::finish, &m::isFinish>>;