Test printing ticket

This commit is contained in:
Siegfried Siegert 2023-05-02 17:10:17 +02:00
parent 8ff17a2e00
commit bbce2b02e3
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 60 additions and 2 deletions

View File

@ -8,6 +8,10 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(
this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
this->hw = new hwapi();
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_gotNewCoin()), this, SLOT(onGotCoin()));
}
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
@ -19,6 +23,8 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceive
// Read a sample variable from setting
QString sampleSetting = settings.value("DEVICE_CONTROLLER/sampleVariable", "defaultValue").toString();
hw->dc_openSerial(5, "115200", "ttymxc2", 1);
this->pluginState = PLUGIN_STATE::INITIALIZED;
return pluginState;
@ -54,14 +60,60 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
strncpy((char*)dynTicketData->licensePlate, printingData["licenseplate"].toByteArray().data(), 7);
strncpy((char*)dynTicketData->vendingPrice, printingData["amount"].toByteArray().data(), 7);
strncpy((char*)dynTicketData->parkingEnd, printingData["parkingend"].toByteArray().data(), 7);
strncpy((char*)dynTicketData->parkingEnd, printingData["parkingEnd"].toByteArray().data(), 7);
strncpy((char*)dynTicketData->currentTime, printingData["currentTime"].toByteArray().data(), 7);
strncpy((char*)dynTicketData->currentDate, printingData["currentDate"].toByteArray().data(), 7);
this->hw->prn_printDocument(1, dynTicketData);
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";
if (!this->hw->dc_isPortOpen()) {
qCritical() << " ... serial port is not open!";
emit this->onPrintFinishedERR();
}
if (!this->hw->prn_printDocument(1, dynTicketData)) {
this->errorCode = "hwapi::prn_printDocument";
this->errorDescription = "hwapi method 'hwapi::prn_printDocument' result is false";
qCritical() << "ERROR:";
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
<< " licenseplate = " << printingData["licenseplate"] << endl
<< " amount = " << printingData["amount"] << endl
<< " parkingEnd = " << printingData["parkingEnd"] << endl
<< " currentTime = " << printingData["currentTime"] << endl
<< " currentDate = " << printingData["currentDate"] << endl;
emit this->onPrintFinishedERR();
}
}
/************************************************************************************************
* private slots, interface to low level hwapi
*
*/
void ATBDeviceControllerPlugin::onPrintFinishedOK()
{
emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
"",
"");
}
void ATBDeviceControllerPlugin::onPrintFinishedERR()
{
this->errorCode = "PRINTER"; // TODO: get more detailed error code from low level API
this->errorDescription = "Printer error"; // TODO: get more detailed error description from low level API
emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
this->errorCode,
this->errorDescription);
}
void ATBDeviceControllerPlugin::onGotCoin()
{
}
/************************************************************************************************

View File

@ -101,6 +101,12 @@ private:
hwinf* hw;
private slots:
void onPrintFinishedOK();
void onPrintFinishedERR();
void onGotCoin();
};
#endif // ATBDEVICECONTROLLERPLUGIN_H