Compare commits
	
		
			33 Commits
		
	
	
		
			2.7.2
			...
			pu/integra
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						eb33c4e920
	
				 | 
					
					
						|||
| 
						
						
							
						
						26c2120743
	
				 | 
					
					
						|||
| 
						
						
							
						
						2452499073
	
				 | 
					
					
						|||
| 
						
						
							
						
						420ca94f41
	
				 | 
					
					
						|||
| 
						
						
							
						
						5fef45ba3e
	
				 | 
					
					
						|||
| 
						
						
							
						
						5c40e088aa
	
				 | 
					
					
						|||
| 
						
						
							
						
						577411289e
	
				 | 
					
					
						|||
| 
						
						
							
						
						cc27b982ff
	
				 | 
					
					
						|||
| 
						
						
							
						
						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
	
				 | 
					
					
						
@@ -24,7 +24,8 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
 | 
			
		||||
    : isMaster(false)
 | 
			
		||||
    : currentProgramMode(PROGRAM_MODE::INIT)
 | 
			
		||||
    , isMaster(false)
 | 
			
		||||
    , pluginState(PLUGIN_STATE::NOT_INITIALIZED)
 | 
			
		||||
    , eventReceiver(nullptr)
 | 
			
		||||
{
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
@@ -290,12 +291,14 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
 | 
			
		||||
    hw->dc_autoRequest(true);
 | 
			
		||||
    hw->rtc_setDateTime();
 | 
			
		||||
    hw->mdb_switchWake(0);   // wakeup MDB components
 | 
			
		||||
    this->currentProgramMode = PROGRAM_MODE::SELL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE()
 | 
			
		||||
{    
 | 
			
		||||
    hw->dc_autoRequest(true);
 | 
			
		||||
    hw->mdb_switchWake(0);   // wakeup MDB components
 | 
			
		||||
    this->currentProgramMode = PROGRAM_MODE::SERVICE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
 | 
			
		||||
@@ -303,12 +306,19 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
 | 
			
		||||
    hw->dc_autoRequest(true);
 | 
			
		||||
    this->diag->diagRequest();
 | 
			
		||||
    hw->mdb_switchWake(1);
 | 
			
		||||
    this->currentProgramMode = PROGRAM_MODE::IDLE;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::onChangedProgramModeToOOO()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    // trigger diagRequest on SERVICE -> IDLE
 | 
			
		||||
    if (this->currentProgramMode == PROGRAM_MODE::SERVICE) {
 | 
			
		||||
        hw->dc_autoRequest(true);
 | 
			
		||||
        this->diag->diagRequest();
 | 
			
		||||
        hw->mdb_switchWake(1);
 | 
			
		||||
    }
 | 
			
		||||
    this->currentProgramMode = PROGRAM_MODE::OOO;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -663,8 +673,6 @@ void ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()
 | 
			
		||||
{
 | 
			
		||||
    qCritical() << "ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()";
 | 
			
		||||
 | 
			
		||||
    this->diag->diagReInit();
 | 
			
		||||
 | 
			
		||||
    QTimer::singleShot(2000, this, SIGNAL(requestModeIDLE()));
 | 
			
		||||
 | 
			
		||||
    this->dbus->finishedBackgroundTask("DOOR_OPEN");
 | 
			
		||||
@@ -1901,8 +1909,17 @@ int ATBDeviceControllerPlugin::init_sc_dbus()
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::onWokeUp(uchar source)
 | 
			
		||||
{
 | 
			
		||||
    if (source == 0x01 || source == 0xFE) {
 | 
			
		||||
        // woke up from device controller
 | 
			
		||||
    /* PTU5 wakeup sources:
 | 
			
		||||
     *    0x01 - on wakeup from DeviceController
 | 
			
		||||
     *    0x02 - on wakeup from WakeupButton
 | 
			
		||||
     *    0x03 - on wakeup from ResetKey
 | 
			
		||||
     *    0x04 - on wakeup from rtc
 | 
			
		||||
     *    0xFE - signal emitted by timer (on mains powered machines)
 | 
			
		||||
     *    0xFF - unknown wakeup source
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    if (source == 0x01 || source == 0x03 || source == 0xFE) {
 | 
			
		||||
        // woke up from device controller, rtc or timer
 | 
			
		||||
        hw->dc_autoRequest(true);
 | 
			
		||||
        this->diag->diagRequest();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,16 @@ using namespace nsDeviceControllerInterface;
 | 
			
		||||
 | 
			
		||||
class QSettings;
 | 
			
		||||
 | 
			
		||||
enum class PROGRAM_MODE {
 | 
			
		||||
    INIT,
 | 
			
		||||
    IDLE,
 | 
			
		||||
    SELL,
 | 
			
		||||
    SERVICE,
 | 
			
		||||
    OOO,
 | 
			
		||||
    NOT_DEFINED
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ATBDeviceControllerPlugin :
 | 
			
		||||
        public DeviceControllerInterface
 | 
			
		||||
@@ -100,6 +110,8 @@ private:
 | 
			
		||||
 | 
			
		||||
   QString serialPortName;
 | 
			
		||||
 | 
			
		||||
   PROGRAM_MODE currentProgramMode;
 | 
			
		||||
 | 
			
		||||
   bool useDebug;
 | 
			
		||||
 | 
			
		||||
   bool isMaster;
 | 
			
		||||
 
 | 
			
		||||
@@ -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)) {
 | 
			
		||||
            this->private_setDiagEvent(DeviceController::State::E255);
 | 
			
		||||
            this->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->private_finishDiag(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::M0255));
 | 
			
		||||
        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,19 @@ 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)) {
 | 
			
		||||
            this->private_setDiagEvent(DeviceController::State::E255);
 | 
			
		||||
            this->private_sendDiagEvent(E255Event, DeviceController::Action::SET);
 | 
			
		||||
        }
 | 
			
		||||
        if (this->E255counter > 5) { this->restartCArun(); }
 | 
			
		||||
                              else { this->E255counter++; }
 | 
			
		||||
 | 
			
		||||
        QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
 | 
			
		||||
 | 
			
		||||
        this->private_finishDiag(false);
 | 
			
		||||
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -166,11 +196,15 @@ void DeviceControllerDiag::sys_superviseSystem()
 | 
			
		||||
        // es gibt keinerlei gültige Daten vom DC
 | 
			
		||||
        qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
 | 
			
		||||
        hw->dc_autoRequest(true);
 | 
			
		||||
 | 
			
		||||
        DCMachineEvent M0254Event = DCMachineEvent(DeviceController::State::M0254);
 | 
			
		||||
        this->private_setDiagEvent(DeviceController::State::M0254);
 | 
			
		||||
        this->diagRequestTimeoutTimer->stop();
 | 
			
		||||
        this->isRequestRunning  = false;
 | 
			
		||||
        this->private_sendDiagEvent(M0254Event, DeviceController::Action::SET);
 | 
			
		||||
 | 
			
		||||
        if (this->E255counter > 5) { this->restartCArun(); }
 | 
			
		||||
                              else { this->E255counter++; }
 | 
			
		||||
        QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
 | 
			
		||||
        this->private_finishDiag(false);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -202,6 +236,8 @@ void DeviceControllerDiag::sys_superviseSystem()
 | 
			
		||||
 | 
			
		||||
void DeviceControllerDiag::sub_componentAssessment()
 | 
			
		||||
{
 | 
			
		||||
    this->machineEventSet.clear();
 | 
			
		||||
 | 
			
		||||
    bool flag_sendOperate = true;
 | 
			
		||||
 | 
			
		||||
    struct T_moduleCondition modCond = {};
 | 
			
		||||
@@ -401,44 +437,77 @@ 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(true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief DeviceControllerDiag::private_finishDiag
 | 
			
		||||
 *
 | 
			
		||||
 * Single point to finish a diag process:
 | 
			
		||||
 *  -
 | 
			
		||||
 */
 | 
			
		||||
void DeviceControllerDiag::private_finishDiag(bool dataValid)
 | 
			
		||||
{
 | 
			
		||||
    this->diagRequestTimeoutTimer->stop();
 | 
			
		||||
    this->isRequestRunning  = false;
 | 
			
		||||
    this->flagInterruptDiag = false;
 | 
			
		||||
 | 
			
		||||
    this->previousMachineEventSet = machineEventSet;
 | 
			
		||||
    this->machineEventSet.clear();
 | 
			
		||||
    // add new elements from machineEventSet
 | 
			
		||||
    this->previousMachineEventSet.unite(machineEventSet);
 | 
			
		||||
 | 
			
		||||
    if (dataValid) {
 | 
			
		||||
        // remove elements not in machineEventSet
 | 
			
		||||
        // ... only if data is valid
 | 
			
		||||
        this->previousMachineEventSet.intersect(machineEventSet);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (this->isDiagBackgroundTask) {
 | 
			
		||||
        this->isDiagBackgroundTask = false;
 | 
			
		||||
        this->dbus->finishedBackgroundTask("E255");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief DeviceControllerDiag::private_setDiagEvent
 | 
			
		||||
 * @param result - result value from 'sub_componentAssessment()',
 | 
			
		||||
@@ -457,18 +526,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 +657,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  = "";
 | 
			
		||||
@@ -606,13 +685,13 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result,
 | 
			
		||||
        eventClass = EVENT_CLASS::WARNING;
 | 
			
		||||
        parameter  = "temperatur warning";
 | 
			
		||||
        break;
 | 
			
		||||
    case DeviceController::State::W255:   // restart carun
 | 
			
		||||
        eventClass = EVENT_CLASS::WARNING;
 | 
			
		||||
    case DeviceController::State::M0255:   // restart carun
 | 
			
		||||
        eventClass = EVENT_CLASS::STATE;
 | 
			
		||||
        parameter  = "restart carun";
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this->lastState = result;
 | 
			
		||||
    this->lastState = result.state;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Variant: send 'parameter' as JSON:
 | 
			
		||||
@@ -646,6 +725,27 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result,
 | 
			
		||||
void DeviceControllerDiag::restartCArun()
 | 
			
		||||
{
 | 
			
		||||
    this->E255counter = 0;
 | 
			
		||||
    this->private_setDiagEvent(DeviceController::State::W255);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    DCMachineEvent M0255Event = DCMachineEvent(DeviceController::State::M0255);
 | 
			
		||||
    if (!this->previousMachineEventSet.contains(M0255Event)) {
 | 
			
		||||
        machineEventSet.insert(M0255Event);
 | 
			
		||||
        private_sendDiagEvent(M0255Event, 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
 | 
			
		||||
@@ -48,6 +49,7 @@ namespace DeviceController {
 | 
			
		||||
        M0252, // cashbox door open
 | 
			
		||||
        M0253, // service or battery door is open
 | 
			
		||||
        M0254, // no valid data from DC
 | 
			
		||||
        M0255, // restart carun
 | 
			
		||||
 | 
			
		||||
        E255,
 | 
			
		||||
 | 
			
		||||
@@ -56,8 +58,6 @@ namespace DeviceController {
 | 
			
		||||
        W003,
 | 
			
		||||
        W004,
 | 
			
		||||
 | 
			
		||||
        W255,
 | 
			
		||||
 | 
			
		||||
        INITIAL_STATE
 | 
			
		||||
    };
 | 
			
		||||
    Q_ENUM_NS(State)
 | 
			
		||||
@@ -72,6 +72,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 +103,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 +113,7 @@ public:
 | 
			
		||||
     */
 | 
			
		||||
    bool isErrorState();
 | 
			
		||||
    bool isOperatingState();
 | 
			
		||||
    QSet<DeviceController::State> getCurrentMachineState();
 | 
			
		||||
    QSet<DCMachineEvent> getCurrentMachineState();
 | 
			
		||||
 | 
			
		||||
    void setTimeout(int timeout);
 | 
			
		||||
 | 
			
		||||
@@ -118,9 +142,11 @@ signals:
 | 
			
		||||
private:
 | 
			
		||||
    QObject *eventReceiver;
 | 
			
		||||
    hwinf* hw;
 | 
			
		||||
    DBusControllerInterface* dbus;
 | 
			
		||||
 | 
			
		||||
    bool isRequestRunning;
 | 
			
		||||
    bool flagInterruptDiag;
 | 
			
		||||
    bool isDiagBackgroundTask;
 | 
			
		||||
 | 
			
		||||
    QTimer *diagRequestTimeoutTimer;
 | 
			
		||||
 | 
			
		||||
@@ -129,8 +155,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 +168,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(bool dataValid = false);
 | 
			
		||||
 | 
			
		||||
    void sys_superviseSystem();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user