2#ifndef SIGNALMONITORVALUES_H
3#define SIGNALMONITORVALUES_H
9#include <QCoreApplication>
20 int _threshold,
bool _high_threshold,
21 int _min,
int _max,
std::chrono::milliseconds _timeout);
35 return QString(
"%1 %2 %3 %4 %5 %6 %7 %8")
65 float rangeconv = ((float) (newmax - newmin)) / (
GetMax() -
GetMin());
66 int newval = (int) (((
GetValue() -
GetMin()) * rangeconv) + newmin);
105 Create(
const QString& _name,
const QString& _longString);
123 return QString(
"Name(%1) Val(%2) thr(%3%4) range(%5,%6) "
124 "timeout(%7 ms) %8 set. %9 good.")
128 .arg(
m_set ?
"is" :
"is NOT",
129 IsGood() ?
"Is" :
"Is NOT" );
134 int _value,
int _threshold,
bool _high_threshold,
135 int _min,
int _max, std::chrono::milliseconds _timeout,
bool _set);
136 bool Set(
const QString& _name,
const QString& _longString);
QString GetShortName(void) const
Returns a space free name of the value. Used by GetStatus().
void SetTimeout(std::chrono::milliseconds _timeout)
void SetThreshold(int _threshold)
static void Init()
Initializes the some static constants needed by SignalMonitorValue.
void SetRange(int _min, int _max)
Sets the minimum and maximum values.
std::chrono::milliseconds GetTimeout() const
Returns how long to wait for a good value in milliseconds.
static std::chrono::milliseconds MaxWait(const SignalMonitorList &slist)
Returns the maximum timeout value in the signal monitor list.
static bool run_static_init
static SignalMonitorValue * Create(const QString &_name, const QString &_longString)
int GetThreshold() const
Returns the threshold at which the value is considered "good".
static bool AllGood(const SignalMonitorList &slist)
Returns true if all the values in the list return true on IsGood().
static QStringList SIGNAL_LOCK
int GetMin() const
Returns smallest value possible, used for signal monitor bars.
std::chrono::milliseconds m_timeout
bool IsHighThreshold() const
Returns true if values greater than the threshold are considered good, false otherwise.
int GetValue() const
Returns the value.
bool Set(const QString &_name, const QString &_longString)
int GetNormalizedValue(int newmin, int newmax) const
Returns the value normalized to the [newmin, newmax] range.
static QStringList ERROR_NO_LINK
int GetMax() const
Returns greatest value possible, used for signal monitor bars.
void SetThreshold(int _threshold, bool _high_threshold)
std::vector< SignalMonitorValue > SignalMonitorList
SignalMonitorValue()=default
bool IsGood() const
Returns true if the value is equal to the threshold, or on the right side of the threshold (depends o...
QString GetName(void) const
Returns the long name of this value.
static QStringList ERROR_NO_CHANNEL
void SetValue(int _value)
static SignalMonitorList Parse(const QStringList &slist)
Converts a list of strings to SignalMonitorValue classes.
QString GetStatus() const
Returns a signal monitor value as one long string.
static eu8 clamp(eu8 value, eu8 low, eu8 high)
std::vector< SignalMonitorValue > SignalMonitorList