23 #include "ns3/abort.h"
25 #include "ns3/simulator.h"
27 NS_LOG_COMPONENT_DEFINE(
"SatInputFileStreamTimeDoubleContainer");
35 static TypeId tid = TypeId(
"ns3::SatInputFileStreamTimeDoubleContainer")
37 .AddConstructor<SatInputFileStreamTimeDoubleContainer>();
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(
"SatInputFileStreamTimeDoubleContainer::SatInputFileStreamTimeDoubleContainer - "
75 "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<double> tempVector =
ReadRow();
123 NS_ABORT_MSG(
"Input stream is not valid for reading.");
134 NS_LOG_FUNCTION(
this);
137 std::vector<double> tempVector;
142 tempVector.push_back(tempValue);
150 NS_LOG_FUNCTION(
this);
155 NS_FATAL_ERROR(
"SatInputFileStreamDoubleContainer::UpdateContainer - Empty file");
161 NS_FATAL_ERROR(
"SatInputFileStreamDoubleContainer::UpdateContainer - Invalid input "
162 "file format (time sample error)");
173 NS_FATAL_ERROR(
"SatInputFileStreamDoubleContainer::UpdateContainer - Invalid input "
174 "file format (time sample error)");
184 NS_LOG_FUNCTION(
this);
192 NS_LOG_INFO(
"Looping samples again with shift value: " <<
m_timeShiftValue);
198 <<
"WARNING! - SatInputFileStreamDoubleContainer::ProceedToNextClosestTimeSample for "
199 <<
m_fileName <<
" is out of samples @ time sample " << Now().GetSeconds()
201 std::cout <<
"The container will loop samples from the beginning." << std::endl;
210 NS_LOG_FUNCTION(
this);
212 double currentTime = Now().GetSeconds();
216 double selectedTime = selectedPosition.at(
m_timeColumn);
219 if (selectedTime == currentTime)
221 return selectedPosition;
225 std::vector<double> closestPosition;
226 if (selectedTime > currentTime)
231 return selectedPosition;
240 return selectedPosition;
245 double linearCoefficient =
246 (currentTime - selectedTime) / (closestPosition.at(
m_timeColumn) - selectedTime);
247 std::size_t rowSize = selectedPosition.size();
248 std::vector<double> interpolatedPosition(rowSize);
249 for (std::size_t i = 0; i < rowSize; ++i)
251 interpolatedPosition[i] =
252 selectedPosition[i] + linearCoefficient * (closestPosition[i] - selectedPosition[i]);
255 return interpolatedPosition;
260 double timeShiftValue,
261 double comparisonTimeValue)
263 NS_LOG_FUNCTION(
this);
267 NS_ASSERT(lastValidPosition >= 0 && lastValidPosition <
m_container.size());
269 NS_LOG_INFO(
"LastValidPosition " << lastValidPosition <<
" column " <<
m_timeColumn
270 <<
" timeShiftValue " << timeShiftValue
271 <<
" comparisonTimeValue " << comparisonTimeValue);
273 bool valueFound =
false;
275 for (uint32_t i = lastValidPosition; i <
m_container.size(); i++)
280 timeShiftValue - comparisonTimeValue);
284 if (difference1 < difference2)
295 lastValidPosition = i;
301 timeShiftValue - comparisonTimeValue);
305 comparisonTimeValue);
307 if (difference1 > difference2)
315 NS_LOG_INFO(
"Done: " << valueFound
326 NS_LOG_FUNCTION(
this);
335 NS_LOG_FUNCTION(
this);
348 NS_LOG_FUNCTION(
this);
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.