added some comments and formatting
This commit is contained in:
33
app/util.h
33
app/util.h
@@ -25,34 +25,53 @@ namespace UTILITY_FUNCTIONS {
|
|||||||
// if so - x will be returned
|
// if so - x will be returned
|
||||||
// if not - lo will be returned if x is smaller than lo
|
// if not - lo will be returned if x is smaller than lo
|
||||||
// - hi will be returned if x is greater than hi
|
// - hi will be returned if x is greater than hi
|
||||||
inline double limit(double x, double lo, double hi) {
|
inline double limit(double x, double lo, double hi)
|
||||||
|
{
|
||||||
return (x < lo) ? lo : (x > hi) ? hi : x;
|
return (x < lo) ? lo : (x > hi) ? hi : x;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double max3(double a, double b, double c) {
|
|
||||||
|
// determine the maximum of the 3 parameters
|
||||||
|
inline double max3(double a, double b, double c)
|
||||||
|
{
|
||||||
return std::max(a, std::max(b, c));
|
return std::max(a, std::max(b, c));
|
||||||
}
|
}
|
||||||
inline double min3(double a, double b, double c) {
|
|
||||||
|
|
||||||
|
// determine the minimum of the 3 parameters
|
||||||
|
inline double min3(double a, double b, double c)
|
||||||
|
{
|
||||||
return std::min(a, std::min(b, c));
|
return std::min(a, std::min(b, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool is_valid(double x) { return std::isfinite(x); }
|
inline bool is_valid(double x)
|
||||||
|
{
|
||||||
|
return std::isfinite(x);
|
||||||
|
}
|
||||||
|
|
||||||
// ST: REAL_TO_INT(x) i.d.R. trunc Richtung 0. Bei Siemens oft ROUND? Du nutzt
|
// ST: REAL_TO_INT(x) i.d.R. trunc Richtung 0. Bei Siemens oft ROUND? Du nutzt
|
||||||
// häufig +0.5.
|
// häufig +0.5.
|
||||||
inline int real_to_int(double x) { return static_cast<int>(x); }
|
inline int real_to_int(double x)
|
||||||
|
{
|
||||||
|
return static_cast<int>(x);
|
||||||
|
}
|
||||||
|
|
||||||
// Platzhalter für GET_VALUE_* (kommt vermutlich aus Parameter-/Recipe-System)
|
// Platzhalter für GET_VALUE_* (kommt vermutlich aus Parameter-/Recipe-System)
|
||||||
inline std::int32_t GET_VALUE_DINT(int /*a*/, int /*b*/, int /*c*/, int /*d*/) {
|
inline int32_t GET_VALUE_DINT(int /*a*/, int /*b*/, int /*c*/, int /*d*/)
|
||||||
|
{
|
||||||
// TODO: an dein Parameter-System anbinden
|
// TODO: an dein Parameter-System anbinden
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
inline double GET_VALUE_REAL(int /*a*/, int /*b*/, int /*c*/, int /*d*/) {
|
|
||||||
|
inline double GET_VALUE_REAL(int /*a*/, int /*b*/, int /*c*/, int /*d*/)
|
||||||
|
{
|
||||||
// TODO: an dein Parameter-System anbinden
|
// TODO: an dein Parameter-System anbinden
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// UJ: not yet needed, maybe future use - leave it for now
|
||||||
class Util{
|
class Util{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user