SOLA
Loading...
Searching...
No Matches
cpps_logger_ns3.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_CPPS_COMMON_CPPS_LOGGER_NS3_H_
18#define DAISI_CPPS_COMMON_CPPS_LOGGER_NS3_H_
19
20#include <ctime>
21
22#include "SOLA/service.h"
23#include "cpps/amr/message/amr_state.h"
24#include "cpps/logical/message/material_flow_update.h"
25#include "cpps/model/order_states.h"
26#include "logging/definitions.h"
27#include "material_flow/model/task.h"
28#include "solanet/uuid.h"
29
30namespace daisi::cpps {
31
33 std::string friendly_name;
34 std::string manufacturer;
35 std::string model_name;
36 uint32_t model_number;
37 uint32_t serial_number;
38 std::string ip_logical_core;
39 uint16_t port_logical_core;
40 std::string ip_logical_asset;
41 uint16_t port_logical_asset;
42 std::string ip_physical;
43 uint16_t port_physical;
44 std::string load_carrier_type;
45 double max_weight;
46 uint64_t load_time;
47 uint64_t unload_time;
48 double max_velocity;
49 double min_velocity;
50 double max_acceleration;
51 double min_acceleration;
52};
53
55 std::string uuid;
56 double x;
57 double y;
58 double z;
59 uint8_t state;
60};
61
63 std::string order;
64 std::string sender_ip;
65 uint16_t sender_port = 0;
66 std::string target_ip;
67 uint16_t target_port = 0;
68 uint8_t message_type = 0;
69 std::string content;
70};
71
73 std::string order;
74 std::string amr;
75 double expected_start_time;
76
77 double execution_duration;
78 double execution_distance;
79 double travel_to_pickup_duration;
80 double travel_to_pickup_distance;
81 double makespan;
82 double delay;
83
84 double delta_execution_duration;
85 double delta_execution_distance;
86 double delta_travel_to_pickup_duration;
87 double delta_travel_to_pickup_distance;
88 double delta_makespan;
89
90 int queue_size;
91 double quality;
92 double costs;
93 double utility;
94};
95
97public:
98 CppsLoggerNs3() = delete;
99 explicit CppsLoggerNs3(LogDeviceApp log_device_application, LogFunction log);
101
102 CppsLoggerNs3(CppsLoggerNs3 &) = delete;
103 CppsLoggerNs3 &operator=(const CppsLoggerNs3 &) = delete;
104 CppsLoggerNs3(CppsLoggerNs3 &&) noexcept = default;
105 CppsLoggerNs3 &operator=(CppsLoggerNs3 &&) = default;
106
107 // cpps specific logging functions
108 void logAMR(const AmrLoggingInfo &amr_info);
109 void logStation(const std::string &name, const std::string &type, ns3::Vector2D position,
110 const std::vector<ns3::Vector2D> &additionalPositions = {});
111 void logTransportService(const sola::Service &service, bool active);
112 void logService(const std::string &uuid, uint8_t type);
113 void logPositionUpdate(const AmrPositionLoggingInfo &logging_info);
114 void logNegotiationTraffic(const NegotiationTrafficLoggingInfo &logging_info);
115 void logExecutedOrderCost(const ExecutedOrderUtilityLoggingInfo &logging_info);
116 void logCppsMessageTypes();
117 void logCppsMessage(solanet::UUID msg_uuid, const std::string &msg_content);
118
119 void logMaterialFlow(const std::string &mf_uuid, const std::string &ip, uint16_t port,
120 uint8_t state);
121 void logMaterialFlowOrder(const material_flow::Order &order, const std::string &task_uuid);
122 void logMaterialFlowTask(const material_flow::Task &task, const std::string &material_flow_uuid);
123 void logMaterialFlowOrderUpdate(const cpps::logical::MaterialFlowUpdate &logging_info);
124
125 // Used for loggers which are initialized before node starts
126 // TODO Refactor to other class
127 void setApplicationUUID(const std::string &app_uuid) {
128 uuid_ = app_uuid;
129 log_device_application_(uuid_);
130 }
131
132private:
133 // TODO Refactor to other class
134 const LogDeviceApp log_device_application_;
135 const LogFunction log_;
136
137 std::string uuid_ = "NOT-KNOWN-YET";
138};
139
140} // namespace daisi::cpps
141
142#endif // CPPS_LOGGER_NS3_H_
Definition cpps_logger_ns3.h:96
Definition task.h:34
Definition cpps_logger_ns3.h:32
Definition cpps_logger_ns3.h:54
Definition cpps_logger_ns3.h:72
Definition cpps_logger_ns3.h:62
Definition material_flow_update.h:30
Definition service.h:15