A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
leo-orbital-shell.cc
Go to the documentation of this file.
1
// Copyright (c) Tim Schubert
2
//
3
// SPDX-License-Identifier: GPL-2.0-only
4
//
5
// Author: Tim Schubert <ns-3-leo@timschubert.net>
6
// Porting: Thiago Miyazaki <miyathiago@gmail.com> <t.miyazaki@unesp.br>
7
8
/**
9
* @file
10
* @ingroup leo
11
* Implementation of LeoOrbitalShell serialization helpers.
12
*/
13
14
#include "
leo-orbital-shell.h
"
15
16
#include "ns3/csv-reader.h"
17
#include "ns3/log.h"
18
19
NS_LOG_COMPONENT_DEFINE
(
"LeoOrbitalShell"
);
20
21
namespace
ns3
22
{
23
24
std::ostream&
25
operator<<
(std::ostream& os,
const
LeoOrbitalShell
& orbit)
26
{
27
os << orbit.
alt
<<
","
<< orbit.
inc
<<
","
<< orbit.
planes
<<
","
<< orbit.
sats
<<
","
28
<< orbit.
phasing
<<
","
<< orbit.
raanSpanDeg
;
29
return
os;
30
}
31
32
std::istream&
33
operator>>
(std::istream& is,
LeoOrbitalShell
& orbit)
34
{
35
// Use CsvReader to parse the CSV from the input stream.
36
CsvReader
csv(is);
37
orbit =
LeoOrbitalShell
{};
// Reset to default values first.
38
if
(!csv.
FetchNextRow
())
39
{
40
return
is;
41
}
42
if
(csv.
ColumnCount
() < 4)
43
{
44
NS_LOG_WARN
(
"Skipping row "
<< csv.
RowNumber
() <<
": expected at least 4 columns, got "
45
<< csv.
ColumnCount
());
46
return
is;
47
}
48
bool
ok = csv.
GetValue
(0, orbit.
alt
);
49
ok &= csv.
GetValue
(1, orbit.
inc
);
50
ok &= csv.
GetValue
(2, orbit.
planes
);
51
ok &= csv.
GetValue
(3, orbit.
sats
);
52
if
(!ok)
53
{
54
return
is;
55
}
56
// Optional 5th column: Walker Delta phasing factor.
57
csv.
GetValue
(4, orbit.
phasing
);
58
// Optional 6th column: RAAN span in degrees.
59
csv.
GetValue
(5, orbit.
raanSpanDeg
);
60
return
is;
61
}
62
63
};
// namespace ns3
ns3::CsvReader
Provides functions for parsing and extracting data from Comma Separated Value (CSV) formatted text fi...
Definition
csv-reader.h:221
ns3::CsvReader::GetValue
bool GetValue(std::size_t columnIndex, T &value) const
Attempt to convert from the string data in the specified column to the specified data type.
Definition
csv-reader.h:399
ns3::CsvReader::RowNumber
std::size_t RowNumber() const
The number of lines that have been read.
Definition
csv-reader.cc:91
ns3::CsvReader::ColumnCount
std::size_t ColumnCount() const
Returns the number of columns in the csv data.
Definition
csv-reader.cc:83
ns3::CsvReader::FetchNextRow
bool FetchNextRow()
Reads one line from the input until a new line is encountered.
Definition
csv-reader.cc:107
ns3::LeoOrbitalShell
Orbit definition.
Definition
leo-orbital-shell.h:76
ns3::LeoOrbitalShell::inc
double inc
Inclination of orbit (degrees).
Definition
leo-orbital-shell.h:108
ns3::LeoOrbitalShell::sats
std::size_t sats
Number of satellites in those planes.
Definition
leo-orbital-shell.h:112
ns3::LeoOrbitalShell::raanSpanDeg
double raanSpanDeg
RAAN span in degrees (360 for Walker Delta, 180 for Walker Star).
Definition
leo-orbital-shell.h:116
ns3::LeoOrbitalShell::planes
std::size_t planes
Number of planes with that altitude and inclination.
Definition
leo-orbital-shell.h:110
ns3::LeoOrbitalShell::alt
double alt
Altitude of orbit (km, from earth surface).
Definition
leo-orbital-shell.h:106
ns3::LeoOrbitalShell::phasing
double phasing
Walker Delta phasing factor F (0 means no inter-plane stagger).
Definition
leo-orbital-shell.h:114
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:194
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition
log.h:253
leo-orbital-shell.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition
angles.cc:148
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition
angles.cc:172
src
mobility
model
leo-orbital-shell.cc
Generated on
for ns-3 by
1.16.1