MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/schematic/ValueBoundaryCapturing.hpp
2024-06-07 11:12:56 +03:00

79 lines
1.5 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.

/*
* ValueBoundaryCapturing.hpp
*
* Created on: 29 нояб. 2023 г.
* Author: titov
*/
#ifndef UMLIBRARY_SCHEMATIC_VALUEBOUNDARYCAPTURING_HPP_
#define UMLIBRARY_SCHEMATIC_VALUEBOUNDARYCAPTURING_HPP_
#include "../systemic/IValue.hpp"
#include "../systemic/IProcess.hh"
#include "../systemic/IFunctor.hh"
namespace schematic {
template<typename T>
class ValueBoundaryCapturing : public systemic::IProcess, public systemic::IFunctor<void> {
public:
ValueBoundaryCapturing( systemic::IValue<T> & value );
const volatile T & getMaximum() const;
const volatile T & getMinimum() const;
void operator()();
void process();
private:
systemic::IValue<T> & value;
T maximum;
T minimum;
};
}
template<typename T>
inline schematic::ValueBoundaryCapturing<T>::ValueBoundaryCapturing(
systemic::IValue<T> & value ) : value(value), maximum(value), minimum(value) {}
template<typename T>
inline const volatile T & schematic::ValueBoundaryCapturing<T>::getMaximum() const {
return maximum;
}
template<typename T>
inline const volatile T & schematic::ValueBoundaryCapturing<T>::getMinimum() const {
return minimum;
}
template<typename T>
inline void schematic::ValueBoundaryCapturing<T>::operator()() {
maximum = minimum = value;
}
template<typename T>
inline void schematic::ValueBoundaryCapturing<T>::process() {
const T temp = value;
if( temp > maximum )
maximum = temp;
if( temp < minimum )
minimum = temp;
}
#endif /* UMLIBRARY_SCHEMATIC_VALUEBOUNDARYCAPTURING_HPP_ */