Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
c84050091b
|
|||
9be2841187
|
|||
3e4db6cfcc
|
|||
5898be8807
|
|||
f20957c14a
|
|||
1bcdb5ba21
|
|||
a43af8ab86
|
@@ -88,7 +88,8 @@ HEADERS += \
|
|||||||
src/ATBAPP/support/JSON.h \
|
src/ATBAPP/support/JSON.h \
|
||||||
src/ATBAPP/support/PTUSystem.h \
|
src/ATBAPP/support/PTUSystem.h \
|
||||||
src/ATBAPP/support/PersistentData.h \
|
src/ATBAPP/support/PersistentData.h \
|
||||||
src/ATBAPP/support/Ticket.h
|
src/ATBAPP/support/Ticket.h \
|
||||||
|
src/ATBAPP/support/TicketUtils.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
src/ATBAPP/ATBHealthEvent.cpp \
|
src/ATBAPP/ATBHealthEvent.cpp \
|
||||||
@@ -101,7 +102,8 @@ SOURCES += \
|
|||||||
src/ATBAPP/support/JSON.cpp \
|
src/ATBAPP/support/JSON.cpp \
|
||||||
src/ATBAPP/support/PTUSystem.cpp \
|
src/ATBAPP/support/PTUSystem.cpp \
|
||||||
src/ATBAPP/support/PersistentData.cpp \
|
src/ATBAPP/support/PersistentData.cpp \
|
||||||
src/ATBAPP/support/Ticket.cpp
|
src/ATBAPP/support/Ticket.cpp \
|
||||||
|
src/ATBAPP/support/TicketUtils.cpp
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
generate-version.sh
|
generate-version.sh
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "src/ATBAPP/support/DBusControllerInterface.h"
|
#include "src/ATBAPP/support/DBusControllerInterface.h"
|
||||||
#include "src/ATBAPP/support/PTUSystem.h"
|
#include "src/ATBAPP/support/PTUSystem.h"
|
||||||
#include "src/ATBAPP/support/CashUtils.h"
|
#include "src/ATBAPP/support/CashUtils.h"
|
||||||
|
#include "src/ATBAPP/support/TicketUtils.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@@ -726,13 +727,28 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
|
|||||||
<< " licenseplate = " << printingData["licenseplate"] << endl
|
<< " licenseplate = " << printingData["licenseplate"] << endl
|
||||||
<< " amount = " << printingData["amount"] << endl
|
<< " amount = " << printingData["amount"] << endl
|
||||||
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
||||||
<< " currentDateTime = " << printingData["currentDateTime"] << endl;
|
<< " currentDateTime = " << printingData["currentDateTime"] << endl
|
||||||
|
<< " ticketNumber = " << printingData["ticketNumber"] << endl;
|
||||||
|
|
||||||
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
|
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
|
||||||
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
|
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
|
||||||
|
|
||||||
QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat);
|
QString parkingEndDateString = TicketUtils::getLocaleDateString(this->printerLocale, parkingEndDateTime.date());
|
||||||
QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat);
|
QString currentDateString = TicketUtils::getLocaleDateString(this->printerLocale, currentDateTime.date());
|
||||||
|
|
||||||
|
/*******************************************************************************************
|
||||||
|
* TEST date formate strings:
|
||||||
|
QLocale ltLocale("lt_LT");
|
||||||
|
QLocale deLocale("de_DE");
|
||||||
|
|
||||||
|
QString ltShortDate = ltLocale.toString(currentDateTime.date(), QLocale::ShortFormat);
|
||||||
|
QString deShortDate = deLocale.toString(currentDateTime.date(), QLocale::ShortFormat);
|
||||||
|
|
||||||
|
qCritical() << "*********************************************************************";
|
||||||
|
qCritical() << " ltShortDate = " << ltShortDate;
|
||||||
|
qCritical() << " deShortDate = " << deShortDate;
|
||||||
|
qCritical() << "*********************************************************************";
|
||||||
|
*/
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------------------
|
||||||
* note: the following highly depends on printer template files!
|
* note: the following highly depends on printer template files!
|
||||||
@@ -758,6 +774,10 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
|
|||||||
QByteArray ba_currentDate = codec->fromUnicode(currentDateString);
|
QByteArray ba_currentDate = codec->fromUnicode(currentDateString);
|
||||||
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
|
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
|
||||||
|
|
||||||
|
// Ticket-Number
|
||||||
|
QByteArray ba_ticketNumber = codec->fromUnicode(printingData["ticketNumber"].toString());
|
||||||
|
memcpy((char*)dynTicketData->dynDat7, ba_ticketNumber.data(), std::min(ba_ticketNumber.size(),8));
|
||||||
|
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
/*
|
/*
|
||||||
@@ -791,7 +811,8 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
|
|||||||
<< " amount = " << printingData["amount"] << endl
|
<< " amount = " << printingData["amount"] << endl
|
||||||
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
||||||
<< " currentTime = " << printingData["currentTime"] << endl
|
<< " currentTime = " << printingData["currentTime"] << endl
|
||||||
<< " currentDate = " << printingData["currentDate"] << endl;
|
<< " currentDate = " << printingData["currentDate"] << endl
|
||||||
|
<< " ticketNumber = " << printingData["ticketNumber"] << endl;
|
||||||
|
|
||||||
|
|
||||||
this->onPrintFinishedERR();
|
this->onPrintFinishedERR();
|
||||||
@@ -1051,9 +1072,8 @@ void ATBDeviceControllerPlugin::private_setupDynTemplateData_START_RECEIPT(struc
|
|||||||
QDateTime parkingEndDateTime = QDateTime::fromString(ticket->getPrintingData()["parkingEnd"].toString(), Qt::ISODate);
|
QDateTime parkingEndDateTime = QDateTime::fromString(ticket->getPrintingData()["parkingEnd"].toString(), Qt::ISODate);
|
||||||
QDateTime currentDateTime = QDateTime::fromString(ticket->getPrintingData()["currentDateTime"].toString(), Qt::ISODate);
|
QDateTime currentDateTime = QDateTime::fromString(ticket->getPrintingData()["currentDateTime"].toString(), Qt::ISODate);
|
||||||
|
|
||||||
QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat);
|
QString parkingEndDateString = TicketUtils::getLocaleDateString(this->printerLocale, parkingEndDateTime.date());
|
||||||
QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat);
|
QString currentDateString = TicketUtils::getLocaleDateString(this->printerLocale, currentDateTime.date());
|
||||||
|
|
||||||
|
|
||||||
// set dynamic printer data:
|
// set dynamic printer data:
|
||||||
QByteArray ba_licenseplate = codec->fromUnicode(ticket->getPrintingData()["licenseplate"].toString());
|
QByteArray ba_licenseplate = codec->fromUnicode(ticket->getPrintingData()["licenseplate"].toString());
|
||||||
@@ -1147,7 +1167,7 @@ void ATBDeviceControllerPlugin::private_setupDynTemplatData_FINE_PAYMENT(struct
|
|||||||
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
|
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
|
||||||
|
|
||||||
QByteArray ba_ticketId = codec->fromUnicode(ticket->getPrintingData()["ticketId"].toString());
|
QByteArray ba_ticketId = codec->fromUnicode(ticket->getPrintingData()["ticketId"].toString());
|
||||||
memcpy((char*)dynTicketData->dynDat7, ba_amount.data(), std::min(ba_ticketId.size(),8));
|
memcpy((char*)dynTicketData->dynDat7, ba_ticketId.data(), std::min(ba_ticketId.size(),8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1178,7 +1198,7 @@ void ATBDeviceControllerPlugin::private_setupDynTemplatData_FREE_TICKET(struct T
|
|||||||
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
|
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
|
||||||
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
|
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
|
||||||
|
|
||||||
QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat);
|
QString parkingEndDateString = TicketUtils::getLocaleDateString(this->printerLocale, parkingEndDateTime.date());
|
||||||
|
|
||||||
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateString);
|
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateString);
|
||||||
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
|
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
|
||||||
|
@@ -142,8 +142,8 @@ void DeviceControllerDiag::private_startDiag()
|
|||||||
void DeviceControllerDiag::sys_superviseSystem()
|
void DeviceControllerDiag::sys_superviseSystem()
|
||||||
{ // this function proofs if vending is possible depending of doors state
|
{ // this function proofs if vending is possible depending of doors state
|
||||||
|
|
||||||
struct T_dynamicCondition dynMaCond;
|
struct T_dynamicCondition dynMaCond = {};
|
||||||
struct T_moduleCondition modCond;
|
struct T_moduleCondition modCond = {};
|
||||||
|
|
||||||
|
|
||||||
qCritical() << " sys_superviseSystem()";
|
qCritical() << " sys_superviseSystem()";
|
||||||
@@ -202,13 +202,13 @@ void DeviceControllerDiag::sub_componentAssessment()
|
|||||||
{
|
{
|
||||||
bool flag_sendOperate = true;
|
bool flag_sendOperate = true;
|
||||||
|
|
||||||
struct T_moduleCondition modCond;
|
struct T_moduleCondition modCond = {};
|
||||||
hw->sys_getDeviceConditions(&modCond);
|
hw->sys_getDeviceConditions(&modCond);
|
||||||
|
|
||||||
struct T_dynamicCondition dynMaCond;
|
struct T_dynamicCondition dynMaCond = {};
|
||||||
hw->sys_getDynMachineConditions(&dynMaCond);
|
hw->sys_getDynMachineConditions(&dynMaCond);
|
||||||
|
|
||||||
struct T_devices devPara;
|
struct T_devices devPara = {};
|
||||||
hw->sys_restoreDeviceParameter(&devPara);
|
hw->sys_restoreDeviceParameter(&devPara);
|
||||||
|
|
||||||
// store some interesting results:
|
// store some interesting results:
|
||||||
@@ -606,7 +606,7 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
|
|||||||
"DC",
|
"DC",
|
||||||
eventClass,
|
eventClass,
|
||||||
eventName,
|
eventName,
|
||||||
1,
|
1, // eventState
|
||||||
parameter,
|
parameter,
|
||||||
"" // second level info
|
"" // second level info
|
||||||
);
|
);
|
||||||
|
26
src/ATBAPP/support/TicketUtils.cpp
Normal file
26
src/ATBAPP/support/TicketUtils.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include "TicketUtils.h"
|
||||||
|
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QDate>
|
||||||
|
|
||||||
|
TicketUtils::TicketUtils(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString TicketUtils::getLocaleDateString(const QLocale & qLocale, const QDate & qDate)
|
||||||
|
{
|
||||||
|
QString dateString;
|
||||||
|
|
||||||
|
if (qLocale.language() == QLocale::Lithuanian) {
|
||||||
|
// QLocale::ShortFormat produces date string: "yyyy-mm-dd" ...
|
||||||
|
// this is to long for the printer.
|
||||||
|
dateString = qDate.toString("yy-MM-dd");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dateString = qLocale.toString(qDate, QLocale::ShortFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dateString;
|
||||||
|
}
|
34
src/ATBAPP/support/TicketUtils.h
Normal file
34
src/ATBAPP/support/TicketUtils.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef TICKETUTILS_H
|
||||||
|
#define TICKETUTILS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class TicketUtils : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TicketUtils(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief getLocaleDateString
|
||||||
|
* @param qLocale
|
||||||
|
* @param qDate
|
||||||
|
* @return a localized date string short format
|
||||||
|
*
|
||||||
|
* Note QLocale::ShortFormat does not result to the
|
||||||
|
* string we need for ticket printing therefore this
|
||||||
|
* helper method was created.
|
||||||
|
*
|
||||||
|
* e.g. using Lithuanian (lt_LT) we get a date in short format:
|
||||||
|
* "2024-08-08" unfortunately this is to long, we need
|
||||||
|
* the year with only two digits.
|
||||||
|
* e.g. in German (de_DE) it is enought: "08.08.24"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static QString getLocaleDateString(const QLocale &qLocale, const QDate &qDate);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TICKETUTILS_H
|
Reference in New Issue
Block a user