Compare commits
	
		
			29 Commits
		
	
	
		
			2.7.2
			...
			pu/account
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						7d5d3b4de0
	
				 | 
					
					
						|||
| 
						
						
							
						
						4a0418611e
	
				 | 
					
					
						|||
| 
						
						
							
						
						6a667d03ea
	
				 | 
					
					
						|||
| 
						
						
							
						
						232deb9245
	
				 | 
					
					
						|||
| 
						
						
							
						
						a87a4e6c14
	
				 | 
					
					
						|||
| 
						
						
							
						
						0467db23d1
	
				 | 
					
					
						|||
| 
						
						
							
						
						e1470d13f1
	
				 | 
					
					
						|||
| 
						
						
							
						
						1165c4b92f
	
				 | 
					
					
						|||
| 
						
						
							
						
						40acd0e0c4
	
				 | 
					
					
						|||
| 
						
						
							
						
						fe3696ce9c
	
				 | 
					
					
						|||
| 
						
						
							
						
						cc6dfee0e2
	
				 | 
					
					
						|||
| 
						
						
							
						
						91d8eb03b3
	
				 | 
					
					
						|||
| 
						
						
							
						
						3bef73ce4b
	
				 | 
					
					
						|||
| 
						
						
							
						
						8d03926de4
	
				 | 
					
					
						|||
| 
						
						
							
						
						b34716ef93
	
				 | 
					
					
						|||
| 
						
						
							
						
						f75f2c57df
	
				 | 
					
					
						|||
| 
						
						
							
						
						18a35acf20
	
				 | 
					
					
						|||
| 
						
						
							
						
						ccc2b8120d
	
				 | 
					
					
						|||
| 
						
						
							
						
						ccc1c6033f
	
				 | 
					
					
						|||
| 
						
						
							
						
						c23364874e
	
				 | 
					
					
						|||
| 
						
						
							
						
						1e5020132f
	
				 | 
					
					
						|||
| 
						
						
							
						
						6bd02f1831
	
				 | 
					
					
						|||
| 
						
						
							
						
						923bff1117
	
				 | 
					
					
						|||
| 
						
						
							
						
						12be31ee49
	
				 | 
					
					
						|||
| 
						
						
							
						
						f8757b352d
	
				 | 
					
					
						|||
| 
						
						
							
						
						4567aed6d1
	
				 | 
					
					
						|||
| 
						
						
							
						
						4df3a83126
	
				 | 
					
					
						|||
| 
						
						
							
						
						5c66abfd87
	
				 | 
					
					
						|||
| 
						
						
							
						
						efe56672ff
	
				 | 
					
					
						
