Send voltage Value as healthEvent

This commit is contained in:
Siegfried Siegert 2023-07-05 18:47:45 +02:00
parent 488152c37d
commit 334d67fd22
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
5 changed files with 50 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#include "src/ATBAPP/ATBHealthEvent.h"
#include "src/ATBAPP/ATBMachineEvent.h"
#include "src/ATBAPP/Utils.h"
#include "src/ATBAPP/support/JSON.h"
#include <QTimer>
#include <QTextCodec>
@ -47,6 +48,7 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
this->diag = new DeviceControllerDiag(this);
connect(this->diag, &DeviceControllerDiag::newVoltage, this, &ATBDeviceControllerPlugin::onNewVoltage);
this->currentSelectedTicketType = 0;
@ -345,6 +347,34 @@ void ATBDeviceControllerPlugin::onAllDoorsClosed()
emit this->requestModeIDLE();
}
void ATBDeviceControllerPlugin::onNewVoltage(uint32_t voltage)
{
qCritical() << "ATBDeviceControllerPlugin::onNewVoltage() = " << voltage;
QString voltageString = QString::number(voltage);
JSON::setPrettySerialize(true);
JSON::JsonObject json;
json = JSON::objectBuilder()
->set("Name", "batt")
->set("Value", voltageString)
->set("Unit", "V")
->create();
ATBHealthEvent *healthEvent = new ATBHealthEvent(
ATB_HEALTH_MODE::STATE,
"VOLTAGE",
JSON::serialize(json)
);
QCoreApplication::postEvent(eventReceiver, healthEvent);
}
// TASKS: printing ------------------------------------------------------------

View File

@ -79,7 +79,7 @@ public slots:
signals:
// public Signals are defined in interface
private:
@ -145,6 +145,9 @@ private slots:
void private_startAccount();
void private_checkAccountData();
void private_getAccountData();
// measurement values
void onNewVoltage(uint32_t voltage);
};
#endif // ATBDEVICECONTROLLERPLUGIN_H

View File

@ -161,6 +161,15 @@ uint8_t DeviceControllerDiag::sub_componentAssessment()
struct T_devices devPara;
hw->sys_restoreDeviceParameter(&devPara);
// store some interesting results:
// -> voltage:
uint32_t voltage = hw->dc_getVoltage();
emit newVoltage(voltage);
// check for invalid states:
if (modCond.rtc>=200)
return 1;
if (modCond.printer==200 || modCond.printer==201) // 200: not connected 201: printer-HW-error 202: no paper

View File

@ -22,6 +22,7 @@ public slots:
signals:
void diagResponse(ATBMachineEvent* machineEvent);
void newVoltage(uint32_t voltage);
private:
QObject *eventReceiver;
@ -35,6 +36,8 @@ private:
uint8_t sub_componentAssessment();
uint8_t sys_getSystemErrors();
int lastVoltage;
private slots:
void onDiagRequestTimeoutTimerTimeout();

View File

@ -135,6 +135,10 @@ signals:
*/
void requestAccountResponse(const QHash<QString, QVariant> & accountData);
/**
* emitted on error
* depending on errorCode: