SOLA
Loading...
Searching...
No Matches
task.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_MATERIAL_FLOW_TASK_H_
18#define DAISI_MATERIAL_FLOW_TASK_H_
19
20#include <variant>
21
22#include "action_order.h"
23#include "cpps/amr/model/amr_static_ability.h"
24#include "cpps/model/order_states.h"
25#include "move_order.h"
26#include "solanet/serializer/serialize.h"
27#include "time_window.h"
28#include "transport_order.h"
29
30namespace daisi::material_flow {
31
32using Order = std::variant<TransportOrder, MoveOrder, ActionOrder>;
33
34class Task {
35public:
36 Task() = default;
37
38 Task(std::string name, std::string connection_string, const std::vector<Order> &orders,
39 std::vector<std::string> follow_up_task_uuids);
40
41 const std::string &getUuid() const;
42 const std::string &getName() const;
43 const std::string &getConnectionString() const;
44
45 const std::vector<Order> &getOrders() const;
46 const std::vector<std::string> &getFollowUpTaskUuids() const;
47
48 void setPrecedingTasks(const std::vector<std::string> &preceding_tasks);
49 const std::vector<std::string> &getPrecedingTaskUuids() const;
50
51 void setAbilityRequirement(const cpps::amr::AmrStaticAbility &ability);
52 cpps::amr::AmrStaticAbility getAbilityRequirement() const;
53
54 bool hasTimeWindow() const;
55 void setTimeWindow(const TimeWindow &time_window);
56 const TimeWindow &getTimeWindow() const;
57 void setSpawnTime(const util::Duration &spawn_time);
58
59 void setOrderState(uint8_t order_index, daisi::cpps::OrderStates state);
60
61 bool operator<(const Task &other) const { return uuid_ < other.uuid_; }
62 bool operator==(const Task &other) const { return uuid_ == other.uuid_; }
63 bool operator!=(const Task &other) const { return uuid_ != other.uuid_; }
64
65 SERIALIZE(uuid_, name_, connection_string_, orders_, follow_up_task_uuids_, preceding_task_uuids_,
66 ability_requirement_);
67
68private:
69 void setOrderState(TransportOrder &order, daisi::cpps::OrderStates state);
70 void setOrderState(MoveOrder &order, daisi::cpps::OrderStates state);
71 void setOrderState(ActionOrder &order, daisi::cpps::OrderStates state);
72
73 std::string uuid_;
74 std::string name_;
75 std::string connection_string_;
76
77 std::vector<Order> orders_;
78
79 std::vector<std::string> follow_up_task_uuids_;
80 std::vector<std::string> preceding_task_uuids_;
81
82 std::optional<TimeWindow> time_window_ = std::nullopt;
83
84 cpps::amr::AmrStaticAbility ability_requirement_ =
86};
87
88} // namespace daisi::material_flow
89
90namespace std {
91
92template <> struct hash<daisi::material_flow::Task> {
93 std::size_t operator()(const daisi::material_flow::Task &task) const {
94 string repr = task.getName();
95 return hash<string>()(repr);
96 }
97};
98
99} // namespace std
100
101#endif
Definition amr_static_ability.h:32
Definition amr_load_carrier.h:29
Definition action_order.h:25
Definition move_order.h:25
Definition task.h:34
Definition time_window.h:27
Definition transport_order.h:28