Compare commits

...

4 Commits

4 changed files with 43 additions and 13 deletions

View File

@@ -24,7 +24,8 @@
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
: isMaster(false)
: currentProgramMode(PROGRAM_MODE::INIT)
, isMaster(false)
, pluginState(PLUGIN_STATE::NOT_INITIALIZED)
, eventReceiver(nullptr)
{
@@ -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;
}
@@ -1899,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();
}

View File

@@ -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;

View File

@@ -144,7 +144,7 @@ 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));
this->machineEventSet.remove(DCMachineEvent(DeviceController::State::M0255));
QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem);
}
else {
@@ -680,8 +680,8 @@ void DeviceControllerDiag::private_sendDiagEvent(DCMachineEvent result, DeviceCo
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;
}
@@ -722,10 +722,10 @@ void DeviceControllerDiag::restartCArun()
this->E255counter = 0;
DCMachineEvent W255Event = DCMachineEvent(DeviceController::State::W255);
if (!this->previousMachineEventSet.contains(W255Event)) {
machineEventSet.insert(W255Event);
private_sendDiagEvent(W255Event, DeviceController::Action::SET);
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"});

View File

@@ -49,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,
@@ -57,8 +58,6 @@ namespace DeviceController {
W003,
W004,
W255,
INITIAL_STATE
};
Q_ENUM_NS(State)