41 m_dVelocity(dInitialVelocity),
42 m_dPosition(dInitialPosition)
68 ::std::chrono::duration< long long, ::std::chrono::system_clock::duration::period > Duration;
80 m_dPosition +=
m_dVelocity / 3.6 * double(Duration.count()) * (
double(::std::chrono::system_clock::duration::period::num) / double(::std::chrono::system_clock::duration::period::den));
100 double dVelocity(0.0);
125 ::std::chrono::duration< long long, ::std::chrono::system_clock::duration::period > Duration;
134 Duration = ::std::chrono::system_clock::now() - m_LastCalculation;
137 m_dPosition += m_dVelocity / 3.6 * double(Duration.count()) * (
double(::std::chrono::system_clock::duration::period::num) / double(::std::chrono::system_clock::duration::period::den));
140 m_dVelocity = dVelocity;
143 m_LastCalculation = ::std::chrono::system_clock::now();
161 m_dPosition = dPosition;
164 m_LastCalculation = ::std::chrono::system_clock::now();
178 m_dIntensity(dIntensity),
180 m_dAdhesion(dAdhesion),
183 m_pPhysicalCalculation(
nullptr)
198 catch (const ::std::bad_alloc& Exception)
201 ::std::cerr <<
"In file " << __FILE__ <<
" at line " << __LINE__ <<
": creation of thread for physical calculation failed" << ::std::endl;
204 m_bCalculate =
false;
244 double dIntensity(0.0);
273 if (dIntensity < 0.0)
279 else if (dIntensity > 100.0)
343 else if (dAdhesion > 1.0)
352 m_dAdhesion = dAdhesion;
368 long double dIntensity(0.0);
369 long double dAccelration(0.0);
370 long double dCurrentVelocity(0.0);
371 long double dNewVelocity(0.0);
372 const long double FRICTION_COEFICIENT(0.25);
373 const long double GRAVITATION_ACCELERATION(9.81);
374 ::std::chrono::high_resolution_clock::time_point StartTime;
375 ::std::chrono::high_resolution_clock::duration SleepTime;
376 const ::std::chrono::high_resolution_clock::duration SAMPLE_TIME(::std::chrono::microseconds(
__DATA_FLOW_SAMPLE_TIME__));
382 StartTime = ::std::chrono::high_resolution_clock::now();
397 dAccelration = ((dIntensity == 0.0 || dCurrentVelocity == 0.0) ? 0.0 : FRICTION_COEFICIENT * GRAVITATION_ACCELERATION * dIntensity / 100.0 *
m_dAdhesion * (
m_dMass / 10000.0 ) * 12960.0);
400 dAccelration = dCurrentVelocity > 0 ? dAccelration : dAccelration * -1.0;
406 dNewVelocity = (dAccelration == 0.0 ? dCurrentVelocity : dCurrentVelocity - dAccelration * (
__DATA_FLOW_SAMPLE_TIME__ * 1e-6) / 3600.0 );
412 if ((dNewVelocity < 0.0L && dCurrentVelocity >= 0.0L) || (dNewVelocity > 0.0L && dCurrentVelocity <= 0.0L))
423 SleepTime = SAMPLE_TIME - (::std::chrono::high_resolution_clock::now() - StartTime);
426 if (SleepTime.count() >= 0 )
429 ::std::this_thread::sleep_for(SleepTime);
435 ::std::cerr <<
"In file " << __FILE__ <<
" in line " << __LINE__ <<
": sample time exceeded in thread" << std::endl;
440 StartTime += SAMPLE_TIME;
502 #ifdef __OETCS_DF_SIM_DEBUG_OUTPUT__
504 ::std::cout <<
"DEBUG: started CEmergencyBrake::SetActivation("<< bActivated <<
")..." << ::std::flush;
510 #ifdef __OETCS_DF_SIM_DEBUG_OUTPUT__
512 ::std::cout <<
"locked..." << ::std::flush;
521 #ifdef __OETCS_DF_SIM_DEBUG_OUTPUT__
523 ::std::cout <<
"done" << ::std::endl;
559 const unsigned int SIZE(Bits.size());
564 ::std::cout <<
"Telegram sent: ";
567 for (x = SIZE - 1; x >= 0; x--)
570 ::std::cout << (Bits[x] ?
"1" :
"0");
575 ::std::cout << ::std::endl;
612 const int BITS(Bits.size());
613 const int BYTES(BITS / 8 + (BITS % 8 == 0 ? 0 : 1));
622 for (by = 0; by < BYTES; by++)
628 for (bi = 0; bi < 8 && (bi + by * 8) < BITS; bi++)
631 cByte |= Bits[bi + by * 8] ? (1 << bi) : 0;
642 Q_EMIT this->NewTelegram(Bytes, BITS);