DCPlugin/src/ATBAPP/DeviceControllerDiag.h
Siegfried Siegert 4567aed6d1
Introduce DCMachineEvent ...
... this is an DC-Plugin internal data-structure which can be
transformed to an ATBMachineEvent and sent to ISMAS.

DCMachineEvent is in fact a couple ot DeviceController::State and a
QString eventID.

Thi eventID is necessary to send a state-reset to ISMAS. ISMAS needs
same enventID for set- and reset Events.
2025-06-11 09:55:25 +02:00

179 lines
3.5 KiB
C++

#ifndef DEVICECONTROLLERDIAG_H
#define DEVICECONTROLLERDIAG_H
#include <QObject>
#include <QSet>
#include <QTimer>
#include <DeviceController/interfaces.h>
#include "DeviceControllerInterface.h"
#include "ATBMachineEvent.h"
#include "support/PersistentData.h"
class DBusControllerInterface;
namespace DeviceController {
Q_NAMESPACE
enum State {
O000,
A000,
E002,
E003,
E004,
E007,
E008,
E009,
E010,
W010, // Coin Escrow
E011,
E018,
E020,
E025,
E026,
E034,
M0071, // cashbox change is ongoing
M0072, // cardtest is running
M0073, // startup-test is running
M0252, // cashbox door open
M0253, // service or battery door is open
M0254, // no valid data from DC
E255,
W001,
W002,
W003,
W004,
W255,
INITIAL_STATE
};
Q_ENUM_NS(State)
enum Action {
SET = 1,
RESET = 0
};
Q_ENUM_NS(Action)
}
// ----------------------------- DCMachineEvent -----------------------------------------
class DCMachineEvent {
public:
DCMachineEvent() = default;
DCMachineEvent(DeviceController::State state, const QString& id) : state(state), eventId(id) {}
DeviceController::State state;
QString eventId;
// Equality operator (required for QSet)
bool operator==(const DCMachineEvent& other) const {
return (state == other.state);
}
};
// Hash function (required for QSet)
inline uint qHash(const DCMachineEvent& key, uint seed = 0) {
return qHash(static_cast<int>(key.state), seed);
}
// ------------------------ DeviceControllerDiag --------------------------------------
class DeviceControllerDiag : public QObject
{
Q_OBJECT
public:
DeviceControllerDiag(PersistentData *pData, QObject *parent = nullptr);
void init(hwinf* hw, DBusControllerInterface *dbus, QObject* eventReceiver);
nsDeviceControllerInterface::COIN_PROCESSOR coinProcessorType;
nsDeviceControllerInterface::BILL_ACCEPTOR billAcceptor;
/**
* return true, if machineEventSet contains an error
*/
bool isErrorState();
bool isOperatingState();
QSet<DCMachineEvent> getCurrentMachineState();
void setTimeout(int timeout);
public slots:
/**
* start diag request
*/
void diagRequest();
/**
* reset / re-init diag request.
* Called e.g. when doors are closed.
*/
void diagReInit();
/**
* reset / restart / reinit deviceController
*/
void restartCArun();
signals:
void diagResponse(ATBMachineEvent* machineEvent);
void newVoltage(uint32_t voltage);
private:
QObject *eventReceiver;
hwinf* hw;
DBusControllerInterface* dbus;
bool isRequestRunning;
bool flagInterruptDiag;
bool isDiagBackgroundTask;
QTimer *diagRequestTimeoutTimer;
void sub_componentAssessment(); // diag exit method
int lastVoltage;
DeviceController::State lastState;
QSet<DCMachineEvent> machineEventSet;
QSet<DCMachineEvent> previousMachineEventSet;
bool _isErrorState;
PersistentData* pData;
int E255counter;
private slots:
void onDiagRequestTimeoutTimerTimeout();
void private_startDiag(); // diag entry method
void private_setDiagEvent(DeviceController::State result);
void private_sendDiagEvent(DCMachineEvent result, DeviceController::Action action);
void sys_superviseSystem();
};
#endif // DEVICECONTROLLERDIAG_H