Restart carun on consecutive E255

This commit is contained in:
Siegfried Siegert 2024-07-15 09:59:08 +02:00
parent 72dbc8b858
commit 6d7d9ade70
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 37 additions and 9 deletions

View File

@ -5,6 +5,8 @@
#include <QUuid>
#include <QDebug>
#include <QProcess>
#include "support/JSON.h"
@ -18,6 +20,7 @@ DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *paren
, lastState(DeviceController::State::INITIAL_STATE)
, _isErrorState(false)
, pData(pData)
, E255counter(0)
{
diagRequestTimeoutTimer = new QTimer(this);
diagRequestTimeoutTimer->setInterval(1000*45);
@ -104,14 +107,20 @@ void DeviceControllerDiag::private_startDiag()
this->private_sendDiagEvent(DeviceController::State::E255);
this->isRequestRunning = false;
this->flagInterruptDiag = false;
if (this->E255counter > 5) {
this->restartCArun();
}
else {
this->E255counter++;
// try it again, until success:
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
/**
* But please note:
* - diag does currently not stop suspend (start a background task)
* - diag is called again in ModeOOO wokeup()
*/
// try it again, until success:
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
/**
* But please note:
* - diag does currently not stop suspend (start a background task)
* - diag is called again in ModeOOO wokeup()
*/
}
return;
}
@ -146,6 +155,8 @@ void DeviceControllerDiag::sys_superviseSystem()
this->private_sendDiagEvent(DeviceController::State::E255);
this->flagInterruptDiag = false;
this->isRequestRunning = false;
if (this->E255counter > 5) { this->restartCArun(); }
else { this->E255counter++; }
return;
}
@ -156,6 +167,8 @@ void DeviceControllerDiag::sys_superviseSystem()
this->private_sendDiagEvent(DeviceController::State::E254);
this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false;
if (this->E255counter > 5) { this->restartCArun(); }
else { this->E255counter++; }
return;
}
@ -168,7 +181,7 @@ void DeviceControllerDiag::sys_superviseSystem()
{
// noch keine Testergebnisse
if (dynMaCond.startupTestIsRunning) {
// TODO?
qCritical() << " startupTestIsRunning --> call again";
}
@ -599,3 +612,12 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
}
/**
* reset / restart / reinit deviceController
*/
void DeviceControllerDiag::restartCArun()
{
this->E255counter = 0;
QProcess::startDetached("/bin/systemctl", {"restart", "carun"});
}

View File

@ -94,6 +94,11 @@ public slots:
*/
void diagReInit();
/**
* reset / restart / reinit deviceController
*/
void restartCArun();
signals:
void diagResponse(ATBMachineEvent* machineEvent);
@ -118,6 +123,8 @@ private:
PersistentData* pData;
int E255counter;
private slots:
void onDiagRequestTimeoutTimerTimeout();
@ -126,7 +133,6 @@ private slots:
void sys_superviseSystem();
};
#endif // DEVICECONTROLLERDIAG_H