863 lines
28 KiB
C++
863 lines
28 KiB
C++
|
#include "ATBHMIconfig.h"
|
||
|
#include "atb_system.h"
|
||
|
#include <QDebug>
|
||
|
#include <QCoreApplication>
|
||
|
#include <QDir>
|
||
|
|
||
|
|
||
|
|
||
|
ATBHMIconfig::ATBHMIconfig(QObject *parent) : QObject(parent) {
|
||
|
this->initEarly();
|
||
|
this->initDefered();
|
||
|
}
|
||
|
|
||
|
ATBHMIconfig::~ATBHMIconfig() {
|
||
|
delete settings;
|
||
|
}
|
||
|
|
||
|
void ATBHMIconfig::initEarly() {
|
||
|
QString settings_file = QCoreApplication::applicationDirPath() + "/ATBQT.ini";
|
||
|
settings = new QSettings(settings_file, QSettings::IniFormat);
|
||
|
settings->setIniCodec("UTF-8");
|
||
|
configGroups = settings->childGroups();
|
||
|
|
||
|
// [COMMON]
|
||
|
|
||
|
settings->beginGroup("COMMON");
|
||
|
|
||
|
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
|
||
|
ComPortName = settings->value("com_port_name", "/dev/ttyS0").toString();
|
||
|
#else
|
||
|
ComPortName = settings->value("com_port_name", "/dev/pts/20").toString();
|
||
|
#endif
|
||
|
ComBaudRate = settings->value("com_baud_rate", "115200").toInt();
|
||
|
|
||
|
if ((ComBaudRate != 115200) &&
|
||
|
(ComBaudRate != 57600) &&
|
||
|
(ComBaudRate != 9600)) { ComBaudRate = 115200; }
|
||
|
|
||
|
|
||
|
lang1 = settings->value("lang1", "de_DE").toString();
|
||
|
lang2 = settings->value("lang2", "en_US").toString();
|
||
|
lang3 = settings->value("lang3", "fr_FR").toString();
|
||
|
lang4 = settings->value("lang4", "ja_JP").toString();
|
||
|
lang5 = settings->value("lang5", "nl-NL").toString();
|
||
|
|
||
|
useLanguage = static_cast<quint8>(settings->value("useLanguage", "255").toInt());
|
||
|
|
||
|
this->defaultLanguage = settings->value("defaultLanguage", "1").toInt();
|
||
|
if ((this->defaultLanguage < 1) || (this->defaultLanguage > 5)) {
|
||
|
this->defaultLanguage = 1;
|
||
|
}
|
||
|
|
||
|
usePayment = static_cast<quint8>(settings->value("usePayment", "255").toInt());
|
||
|
|
||
|
useVehicle = static_cast<quint8>(settings->value("useVehicle", "255").toInt());
|
||
|
|
||
|
useProduct = static_cast<quint8>(settings->value("useProduct", "255").toInt());
|
||
|
|
||
|
|
||
|
textfilename = settings->value("textfile", "HMI_Texte.xml").toString();
|
||
|
#if defined (ARCH_DesktopLinux)
|
||
|
QString filename = textfilename.split("/").last();
|
||
|
textfilename = qApp->applicationDirPath() + "/text/" + filename;
|
||
|
#endif
|
||
|
|
||
|
#if defined (ARCH_DesktopLinux)
|
||
|
logfilename = QDir::homePath() + "/ATBAPP_VMC.log";
|
||
|
#else
|
||
|
logfilename = settings->value("logfile", "/var/log/atbqt.log").toString();
|
||
|
#endif
|
||
|
|
||
|
oooServiceNumber = settings->value("ooo_serviceNumber", "").toString();
|
||
|
|
||
|
oooServiceEmail = settings->value("ooo_serviceEmail", "").toString();
|
||
|
|
||
|
oooAlternativeLocation = settings->value("ooo_alternativeLocation", "").toString();
|
||
|
|
||
|
alternativeLogoFilename = settings->value("alternativeLogoFile").toString();
|
||
|
|
||
|
this->features = 0;
|
||
|
|
||
|
// deprecated:
|
||
|
qmPath = qApp->applicationDirPath() + "/translations";
|
||
|
|
||
|
settings->endGroup();
|
||
|
|
||
|
/*
|
||
|
* note: PSA configuration settings are not stored in ini-file
|
||
|
*/
|
||
|
cust_nr = "0";
|
||
|
group_nr = "0";
|
||
|
zone_nr = "0";
|
||
|
machine_nr = "0";
|
||
|
validPSAconfig = false;
|
||
|
}
|
||
|
|
||
|
|
||
|
void ATBHMIconfig::initDefered() {
|
||
|
bool ok = false;
|
||
|
|
||
|
// [COMMON]
|
||
|
|
||
|
settings->beginGroup("COMMON");
|
||
|
|
||
|
SuspendMethode = settings->value("suspend_methode", "sysfs").toString();
|
||
|
SuspendProgram = settings->value("suspend_program", "").toString();
|
||
|
SuspendTime = settings->value("suspend_time", "10").toString();
|
||
|
|
||
|
if (settings->value("feature_Log", "on").toString() == "on" ||
|
||
|
settings->value("feature_Log", "on").toString() == "yes" )
|
||
|
{ this->setFeatureLog(); }
|
||
|
else { this->unsetFeatureLog(); }
|
||
|
|
||
|
if (settings->value("feature_TouchFeedback", "on").toString() == "on" ||
|
||
|
settings->value("feature_TouchFeedback", "on").toString() == "yes" )
|
||
|
{ this->setFeatureTF(); }
|
||
|
else { this->unsetFeatureTF(); }
|
||
|
|
||
|
if (settings->value("feature_DisplayControl", "off").toString() == "on" ||
|
||
|
settings->value("feature_DisplayControl", "off").toString() == "yes" )
|
||
|
{ this->setFeatureDC(); }
|
||
|
else { this->unsetFeatureDC(); }
|
||
|
|
||
|
if (settings->value("feature_StartButton", "on").toString() == "on" ||
|
||
|
settings->value("feature_StartButton", "on").toString() == "yes" )
|
||
|
{ this->setFeatureStartButton(); }
|
||
|
else { this->unsetFeatureStartButton(); }
|
||
|
|
||
|
if (settings->value("feature_selfOOO", "on").toString() == "on" ||
|
||
|
settings->value("feature_selfOOO", "on").toString() == "yes" )
|
||
|
{ this->setFeatureSelfOOO(); }
|
||
|
else { this->unsetFeatureSelfOOO(); }
|
||
|
|
||
|
if (settings->value("feature_DBusDisplayControl", "on").toString() == "on" ||
|
||
|
settings->value("feature_DBusDisplayControl", "on").toString() == "yes" )
|
||
|
{ this->setFeatureDBusDisplayControl(); }
|
||
|
else { this->unsetFeatureDBusDisplayControl(); }
|
||
|
|
||
|
if (settings->value("feature_DBusSuspendControl", "on").toString() == "on" ||
|
||
|
settings->value("feature_DBusSuspendControl", "on").toString() == "yes" )
|
||
|
{ this->setFeatureDBusSuspendControl(); }
|
||
|
else { this->unsetFeatureDBusSuspendControl(); }
|
||
|
|
||
|
if (settings->value("feature_ShowParkingTime", "on").toString() == "on" ||
|
||
|
settings->value("feature_ShowParkingTime", "on").toString() == "yes" )
|
||
|
{ this->setFeatureShowParkingTime(); }
|
||
|
else { this->unsetFeatureShowParkingTime(); }
|
||
|
|
||
|
|
||
|
touch_feedback_gpio = settings->value("touch_feedback_gpio", "121").toString();
|
||
|
|
||
|
touch_feedback_on_value = settings->value("touch_feedback_on_value", "0").toString();
|
||
|
touch_feedback_off_value = settings->value("touch_feedback_off_value", "1").toString();
|
||
|
|
||
|
QString ooo_mode = settings->value("ooo_mode", "useDisk").toString();
|
||
|
if (ooo_mode == "useDisk")
|
||
|
this->oooMode = OOO_MODE::USE_PARKDISK;
|
||
|
else if (ooo_mode == "otherMachine")
|
||
|
this->oooMode = OOO_MODE::USE_OTHER_MACHINE;
|
||
|
else
|
||
|
this->oooMode = OOO_MODE::DEFAULT;
|
||
|
|
||
|
characterSet = settings->value("CharacterSet", "ISO 8859-15").toByteArray();
|
||
|
|
||
|
qrCodeLink = settings->value("QRCodeLink", "").toString();
|
||
|
|
||
|
SellTimeoutTime = settings->value("sellTimeout_time", "60").toString();
|
||
|
|
||
|
this->privateReadInputDevices();
|
||
|
|
||
|
this->lpLocalExample = settings->value("LicencePlateExampleString", "HOAB123").toString();
|
||
|
|
||
|
|
||
|
#if defined (USE_BARCODESCANNER)
|
||
|
if (settings->value("useBarcode", "on").toString() == "on" ||
|
||
|
settings->value("useBarcode", "on").toString() == "yes" )
|
||
|
{ this->useBarcode = true; }
|
||
|
else { this->useBarcode = false; }
|
||
|
#endif // USE_BARCODESCANNER
|
||
|
|
||
|
#ifdef USE_RFIDREADER
|
||
|
if (settings->value("useRFID", "on").toString() == "on" ||
|
||
|
settings->value("useRFID", "on").toString() == "yes" )
|
||
|
{ this->useRFID = true; }
|
||
|
else { this->useRFID = false; }
|
||
|
#endif
|
||
|
|
||
|
// DEBUG
|
||
|
qDebug() << "ATBHMIconfig::initDefered() com_port_name = " << ComPortName;
|
||
|
qDebug() << "ATBHMIconfig::initDefered() touch_feedback_gpio = " << touch_feedback_gpio;
|
||
|
|
||
|
// DEBUG: write settings to file:
|
||
|
/*
|
||
|
settings->setValue("com_port_name", this->ComPortName);
|
||
|
settings->setValue("lang1", "de_DE");
|
||
|
settings->setValue("lang2", "en_US");
|
||
|
settings->setValue("lang3", "fr_FR");
|
||
|
settings->setValue("lang4", "ja_JP");
|
||
|
settings->setValue("textfile", "HMI_Texte.xml");
|
||
|
settings->setValue("logfile", "/var/log/atbqt.log");
|
||
|
settings->setValue("feature_Log", false);
|
||
|
settings->setValue("feature_TouchFeedback", true);
|
||
|
settings->setValue("feature_DisplayControl", true);
|
||
|
settings->setValue("feature_SystemSuspend", true);
|
||
|
settings->setValue("suspend_methode", "sysfs");
|
||
|
settings->setValue("suspend_program", "");
|
||
|
settings->setValue("suspend_time", 10);
|
||
|
settings->setValue("touch_feedback_gpio", 121);
|
||
|
settings->setValue("touch_feedback_on_value", 0);
|
||
|
settings->setValue("touch_feedback_off_value", 1);
|
||
|
*/
|
||
|
|
||
|
this->HelpButtonUsed = settings->value("showHelpButton", "0").toBool();
|
||
|
this->InfoButtonUsed = settings->value("showInfoButton", "0").toBool();
|
||
|
|
||
|
this->ScreenChangeTimeoutTime = settings->value("screenChangeTimeoutTime", "10").toUInt();
|
||
|
|
||
|
settings->endGroup();
|
||
|
|
||
|
// [PAYMENT]
|
||
|
|
||
|
settings->beginGroup("PAYMENT");
|
||
|
|
||
|
QString cashVariantString = settings->value("cashVariant", "CoinsOnly").toString();
|
||
|
if (cashVariantString == "CoinsOnly") {
|
||
|
this->cashVariant = PAYMENT_VARIANTS::CASH_VARIANT::CoinsOnly;
|
||
|
}
|
||
|
else
|
||
|
if (cashVariantString == "CoinsAndNotes") {
|
||
|
this->cashVariant = PAYMENT_VARIANTS::CASH_VARIANT::CoinsAndNotes;
|
||
|
}
|
||
|
else {
|
||
|
// Default
|
||
|
this->cashVariant = PAYMENT_VARIANTS::CASH_VARIANT::CoinsOnly;
|
||
|
}
|
||
|
|
||
|
this->currencySymbol = settings->value("currencySymbol", "€").toString();
|
||
|
|
||
|
|
||
|
QString paymentPointInTimeString = settings->value("paymentPointInTime", "poe").toString();
|
||
|
if (paymentPointInTimeString == "poe") {
|
||
|
this->paymentPointInTime = PAYMENT_POINTINTIME::PAY_ON_EXIT;
|
||
|
}
|
||
|
else
|
||
|
if (paymentPointInTimeString == "poa") {
|
||
|
this->paymentPointInTime = PAYMENT_POINTINTIME::PAY_ON_ARRIVAL;
|
||
|
}
|
||
|
else
|
||
|
if (paymentPointInTimeString == "ign") {
|
||
|
this->paymentPointInTime = PAYMENT_POINTINTIME::IGNORE;
|
||
|
}
|
||
|
else {
|
||
|
// Default
|
||
|
this->paymentPointInTime = PAYMENT_POINTINTIME::PAY_ON_EXIT;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (settings->value("useHonestPayment", "on").toString() == "on" ||
|
||
|
settings->value("useHonestPayment", "on").toString() == "yes" )
|
||
|
{ this->honestPayment = true; }
|
||
|
else { this->honestPayment = false; }
|
||
|
|
||
|
|
||
|
settings->endGroup();
|
||
|
|
||
|
// [CUSTOMER]
|
||
|
|
||
|
settings->beginGroup("CUSTOMER");
|
||
|
|
||
|
this->DiscountUsed = settings->value("DiscountUsed", "1").toBool();
|
||
|
this->QRCodeReceiptUsed = settings->value("QRCodeReceiptUsed", "1").toBool();
|
||
|
|
||
|
settings->endGroup();
|
||
|
|
||
|
#ifdef USE_EXTERNAL_TICKETMANAGER
|
||
|
// [BARCODE_VERIFICATION]
|
||
|
|
||
|
settings->beginGroup("BARCODE_VERIFICATION");
|
||
|
|
||
|
this->endOfSellingTime = settings->value("EndOfSellingTime", "06:00").toString();
|
||
|
this->blockingTimeMin = settings->value("BlockingTime_Min", "15").toInt(&ok);
|
||
|
if (!ok) this->blockingTimeMin = 15;
|
||
|
|
||
|
settings->endGroup();
|
||
|
#endif
|
||
|
|
||
|
|
||
|
#ifdef USE_ISMAS
|
||
|
// [ISMAS]
|
||
|
|
||
|
settings->beginGroup("ISMAS");
|
||
|
|
||
|
this->ismasHost = settings->value("ISMAS_HOST", "87.139.50.222").toString();
|
||
|
this->ismasPort = settings->value("ISMAS_PORT", "10000").toInt(&ok);
|
||
|
this->ismasID = settings->value("ISMAS_ID", "").toString();
|
||
|
|
||
|
if (settings->value("ISMAS_DEBUG", "on").toString() == "on" ||
|
||
|
settings->value("ISMAS_DEBUG", "on").toString() == "yes")
|
||
|
{ this->ismasDebug = true; }
|
||
|
else { this->ismasDebug = false; }
|
||
|
|
||
|
if (settings->value("ISMAS_CheckEntries", "on").toString() == "on" ||
|
||
|
settings->value("ISMAS_CheckEntries", "on").toString() == "yes")
|
||
|
{ this->ismasCheckEntries = true; }
|
||
|
else { this->ismasCheckEntries = false; }
|
||
|
|
||
|
this->ismasConnectionTimeout = settings->value("ISMAS_ConnectionTimeout", "2").toInt(&ok);
|
||
|
if (!ok) this->ismasConnectionTimeout = 2;
|
||
|
|
||
|
if (settings->value("usePinGenerator", "off").toString() == "on" ||
|
||
|
settings->value("usePinGenerator", "off").toString() == "yes" )
|
||
|
{ this->usePINgenerator = true; }
|
||
|
else { this->usePINgenerator = false; }
|
||
|
|
||
|
settings->endGroup();
|
||
|
#endif
|
||
|
|
||
|
// [ERRORCODE_MAPPING]
|
||
|
|
||
|
if (settings->childGroups().contains("ERRORCODE_MAPPING")) {
|
||
|
settings->beginGroup("ERRORCODE_MAPPING");
|
||
|
|
||
|
QStringList ErrorCodes = settings->childKeys();
|
||
|
|
||
|
for (int i = 0; i < ErrorCodes.size(); ++i) {
|
||
|
errorTextHash.insert(ErrorCodes.at(i), settings->value(ErrorCodes.at(i),"").toString());
|
||
|
}
|
||
|
|
||
|
settings->endGroup();
|
||
|
}
|
||
|
|
||
|
|
||
|
qDebug() << ok;
|
||
|
}
|
||
|
|
||
|
|
||
|
QSettings * ATBHMIconfig::getSettingsPtr() { return this->settings; }
|
||
|
|
||
|
const QSettings & ATBHMIconfig::getSettings() { return *(this->settings); }
|
||
|
|
||
|
QString ATBHMIconfig::getComPortName() { return this->ComPortName; }
|
||
|
|
||
|
QString ATBHMIconfig::getSuspendMethode() { return this->SuspendMethode; }
|
||
|
|
||
|
QString ATBHMIconfig::getSuspendProgram() { return this->SuspendProgram; }
|
||
|
|
||
|
|
||
|
/***********************************************************************************************
|
||
|
* get suspend time (-> time, after system goes to suspend) in seconds
|
||
|
*/
|
||
|
QString ATBHMIconfig::getSuspendTime() { return this->SuspendTime; }
|
||
|
|
||
|
|
||
|
/***********************************************************************************************
|
||
|
* get sell timout time (-> time, after system switched back to mode idle, if we do not have
|
||
|
* any user inputs or vmc messages during sell mode) in seconds
|
||
|
*/
|
||
|
QString ATBHMIconfig::getSellTimeoutTime() { return this->SellTimeoutTime; }
|
||
|
|
||
|
quint32 ATBHMIconfig::getHMIScreenChangeTimeoutTime() { return this->ScreenChangeTimeoutTime; }
|
||
|
|
||
|
QString ATBHMIconfig::getQmPath() { return this->qmPath; }
|
||
|
|
||
|
bool ATBHMIconfig::hasFeatureTF() { return ((this->features & this->featureMaskTF) != 0); }
|
||
|
bool ATBHMIconfig::hasFeatureLog() { return ((this->features & this->featureMaskLog) != 0); }
|
||
|
bool ATBHMIconfig::hasFeatureDC() { return ((this->features & this->featureMaskDC) != 0); }
|
||
|
bool ATBHMIconfig::hasFeatureStartButton() { return ((this->features & this->featureMaskStartButton) != 0); }
|
||
|
bool ATBHMIconfig::hasFeatureSelfOOO() { return ((this->features & this->featureMaskSelfOOO) != 0); }
|
||
|
bool ATBHMIconfig::hasFeatureDBusDisplayControl() { return ((this->features & this->featureMaskDBusDisplayControl) != 0); }
|
||
|
bool ATBHMIconfig::hasFeatureDBusSuspendControl() { return ((this->features & this->featureMaskDBusSuspendControl) != 0); }
|
||
|
bool ATBHMIconfig::hasFeatureShowParkingTime() { return ((this->features & this->featureMaskShowParkingTime) != 0); }
|
||
|
|
||
|
void ATBHMIconfig::setFeatureTF() { this->features |= this->featureMaskTF; }
|
||
|
void ATBHMIconfig::unsetFeatureTF() { this->features &= ~(this->featureMaskTF); }
|
||
|
void ATBHMIconfig::setFeatureLog() { this->features |= this->featureMaskLog; }
|
||
|
void ATBHMIconfig::unsetFeatureLog() { this->features &= ~(this->featureMaskLog); }
|
||
|
void ATBHMIconfig::setFeatureStartButton() { this->features |= this->featureMaskStartButton; }
|
||
|
void ATBHMIconfig::unsetFeatureStartButton() { this->features &= ~(this->featureMaskStartButton); }
|
||
|
void ATBHMIconfig::setFeatureSelfOOO() { this->features |= this->featureMaskSelfOOO; }
|
||
|
void ATBHMIconfig::unsetFeatureSelfOOO() { this->features &= ~(this->featureMaskSelfOOO); }
|
||
|
|
||
|
|
||
|
void ATBHMIconfig::setFeatureDC()
|
||
|
{
|
||
|
// this features are mutually exclusive
|
||
|
if (this->hasFeatureDBusDisplayControl()) {
|
||
|
this->unsetFeatureDBusDisplayControl();
|
||
|
}
|
||
|
this->features |= this->featureMaskDC;
|
||
|
}
|
||
|
|
||
|
void ATBHMIconfig::unsetFeatureDC() { this->features &= ~(this->featureMaskDC); }
|
||
|
|
||
|
|
||
|
void ATBHMIconfig::setFeatureDBusDisplayControl()
|
||
|
{
|
||
|
// this features are mutually exclusive
|
||
|
if (this->hasFeatureDC()) {
|
||
|
this->unsetFeatureDC();
|
||
|
}
|
||
|
this->features |= this->featureMaskDBusDisplayControl;
|
||
|
}
|
||
|
|
||
|
void ATBHMIconfig::setFeatureDBusSuspendControl()
|
||
|
{
|
||
|
this->features |= this->featureMaskDBusSuspendControl;
|
||
|
}
|
||
|
|
||
|
void ATBHMIconfig::unsetFeatureDBusDisplayControl() { this->features &= ~(this->featureMaskDBusDisplayControl); }
|
||
|
void ATBHMIconfig::unsetFeatureDBusSuspendControl() { this->features &= ~(this->featureMaskDBusSuspendControl); }
|
||
|
|
||
|
void ATBHMIconfig::setFeatureShowParkingTime() { this->features |= this->featureMaskShowParkingTime; }
|
||
|
void ATBHMIconfig::unsetFeatureShowParkingTime() { this->features &= ~(this->featureMaskShowParkingTime); }
|
||
|
|
||
|
|
||
|
QString ATBHMIconfig::getTouchFeedbackGPIO() { return this->touch_feedback_gpio; }
|
||
|
QString ATBHMIconfig::getTouchFeedbackOnValue() { return this->touch_feedback_on_value; }
|
||
|
QString ATBHMIconfig::getTouchFeedbackOffValue() { return this->touch_feedback_off_value; }
|
||
|
|
||
|
QString ATBHMIconfig::getTextfileName() { return this->textfilename; }
|
||
|
|
||
|
QString ATBHMIconfig::getAlternativeLogoFilename() { return this->alternativeLogoFilename; }
|
||
|
|
||
|
#ifdef USE_BARCODESCANNER
|
||
|
bool ATBHMIconfig::getUseBarcodeScanner() { return this->useBarcode; }
|
||
|
QString & ATBHMIconfig::getBarcodeScannerInputDevice() { return this->barcodeScannerInputDeviceName; }
|
||
|
#endif
|
||
|
|
||
|
#ifdef USE_RFIDREADER
|
||
|
bool ATBHMIconfig::getUseRFIDReader() { return this->useRFID; }
|
||
|
QString & ATBHMIconfig::getRFIDReaderInputDevice() { return this->rfidReaderInputDeviceName; }
|
||
|
#endif
|
||
|
|
||
|
PAYMENT_VARIANTS::CASH_VARIANT ATBHMIconfig::getCashVariant() { return this->cashVariant; }
|
||
|
|
||
|
bool ATBHMIconfig::discountIsUsed() { return this->DiscountUsed; }
|
||
|
bool ATBHMIconfig::qrCodeReceiptIsUsed() { return this->QRCodeReceiptUsed; }
|
||
|
|
||
|
#ifdef USE_EXTERNAL_TICKETMANAGER
|
||
|
/**********************************************************************
|
||
|
* for barcode verification:
|
||
|
*
|
||
|
* EndOfSellingTime: time, when all daily data (e.g. blocking list) is reset
|
||
|
* BlockingTime: time, in minutes, how long a verified ticket is blocked for reentry
|
||
|
*/
|
||
|
QString ATBHMIconfig::getEndOfSellingTime() { return this->endOfSellingTime; }
|
||
|
int ATBHMIconfig::getBlockingTime() { return this->blockingTimeMin; }
|
||
|
#endif
|
||
|
|
||
|
QString ATBHMIconfig::getLang(int lang)
|
||
|
{
|
||
|
switch (lang) {
|
||
|
case 1: return this->lang1;
|
||
|
break;
|
||
|
case 2: return this->lang2;
|
||
|
break;
|
||
|
case 3: return this->lang3;
|
||
|
break;
|
||
|
case 4: return this->lang4;
|
||
|
break;
|
||
|
case 5: return this->lang5;
|
||
|
break;
|
||
|
default: return "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Returns the ordered list of configured languages.
|
||
|
* { <lang1>, <lang2>, ... , <langN> }
|
||
|
* This languages should be available in text file.
|
||
|
*/
|
||
|
QStringList ATBHMIconfig::getConfiguredLanguages()
|
||
|
{
|
||
|
QStringList langs;
|
||
|
langs << lang1 << lang2 << lang3 << lang4 << lang5;
|
||
|
return langs;
|
||
|
}
|
||
|
|
||
|
|
||
|
QString ATBHMIconfig::getCountry(int country)
|
||
|
{
|
||
|
switch (country) {
|
||
|
case 1: return this->country1;
|
||
|
break;
|
||
|
case 2: return this->country2;
|
||
|
break;
|
||
|
case 3: return this->country3;
|
||
|
break;
|
||
|
case 4: return this->country4;
|
||
|
break;
|
||
|
case 5: return this->country5;
|
||
|
break;
|
||
|
default: return "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool ATBHMIconfig::isLanguageUsed(int lang)
|
||
|
{
|
||
|
switch (lang) {
|
||
|
case 1: return (this->useLanguage & 0x80) ? (true) : (false);
|
||
|
break;
|
||
|
case 2: return (this->useLanguage & 0x40) ? (true) : (false);
|
||
|
break;
|
||
|
case 3: return (this->useLanguage & 0x20) ? (true) : (false);
|
||
|
break;
|
||
|
case 4: return (this->useLanguage & 0x10) ? (true) : (false);
|
||
|
break;
|
||
|
case 5: return (this->useLanguage & 0x08) ? (true) : (false);
|
||
|
break;
|
||
|
default: return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool ATBHMIconfig::isInfoButtonUsed() { return this->InfoButtonUsed; }
|
||
|
bool ATBHMIconfig::isHelpButtonUsed() { return this->HelpButtonUsed; }
|
||
|
|
||
|
|
||
|
bool ATBHMIconfig::isPaymentUsed(int payment)
|
||
|
{
|
||
|
switch (payment) {
|
||
|
case 1: return (this->usePayment & 0x80) ? (true) : (false);
|
||
|
break;
|
||
|
case 2: return (this->usePayment & 0x40) ? (true) : (false);
|
||
|
break;
|
||
|
case 3: return (this->usePayment & 0x20) ? (true) : (false);
|
||
|
break;
|
||
|
case 4: return (this->usePayment & 0x10) ? (true) : (false);
|
||
|
break;
|
||
|
default: return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
bool ATBHMIconfig::isVehicleUsed(int vehicle)
|
||
|
{
|
||
|
switch (vehicle) {
|
||
|
case 1: return (this->useVehicle & 0x80) ? (true) : (false);
|
||
|
break;
|
||
|
case 2: return (this->useVehicle & 0x40) ? (true) : (false);
|
||
|
break;
|
||
|
case 3: return (this->useVehicle & 0x20) ? (true) : (false);
|
||
|
break;
|
||
|
case 4: return (this->useVehicle & 0x10) ? (true) : (false);
|
||
|
break;
|
||
|
case 5: return (this->useVehicle & 0x08) ? (true) : (false);
|
||
|
break;
|
||
|
case 6: return (this->useVehicle & 0x04) ? (true) : (false);
|
||
|
break;
|
||
|
case 7: return (this->useVehicle & 0x02) ? (true) : (false);
|
||
|
break;
|
||
|
case 8: return (this->useVehicle & 0x01) ? (true) : (false);
|
||
|
break;
|
||
|
default: return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
bool ATBHMIconfig::isProductUsed(int product)
|
||
|
{
|
||
|
switch (product) {
|
||
|
case 1: return (this->useProduct & 0x80) ? (true) : (false);
|
||
|
break;
|
||
|
case 2: return (this->useProduct & 0x40) ? (true) : (false);
|
||
|
break;
|
||
|
case 3: return (this->useProduct & 0x20) ? (true) : (false);
|
||
|
break;
|
||
|
case 4: return (this->useProduct & 0x10) ? (true) : (false);
|
||
|
break;
|
||
|
case 5: return (this->useProduct & 0x08) ? (true) : (false);
|
||
|
break;
|
||
|
case 6: return (this->useProduct & 0x04) ? (true) : (false);
|
||
|
break;
|
||
|
case 7: return (this->useProduct & 0x02) ? (true) : (false);
|
||
|
break;
|
||
|
case 8: return (this->useProduct & 0x01) ? (true) : (false);
|
||
|
break;
|
||
|
default: return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
QString ATBHMIconfig::getLogFileName()
|
||
|
{
|
||
|
return this->logfilename;
|
||
|
}
|
||
|
|
||
|
int ATBHMIconfig::getDefaultLanguage()
|
||
|
{
|
||
|
return this->defaultLanguage;
|
||
|
}
|
||
|
|
||
|
void ATBHMIconfig::setDefaultLanguage(quint8 lang)
|
||
|
{
|
||
|
this->defaultLanguage = lang;
|
||
|
}
|
||
|
|
||
|
|
||
|
int ATBHMIconfig::getComBaudRate()
|
||
|
{
|
||
|
return this->ComBaudRate;
|
||
|
}
|
||
|
|
||
|
|
||
|
/********************************************************************************
|
||
|
* Funktions for storing some machine specific configuration data in filesystem.
|
||
|
*
|
||
|
* Note: this functions must reduce write operations to flash memory.
|
||
|
* Therefore, first the data values are read from memory and compared to the new ones.
|
||
|
* Only changed values should be written.
|
||
|
* Additionally, open files, read their values and compare this values is time consuming.
|
||
|
* So we store this values also in our config-object and do only a comparisson if values
|
||
|
* have changed.
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
QString & ATBHMIconfig::getCustNr()
|
||
|
{
|
||
|
if (!this->validPSAconfig) { this->readPSAConfig(); }
|
||
|
return this->cust_nr;
|
||
|
}
|
||
|
|
||
|
QString & ATBHMIconfig::getGroupNr()
|
||
|
{
|
||
|
if (!this->validPSAconfig) { this->readPSAConfig(); }
|
||
|
return this->group_nr;
|
||
|
}
|
||
|
|
||
|
QString & ATBHMIconfig::getZoneNr()
|
||
|
{
|
||
|
if (!this->validPSAconfig) { this->readPSAConfig(); }
|
||
|
return this->zone_nr;
|
||
|
}
|
||
|
|
||
|
QString & ATBHMIconfig::getMachineNr()
|
||
|
{
|
||
|
if (!this->validPSAconfig) { this->readPSAConfig(); }
|
||
|
return this->machine_nr;
|
||
|
}
|
||
|
|
||
|
quint8 ATBHMIconfig::readPSAConfig()
|
||
|
{
|
||
|
this->cust_nr = ATB_system::readPSAConfigString("/etc/cust_nr");
|
||
|
this->group_nr = ATB_system::readPSAConfigString("/etc/group_nr");
|
||
|
this->zone_nr = ATB_system::readPSAConfigString("/etc/zone_nr");
|
||
|
this->machine_nr = ATB_system::readPSAConfigString("/etc/machine_nr");
|
||
|
this->validPSAconfig = true;
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
void ATBHMIconfig::setCustNr(const QString& cust_nr)
|
||
|
{
|
||
|
if (! validPSAconfig) { this->readPSAConfig(); }
|
||
|
|
||
|
// compare to cached value:
|
||
|
|
||
|
if (cust_nr != this->cust_nr) { // Customer number has changed
|
||
|
ATB_system::setPSAConfigString("/etc/cust_nr", cust_nr);
|
||
|
this->cust_nr = cust_nr;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void ATBHMIconfig::setGroupNr(const QString& group_nr)
|
||
|
{
|
||
|
if (! validPSAconfig) { this->readPSAConfig(); }
|
||
|
|
||
|
// compare to cached value:
|
||
|
|
||
|
if (group_nr != this->group_nr) {
|
||
|
ATB_system::setPSAConfigString("/etc/group_nr", group_nr);
|
||
|
this->group_nr = group_nr;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void ATBHMIconfig::setZoneNr(const QString& zone_nr)
|
||
|
{
|
||
|
if (! validPSAconfig) { this->readPSAConfig(); }
|
||
|
|
||
|
// compare to cached value:
|
||
|
|
||
|
if (zone_nr != this->zone_nr) {
|
||
|
ATB_system::setPSAConfigString("/etc/zone_nr", zone_nr);
|
||
|
this->zone_nr = zone_nr;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void ATBHMIconfig::setMachineNr(const QString &machine_nr)
|
||
|
{
|
||
|
if (! validPSAconfig) { this->readPSAConfig(); }
|
||
|
|
||
|
// compare to cached value:
|
||
|
|
||
|
if (machine_nr != this->machine_nr) {
|
||
|
ATB_system::setPSAConfigString("/etc/machine_nr", machine_nr);
|
||
|
this->machine_nr = machine_nr;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
OOO_MODE ATBHMIconfig::getOOOMode()
|
||
|
{
|
||
|
return this->oooMode;
|
||
|
}
|
||
|
|
||
|
QString ATBHMIconfig::getOOOModeString()
|
||
|
{
|
||
|
switch (this->oooMode) {
|
||
|
case OOO_MODE::USE_OTHER_MACHINE:
|
||
|
return QString("otherMachine");
|
||
|
break;
|
||
|
case OOO_MODE::USE_PARKDISK:
|
||
|
return QString("useDisk");
|
||
|
break;
|
||
|
default:
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
QString ATBHMIconfig::getOOOServiceNumber()
|
||
|
{
|
||
|
return this->oooServiceNumber;
|
||
|
}
|
||
|
|
||
|
QString ATBHMIconfig::getOOOServiceEmail()
|
||
|
{
|
||
|
return this->oooServiceEmail;
|
||
|
}
|
||
|
|
||
|
QString ATBHMIconfig::getOOOAlternativeLocation()
|
||
|
{
|
||
|
return this->oooAlternativeLocation;
|
||
|
}
|
||
|
|
||
|
QString ATBHMIconfig::getLicensePlateExampleString()
|
||
|
{
|
||
|
return this->lpLocalExample;
|
||
|
}
|
||
|
|
||
|
QString ATBHMIconfig::getQrCodeLink()
|
||
|
{
|
||
|
return this->qrCodeLink;
|
||
|
}
|
||
|
|
||
|
const QByteArray & ATBHMIconfig::getDefaultCharacterSet() const
|
||
|
{
|
||
|
return this->characterSet;
|
||
|
}
|
||
|
|
||
|
|
||
|
const QString & ATBHMIconfig::getPaymentCurrencySymbol()
|
||
|
{
|
||
|
return this->currencySymbol;
|
||
|
}
|
||
|
|
||
|
PAYMENT_POINTINTIME ATBHMIconfig::getPaymentPointInTime()
|
||
|
{
|
||
|
return this->paymentPointInTime;
|
||
|
}
|
||
|
|
||
|
bool ATBHMIconfig::useHonestPayment()
|
||
|
{
|
||
|
return this->honestPayment;
|
||
|
}
|
||
|
|
||
|
/***************************************************************************
|
||
|
* public slot to re-read config
|
||
|
*
|
||
|
* This slot could be called e.g. on a mode switch from 'service' to 'sell' or vv.
|
||
|
*/
|
||
|
void ATBHMIconfig::reReadSettings()
|
||
|
{
|
||
|
this->privateReadInputDevices();
|
||
|
}
|
||
|
|
||
|
/* private common function to set/read input device names.
|
||
|
*/
|
||
|
void ATBHMIconfig::privateReadInputDevices()
|
||
|
{
|
||
|
#if defined (USE_BARCODESCANNER)
|
||
|
barcodeScannerInputDeviceName = ATB_system::getEventDeviceName(ATB_system::EVENT_DEVICE_BARCODEREADER);
|
||
|
#endif // USE_BARCODESCANNER
|
||
|
|
||
|
#if defined (USE_RFIDREADER)
|
||
|
rfidReaderInputDeviceName = ATB_system::getEventDeviceName(ATB_system::EVENT_DEVICE_RFIDREADER);
|
||
|
#endif // USE_RFIDREADER
|
||
|
}
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
* ISMAS
|
||
|
*/
|
||
|
#ifdef USE_ISMAS
|
||
|
QString ATBHMIconfig::getISMASHost() { return this->ismasHost; }
|
||
|
quint16 ATBHMIconfig::getISMASPort() { return this->ismasPort; }
|
||
|
bool ATBHMIconfig::isIsmasDebug() { return this->ismasDebug; }
|
||
|
bool ATBHMIconfig::IsmasCheckEntries() { return this->ismasCheckEntries; }
|
||
|
quint16 ATBHMIconfig::getIsmasConnectionTimeout() { return this->ismasConnectionTimeout; }
|
||
|
bool ATBHMIconfig::UsePINgenerator() { return this->usePINgenerator; }
|
||
|
QString ATBHMIconfig::getISMASId()
|
||
|
{
|
||
|
// if no ismasID is defined, we use customer Number (-> "ATB device Id" in Multipass)
|
||
|
if (this->ismasID == "") {
|
||
|
return this->getCustNr();
|
||
|
}
|
||
|
return this->ismasID;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
* public methods for ErrorCode
|
||
|
*/
|
||
|
QString ATBHMIconfig::getErrorText(const QString & errorCode)
|
||
|
{
|
||
|
return errorTextHash.value(errorCode);
|
||
|
}
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
* get tools name/path
|
||
|
*/
|
||
|
|
||
|
/*****************************************************************************
|
||
|
* check availability of network diag tool
|
||
|
*
|
||
|
* possible install path for networkDiag:
|
||
|
* 1) /usr/bin/atb_networkDiag
|
||
|
* 2) /opt/app/tools/networkDiag
|
||
|
* 3) /opt/app/atb_networkDiag/networkDiag
|
||
|
*
|
||
|
* Check, if file exists and if it is executable,
|
||
|
* Return path/name for binary.
|
||
|
*/
|
||
|
QString & ATBHMIconfig::getNetworkDiagTool()
|
||
|
{
|
||
|
// search list for config file:
|
||
|
QStringList binFileList;
|
||
|
|
||
|
// check, if file exists and if it is executable
|
||
|
#if defined (ARCH_PTU4)
|
||
|
binFileList << "/usr/bin/atbNetworkDiag"
|
||
|
<< "/opt/app/tools/networkDiag"
|
||
|
<< "/opt/app/atbNetworkDiag/networkDiag";
|
||
|
#else
|
||
|
binFileList << QDir::homePath().append("/atbNetworkDiag");
|
||
|
#endif
|
||
|
|
||
|
// using C++11 range based loop: -> take first file, which is readable
|
||
|
for (const auto& filename : binFileList) {
|
||
|
if (QFileInfo(filename).isExecutable()) {
|
||
|
this->networkDiagToolName = filename;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return this->networkDiagToolName;
|
||
|
}
|