MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/processing/SignalSync.cpp
2024-06-07 11:12:56 +03:00

60 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* SignalSync.cpp
*
* Created on: 12 апр. 2022 г.
* 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;
}