|
|
|
@@ -28,6 +28,7 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
|
|
|
|
|
, isMaster(false)
|
|
|
|
|
, pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
|
|
|
|
, eventReceiver(nullptr)
|
|
|
|
|
, latestAccountNumber(0)
|
|
|
|
|
{
|
|
|
|
|
this->setParent(parent);
|
|
|
|
|
|
|
|
|
@@ -42,7 +43,8 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
|
|
|
|
|
|
|
|
|
|
// read variables from setting
|
|
|
|
|
this->serialPortName = settings.value("ATBDeviceControllerPlugin/serialPort", "ttymxc2").toString();
|
|
|
|
|
QByteArray printerEncoding = settings.value("ATBDeviceControllerPlugin/printerEncoding", "ISO 8859-2").toString().toLatin1();
|
|
|
|
|
// QByteArray printerEncoding = settings.value("ATBDeviceControllerPlugin/printerEncoding", "ISO 8859-2").toString().toLatin1();
|
|
|
|
|
QByteArray printerEncoding = settings.value("ATBDeviceControllerPlugin/printerEncoding", "Windows-1250").toString().toLatin1();
|
|
|
|
|
QString printerLocaleString = settings.value("ATBDeviceControllerPlugin/printerLocale", "de_DE").toString().toLatin1();
|
|
|
|
|
this->printerLocale = QLocale(printerLocaleString);
|
|
|
|
|
|
|
|
|
@@ -131,7 +133,7 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
|
|
|
|
|
this->codec = QTextCodec::codecForName(printerEncoding);
|
|
|
|
|
|
|
|
|
|
if (this->codec == nullptr) {
|
|
|
|
|
printerEncoding = "ISO 8859-1";
|
|
|
|
|
printerEncoding = "Windows-1250";
|
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin: ERROR: printer encoding \"" << printerEncoding << "\" is not supported!";
|
|
|
|
|
qCritical() << " ... use default encoding: " << printerEncoding;
|
|
|
|
|
this->codec = QTextCodec::codecForName(printerEncoding);
|
|
|
|
@@ -327,6 +329,12 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToOOO()
|
|
|
|
|
this->currentProgramMode = PROGRAM_MODE::OOO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::requestDiag()
|
|
|
|
|
{
|
|
|
|
|
hw->dc_autoRequest(true);
|
|
|
|
|
this->diag->diagRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TASKS: Cash handling -------------------------------------------------------
|
|
|
|
|
void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount)
|
|
|
|
@@ -493,13 +501,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()));
|
|
|
|
@@ -522,11 +530,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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -543,6 +565,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));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -804,16 +834,25 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QHash<QString, QVarian
|
|
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingString)
|
|
|
|
|
{
|
|
|
|
|
this->codec = QTextCodec::codecForName("Windows-1250");
|
|
|
|
|
|
|
|
|
|
qCritical() << "Printer codec forced:"
|
|
|
|
|
<< this->codec->name();
|
|
|
|
|
|
|
|
|
|
QByteArray ba_receipt = this->codec->fromUnicode(printingString);
|
|
|
|
|
|
|
|
|
|
//QByteArray ba = printingString.toUtf8();
|
|
|
|
|
hw->prn_switchPower(true);
|
|
|
|
|
hw->prn_sendPrnSetup(100, 25, 'c', 0);
|
|
|
|
|
hw->prn_setFonts(printerDefaultFont.font,
|
|
|
|
|
printerDefaultFont.size,
|
|
|
|
|
//printerDefaultFont.size,
|
|
|
|
|
11,
|
|
|
|
|
printerDefaultFont.width,
|
|
|
|
|
printerDefaultFont.height);
|
|
|
|
|
hw->prn_sendText(&ba_receipt);
|
|
|
|
|
|
|
|
|
|
qCritical() << "Receipt bytes (hex):";
|
|
|
|
|
qCritical().noquote() << ba_receipt.toHex(' ');
|
|
|
|
|
hw->prn_sendText(&ba_receipt);
|
|
|
|
|
// DEBUG
|
|
|
|
|
//qCritical() << "---------------------------------------------------------------";
|
|
|
|
|
//qCritical() << "ATBDeviceControllerPlugin::requestPrintReceipt()";
|
|
|
|
@@ -823,11 +862,38 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingStri
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this->printResultCheckCounter = 0;
|
|
|
|
|
QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrintingReceipt()));
|
|
|
|
|
//QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrintingReceipt()));
|
|
|
|
|
|
|
|
|
|
//QTimer::singleShot(2000, this, [this](){ hw->prn_cut(3); } );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::requestPrintQR(const QString & printingString)
|
|
|
|
|
{
|
|
|
|
|
QByteArray ba_qr = this->codec->fromUnicode(printingString);
|
|
|
|
|
|
|
|
|
|
//QByteArray ba = printingString.toUtf8();
|
|
|
|
|
hw->prn_switchPower(true);
|
|
|
|
|
hw->prn_sendQRdata(&ba_qr);
|
|
|
|
|
hw->prn_printQRcode();
|
|
|
|
|
// DEBUG
|
|
|
|
|
qCritical() << "---------------------------------------------------------------";
|
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin::requestPrintQR()";
|
|
|
|
|
qCritical() << " QR data:";
|
|
|
|
|
qCritical() << QString(ba_qr);
|
|
|
|
|
qCritical() << "---------------------------------------------------------------";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this->printResultCheckCounter = 0;
|
|
|
|
|
//QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrintingReceipt()));
|
|
|
|
|
|
|
|
|
|
//QTimer::singleShot(2000, this, [this](){ hw->prn_cut(3); } );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::requestPrintCut(const qint16 & printTimer)
|
|
|
|
|
{
|
|
|
|
|
QTimer::singleShot(printTimer, this, SLOT(onPrinterWaitForPrintingReceipt()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::onPrinterWaitForPrintingReceipt()
|
|
|
|
|
{
|
|
|
|
|
quint8 printerResult = this->hw->prn_getPrintResult();
|
|
|
|
|