Loading...
Searching...
No Matches
satellite-position-input-trace-container.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2018 CNES
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Mathias Ettinger <mettinger@toulouse.viveris.com>
19 */
20
22
24
25#include "ns3/log.h"
26
27#include <ios>
28#include <stdint.h>
29#include <string>
30#include <utility>
31#include <vector>
32
33NS_LOG_COMPONENT_DEFINE("SatPositionInputTraceContainer");
34
35namespace ns3
36{
37
38NS_OBJECT_ENSURE_REGISTERED(SatPositionInputTraceContainer);
39
40TypeId
42{
43 static TypeId tid = TypeId("ns3::SatPositionInputTraceContainer")
44 .SetParent<SatBaseTraceContainer>()
45 .AddConstructor<SatPositionInputTraceContainer>();
46 return tid;
47}
48
53
60
61void
63{
64 NS_LOG_FUNCTION(this);
65
66 Reset();
67
68 SatBaseTraceContainer::DoDispose();
69}
70
71void
73{
74 NS_LOG_FUNCTION(this);
75
76 if (!m_container.empty())
77 {
78 m_container.clear();
79 }
80}
81
82Ptr<SatInputFileStreamTimeDoubleContainer>
83SatPositionInputTraceContainer::AddNode(const std::string& filename)
84{
85 NS_LOG_FUNCTION(this << filename);
86
87 std::pair<container_t::iterator, bool> result = m_container.insert(
88 std::make_pair(filename,
89 CreateObject<SatInputFileStreamTimeDoubleContainer>(
90 filename.c_str(),
91 std::ios::in,
93
94 if (result.second == false)
95 {
96 NS_FATAL_ERROR("SatPositionInputTraceContainer::AddNode failed");
97 }
98
99 return result.first->second;
100}
101
102Ptr<SatInputFileStreamTimeDoubleContainer>
104{
105 NS_LOG_FUNCTION(this);
106
107 container_t::iterator iter = m_container.find(key);
108
109 if (iter == m_container.end())
110 {
111 return AddNode(key);
112 }
113
114 return iter->second;
115}
116
120{
121 NS_LOG_FUNCTION(this);
122
123 std::vector<double> row = FindNode(key)->InterpolateBetweenClosestTimeSamples();
127 refEllipsoid);
128}
129
130} // namespace ns3
GeoCoordinate class is used to store and operate with geodetic coordinates.
static const uint32_t POSITION_TRACE_DEFAULT_ALTITUDE_INDEX
Default altitude value index for positions traces.
static const uint32_t POSITION_TRACE_DEFAULT_LATITUDE_INDEX
Default latitude value index for positions traces.
static const uint32_t POSITION_TRACE_DEFAULT_LONGITUDE_INDEX
Default longitude value index for positions traces.
static const uint32_t POSITION_TRACE_DEFAULT_NUMBER_OF_COLUMNS
Default number of columns for position traces.
Ptr< SatInputFileStreamTimeDoubleContainer > AddNode(const std::string &key)
Function for adding the node to the map.
static TypeId GetTypeId(void)
NS-3 type id function.
void Reset()
Function for resetting the variables.
GeoCoordinate GetPosition(const std::string &key, GeoCoordinate::ReferenceEllipsoid_t refEllipsoid)
Function for getting the Rx power density.
Ptr< SatInputFileStreamTimeDoubleContainer > FindNode(const std::string &key)
Function for finding the container matching the key.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.