@@ -27,6 +27,7 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
 | 
			
		||||
    : isMaster(false)
 | 
			
		||||
    , pluginState(PLUGIN_STATE::NOT_INITIALIZED)
 | 
			
		||||
    , eventReceiver(nullptr)
 | 
			
		||||
    , latestAccountNumber(0)
 | 
			
		||||
{
 | 
			
		||||
    this->setParent(parent);
 | 
			
		||||
 | 
			
		||||
@@ -133,7 +134,7 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
 | 
			
		||||
        qCritical() << "ATBDeviceControllerPlugin: Set printer encoding to " << printerEncoding;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this->diag->init(this->hw, this->eventReceiver);
 | 
			
		||||
    this->diag->init(this->hw, this->dbus, this->eventReceiver);
 | 
			
		||||
 | 
			
		||||
    this->pluginState = PLUGIN_STATE::INITIALIZED;
 | 
			
		||||
 | 
			
		||||
@@ -311,6 +312,12 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToOOO()
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::requestDiag()
 | 
			
		||||
{
 | 
			
		||||
    hw->dc_autoRequest(true);
 | 
			
		||||
    this->diag->diagRequest();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// TASKS: Cash handling -------------------------------------------------------
 | 
			
		||||
void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount)
 | 
			
		||||
@@ -477,13 +484,13 @@ void ATBDeviceControllerPlugin::private_startAccount()
 | 
			
		||||
 | 
			
		||||
    qsort( backupedAccNumbers, nrOfVals, sizeof (uint16_t), Utils::compare );
 | 
			
		||||
 | 
			
		||||
    uint16_t latestAccountNumber = backupedAccNumbers[nrOfVals-1];
 | 
			
		||||
    this->latestAccountNumber = backupedAccNumbers[nrOfVals-1];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // DEBUG
 | 
			
		||||
    qCritical() << "       latestAccountNumber = " << latestAccountNumber;
 | 
			
		||||
    qCritical() << "       latestAccountNumber = " << this->latestAccountNumber;
 | 
			
		||||
 | 
			
		||||
    hw->log_selectVaultRecord(latestAccountNumber);
 | 
			
		||||
    hw->log_selectVaultRecord(this->latestAccountNumber);
 | 
			
		||||
 | 
			
		||||
    this->accountCheckCounter = 0;
 | 
			
		||||
    QTimer::singleShot(500, this, SLOT(private_checkAccountData()));
 | 
			
		||||
@@ -506,11 +513,25 @@ void ATBDeviceControllerPlugin::private_checkAccountData()
 | 
			
		||||
            // cannot get accountData within ~10*500ms
 | 
			
		||||
            qCritical() << "checkAccountData() failed";
 | 
			
		||||
 | 
			
		||||
            // simulate:
 | 
			
		||||
            this->private_getAccountData();
 | 
			
		||||
            JSON::setPrettySerialize(false);
 | 
			
		||||
            JSON::JsonObject json = JSON::objectBuilder()
 | 
			
		||||
                      ->set("Error", QString("check account data failed"))
 | 
			
		||||
                      ->set("AccountNumber", this->latestAccountNumber)
 | 
			
		||||
                ->create();
 | 
			
		||||
            QString parameterJsonString = JSON::serialize(json);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            // TODO: create and send an HealthEvent...
 | 
			
		||||
            QString eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8);
 | 
			
		||||
            ATBMachineEvent *machineEvent = new ATBMachineEvent(
 | 
			
		||||
                        eventId,                           // id
 | 
			
		||||
                        "DC",                              // device name: PTU/PRINTER/DC/...
 | 
			
		||||
                        EVENT_CLASS::STATE,                // reason of event: Error/Warning/Alarm
 | 
			
		||||
                        "M01000",                          // eventName
 | 
			
		||||
                        1,                                 // state
 | 
			
		||||
                        parameterJsonString,               // parameter
 | 
			
		||||
                        "ACCOUNT"                          // second level info
 | 
			
		||||
                        );
 | 
			
		||||
            QCoreApplication::postEvent(this, machineEvent);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -527,6 +548,14 @@ void ATBDeviceControllerPlugin::private_getAccountData()
 | 
			
		||||
 | 
			
		||||
    QHash<QString, QVariant> accountData;
 | 
			
		||||
 | 
			
		||||
    if (this->latestAccountNumber != retVR.AccountingNumber) {
 | 
			
		||||
        // this is the wrong account! -> read again
 | 
			
		||||
        hw->log_selectVaultRecord(this->latestAccountNumber);
 | 
			
		||||
 | 
			
		||||
        QTimer::singleShot(500, this, SLOT(private_checkAccountData()));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    accountData.insert("AccountingNumber", QString::number(retVR.AccountingNumber));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -663,8 +692,6 @@ void ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()
 | 
			
		||||
{
 | 
			
		||||
    qCritical() << "ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()";
 | 
			
		||||
 | 
			
		||||
    this->diag->diagReInit();
 | 
			
		||||
 | 
			
		||||
    QTimer::singleShot(2000, this, SIGNAL(requestModeIDLE()));
 | 
			
		||||
 | 
			
		||||
    this->dbus->finishedBackgroundTask("DOOR_OPEN");
 | 
			
		||||
 
 | 
			
		||||
@@ -87,7 +87,7 @@ public slots:
 | 
			
		||||
    void reboot();
 | 
			
		||||
    void reset();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    void requestDiag();
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    // public Signals are defined in interface
 | 
			
		||||
@@ -130,6 +130,8 @@ private:
 | 
			
		||||
   // counts failed hw->log_chkIfVaultRecordAvailable()
 | 
			
		||||
   int accountCheckCounter;
 | 
			
		||||
 | 
			
		||||
   uint16_t latestAccountNumber;
 | 
			
		||||
 | 
			
		||||
   // counts faild hw->prn-getPrintResult()
 | 
			
		||||
   int printResultCheckCounter;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@
 | 
			
		||||
#include <QProcess>
 | 
			
		||||
 | 
			
		||||
#include "support/JSON.h"
 | 
			
		||||
#include "src/ATBAPP/support/DBusControllerInterface.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *parent)
 | 
			
		||||
@@ -17,6 +18,7 @@ DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *paren
 | 
			
		||||
    , eventReceiver(nullptr)
 | 
			
		||||
    , isRequestRunning(false)
 | 
			
		||||
    , flagInterruptDiag(false)
 | 
			
		||||
    , isDiagBackgroundTask(false)
 | 
			
		||||
    , lastState(DeviceController::State::INITIAL_STATE)
 | 
			
		||||
    , _isErrorState(false)
 | 
			
		||||
    , pData(pData)
 | 
			
		||||
@@ -29,10 +31,11 @@ DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *paren
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void DeviceControllerDiag::init(hwinf *hw, QObject* eventReceiver)
 | 
			
		||||
void DeviceControllerDiag::init(hwinf *hw, DBusControllerInterface *dbus, QObject* eventReceiver)
 | 
			
		||||
{
 | 
			
		||||
    this->hw = hw;
 | 
			
		||||
    this->eventReceiver = eventReceiver;
 | 
			
		||||
    this->dbus = dbus;
 | 
			
		||||
 | 
			
		||||
    // make a system check on startup:
 | 
			
		||||
    QTimer::singleShot(2000, this, &DeviceControllerDiag::diagRequest);
 | 
			
		||||
@@ -42,6 +45,7 @@ void DeviceControllerDiag::init(hwinf *hw, QObject* eventReceiver)
 | 
			
		||||
void DeviceControllerDiag::diagReInit()
 | 
			
		||||
{
 | 
			
		||||
    this->machineEventSet.clear();
 | 
			
		||||
    this->previousMachineEventSet.clear();
 | 
			
		||||
    this->_isErrorState = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -92,8 +96,11 @@ bool DeviceControllerDiag::isOperatingState()
 | 
			
		||||
    return !this->_isErrorState;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QSet<DeviceController::State> DeviceControllerDiag::getCurrentMachineState()
 | 
			
		||||
QSet<DCMachineEvent> DeviceControllerDiag::getCurrentMachineState()
 | 
			
		||||
{
 | 
			
		||||
    // ensure that currentMachineEventSet is delivered here
 | 
			
		||||
    if (this->isRequestRunning) return this->previousMachineEventSet;
 | 
			
		||||
 | 
			
		||||
    return this->machineEventSet;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -104,11 +111,15 @@ void DeviceControllerDiag::private_startDiag()
 | 
			
		||||
    // check for DiagRequestTimeoutTimerTimeout:
 | 
			
		||||
    if (this->flagInterruptDiag) {
 | 
			
		||||
        qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
 | 
			
		||||
        this->private_setDiagEvent(DeviceController::State::E255);
 | 
			
		||||
        this->isRequestRunning  = false;
 | 
			
		||||
        this->flagInterruptDiag = false;
 | 
			
		||||
        DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255);
 | 
			
		||||
        if (!this->previousMachineEventSet.contains(E255Event)) {
 | 
			
		||||
            machineEventSet.insert(E255Event);
 | 
			
		||||
            private_sendDiagEvent(E255Event, DeviceController::Action::SET);
 | 
			
		||||
        }
 | 
			
		||||
        if (this->E255counter > 5) {
 | 
			
		||||
            this->restartCArun();
 | 
			
		||||
            // try it again, until success:
 | 
			
		||||
            QTimer::singleShot(1000, this, &DeviceControllerDiag::diagRequest);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this->E255counter++;
 | 
			
		||||
@@ -121,6 +132,9 @@ void DeviceControllerDiag::private_startDiag()
 | 
			
		||||
             * - diag is called again in ModeOOO wokeup()
 | 
			
		||||
             */
 | 
			
		||||
        }
 | 
			
		||||
        this->diagRequestTimeoutTimer->stop();
 | 
			
		||||
        this->isRequestRunning  = false;
 | 
			
		||||
        this->flagInterruptDiag = false;
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -129,13 +143,21 @@ void DeviceControllerDiag::private_startDiag()
 | 
			
		||||
 | 
			
		||||
    if (result) {
 | 
			
		||||
        qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is valid";
 | 
			
		||||
        this->machineEventSet.remove(DCMachineEvent(DeviceController::State::E255));
 | 
			
		||||
        this->machineEventSet.remove(DCMachineEvent(DeviceController::State::W255));
 | 
			
		||||
        QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is +++not+++ valid";
 | 
			
		||||
 | 
			
		||||
        // try it again
 | 
			
		||||
        hw->dc_autoRequest(true);
 | 
			
		||||
 | 
			
		||||
        if (! this->isDiagBackgroundTask) {
 | 
			
		||||
            this->isDiagBackgroundTask = true;
 | 
			
		||||
            this->dbus->startBackgroundTask("E255");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // try it again
 | 
			
		||||
        QTimer::singleShot(200, this, &DeviceControllerDiag::private_startDiag);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -153,11 +175,18 @@ void DeviceControllerDiag::sys_superviseSystem()
 | 
			
		||||
    // check for DiagRequestTimeoutTimerTimeout:
 | 
			
		||||
    if (this->flagInterruptDiag) {
 | 
			
		||||
        qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!";
 | 
			
		||||
        this->private_setDiagEvent(DeviceController::State::E255);
 | 
			
		||||
        this->flagInterruptDiag = false;
 | 
			
		||||
        this->isRequestRunning  = false;
 | 
			
		||||
        // send
 | 
			
		||||
        DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255);
 | 
			
		||||
        if (!this->previousMachineEventSet.contains(E255Event)) {
 | 
			
		||||
            machineEventSet.insert(E255Event);
 | 
			
		||||
            private_sendDiagEvent(E255Event, DeviceController::Action::SET);
 | 
			
		||||
        }
 | 
			
		||||
        if (this->E255counter > 5) { this->restartCArun(); }
 | 
			
		||||
                              else { this->E255counter++; }
 | 
			
		||||
        QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
 | 
			
		||||
        this->diagRequestTimeoutTimer->stop();
 | 
			
		||||
        this->isRequestRunning  = false;
 | 
			
		||||
        this->flagInterruptDiag = false;
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -166,11 +195,17 @@ void DeviceControllerDiag::sys_superviseSystem()
 | 
			
		||||
        // es gibt keinerlei gültige Daten vom DC
 | 
			
		||||
        qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
 | 
			
		||||
        hw->dc_autoRequest(true);
 | 
			
		||||
        this->private_setDiagEvent(DeviceController::State::M0254);
 | 
			
		||||
        this->diagRequestTimeoutTimer->stop();
 | 
			
		||||
        this->isRequestRunning  = false;
 | 
			
		||||
 | 
			
		||||
        DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::M0254);
 | 
			
		||||
        previousMachineEventSet.insert(E255Event);
 | 
			
		||||
        private_sendDiagEvent(E255Event, DeviceController::Action::SET);
 | 
			
		||||
 | 
			
		||||
        if (this->E255counter > 5) { this->restartCArun(); }
 | 
			
		||||
                              else { this->E255counter++; }
 | 
			
		||||
        QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
 | 
			
		||||
        this->diagRequestTimeoutTimer->stop();
 | 
			
		||||
        this->isRequestRunning  = false;
 | 
			
		||||
        this->flagInterruptDiag = false;
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -202,6 +237,8 @@ void DeviceControllerDiag::sys_superviseSystem()
 | 
			
		||||
 | 
			
		||||
void DeviceControllerDiag::sub_componentAssessment()
 | 
			
		||||
{
 | 
			
		||||
    this->machineEventSet.clear();
 | 
			
		||||
 | 
			
		||||
    bool flag_sendOperate = true;
 | 
			
		||||
 | 
			
		||||
    struct T_moduleCondition modCond = {};
 | 
			
		||||
@@ -401,42 +438,69 @@ void DeviceControllerDiag::sub_componentAssessment()
 | 
			
		||||
        this->private_setDiagEvent(DeviceController::State::W004);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (flag_sendOperate) {
 | 
			
		||||
        this->private_setDiagEvent(DeviceController::State::O000);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // compare machineEventSets
 | 
			
		||||
    // New events: present in current but not previous
 | 
			
		||||
    QSet<DeviceController::State> newEvents = this->machineEventSet - this->previousMachineEventSet;
 | 
			
		||||
    QSet<DCMachineEvent> newEvents = this->machineEventSet - this->previousMachineEventSet;
 | 
			
		||||
 | 
			
		||||
    // Reset events: present in previous but not current
 | 
			
		||||
    QSet<DeviceController::State> resetEvents = this->previousMachineEventSet - this->machineEventSet;
 | 
			
		||||
    QSet<DCMachineEvent> resetEvents = this->previousMachineEventSet - this->machineEventSet;
 | 
			
		||||
 | 
			
		||||
    // DEBUG EventSets:
 | 
			
		||||
    qCritical() << "sub_componentAssessment():";
 | 
			
		||||
    qCritical() << "    newEvents: " << newEvents.size();
 | 
			
		||||
    qCritical() << "  resetEvents: " << resetEvents.size();
 | 
			
		||||
    QStringList DeviceControllerStateStringList;
 | 
			
		||||
    for (const DCMachineEvent& event : this->machineEventSet) {
 | 
			
		||||
        DeviceControllerStateStringList.append(QMetaEnum::fromType<DeviceController::State>().valueToKey(event.state));
 | 
			
		||||
    }
 | 
			
		||||
    qCritical() << "diagReq result: " << DeviceControllerStateStringList;
 | 
			
		||||
 | 
			
		||||
    // Triggering Actions
 | 
			
		||||
    // Iterate through the results
 | 
			
		||||
    for (const DeviceController::State& event : newEvents) {
 | 
			
		||||
    // send SET:
 | 
			
		||||
    for (const DCMachineEvent& event : newEvents) {
 | 
			
		||||
        private_sendDiagEvent(event, DeviceController::Action::SET);  // New event detected
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Proposal: send reset
 | 
			
		||||
    /*
 | 
			
		||||
    for (const DeviceController::State& event : resetEvents) {
 | 
			
		||||
    // send RESET:
 | 
			
		||||
    for (const DCMachineEvent& event : resetEvents) {
 | 
			
		||||
        private_sendDiagEvent(event, DeviceController::Action::RESET);  // Event no longer present
 | 
			
		||||
    }
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
    // send Operate if there is no error
 | 
			
		||||
    if (flag_sendOperate) {
 | 
			
		||||
        // O000 must not be part of machineEventSet
 | 
			
		||||
        DCMachineEvent O000DCMachineEvent = DCMachineEvent(DeviceController::State::O000);
 | 
			
		||||
        this->private_sendDiagEvent(O000DCMachineEvent, DeviceController::Action::SET);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // finish diag
 | 
			
		||||
    this->private_finishDiag();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief DeviceControllerDiag::private_finishDiag
 | 
			
		||||
 *
 | 
			
		||||
 * Single point to finish a diag process:
 | 
			
		||||
 *  -
 | 
			
		||||
 */
 | 
			
		||||
void DeviceControllerDiag::private_finishDiag()
 | 
			
		||||
{
 | 
			
		||||
    this->diagRequestTimeoutTimer->stop();
 | 
			
		||||
    this->isRequestRunning  = false;
 | 
			
		||||
    this->flagInterruptDiag = false;
 | 
			
		||||
 | 
			
		||||
    this->previousMachineEventSet = machineEventSet;
 | 
			
		||||
    this->machineEventSet.clear();
 | 
			
		||||
    this->previousMachineEventSet.unite(machineEventSet);      // add new elements from machineEventSet
 | 
			
		||||
    this->previousMachineEventSet.intersect(machineEventSet);  // remove elements not in machineEventSet
 | 
			
		||||
 | 
			
		||||
    if (this->isDiagBackgroundTask) {
 | 
			
		||||
        this->isDiagBackgroundTask = false;
 | 
			
		||||
        this->dbus->finishedBackgroundTask("E255");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -457,18 +521,29 @@ void DeviceControllerDiag::private_setDiagEvent(DeviceController::State result)
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    machineEventSet.insert(result);
 | 
			
		||||
    DCMachineEvent newState = DCMachineEvent(result);
 | 
			
		||||
 | 
			
		||||
    // DEBUG
 | 
			
		||||
    qCritical() << "----> setDiagEvent: " << newState.state << " with id: " << newState.eventId;
 | 
			
		||||
 | 
			
		||||
    machineEventSet.insert(newState);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result, DeviceController::Action action)
 | 
			
		||||
{
 | 
			
		||||
    QString eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8);
 | 
			
		||||
 | 
			
		||||
    QString eventName = QMetaEnum::fromType<DeviceController::State>().valueToKey(result);;
 | 
			
		||||
/**
 | 
			
		||||
 * @brief DeviceControllerDiag::private_sendDiagEvent
 | 
			
		||||
 * @param result   WXXX | EXXX | O000
 | 
			
		||||
 * @param action   SET|RESET
 | 
			
		||||
 */
 | 
			
		||||
void DeviceControllerDiag::private_sendDiagEvent(DCMachineEvent result, DeviceController::Action action)
 | 
			
		||||
{
 | 
			
		||||
    QString eventId = result.eventId;
 | 
			
		||||
 | 
			
		||||
    QString eventName = QMetaEnum::fromType<DeviceController::State>().valueToKey(result.state);
 | 
			
		||||
    EVENT_CLASS eventClass = EVENT_CLASS::STATE;
 | 
			
		||||
    QString parameter;
 | 
			
		||||
    switch (result) {
 | 
			
		||||
    switch (result.state) {
 | 
			
		||||
 | 
			
		||||
    case DeviceController::State::INITIAL_STATE:
 | 
			
		||||
        break;
 | 
			
		||||
@@ -577,7 +652,6 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result,
 | 
			
		||||
        parameter  = "no valid data from DeviceController";
 | 
			
		||||
        break;
 | 
			
		||||
    case DeviceController::State::O000:   // everything is fine
 | 
			
		||||
        this->machineEventSet.clear();
 | 
			
		||||
        this->_isErrorState = false;
 | 
			
		||||
        eventClass = EVENT_CLASS::OPERATE;
 | 
			
		||||
        parameter  = "";
 | 
			
		||||
@@ -612,7 +686,7 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result,
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this->lastState = result;
 | 
			
		||||
    this->lastState = result.state;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Variant: send 'parameter' as JSON:
 | 
			
		||||
@@ -646,6 +720,27 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result,
 | 
			
		||||
void DeviceControllerDiag::restartCArun()
 | 
			
		||||
{
 | 
			
		||||
    this->E255counter = 0;
 | 
			
		||||
    this->private_setDiagEvent(DeviceController::State::W255);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    DCMachineEvent W255Event = DCMachineEvent(DeviceController::State::W255);
 | 
			
		||||
    if (!this->previousMachineEventSet.contains(W255Event)) {
 | 
			
		||||
        machineEventSet.insert(W255Event);
 | 
			
		||||
        private_sendDiagEvent(W255Event, DeviceController::Action::SET);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QProcess::startDetached("/bin/systemctl", {"restart", "carun"});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/****************************************************************************************************
 | 
			
		||||
 *
 | 
			
		||||
 *                                 DCMachineEvent
 | 
			
		||||
 */
 | 
			
		||||
DCMachineEvent::DCMachineEvent(DeviceController::State state) : state(state)
 | 
			
		||||
{
 | 
			
		||||
    this->eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@
 | 
			
		||||
 | 
			
		||||
#include "support/PersistentData.h"
 | 
			
		||||
 | 
			
		||||
class DBusControllerInterface;
 | 
			
		||||
 | 
			
		||||
namespace DeviceController {
 | 
			
		||||
    Q_NAMESPACE
 | 
			
		||||
@@ -72,6 +73,30 @@ namespace DeviceController {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// ----------------------------- DCMachineEvent -----------------------------------------
 | 
			
		||||
 | 
			
		||||
class DCMachineEvent {
 | 
			
		||||
public:
 | 
			
		||||
    DCMachineEvent() = default;
 | 
			
		||||
    DCMachineEvent(DeviceController::State state);
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
@@ -79,7 +104,7 @@ class DeviceControllerDiag : public QObject
 | 
			
		||||
public:
 | 
			
		||||
    DeviceControllerDiag(PersistentData *pData, QObject *parent = nullptr);
 | 
			
		||||
 | 
			
		||||
    void init(hwinf* hw, QObject* eventReceiver);
 | 
			
		||||
    void init(hwinf* hw, DBusControllerInterface *dbus, QObject* eventReceiver);
 | 
			
		||||
 | 
			
		||||
    nsDeviceControllerInterface::COIN_PROCESSOR coinProcessorType;
 | 
			
		||||
    nsDeviceControllerInterface::BILL_ACCEPTOR  billAcceptor;
 | 
			
		||||
@@ -89,7 +114,7 @@ public:
 | 
			
		||||
     */
 | 
			
		||||
    bool isErrorState();
 | 
			
		||||
    bool isOperatingState();
 | 
			
		||||
    QSet<DeviceController::State> getCurrentMachineState();
 | 
			
		||||
    QSet<DCMachineEvent> getCurrentMachineState();
 | 
			
		||||
 | 
			
		||||
    void setTimeout(int timeout);
 | 
			
		||||
 | 
			
		||||
@@ -118,9 +143,11 @@ signals:
 | 
			
		||||
private:
 | 
			
		||||
    QObject *eventReceiver;
 | 
			
		||||
    hwinf* hw;
 | 
			
		||||
    DBusControllerInterface* dbus;
 | 
			
		||||
 | 
			
		||||
    bool isRequestRunning;
 | 
			
		||||
    bool flagInterruptDiag;
 | 
			
		||||
    bool isDiagBackgroundTask;
 | 
			
		||||
 | 
			
		||||
    QTimer *diagRequestTimeoutTimer;
 | 
			
		||||
 | 
			
		||||
@@ -129,8 +156,8 @@ private:
 | 
			
		||||
    int lastVoltage;
 | 
			
		||||
 | 
			
		||||
    DeviceController::State lastState;
 | 
			
		||||
    QSet<DeviceController::State> machineEventSet;
 | 
			
		||||
    QSet<DeviceController::State> previousMachineEventSet;
 | 
			
		||||
    QSet<DCMachineEvent> machineEventSet;
 | 
			
		||||
    QSet<DCMachineEvent> previousMachineEventSet;
 | 
			
		||||
    bool _isErrorState;
 | 
			
		||||
 | 
			
		||||
    PersistentData* pData;
 | 
			
		||||
@@ -142,7 +169,9 @@ private slots:
 | 
			
		||||
 | 
			
		||||
    void private_startDiag();                                    // diag entry method
 | 
			
		||||
    void private_setDiagEvent(DeviceController::State result);
 | 
			
		||||
    void private_sendDiagEvent(DeviceController::State result, DeviceController::Action action);
 | 
			
		||||
    void private_sendDiagEvent(DCMachineEvent result, DeviceController::Action action);
 | 
			
		||||
 | 
			
		||||
    void private_finishDiag();
 | 
			
		||||
 | 
			
		||||
    void sys_superviseSystem();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -104,6 +104,9 @@ public slots:
 | 
			
		||||
    virtual void reboot() = 0;
 | 
			
		||||
    virtual void reset() = 0;
 | 
			
		||||
 | 
			
		||||
    virtual void requestDiag() = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
 | 
			
		||||
@@ -213,7 +216,7 @@ signals:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_INTERFACE(DeviceControllerInterface,
 | 
			
		||||
                    "eu.atb.ptu.plugin.DeviceControllerInterface/1.2.1")
 | 
			
		||||
                    "eu.atb.ptu.plugin.DeviceControllerInterface/1.2.2")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace nsDeviceControllerInterface {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user