Skip to content
Snippets Groups Projects
Commit e291aec1 authored by Peter Altenbernd's avatar Peter Altenbernd
Browse files

Error Handling überarbeitet

parent 7a9d29a4
Branches
No related tags found
No related merge requests found
......@@ -557,6 +557,7 @@ void HeatControl::setMode(int pos, const Mode &mode)
assert(pos >= 0 and pos < SHNodeIdSize * SHSensorIdSize);
C[pos]->m_mode = mode;
C[pos]->m_switch->setIgnoreF3error();
writeCSV();
}
......
......@@ -89,7 +89,7 @@ void Server::startTimers()
// Timer zum regelmäßigen Übersenden der Werte an den / die Clients:
QTimer *submitTimer = new QTimer;
connect(submitTimer, &QTimer::timeout, this, &Server::showSensorValues);
submitTimer->start(15000); // ms
submitTimer->start(17 * 1000); // ms
// Kontrolle der Zeitstempel:
QTimer *timeStampTimer = new QTimer(this);
......@@ -100,12 +100,12 @@ void Server::startTimers()
// heatControl Timer:
QTimer *heatControlTimer = new QTimer(this);
connect(heatControlTimer, &QTimer::timeout, this, &HeatControl::processALL);
heatControlTimer->start(60000); // ms
heatControlTimer->start(61 * 1000); // ms
// SolarControl Timer:
QTimer *SolarControlTimer = new QTimer(this);
connect(SolarControlTimer, &QTimer::timeout, m_solarControl, &SolarControl::process);
SolarControlTimer->start(60000); // ms
SolarControlTimer->start(61 * 1000); // ms
}
......
......@@ -14,6 +14,7 @@ SHactuator::SHactuator(QString name, int nid, QTcpSocket *psocket, unsigned int
// S[pos] = this;
m_ignoreF3error = true;
}
......@@ -37,7 +38,7 @@ void SHactuator::setValue(const QString &payl)
m_switchState = State::OFF;
SHsensor::setValue("OFF");
if (m_switchState != m_assignedState)
if (not m_ignoreF3error and m_switchState != m_assignedState)
setError(switchError);
else
resetError(switchError);
......@@ -47,7 +48,7 @@ void SHactuator::setValue(const QString &payl)
m_switchState = State::ON;
SHsensor::setValue("ON");
if (m_switchState != m_assignedState)
if (not m_ignoreF3error and m_switchState != m_assignedState)
setError(switchError);
else
resetError(switchError);
......@@ -68,6 +69,7 @@ void SHactuator::setValue(const QString &payl)
void SHactuator::ON()
{
m_assignedState = State::ON;
m_ignoreF3error = false;
if (not SHsensor::isTesting())
socket->write(QByteArray(msg(1).toUtf8()));
......@@ -84,6 +86,7 @@ void SHactuator::ON()
void SHactuator::OFF()
{
m_assignedState = State::OFF;
m_ignoreF3error = false;
if (not SHsensor::isTesting())
socket->write(QByteArray(msg(0).toUtf8()));
......@@ -134,6 +137,16 @@ unsigned int SHactuator::powerDemand() const
/*
*
*/
void SHactuator::setIgnoreF3error() // beim setzen eines neuen Modes im Controller
{
m_ignoreF3error = true;
}
/*
*
*/
......
......@@ -22,12 +22,15 @@ public:
unsigned int powerDemand() const;
void setIgnoreF3error();
private:
friend class TestSHserver;
QTcpSocket * socket;
State m_switchState = State::UNKOWN; // vom Switch empfangen
State m_assignedState = State::UNKOWN; // von SolarControl gesetzt
unsigned int m_powerDemand;
bool m_ignoreF3error; // Für Controlled Switches: Solange noch kein process() (d.h. ON() oder OFF()) gelaufen ist, kein Konsistenz-Check
QString msg(int payload);
......
......@@ -185,7 +185,7 @@ void SHsensor::checkTimeStamp()
QTime time = m_timestamp.addSecs(CONTROL_INTERVALL);
if (SHsensor::currentTime() > time) {
setValue(NOVALUE);
setValue(NOVALUE); // wird zu F1 error
}
}
......@@ -483,13 +483,8 @@ SHsensor::ErrorType SHsensor::error() const
void SHsensor::setError(ErrorType newError)
{
if (not isError()) { // keine Aktion falls es bereits einen Fehler gibt
if (m_errorIndicated == newError) { // Fehler persistiert
m_error = newError;
m_errorTime = m_timestamp;
m_errorIndicated = noError;
} else { // einmal ist keinmal: erst wenn es dabei bleibt, wird auf Fehler gesetzt
m_errorIndicated = newError;
}
m_error = newError;
m_errorTime = m_timestamp;
}
}
......@@ -505,7 +500,6 @@ void SHsensor::resetError(ErrorType oldError)
m_previousError = m_error;
m_previousErrorTime = m_errorTime;
m_error = noError;
m_errorIndicated = noError;
}
}
......
......@@ -30,7 +30,7 @@ public:
enum SensorType {none, lightSensor, tempSensor, powerSensor, Switch, Switch2};
enum ErrorType {noError, noValueError, stupidValueError, switchError};
static const int typeSize = Switch2+1;
static const int CONTROL_INTERVALL = 120; // sec
static const int CONTROL_INTERVALL = 97; // sec
SHsensor(QString name, int nid, SensorType type);
......@@ -56,11 +56,12 @@ protected:
// errors:
ErrorType m_error;
ErrorType m_errorIndicated; // einmal ist keinmal
ErrorType m_previousError;
QTime m_errorTime;
QTime m_previousErrorTime;
void setError(ErrorType newError);
void resetError(ErrorType oldError);
private:
......@@ -111,8 +112,6 @@ public:
static void setValue(int nid, int sid, const QString & payl);
static QString getValue(int nid, int sid);
ErrorType error() const;
void setError(ErrorType newError);
void resetError(ErrorType oldError);
bool isError() const;
SensorType type() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment