SOLA
Loading...
Searching...
No Matches
pickup_station.h
1// Copyright 2023 The SOLA authors
2//
3// This file is part of DAISI.
4//
5// DAISI is free software: you can redistribute it and/or modify it under the terms of the GNU
6// General Public License as published by the Free Software Foundation; version 2.
7//
8// DAISI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10// Public License for more details.
11//
12// You should have received a copy of the GNU General Public License along with DAISI. If not, see
13// <https://www.gnu.org/licenses/>.
14//
15// SPDX-License-Identifier: GPL-2.0-only
16
17#ifndef DAISI_PATH_PLANNING_PICKUP_STATION_H_
18#define DAISI_PATH_PLANNING_PICKUP_STATION_H_
19
20#include <queue>
21
22#include "agv_info.h"
23#include "agv_queue.h"
24#include "agv_state.h"
25#include "next_to_mode.h"
26#include "ns3/vector.h"
27#include "path_planning/consensus/consensus.h"
28#include "path_planning/consensus/consensus_types.h"
29#include "path_planning/consensus/paxos/constants.h"
30#include "path_planning/consensus/paxos/message/accept_message.h"
31#include "path_planning/consensus/paxos/message/ok_message.h"
32#include "path_planning/consensus/paxos/message/prepare_message.h"
33#include "path_planning/consensus/paxos/message/promise_message.h"
34#include "path_planning/constants.h"
35#include "path_planning/message/misc/new_authority_agv.h"
36#include "path_planning/message/misc/reached_goal.h"
37#include "path_planning/path_planning_logger_ns_3.h"
38#include "path_planning/task.h"
39#include "sola-ns3/sola_ns3_wrapper.h"
40#include "station.h"
41#include "transport_order_info.h"
42
43namespace daisi::path_planning {
44
48public:
49 PickupStation(PickupStationInfo info, std::shared_ptr<PathPlanningLoggerNs3> logger,
50 consensus::ConsensusSettings settings, NextTOMode next_to_mode, uint32_t device_id);
51 void postInit();
52 [[nodiscard]] std::string getConnectionString() const { return sola_->getConectionString(); }
53
54 void setRoutes(StationRoutes routes);
55 void setDeliveryStations(DeliveryStationPoints points);
56
57 [[nodiscard]] size_t numberAGVAtStation() const;
58
59 [[nodiscard]] PickupStationInfo getStationInfo() const { return info_; }
60
61 void scheduleSpawnTO(uint32_t start_time, uint32_t stop_time,
62 std::function<TransportOrderInfo(void)> order_create);
63
64private:
65 [[nodiscard]] std::string getFullName() const;
66
67 void spawnTO();
68
73 void update(const std::string &agv_id);
74
78 void addToAGVOwnership(const message::NewAuthorityAGV &msg);
79
86 [[nodiscard]] std::optional<uint32_t> getRandomStationIfOtherSideNearer(
87 uint32_t delivery_station_id);
88
94 void negotiationGo(const std::string &agv_uuid);
95
96 void processMessage(const sola::Message &msg);
97
98 void processReachedGoal(const message::ReachedGoal &msg);
99 void processNewAuthorityAGV(const message::NewAuthorityAGV &msg);
100 void topicMessage(const sola::TopicMessage &msg);
101
107 [[nodiscard]] ns3::Vector2D getNextPoint(AGVInfo &agv);
108
109 void initiateConsensus(const std::string &agv_id, RouteIdentifier d);
110 void initiateConsensusToDelivery(AGVInfo &agv);
111 void initiateConsensusToPickup(AGVInfo &agv);
112 void init();
113
114 const uint32_t device_id_ = 0;
115
116 PickupStationInfo info_;
117
118 uint32_t current_delay_ = 0;
119 uint32_t retry_ = 1;
120
121 std::function<TransportOrderInfo()>
122 create_order_;
123
124 AGVQueue queue_;
125 uint32_t amrs_to_initialize_ = 0;
126
127 uint32_t to_stop_time_ = 0;
128
129 std::shared_ptr<PathPlanningLoggerNs3> logger_;
130 std::shared_ptr<sola_ns3::SOLAWrapperNs3> sola_;
131
132 consensus::ConsensusSettings consensus_settings_;
133 std::optional<consensus::Consensus> consensus_;
134
135 std::unordered_map<std::string, AGVInfo> agv_ownership_;
136
137 struct ConsensusData {
138 std::string agv_uuid;
139 PointTimePairs pairs;
140 };
141
142 std::optional<ConsensusData>
143 current_consensus_;
145 NextTOMode next_to_mode_;
146};
147
148} // namespace daisi::path_planning
149
150#endif // DAISI_PATH_PLANNING_PICKUP_STATION_H_
Single-point parking queue with unlimited space.
Definition agv_queue.h:27
Definition pickup_station.h:47
Definition new_authority_agv.h:27
Static and dynamic AGV information that a station needs to know.
Definition agv_info.h:31
Identifier of a route from a station and point type to another station with given point type.
Definition destination.h:29
Definition transport_order_info.h:26
Definition reached_goal.h:27
Definition message.h:20