23 #include "ns3/abort.h"
25 #include "ns3/simulator.h"
27 NS_LOG_COMPONENT_DEFINE(
"SatInputFileStreamTimeLongDoubleContainer");
35 static TypeId tid = TypeId(
"ns3::SatInputFileStreamTimeLongDoubleContainer")
37 .AddConstructor<SatInputFileStreamTimeLongDoubleContainer>();
43 std::ios::openmode filemode,
45 : m_inputFileStreamWrapper(),
50 m_valuesInRow(valuesInRow),
51 m_lastValidPosition(0),
62 : m_inputFileStreamWrapper(),
68 m_lastValidPosition(),
73 NS_LOG_FUNCTION(
this);
74 NS_FATAL_ERROR(
"SatInputFileStreamTimeLongDoubleContainer::"
75 "SatInputFileStreamTimeLongDoubleContainer - Constructor not in use");
80 NS_LOG_FUNCTION(
this);
88 NS_LOG_FUNCTION(
this);
96 std::ios::openmode filemode,
99 NS_LOG_FUNCTION(
this);
112 std::vector<long double> tempVector =
ReadRow();
123 NS_ABORT_MSG(
"Input stream is not valid for reading.");
131 std::vector<long double>
134 NS_LOG_FUNCTION(
this);
136 long double tempValue;
137 std::vector<long double> tempVector;
142 tempVector.push_back(tempValue);
150 NS_LOG_FUNCTION(
this);
155 NS_FATAL_ERROR(
"SatInputFileStreamTimeLongDoubleContainer::UpdateContainer - Empty file");
161 NS_FATAL_ERROR(
"SatInputFileStreamTimeLongDoubleContainer::UpdateContainer - Invalid "
162 "input file format (time sample error)");
173 NS_FATAL_ERROR(
"SatInputFileStreamTimeLongDoubleContainer::UpdateContainer - "
174 "Invalid input file format (time sample error)");
181 std::vector<long double>
184 NS_LOG_FUNCTION(
this);
192 NS_LOG_INFO(
"Looping samples again with shift value: " <<
m_timeShiftValue);
199 "SatInputFileStreamTimeLongDoubleContainer::ProceedToNextClosestTimeSample for "
200 <<
m_fileName <<
" is out of samples @ time sample " << Now().GetSeconds()
202 std::cout <<
"The container will loop samples from the beginning." << std::endl;
208 std::vector<long double>
211 NS_LOG_FUNCTION(
this);
213 long double currentTime = Now().GetSeconds();
217 long double selectedTime = selectedPosition.at(
m_timeColumn);
220 if (selectedTime == currentTime)
222 return selectedPosition;
226 std::vector<long double> closestPosition;
227 if (selectedTime > currentTime)
232 return selectedPosition;
241 return selectedPosition;
246 long double linearCoefficient =
247 (currentTime - selectedTime) / (closestPosition.at(
m_timeColumn) - selectedTime);
248 std::size_t rowSize = selectedPosition.size();
249 std::vector<long double> interpolatedPosition(rowSize);
250 for (std::size_t i = 0; i < rowSize; ++i)
252 interpolatedPosition[i] =
253 selectedPosition[i] + linearCoefficient * (closestPosition[i] - selectedPosition[i]);
256 return interpolatedPosition;
261 long double timeShiftValue,
262 long double comparisonTimeValue)
264 NS_LOG_FUNCTION(
this);
268 NS_ASSERT(lastValidPosition >= 0 && lastValidPosition <
m_container.size());
270 NS_LOG_INFO(
"LastValidPosition " << lastValidPosition <<
" column " <<
m_timeColumn
271 <<
" timeShiftValue " << timeShiftValue
272 <<
" comparisonTimeValue " << comparisonTimeValue);
274 bool valueFound =
false;
276 for (uint32_t i = lastValidPosition; i <
m_container.size(); i++)
281 timeShiftValue - comparisonTimeValue);
282 long double difference2 =
285 if (difference1 < difference2)
296 lastValidPosition = i;
302 timeShiftValue - comparisonTimeValue);
303 long double difference2 =
306 comparisonTimeValue);
308 if (difference1 > difference2)
316 NS_LOG_INFO(
"Done: " << valueFound
327 NS_LOG_FUNCTION(
this);
336 NS_LOG_FUNCTION(
this);
349 NS_LOG_FUNCTION(
this);
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.