ATBAPP: Rework for ticket printing

This commit is contained in:
Siegfried Siegert 2023-05-18 11:57:54 +02:00
parent e32142cd62
commit 48d6a34b16
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 37 additions and 15 deletions

View File

@ -76,8 +76,8 @@ struct Tprn_currentSettings {
struct T_dynDat {
uint8_t licensePlate[8];
uint8_t vendingPrice[8];
uint8_t parkingEnd[8];
uint8_t currentTime[8];
uint8_t parkingEndTime[8];
uint8_t parkingEndDate[8];
uint8_t currentDate[8];
uint8_t dynDat5[8];
uint8_t dynDat6[8];

View File

@ -76,24 +76,46 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
struct T_dynDat *dynTicketData = new T_dynDat;
memset(dynTicketData, 0, sizeof(*dynTicketData));
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
<< " licenseplate = " << printingData["licenseplate"] << endl
<< " amount = " << printingData["amount"] << endl
<< " parkingEnd = " << printingData["parkingEnd"] << endl
<< " currentTime = " << printingData["currentTime"] << endl
<< " currentDate = " << printingData["currentDate"] << endl;
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
<< " licenseplate = " << printingData["licenseplate"] << endl
<< " amount = " << printingData["amount"] << endl
<< " parkingEnd = " << printingData["parkingEnd"] << endl
<< " currentDateTime = " << printingData["currentDateTime"] << endl;
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
/* -----------------------------------------------------------------------------------------
* note: the following highly depends on printer template files!
* -----------------------------------------------------------------------------------------
*/
// set dynamic printer data:
memcpy((char*)dynTicketData->licensePlate, codec->fromUnicode(printingData["licenseplate"].toString()).data(), 8);
memcpy((char*)dynTicketData->vendingPrice, codec->fromUnicode(printingData["amount"].toString()).data(), 8);
QByteArray ba_licenseplate = codec->fromUnicode(printingData["licenseplate"].toString());
memcpy((char*)dynTicketData->licensePlate, ba_licenseplate.data(), std::min(ba_licenseplate.size(),8));
QDateTime parkingEndQDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(printingData["currentTime"].toString(), Qt::ISODate);
QByteArray ba_amount = codec->fromUnicode(printingData["amount"].toString());
memcpy((char*)dynTicketData->vendingPrice, ba_amount.data(), std::min(ba_amount.size(),8));
memcpy((char*)dynTicketData->parkingEnd, codec->fromUnicode(parkingEndQDateTime.toString("hh:mm")).data(), 8);
memcpy((char*)dynTicketData->currentTime, codec->fromUnicode(currentDateTime.toString("hh:mm")).data(), 8);
memcpy((char*)dynTicketData->currentDate, codec->fromUnicode(currentDateTime.toString("dd.MM.yy")).data(), 8);
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
memcpy((char*)dynTicketData->parkingEndTime, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("dd.MM.yy"));
memcpy((char*)dynTicketData->parkingEndDate, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("dd.MM.yy"));
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
// DEBUG
/*
uint8_t* buf = dynTicketData->licensePlate;
int length = 64;
for (int i = 0; i < length; ++i) {
fprintf(stderr, "%d %02x %c\n", i, buf[i], buf[i]);
}
fprintf(stderr, "\n");
*/
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";