SOLA
Loading...
Searching...
No Matches
spawn_info_scenario.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_MANAGER_SPAWN_INFO_SCENARIO_H_
18#define DAISI_CPPS_MANAGER_SPAWN_INFO_SCENARIO_H_
19
20#include "manager/scenariofile_component.h"
21#include "ns3/core-module.h"
22
23namespace daisi::cpps {
24
26 std::string type;
27
28 // absolute
29 uint16_t number = 0;
30
31 // relative
32 double percentage = 0.0;
33
34 // gaussian
35 double mean = 0.0;
36 double sigma = 0.0;
37
38 void parse(const YAML::Node &node) {
39 SERIALIZE_VAR(type);
40
41 if (isAbsolute()) {
42 SERIALIZE_VAR(number);
43 } else if (isRelative()) {
44 SERIALIZE_VAR(percentage);
45 } else if (isGaussian()) {
46 SERIALIZE_VAR(mean);
47 SERIALIZE_VAR(sigma);
48 } else {
49 throw std::runtime_error("Invalid spawn distribution type '" + type + "'.");
50 }
51 }
52
53 bool isAbsolute() const { return type == "absolute"; }
54 bool isRelative() const { return type == "relative"; }
55 bool isGaussian() const { return type == "gaussian"; }
56};
57
59 std::string entity;
60 std::string friendly_name;
61 ns3::Time start_time;
62
63 SpawnDistributionScenario spawn_distribution;
64
65 void parse(const YAML::Node &node) {
66 SERIALIZE_VAR(entity);
67 SERIALIZE_VAR(friendly_name);
68 SERIALIZE_NS3_TIME(start_time);
69
70 SERIALIZE_VAR(spawn_distribution);
71 }
72
73 bool isAmr() const { return entity == "amr"; }
74 bool isMaterialFlow() const { return entity == "mf"; }
75
76 bool operator>(const SpawnInfoScenario &other) const {
77 return start_time > other.start_time || friendly_name > other.friendly_name;
78 }
79};
80
81} // namespace daisi::cpps
82
83#endif
Definition spawn_info_scenario.h:25
Definition spawn_info_scenario.h:58