Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
28a916bf92
|
|||
|
b8648338fd
|
|||
|
eb33c4e920
|
|||
|
26c2120743
|
|||
|
2452499073
|
|||
|
420ca94f41
|
|||
|
5fef45ba3e
|
|||
|
5c40e088aa
|
|||
|
577411289e
|
|||
|
cc27b982ff
|
|||
|
a87a4e6c14
|
|||
|
0467db23d1
|
|||
|
e1470d13f1
|
|||
|
1165c4b92f
|
|||
|
40acd0e0c4
|
|||
|
fe3696ce9c
|
@@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
|
|
||||||
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
|
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
|
||||||
: isMaster(false)
|
: currentProgramMode(PROGRAM_MODE::INIT)
|
||||||
|
, isMaster(false)
|
||||||
, pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
, pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
||||||
, eventReceiver(nullptr)
|
, eventReceiver(nullptr)
|
||||||
{
|
{
|
||||||
@@ -47,6 +48,12 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
|
|||||||
|
|
||||||
this->initTicketTemplateList(&settings);
|
this->initTicketTemplateList(&settings);
|
||||||
|
|
||||||
|
// configurable default printer settings for 'prn_sendText()' used e.g. for bank receipts
|
||||||
|
this->printerDefaultFont.font = settings.value("ATBDeviceControllerPlugin/printerDefaultFont", "8").toUInt();
|
||||||
|
this->printerDefaultFont.size = settings.value("ATBDeviceControllerPlugin/printerDefaultSize", "12").toUInt();
|
||||||
|
this->printerDefaultFont.width = settings.value("ATBDeviceControllerPlugin/printerDefaultWidth", "0").toUInt();
|
||||||
|
this->printerDefaultFont.height = settings.value("ATBDeviceControllerPlugin/printerDefaultHeight", "0").toUInt();
|
||||||
|
|
||||||
this->init_sc_dbus();
|
this->init_sc_dbus();
|
||||||
|
|
||||||
QString persistentDataFile = "/mnt/system_data/dc_persistentData.dat";
|
QString persistentDataFile = "/mnt/system_data/dc_persistentData.dat";
|
||||||
@@ -290,12 +297,14 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
|
|||||||
hw->dc_autoRequest(true);
|
hw->dc_autoRequest(true);
|
||||||
hw->rtc_setDateTime();
|
hw->rtc_setDateTime();
|
||||||
hw->mdb_switchWake(0); // wakeup MDB components
|
hw->mdb_switchWake(0); // wakeup MDB components
|
||||||
|
this->currentProgramMode = PROGRAM_MODE::SELL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE()
|
void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE()
|
||||||
{
|
{
|
||||||
hw->dc_autoRequest(true);
|
hw->dc_autoRequest(true);
|
||||||
hw->mdb_switchWake(0); // wakeup MDB components
|
hw->mdb_switchWake(0); // wakeup MDB components
|
||||||
|
this->currentProgramMode = PROGRAM_MODE::SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
|
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
|
||||||
@@ -303,12 +312,19 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
|
|||||||
hw->dc_autoRequest(true);
|
hw->dc_autoRequest(true);
|
||||||
this->diag->diagRequest();
|
this->diag->diagRequest();
|
||||||
hw->mdb_switchWake(1);
|
hw->mdb_switchWake(1);
|
||||||
|
this->currentProgramMode = PROGRAM_MODE::IDLE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::onChangedProgramModeToOOO()
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -788,11 +804,39 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QHash<QString, QVarian
|
|||||||
|
|
||||||
void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingString)
|
void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingString)
|
||||||
{
|
{
|
||||||
|
// DEBUG --------------------------------------------------
|
||||||
|
QByteArray ba = printingString.toUtf8();
|
||||||
|
QString hexStrOrigin;
|
||||||
|
for (int i = 0; i < ba.size(); ++i) {
|
||||||
|
if (i > 0) hexStrOrigin += ":";
|
||||||
|
hexStrOrigin += QString("%1").arg((unsigned char)ba[i], 2, 16, QChar('0')).toUpper();
|
||||||
|
}
|
||||||
|
qCritical() << "-------------- printString as UTF-8 -------------";
|
||||||
|
qCritical() << hexStrOrigin;
|
||||||
|
qCritical() << "-------------------------------------------------";
|
||||||
|
|
||||||
|
|
||||||
QByteArray ba_receipt = this->codec->fromUnicode(printingString);
|
QByteArray ba_receipt = this->codec->fromUnicode(printingString);
|
||||||
|
|
||||||
|
|
||||||
|
// DEBUG --------------------------------------------------
|
||||||
|
QString hexStringConverted;
|
||||||
|
for (int i = 0; i < ba_receipt.size(); ++i) {
|
||||||
|
if (i > 0) hexStringConverted += ":";
|
||||||
|
hexStringConverted += QString("%1").arg((unsigned char)ba_receipt[i], 2, 16, QChar('0')).toUpper();
|
||||||
|
}
|
||||||
|
qCritical() << "------------------" << this->codec->name() << "-----------------";
|
||||||
|
qCritical() << hexStringConverted;
|
||||||
|
qCritical() << "-------------------------------------------------";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//QByteArray ba = printingString.toUtf8();
|
//QByteArray ba = printingString.toUtf8();
|
||||||
hw->prn_switchPower(true);
|
hw->prn_switchPower(true);
|
||||||
hw->prn_setFonts(8,12,0,0);
|
hw->prn_setFonts(printerDefaultFont.font,
|
||||||
|
printerDefaultFont.size,
|
||||||
|
printerDefaultFont.width,
|
||||||
|
printerDefaultFont.height);
|
||||||
hw->prn_sendText(&ba_receipt);
|
hw->prn_sendText(&ba_receipt);
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
@@ -1899,8 +1943,17 @@ int ATBDeviceControllerPlugin::init_sc_dbus()
|
|||||||
|
|
||||||
void ATBDeviceControllerPlugin::onWokeUp(uchar source)
|
void ATBDeviceControllerPlugin::onWokeUp(uchar source)
|
||||||
{
|
{
|
||||||
if (source == 0x01 || source == 0xFE) {
|
/* PTU5 wakeup sources:
|
||||||
// woke up from device controller
|
* 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);
|
hw->dc_autoRequest(true);
|
||||||
this->diag->diagRequest();
|
this->diag->diagRequest();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,23 @@ using namespace nsDeviceControllerInterface;
|
|||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
|
||||||
|
enum class PROGRAM_MODE {
|
||||||
|
INIT,
|
||||||
|
IDLE,
|
||||||
|
SELL,
|
||||||
|
SERVICE,
|
||||||
|
OOO,
|
||||||
|
NOT_DEFINED
|
||||||
|
};
|
||||||
|
|
||||||
|
class PrinterDefaultsFont
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
quint8 font;
|
||||||
|
quint8 size;
|
||||||
|
quint8 width;
|
||||||
|
quint8 height;
|
||||||
|
};
|
||||||
|
|
||||||
class ATBDeviceControllerPlugin :
|
class ATBDeviceControllerPlugin :
|
||||||
public DeviceControllerInterface
|
public DeviceControllerInterface
|
||||||
@@ -100,6 +117,8 @@ private:
|
|||||||
|
|
||||||
QString serialPortName;
|
QString serialPortName;
|
||||||
|
|
||||||
|
PROGRAM_MODE currentProgramMode;
|
||||||
|
|
||||||
bool useDebug;
|
bool useDebug;
|
||||||
|
|
||||||
bool isMaster;
|
bool isMaster;
|
||||||
@@ -121,6 +140,8 @@ private:
|
|||||||
|
|
||||||
QTextCodec *codec;
|
QTextCodec *codec;
|
||||||
|
|
||||||
|
PrinterDefaultsFont printerDefaultFont;
|
||||||
|
|
||||||
bool private_loadCashAgentLib(QString pluginName);
|
bool private_loadCashAgentLib(QString pluginName);
|
||||||
|
|
||||||
quint8 currentSelectedTicketType;
|
quint8 currentSelectedTicketType;
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ void DeviceControllerDiag::diagRequest()
|
|||||||
qCritical() << "DeviceControllerDiag::diagRequest() is already running";
|
qCritical() << "DeviceControllerDiag::diagRequest() is already running";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->machineEventSet.clear();
|
|
||||||
this->isRequestRunning = true;
|
this->isRequestRunning = true;
|
||||||
this->diagRequestTimeoutTimer->start();
|
this->diagRequestTimeoutTimer->start();
|
||||||
|
|
||||||
@@ -114,8 +113,8 @@ void DeviceControllerDiag::private_startDiag()
|
|||||||
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
|
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
|
||||||
DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255);
|
DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255);
|
||||||
if (!this->previousMachineEventSet.contains(E255Event)) {
|
if (!this->previousMachineEventSet.contains(E255Event)) {
|
||||||
machineEventSet.insert(E255Event);
|
this->private_setDiagEvent(DeviceController::State::E255);
|
||||||
private_sendDiagEvent(E255Event, DeviceController::Action::SET);
|
this->private_sendDiagEvent(E255Event, DeviceController::Action::SET);
|
||||||
}
|
}
|
||||||
if (this->E255counter > 5) {
|
if (this->E255counter > 5) {
|
||||||
this->restartCArun();
|
this->restartCArun();
|
||||||
@@ -133,7 +132,9 @@ void DeviceControllerDiag::private_startDiag()
|
|||||||
* - diag is called again in ModeOOO wokeup()
|
* - diag is called again in ModeOOO wokeup()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
this->private_finishDiag();
|
|
||||||
|
this->private_finishDiag(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +144,7 @@ void DeviceControllerDiag::private_startDiag()
|
|||||||
if (result) {
|
if (result) {
|
||||||
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is valid";
|
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is valid";
|
||||||
this->machineEventSet.remove(DCMachineEvent(DeviceController::State::E255));
|
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);
|
QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -177,13 +178,16 @@ void DeviceControllerDiag::sys_superviseSystem()
|
|||||||
// send
|
// send
|
||||||
DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255);
|
DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255);
|
||||||
if (!this->previousMachineEventSet.contains(E255Event)) {
|
if (!this->previousMachineEventSet.contains(E255Event)) {
|
||||||
machineEventSet.insert(E255Event);
|
this->private_setDiagEvent(DeviceController::State::E255);
|
||||||
private_sendDiagEvent(E255Event, DeviceController::Action::SET);
|
this->private_sendDiagEvent(E255Event, DeviceController::Action::SET);
|
||||||
}
|
}
|
||||||
if (this->E255counter > 5) { this->restartCArun(); }
|
if (this->E255counter > 5) { this->restartCArun(); }
|
||||||
else { this->E255counter++; }
|
else { this->E255counter++; }
|
||||||
|
|
||||||
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
|
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
|
||||||
this->private_finishDiag();
|
|
||||||
|
this->private_finishDiag(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,14 +197,14 @@ void DeviceControllerDiag::sys_superviseSystem()
|
|||||||
qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
|
qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
|
||||||
hw->dc_autoRequest(true);
|
hw->dc_autoRequest(true);
|
||||||
|
|
||||||
DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::M0254);
|
DCMachineEvent M0254Event = DCMachineEvent(DeviceController::State::M0254);
|
||||||
machineEventSet.insert(E255Event);
|
this->private_setDiagEvent(DeviceController::State::M0254);
|
||||||
private_sendDiagEvent(E255Event, DeviceController::Action::SET);
|
this->private_sendDiagEvent(M0254Event, DeviceController::Action::SET);
|
||||||
|
|
||||||
if (this->E255counter > 5) { this->restartCArun(); }
|
if (this->E255counter > 5) { this->restartCArun(); }
|
||||||
else { this->E255counter++; }
|
else { this->E255counter++; }
|
||||||
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
|
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
|
||||||
this->private_finishDiag();
|
this->private_finishDiag(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,6 +236,8 @@ void DeviceControllerDiag::sys_superviseSystem()
|
|||||||
|
|
||||||
void DeviceControllerDiag::sub_componentAssessment()
|
void DeviceControllerDiag::sub_componentAssessment()
|
||||||
{
|
{
|
||||||
|
this->machineEventSet.clear();
|
||||||
|
|
||||||
bool flag_sendOperate = true;
|
bool flag_sendOperate = true;
|
||||||
|
|
||||||
struct T_moduleCondition modCond = {};
|
struct T_moduleCondition modCond = {};
|
||||||
@@ -470,7 +476,7 @@ void DeviceControllerDiag::sub_componentAssessment()
|
|||||||
|
|
||||||
|
|
||||||
// finish diag
|
// finish diag
|
||||||
this->private_finishDiag();
|
this->private_finishDiag(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -479,14 +485,20 @@ void DeviceControllerDiag::sub_componentAssessment()
|
|||||||
* Single point to finish a diag process:
|
* Single point to finish a diag process:
|
||||||
* -
|
* -
|
||||||
*/
|
*/
|
||||||
void DeviceControllerDiag::private_finishDiag()
|
void DeviceControllerDiag::private_finishDiag(bool dataValid)
|
||||||
{
|
{
|
||||||
this->diagRequestTimeoutTimer->stop();
|
this->diagRequestTimeoutTimer->stop();
|
||||||
this->isRequestRunning = false;
|
this->isRequestRunning = false;
|
||||||
this->flagInterruptDiag = false;
|
this->flagInterruptDiag = false;
|
||||||
|
|
||||||
this->previousMachineEventSet.unite(machineEventSet); // add new elements from machineEventSet
|
// add new elements from machineEventSet
|
||||||
this->previousMachineEventSet.intersect(machineEventSet); // remove elements not in machineEventSet
|
this->previousMachineEventSet.unite(machineEventSet);
|
||||||
|
|
||||||
|
if (dataValid) {
|
||||||
|
// remove elements not in machineEventSet
|
||||||
|
// ... only if data is valid
|
||||||
|
this->previousMachineEventSet.intersect(machineEventSet);
|
||||||
|
}
|
||||||
|
|
||||||
if (this->isDiagBackgroundTask) {
|
if (this->isDiagBackgroundTask) {
|
||||||
this->isDiagBackgroundTask = false;
|
this->isDiagBackgroundTask = false;
|
||||||
@@ -673,8 +685,8 @@ void DeviceControllerDiag::private_sendDiagEvent(DCMachineEvent result, DeviceCo
|
|||||||
eventClass = EVENT_CLASS::WARNING;
|
eventClass = EVENT_CLASS::WARNING;
|
||||||
parameter = "temperatur warning";
|
parameter = "temperatur warning";
|
||||||
break;
|
break;
|
||||||
case DeviceController::State::W255: // restart carun
|
case DeviceController::State::M0255: // restart carun
|
||||||
eventClass = EVENT_CLASS::WARNING;
|
eventClass = EVENT_CLASS::STATE;
|
||||||
parameter = "restart carun";
|
parameter = "restart carun";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -715,9 +727,11 @@ void DeviceControllerDiag::restartCArun()
|
|||||||
this->E255counter = 0;
|
this->E255counter = 0;
|
||||||
|
|
||||||
|
|
||||||
DCMachineEvent W255Event = DCMachineEvent(DeviceController::State::W255);
|
DCMachineEvent M0255Event = DCMachineEvent(DeviceController::State::M0255);
|
||||||
machineEventSet.insert(W255Event);
|
if (!this->previousMachineEventSet.contains(M0255Event)) {
|
||||||
private_sendDiagEvent(W255Event, DeviceController::Action::SET);
|
machineEventSet.insert(M0255Event);
|
||||||
|
private_sendDiagEvent(M0255Event, DeviceController::Action::SET);
|
||||||
|
}
|
||||||
|
|
||||||
QProcess::startDetached("/bin/systemctl", {"restart", "carun"});
|
QProcess::startDetached("/bin/systemctl", {"restart", "carun"});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace DeviceController {
|
|||||||
M0252, // cashbox door open
|
M0252, // cashbox door open
|
||||||
M0253, // service or battery door is open
|
M0253, // service or battery door is open
|
||||||
M0254, // no valid data from DC
|
M0254, // no valid data from DC
|
||||||
|
M0255, // restart carun
|
||||||
|
|
||||||
E255,
|
E255,
|
||||||
|
|
||||||
@@ -57,8 +58,6 @@ namespace DeviceController {
|
|||||||
W003,
|
W003,
|
||||||
W004,
|
W004,
|
||||||
|
|
||||||
W255,
|
|
||||||
|
|
||||||
INITIAL_STATE
|
INITIAL_STATE
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(State)
|
Q_ENUM_NS(State)
|
||||||
@@ -171,7 +170,7 @@ private slots:
|
|||||||
void private_setDiagEvent(DeviceController::State result);
|
void private_setDiagEvent(DeviceController::State result);
|
||||||
void private_sendDiagEvent(DCMachineEvent result, DeviceController::Action action);
|
void private_sendDiagEvent(DCMachineEvent result, DeviceController::Action action);
|
||||||
|
|
||||||
void private_finishDiag();
|
void private_finishDiag(bool dataValid = false);
|
||||||
|
|
||||||
void sys_superviseSystem();
|
void sys_superviseSystem();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user