Compare commits
4 Commits
pu/integra
...
pu/account
Author | SHA1 | Date | |
---|---|---|---|
7d5d3b4de0
|
|||
4a0418611e
|
|||
6a667d03ea
|
|||
232deb9245
|
@@ -24,10 +24,10 @@
|
||||
|
||||
|
||||
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
|
||||
: currentProgramMode(PROGRAM_MODE::INIT)
|
||||
, isMaster(false)
|
||||
: isMaster(false)
|
||||
, pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
||||
, eventReceiver(nullptr)
|
||||
, latestAccountNumber(0)
|
||||
{
|
||||
this->setParent(parent);
|
||||
|
||||
@@ -291,14 +291,12 @@ 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()
|
||||
@@ -306,19 +304,18 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::requestDiag()
|
||||
{
|
||||
hw->dc_autoRequest(true);
|
||||
this->diag->diagRequest();
|
||||
}
|
||||
|
||||
|
||||
@@ -487,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()));
|
||||
@@ -516,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,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));
|
||||
|
||||
|
||||
@@ -1909,17 +1928,8 @@ int ATBDeviceControllerPlugin::init_sc_dbus()
|
||||
|
||||
void ATBDeviceControllerPlugin::onWokeUp(uchar source)
|
||||
{
|
||||
/* 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
|
||||
if (source == 0x01 || source == 0xFE) {
|
||||
// woke up from device controller
|
||||
hw->dc_autoRequest(true);
|
||||
this->diag->diagRequest();
|
||||
}
|
||||
|
@@ -25,16 +25,6 @@ using namespace nsDeviceControllerInterface;
|
||||
|
||||
class QSettings;
|
||||
|
||||
enum class PROGRAM_MODE {
|
||||
INIT,
|
||||
IDLE,
|
||||
SELL,
|
||||
SERVICE,
|
||||
OOO,
|
||||
NOT_DEFINED
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ATBDeviceControllerPlugin :
|
||||
public DeviceControllerInterface
|
||||
@@ -97,7 +87,7 @@ public slots:
|
||||
void reboot();
|
||||
void reset();
|
||||
|
||||
|
||||
void requestDiag();
|
||||
|
||||
signals:
|
||||
// public Signals are defined in interface
|
||||
@@ -110,8 +100,6 @@ private:
|
||||
|
||||
QString serialPortName;
|
||||
|
||||
PROGRAM_MODE currentProgramMode;
|
||||
|
||||
bool useDebug;
|
||||
|
||||
bool isMaster;
|
||||
@@ -142,6 +130,8 @@ private:
|
||||
// counts failed hw->log_chkIfVaultRecordAvailable()
|
||||
int accountCheckCounter;
|
||||
|
||||
uint16_t latestAccountNumber;
|
||||
|
||||
// counts faild hw->prn-getPrintResult()
|
||||
int printResultCheckCounter;
|
||||
|
||||
|
@@ -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::M0255));
|
||||
this->machineEventSet.remove(DCMachineEvent(DeviceController::State::W255));
|
||||
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::M0255: // restart carun
|
||||
eventClass = EVENT_CLASS::STATE;
|
||||
case DeviceController::State::W255: // restart carun
|
||||
eventClass = EVENT_CLASS::WARNING;
|
||||
parameter = "restart carun";
|
||||
break;
|
||||
}
|
||||
@@ -722,10 +722,10 @@ void DeviceControllerDiag::restartCArun()
|
||||
this->E255counter = 0;
|
||||
|
||||
|
||||
DCMachineEvent M0255Event = DCMachineEvent(DeviceController::State::M0255);
|
||||
if (!this->previousMachineEventSet.contains(M0255Event)) {
|
||||
machineEventSet.insert(M0255Event);
|
||||
private_sendDiagEvent(M0255Event, DeviceController::Action::SET);
|
||||
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"});
|
||||
|
@@ -49,7 +49,6 @@ namespace DeviceController {
|
||||
M0252, // cashbox door open
|
||||
M0253, // service or battery door is open
|
||||
M0254, // no valid data from DC
|
||||
M0255, // restart carun
|
||||
|
||||
E255,
|
||||
|
||||
@@ -58,6 +57,8 @@ namespace DeviceController {
|
||||
W003,
|
||||
W004,
|
||||
|
||||
W255,
|
||||
|
||||
INITIAL_STATE
|
||||
};
|
||||
Q_ENUM_NS(State)
|
||||
|
@@ -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