MotorControlModuleSDFM_TMS3.../Projects/EFC_Application/UMLibrary/processing/SignalSync.cpp

60 lines
1.3 KiB
C++
Raw Normal View History

/*
* SignalSync.cpp
*
* Created on: 12 <EFBFBD><EFBFBD><EFBFBD>. 2022 <EFBFBD>.
* Author: titov
*/
#include "SignalSync.hh"
processing::SignalSynchroSource::SignalSynchroSource( systemic::ISignal & raw ) : raw(raw) {}
const processing::SignalSynchroSource::Point & processing::SignalSynchroSource::point() const {
return current;
}
void processing::SignalSynchroSource::process() {
current.timestamp = (*peripheral::nanotimer::point)();
current.value = raw;
}
processing::SignalSynchroSync::SignalSynchroSync( const Point & z ) : point(z) {}
const float & processing::SignalSynchroSync::value() const {
return sync_value;
}
void processing::SignalSynchroSync::process() {
Point temp;
do temp = point;
while( temp != point );
if( temp != prev_point ) {
dvalue = temp.value - prev_point.value;
dtime = (*peripheral::nanotimer::delta)( prev_point.timestamp, temp.timestamp );
prev_point = temp;
}
float correction = ( dvalue * dtime ) /
(*peripheral::nanotimer::delta)( prev_point.timestamp, (*peripheral::nanotimer::point)() );
sync_value = prev_point.value + correction;
}
bool processing::SignalSynchroSource::Point::operator!=( const Point & right ) const {
return value != right.value or timestamp != right.timestamp;
}