delete obsolete files

This commit is contained in:
Gerhard Hoffmann 2023-11-13 12:50:57 +01:00
parent 3bbf36cdd7
commit 838c02d9e2
6 changed files with 0 additions and 4899 deletions

View File

@ -1,858 +0,0 @@
#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();
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; }
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;
}

View File

@ -1,285 +0,0 @@
#ifndef ATBHMICONFIG_H
#define ATBHMICONFIG_H
#include <QObject>
#include <QSettings>
#include <ATBAPP.h>
#include "version.h"
/***************************************
* Sample configuration:
*
* [General]
* com_port_name=/dev/pts/16
* machine_nr=99
*
* suspend_methode=sysfs
* suspend_program=
* suspend_time=10
*
* touch_feedback=on
* touch_feedback_gpio=115 // 115 = beep; 121 = vibration motor
* touch_feedback_on_value=0 // 0 (buzzer) 1 (vibration)
* touch_feedback_off_value=1 // 1 (buzzer) 0 (vibration)
*
* log=on // loggin is on
*
* lang1=de_DE
* lang2=en_US
* lang3=fr_FR
* lang4=ja_JP
*
* textfile=HMI_Texte.xml
*
*/
enum class OOO_MODE : quint8;
class ATBHMIconfig : public QObject
{
Q_OBJECT
QString ComPortName;
QString SuspendMethode;
QString SuspendProgram;
QString SuspendTime;
QString SellTimeoutTime;
QString qmPath;
QString touch_feedback_gpio;
QString touch_feedback_on_value;
QString touch_feedback_off_value;
QString lang1;
QString lang2;
QString lang3;
QString lang4;
QString lang5;
quint8 useLanguage;
quint8 useVehicle;
quint8 useProduct;
quint8 usePayment;
QString country1;
QString country2;
QString country3;
QString country4;
QString country5;
QSettings *settings;
quint16 features;
static const quint16 featureMaskTF = 0x0001;
static const quint16 featureMaskLog = 0x0002;
static const quint16 featureMaskDC = 0x0004; // manuell display control, (in future deprecated)
static const quint16 featureMaskSusp = 0x0008; // manuell suspend control, (in future deprecated)
static const quint16 featureMaskStartButton = 0x0010;
static const quint16 featureMaskSelfOOO = 0x0020;
static const quint16 featureMaskDBusDisplayControl = 0x0040;
static const quint16 featureMaskDBusSuspendControl = 0x0080;
static const quint16 featureMaskShowParkingTime = 0x0100;
QString logfilename;
QString textfilename;
QString alternativeLogoFilename;
QString oooServiceNumber;
QString oooServiceEmail;
QString oooAlternativeLocation;
QString qrCodeLink;
QString lpLocalExample;
QString currencySymbol;
quint8 defaultLanguage;
bool HelpButtonUsed;
bool InfoButtonUsed;
bool DiscountUsed;
bool QRCodeReceiptUsed;
int ComBaudRate;
QString cust_nr;
QString group_nr;
QString zone_nr;
QString machine_nr;
bool validPSAconfig;
QByteArray characterSet;
PAYMENT_VARIANTS::CASH_VARIANT cashVariant;
// ErrorCode-mapping
QHash<QString,QString> errorTextHash;
public:
explicit ATBHMIconfig(QObject *parent = nullptr);
~ATBHMIconfig();
QSettings *getSettingsPtr();
const QSettings & getSettings();
void initEarly();
void initDefered();
QString getComPortName();
QString getSuspendMethode();
QString getSuspendProgram();
QString getSuspendTime();
QString getSellTimeoutTime();
quint32 getHMIScreenChangeTimeoutTime();
QString getQmPath();
QString getLang(int lang);
QString getCountry(int country);
bool isLanguageUsed(int lang);
bool isInfoButtonUsed();
bool isHelpButtonUsed();
bool isPaymentUsed(int payment);
bool isVehicleUsed(int vehicle);
bool isProductUsed(int product);
bool isProcductUsed(int product);
QString getTouchFeedbackGPIO();
QString getTouchFeedbackOnValue();
QString getTouchFeedbackOffValue();
bool hasFeatureTF(); // touch feedback
bool hasFeatureLog(); // log serial communication
bool hasFeatureDC(); // display control
bool hasFeatureStartButton(); // StartButton
bool hasFeatureSelfOOO(); // self ooo capability
bool hasFeatureDBusDisplayControl();
bool hasFeatureDBusSuspendControl();
bool hasFeatureShowParkingTime(); // show parking time in addition to parking end time
QString getTextfileName();
QString getAlternativeLogoFilename();
const QByteArray & getDefaultCharacterSet() const;
QString getOOOServiceNumber();
QString getOOOServiceEmail();
QString getOOOAlternativeLocation();
QString getLicensePlateExampleString();
QString getQrCodeLink();
const QString & getPaymentCurrencySymbol();
void setFeatureTF();
void unsetFeatureTF();
void setFeatureLog();
void unsetFeatureLog();
void setFeatureDC();
void unsetFeatureDC();
void setFeatureStartButton();
void unsetFeatureStartButton();
void setFeatureSelfOOO();
void unsetFeatureSelfOOO();
void setFeatureDBusDisplayControl();
void unsetFeatureDBusDisplayControl();
void setFeatureDBusSuspendControl();
void unsetFeatureDBusSuspendControl();
void setFeatureShowParkingTime();
void unsetFeatureShowParkingTime();
QString getLogFileName();
int getDefaultLanguage();
QStringList getConfiguredLanguages();
int getComBaudRate();
QString getErrorText(const QString & errorCode);
// machine configuration
QString & getCustNr();
QString & getGroupNr();
QString & getZoneNr();
QString & getMachineNr();
quint8 readPSAConfig();
PAYMENT_VARIANTS::CASH_VARIANT getCashVariant();
bool discountIsUsed();
bool qrCodeReceiptIsUsed();
// service programs
QString & getNetworkDiagTool();
//QString & getPTUConfig();
//QString & getPTUUpdate();
OOO_MODE getOOOMode();
QString getOOOModeString();
PAYMENT_POINTINTIME getPaymentPointInTime();
bool useHonestPayment();
QStringList configGroups;
private:
OOO_MODE oooMode;
PAYMENT_POINTINTIME paymentPointInTime;
bool honestPayment;
void privateReadInputDevices();
QString networkDiagToolName;
signals:
public slots:
void setDefaultLanguage(quint8 lang);
void setCustNr(const QString& cust_nr);
void setGroupNr(const QString& group_nr);
void setZoneNr(const QString& zone_nr);
void setMachineNr(const QString& machine_nr);
void reReadSettings();
};
enum class OOO_MODE : quint8 {
DEFAULT = 0,
USE_PARKDISK = 1,
USE_OTHER_MACHINE = 2
};
#endif // ATBHMICONFIG_H

File diff suppressed because it is too large Load Diff

View File

@ -1,242 +0,0 @@
#ifndef APPCONTROL_H
#define APPCONTROL_H
#include <QObject>
#include "version.h"
#include "atb_system.h"
#include "ATBAPP.h"
#include "plugins/PluginManager.h"
#include "plugins/CC/CCInterface.h"
#include "plugins/CalculatePrice/CalculatePriceInterface.h"
#include "support/VendingData.h"
#include "CalculatePrice/CalculatePriceDefault.h"
class VMC;
class ATBHMIconfig;
class VendingData;
class QTimer;
class AppControl : public QObject {
Q_OBJECT
public:
explicit AppControl(QObject *parent = nullptr);
PROGRAM_MODE getCurrentProgramMode();
bool requestProgramMode(PROGRAM_MODE newProgramMode);
bool isProgramModeSELL();
bool isProgramModeSELL_ENABLE();
bool isProgramModeSERVICE();
bool isProgramModeIDLE();
bool isProgramModeOOO();
public slots:
void onRequestOfflineProcessing();
// e.g. by button event,
// by vmc screen command,
// by vmc data display command
// ...
void restartSellModeTimeoutTimer();
// slots for LED configuration:
void LEDs_default();
void LEDs_ooo();
// CC-Plugin
void onCCStartTransactionResult(nsCCInterface::RESULT_STATE resultState, QString & result);
void onCCConfirmTransactionResult(nsCCInterface::RESULT_STATE resultState, QString & result);
void onCCCancelTransactionResult(nsCCInterface::RESULT_STATE resultState, QString & result);
void onCCRevertTransactionResult(nsCCInterface::RESULT_STATE resultState, QString & result);
void onCCPreAuthTransactionResult(nsCCInterface::RESULT_STATE resultState, QString & result);
void onCCBookTotalTransactionResult(nsCCInterface::RESULT_STATE resultState, QString & result);
void onCCCancelPreAuthTransactionResult(nsCCInterface::RESULT_STATE resultState, QString & result);
void onCCRequestCardInfoResult(nsCCInterface::RESULT_STATE resultState, QString & result);
// CalculatePricePlugin
#ifdef USE_CALCULATEPRICE_PLUGIN
void onCalculatePrice(QString & licensePlate);
void onCalculatePrice(uint parktime);
void onCalculatePrice(QString & cardInfo, QString & cardTransactionInfo);
void onCalculatePrice();
void onCalculatedPrice(nsCalculatePriceInterface::RESULT_STATE resultState,
const QString & accessInformation,
const QString & accessInformationType,
const QString & amountDuePeriodStart,
const QString & amountDuePeriodEnd,
const PriceInfo & priceInfo,
const QString & errorCode,
const QString & errorDescription);
void onProcessTransaction(nsCalculatePriceInterface::RESULT_STATE resultState,
const QString & errorCode,
const QString & errorDescription);
QChar private_getAccessInformationField(const QString & accessInformationType);
QString private_calculatedPrice(nsCalculatePriceInterface::RESULT_STATE resultState,
const QString & accessInformation,
const QString & accessInformationType,
const QString & amountDuePeriodStart,
const QString & amountDuePeriodEnd,
const PriceInfo & priceInfo,
const QString & errorCode,
const QString & errorDescription);
#endif // USE_CALCULATEPRICE_PLUGIN
// vmc control
void onVMCFormatedString(FormatedStringList data);
void onVMCSellData(quint8 nr,QString data);
// deprecated vmc control for cc
// this allows cc control by screens
void onVMC_ccStartTransaction();
void onVMC_ccCancelTransaction();
void onVMC_ccConfirmTransaction();
void onVMC_ccStartPreauthorisation();
void onVMC_ccCancelPreauthorisation();
void onVMC_ccConfirmPreauthorisation();
void onVMC_ccStartReadCard();
// new control interface
void onControl_switchMode(quint16 mode);
void onControl_switchScreen(quint16 screen);
void onControl_setText(quint16 screenNr, quint16 textNr, quint16 lang, QString text);
void onShowCurrentIdle();
void onShowCurrentOOO();
// vendingData
void onSetVendingData(QString key, QByteArray value);
signals:
// signals for signaling a mode change to sub-modules:
void changedProgramMode(PROGRAM_MODE newProgramMode);
void changedModeToSELL();
void changedModeToSERVICE();
void changedModeToIDLE();
void changedModeToOOO();
void doOfflineProcessing();
// cc
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private:
PROGRAM_MODE programmode;
ATBHMIconfig *config;
ATB_system *system;
VMC *vmc;
VendingData *vendingData;
PluginManager *pluginManager;
void private_setupProgramModeSELL();
void private_setupProgramModeSELL_ENABLE();
void private_setupProgramModeSERVICE();
void private_setupProgramModeIDLE();
void private_setupProgramModeOOO();
void private_unsetProgramModeSERVICE();
void private_unsetProgramModeOOO();
// plugins
CCInterface *cc;
CalculatePriceInterface *calcPriceBackend;
// init methods called from constructor
void private_initCCPlugin();
void private_initCalculatePricePlugin();
void private_initSimulationPlugin();
// timers
QTimer *sellModeTimeoutTimer;
// flag to prepare for OOO in next idle
quint8 prepareInternalOOO;
// action processing
quint8 startAction(APP_ACTION action);
#if defined (ARCH_DesktopLinux)
void private_screenshot();
#endif
#if defined (CUST00318)
// hack for 00318/Nexobility
void private_CUST00318_handle_CC_ERROR_0x13();
#endif
// mouse detection
#if defined (ARCH_PTU4)
QFileSystemWatcher *pInputDeviceWatcher;
void setMouse(const QString & mouseDeviceFile, const QString & touchDeviceFile);
void closeMouse(const QString & mouseDeviceFile, const QString & touchDeviceFile);
bool mousePresent;
#endif
private slots:
// firstRun -> things done with running event loop
void firstRun();
// timers
void onSellModeTimerTimeout();
/********************************************
* CC - Slots
*/
void onCCStartTransaction();
void onCCStartConfirmTransaction();
void onCCCancelTransaction();
void onCCStartPreauthorisation();
void onCCConfirmPreauthorisation();
void onCCCancelPreauthorisationRequest();
void onCCPrintReceipt();
void onCCErrorBackend(QString & result);
void onCCStartReadCard();
/*******************************************/
// called, if system was woken up
void onWakeUp();
/********************************************
* Barcode / QR-Code - Slots
*/
#ifdef USE_BARCODESCANNER
// called, if a barcode was read from scanner
void onReadBarcode(QString & barcode);
// called, if a new barcode should be created and sent to vmc
void onRequestNewBarcode();
#endif
/*******************************************/
#if defined (Q_WS_QWS)
void onInputDeviceWatcher_directoryChanged(const QString& path);
#endif
/********************************************
* ISMAS
*/
void onProcessed_QRCode(QHash<QString, QByteArray> data);
/********************************************
* Signal System Errors
*/
void onSignalSystemErrors(const QString & errorCode, const QString & errorDescription);
};
#endif // APPCONTROL_H

View File

@ -1,652 +0,0 @@
#include "atb_system.h"
#include "ATBHMIconfig.h"
#include <QDebug>
#include <QProcess>
#include <QFile>
#include <QDir>
#include <QFileInfo>
#include <QTextStream>
#include <QString>
#include <QTimer>
ATB_system::ATB_system(ATBHMIconfig *config, QObject *parent) :
QObject(parent)
{
this->config = config;
this->tf_gpio = nullptr;
#if defined (ARCH_PTU2)
if (config->hasFeatureTF()) init_touch_feedback();
#elif defined (ARCH_PTU4)
if (config->hasFeatureTF()) init_touch_feedback();
#endif
}
ATB_system::~ATB_system()
{
if (config->hasFeatureTF()) {
delete(this->tf_gpio_outstream);
delete(this->tf_gpio);
}
}
void ATB_system::executeSystemCommand(quint16 cmd, QByteArray data)
{
Q_UNUSED(data);
switch (cmd) {
case SYS_COMMAND_SLEEP:
qDebug() << "ATB_system::executeSystemCommand(): " << cmd;
dbus_permitSuspend();
break;
case SYS_COMMAND_DIMLOW:
if (config->hasFeatureDBusDisplayControl()) {
dbus_DimControlStart();
} else {
this->DimLow();
}
break;
case SYS_COMMAND_DIMHIGH:
if (config->hasFeatureDBusDisplayControl()) {
dbus_DimHighPermanent();
} else {
this->DimHigh();
}
break;
case SYS_COMMAND_BEEP:
if (config->hasFeatureTF()) this->Beep();
break;
case SYS_COMMAND_MACHINE_NUMBER: // deprecated and not used
// setMachineNumber(data);
break;
case SYS_COMMAND_LED_CONTROL:
this->privateConfigLED(data);
break;
case SYS_COMMAND_HALT:
this->halt();
break;
case SYS_COMMAND_REBOOT:
this->reboot();
break;
default:
qDebug() << "ATB_system::executeSystemCommand(): unknown command: " << cmd;
break;
}
}
/*****************************************************************************
* stubs for display control
*
* this methodes should later be scriptable an call corresponding methodes
* in DisplayControl via DBus.
*/
void ATB_system::DimLow() { return; }
void ATB_system::DimHigh()
{
//if (config->hasFeatureDC())
// this->dc->DimHigh();
}
//void ATB_system::Dim(quint8 value) { if (config->hasFeatureDC()) this->dc->Dim((uchar)value); }
void ATB_system::DimStart() { return; }
void ATB_system::DimStop() { return; }
/*****************************************************************************
*/
void ATB_system::Beep() {
qDebug() << "ATB_system::Beep(): now i should make a beep!";
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
QTimer::singleShot (BEEPTIMEOUT, this, SLOT(BeepStop()) );
*(this->tf_gpio_outstream) << config->getTouchFeedbackOnValue();
this->tf_gpio_outstream->flush();
#endif
}
void ATB_system::BeepStop() {
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
*(this->tf_gpio_outstream) << config->getTouchFeedbackOffValue();
this->tf_gpio_outstream->flush();
#endif
}
/********************************************************************************
* set date/time
*
* Datestring format: YYYY-MM-DD hh:mm[:ss]
* This is a format that is accepted both by busybox-date (e.g. PTU2) and by
* coreutils-date.
*
* example:
* /bin/date -s "2015-08-05 17:55:00"
*
*/
void ATB_system::setDateTime(const QString & dateTimeString)
{
QString datetimeCMD = "/bin/date -s " + dateTimeString;
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
QProcess::startDetached(datetimeCMD);
// the following does not work on PTU2:
//QProcess::startDetached ("/sbin/hwclock -w");
#endif
}
/********************************************************************************
* static functions to write single values to files.
*
* Used e.g. to store some machine specific settings like customer number or machine
* number in filesystem.
*
* This data should be updated rarely and the calling function must keep this in mind!
*
* Note: QFile::open() creates a file, if it is not existing.
*/
quint8 ATB_system::setPSAConfigInt(const QString &filename, quint16 iValue)
{
return setPSAConfigString(filename, QString::number(iValue));
}
quint8 ATB_system::setPSAConfigString(const QString & filename, const QString & sValue)
{
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
QFile file(filename);
#else
QFile file(QDir::homePath() + filename);
#endif
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "ATB_system::setPSAConfigString() cannot open file: " << filename;
qDebug() << " file.errorString() = " << file.errorString();
return 0;
}
qDebug() << "ATB_system::setPSAConfigString() write file: " << filename;
QTextStream out(&file);
out << sValue;
out.flush();
file.close();
return 1;
}
quint16 ATB_system::readPSAConfigInt(const QString & filename)
{
bool ok;
quint16 result = (quint16)readPSAConfigString(filename).toInt(&ok);
if (!ok) {
result = 0;
}
return result;
}
QString ATB_system::readPSAConfigString(const QString & filename)
{
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
QFileInfo fileinfo(filename);
#else
QFileInfo fileinfo(QDir::homePath() + filename);
#endif
if (! fileinfo.isReadable() ) {
qDebug() << "ATB_system::readPSAConfigString(): \"" << filename << "\" is not readable";
return 0;
}
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
QFile file(filename);
#else
QFile file(QDir::homePath() + filename);
#endif
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "ATB_system::readPSAConfigString() cannot open file: " << filename;
return 0;
}
QTextStream in(&file);
QString stringValue = in.readLine(100);
qDebug() << "ATB_system::readPSAConfigString() stringValue = " << stringValue;
file.close();
return stringValue;
}
/********************************************************************************
* LED control interface
*
*/
void ATB_system::onConfigLED(LED_NAME LED, LED_TRIGGER trigger, quint16 delayOn, quint16 delayOff)
{
QString LEDPath = "/sys/class/leds/";
QString LEDName = "";
QString LEDtrigger = "";
// DEBUG
// ////////
switch (LED) {
#if defined (ARCH_PTU2)
case ATB_LED1: LEDName.append("atb_led1"); break;
case ATB_LED2: LEDName.append("atb_led2"); break;
case ATB_LED3: LEDName.append("atb_led3"); break;
case ATB_LED4: LEDName.append("atb_led4"); break;
#elif defined (ARCH_PTU4)
case ATB_LED1: LEDName.append("D504"); break;
case ATB_LED2: LEDName.append("D503"); break;
case ATB_LED3: LEDName.append("D502"); break;
case ATB_LED4: LEDName.append("D501"); break;
#endif
default: return;
}
switch (trigger) {
case LED_TRIGGER_NONE: LEDtrigger.append("none"); break;
case LED_TRIGGER_TIMER: LEDtrigger.append("timer"); break;
#if defined (ARCH_PTU2)
case LED_TRIGGER_DEFAULT_ON: LEDtrigger.append("default-on"); break;
#elif defined (ARCH_PTU4)
/* note: ptu4 leds currently do not support 'default-on' trigger
* workaround is to set delay_off to '0'
*/
case LED_TRIGGER_DEFAULT_ON: LEDtrigger.append("timer");
trigger = LED_TRIGGER_TIMER;
delayOn = 1;
delayOff = 0;
break;
#endif
default: return;
}
QString filename = LEDPath + LEDName + "/trigger";
// set trigger
this->privateSetLEDTrigger(filename, LEDtrigger);
// set delays for trigger 'timer'
if (trigger == LED_TRIGGER_TIMER) {
// set delay on
if (delayOn != 0) {
filename = LEDPath + LEDName + "/delay_on";
this->privateSetLEDDelayOn(filename, QString::number(delayOn));
}
// set delay off
if (delayOff != 0) {
filename = LEDPath + LEDName + "/delay_off";
this->privateSetLEDDelayOn(filename, QString::number(delayOff));
}
}
return;
}
/*****************************************************************************
* wrapper function for LED control.
*
* TODO: Test, check: plausibillity, cmd.lenght(), type casts to LED_NAME, LED_TRIGGER
*/
void ATB_system::privateConfigLED(const QByteArray & cmd)
{
quint16 delayOn = (quint8)cmd.at(3) + ((quint16)(cmd.at(2) << 8));
quint16 delayOff = (quint8)cmd.at(5) + ((quint16)(cmd.at(4) << 8));
this->onConfigLED((LED_NAME)cmd.at(0), (LED_TRIGGER)cmd.at(1), delayOn, delayOff);
}
void ATB_system::privateSetLEDTrigger(const QString & led, const QString & trigger)
{
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
QFile file(led);
#else
QFile file(QDir::homePath() + led);
#endif
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "ATB_system::onConfigLED() cannot open file: " << led;
qDebug() << " file.errorString() = " << file.errorString();
return;
}
qDebug() << "ATB_system::onConfigLED() write file: " << led;
QTextStream out(&file);
out << trigger;
out.flush();
file.close();
}
void ATB_system::privateSetLEDDelayOn(const QString & led, const QString & delayOn)
{
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
QFile file(led);
#else
QFile file(QDir::homePath() + led);
#endif
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "ATB_system::onConfigLED() cannot open file: " << led;
qDebug() << " file.errorString() = " << file.errorString();
return;
}
qDebug() << "ATB_system::onConfigLED() write file: " << led;
QTextStream out(&file);
out << delayOn;
out.flush();
file.close();
}
void ATB_system::privateSetLEDDelayOff(const QString & led, const QString & delayOff)
{
#if defined (ARCH_PTU2) || defined (ARCH_PTU4)
QFile file(led);
#else
QFile file(QDir::homePath() + led);
#endif
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "ATB_system::onConfigLED() cannot open file: " << led;
qDebug() << " file.errorString() = " << file.errorString();
return;
}
qDebug() << "ATB_system::onConfigLED() write file: " << led;
QTextStream out(&file);
out << delayOff;
out.flush();
file.close();
}
/*****************************************************************************
* functions for switching blink button on/off
* This is only available on PTU4
*/
void ATB_system::switchBlinkButtonOn()
{
this->privateSwitchBlinkButton(true);
}
void ATB_system::switchBlinkButtonOff()
{
this->privateSwitchBlinkButton(false);
}
void ATB_system::privateSwitchBlinkButton(bool on)
{
#if defined (ARCH_PTU2)
#elif defined (ARCH_PTU4)
QString BlinkLED("/sys/class/leds/TIMER_RESET/brightness");
QFile file(BlinkLED);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "ATB_system::privateSwitchBlinkButton() cannot open file: " << BlinkLED;
qDebug() << " file.errorString() = " << file.errorString();
return;
}
QTextStream out(&file);
if (on) { out << "0"; }
else { out << "1"; }
out.flush();
file.close();
#else
Q_UNUSED(on)
#endif
}
/*****************************************************************************
* halt system.
*
*/
void ATB_system::halt()
{
QProcess::startDetached("/sbin/halt");
}
/*****************************************************************************
* reboot system.
*
*/
void ATB_system::reboot()
{
QProcess::startDetached("/sbin/reboot");
}
/*****************************************************************************
* functions for wake vmc
* This is only available on PTU4
*/
void ATB_system::onWakeVMC()
{
#if defined (ARCH_PTU2)
#elif defined (ARCH_PTU4)
if (config->hasFeatureDBusSuspendControl()) {
this->dbus_wakeSystem();
}
#endif
}
/*****************************************************************************
* get event device name by a type:
*
* e.g. type is TOUCHSCREEN:
* getEventDeviceName(TOUCHSCREEN) returns "/dev/input/event0"
*
*/
QString ATB_system::getEventDeviceName(DEVICE_TYPE type)
{
QString procDevices = "/proc/bus/input/devices";
QFile inFile(procDevices);
if (!inFile.open(QFile::ReadOnly)) {
qCritical() << "ATB_system::getEventDeviceName() ERROR open()" << procDevices;
return "";
}
QTextStream textInStream(&inFile);
QString line;
QString N_RegExp;
QString DeviceTypeName;
int lineCounter = 0;
bool typeFound = false;
QString H_RegExp = "^H: Handlers"; // H: Handlers=kbd event2
QString eventDeviceName = "";
QString eventPart;
QStringList devNames;
QString DeviceNamePattern;
//PTU4 Touchscreen N: Name="atmel_mxt_ts T100 touchscreen"
//PTU4 GPIO kys N: Name="gpio_keys.6"
//RFID Reader, Stronglink SL040 N: Name="StrongLink USB CardReader"
//2D Scanner, Datalogig DSE0420 N: Name="Datalogic ADC Inc. Handheld Barcode Scanner" VID: 05f9, PID:4005
//2D Scanner, Datalogig DSM0400 N: Name="Datalogic Handheld Barcode Scanner" VID: 05f9, PID:4005
//2D Scanner, Honeywell N56000 N: Name="Honeywell Imaging & Mobility N5600"
//2D Scanner, Newland FM3080 N: Name="Newland Auto-ID NLS-FM3080V2-20 USB POS KBW" VID: 1eab, PID:0022
//2D Scanner, Opticon MDI-4000 N: Name="Opticon Opticon USB Barcode Reader"
//USB Mouse N: Name="Logitech USB-PS/2 Optical Mouse"
/* Datalogic DSE0420
I: Bus=0003 Vendor=05f9 Product=4005 Version=0110
N: Name="Datalogic ADC Inc. Handheld Barcode Scanner"
P: Phys=usb-700000.ehci-2.3/input2
S: Sysfs=/devices/ahb.0/700000.ehci/usb1/1-2/1-2.3/1-2.3:1.2/input/input14
U: Uniq=S/N G16C15795
H: Handlers=kbd event3
B: PROP=0
B: EV=120013
B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe
B: MSC=10
B: LED=1f
*/
/* Datalogic DSM04XX
I: Bus=0003 Vendor=05f9 Product=4005 Version=0110
N: Name="Datalogic Handheld Barcode Scanner"
P: Phys=usb-700000.ehci-2.3/input0
S: Sysfs=/devices/ahb.0/700000.ehci/usb1/1-2/1-2.3/1-2.3:1.0/input/input15
U: Uniq=S/N G21FA0180
H: Handlers=kbd event3
B: PROP=0
B: EV=120013
B: KEY=e080ffdf 1cfffff ffffffff fffffffe
B: MSC=10
B: LED=1f
*/
/*
I: Bus=0003 Vendor=1eab Product=0022 Version=0110
N: Name="Newland Auto-ID NLS-FM3080V2-20 USB POS KBW"
P: Phys=usb-700000.ehci-2.2/input0
S: Sysfs=/devices/ahb.0/700000.ehci/usb1/1-2/1-2.2/1-2.2:1.0/input/input6
U: Uniq=FM3080V2-20-BH00017
H: Handlers=kbd event2
B: PROP=0
B: EV=120013
B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe
B: MSC=10
B: LED=1f
*/
switch (type) {
case EVENT_DEVICE_BARCODEREADER:
N_RegExp = "^N: Name=.+(Barcode|Honeywell Imaging|Newland Auto).+";
DeviceTypeName = "1D/2D-Scanner";
DeviceNamePattern = "event";
break;
case EVENT_DEVICE_TOUCHSCREEN:
N_RegExp = "^N: Name=.+touch.+";
DeviceTypeName = "Touchscreen";
DeviceNamePattern = "event";
break;
case EVENT_DEVICE_GPIO_KEYBOARD:
N_RegExp = "^N: Name=.+gpio.+";
DeviceTypeName = "gpio-keys";
DeviceNamePattern = "event";
break;
case EVENT_DEVICE_KEYBOARD:
N_RegExp = "^N: Name=.+touch.+";
DeviceTypeName = "keyboard";
DeviceNamePattern = "event";
break;
case EVENT_DEVICE_RFIDREADER:
N_RegExp = "^N: Name=.+Card.+";
DeviceTypeName = "card reader";
DeviceNamePattern = "event";
break;
case EVENT_DEVICE_USBMOUSE:
N_RegExp = "^N: Name=.+USB.+Mouse.+";
DeviceTypeName = "USB Mouse";
DeviceNamePattern = "mouse";
break;
}
qDebug() << "ATB_system::getEventDeviceName() N_RegExp = " << N_RegExp;
do {
line = textInStream.readLine();
// DEBUG
//qDebug() << " " << line;
// find "N:"-line:
if (line.contains(QRegExp(N_RegExp))) {
typeFound = true;
lineCounter = 0;
qDebug() << "ATB_system::getEventDeviceName() found N_RegExp = " << N_RegExp;
}
if (typeFound) {
// found "N:"-line, now search for "H:"-line;
// the corresponding "H:"-line should be within the next 7 following text lines.
// example lines:
// - "H: Handlers=event0 mouse0" -> for touchscreen on PTU4
// - "H: Handlers=event3 mouse1" -> for USB mouse on PTU4
lineCounter++;
if ( (lineCounter<=7) && (line.contains(QRegExp(H_RegExp))) ) {
eventPart = line.split("=", QString::SkipEmptyParts).takeLast();
devNames = eventPart.split(" ", QString::SkipEmptyParts);
for (int i=0; i<devNames.size(); i++ ) {
if (devNames.at(i).contains(DeviceNamePattern)) {
eventDeviceName = "/dev/input/" + devNames.at(i);
qDebug() << "ATB_system::getEventDeviceName() found device = " << eventDeviceName;
}
}
}
if ( lineCounter>7 ) {
lineCounter=0;
typeFound = false;
}
}
} while (!line.isNull());
if (eventDeviceName == "") {
qCritical() << "ATB_system::getEventDeviceName(): could not detect input event device type " << DeviceTypeName;
}
return eventDeviceName;
}

View File

@ -1,117 +0,0 @@
#ifndef ATB_SYSTEM_H
#define ATB_SYSTEM_H
#include <QObject>
#include <QFile>
#include <QTextStream>
#include "version.h"
#define SYS_COMMAND_SLEEP 0x0001
#define SYS_COMMAND_DIMLOW 0x0002
#define SYS_COMMAND_DIMHIGH 0x0003
#define SYS_COMMAND_BEEP 0x0004
#define SYS_COMMAND_MACHINE_NUMBER 0x0005
#define SYS_COMMAND_HALT 0x0006
#define SYS_COMMAND_REBOOT 0x0007
#define SYS_COMMAND_LED_CONTROL 0x3600
#if defined (ARCH_PTU2)
#define BEEPTIMEOUT 200
#elif defined (ARCH_PTU4)
#define BEEPTIMEOUT 100
#else
#define BEEPTIMEOUT 100
#endif
class ATBHMIconfig;
class ATB_system : public QObject {
Q_OBJECT
private:
ATBHMIconfig *config;
QFile *tf_gpio;
QTextStream *tf_gpio_outstream;
quint8 current_dim_value;
void privateConfigLED(const QByteArray & cmd);
void privateSetLEDTrigger(const QString & led, const QString & trigger);
void privateSetLEDDelayOn(const QString & led, const QString & delayOn);
void privateSetLEDDelayOff(const QString & led, const QString & delayOff);
void privateSwitchBlinkButton(bool on);
public:
explicit ATB_system(ATBHMIconfig *config, QObject *parent = nullptr);
~ATB_system();
static quint8 setPSAConfigInt(const QString & filename, quint16 iValue);
static quint16 readPSAConfigInt(const QString &filename);
static quint8 setPSAConfigString(const QString & filename, const QString & sValue);
static QString readPSAConfigString(const QString & filename);
enum LED_NAME {
ATB_LED1 = 1,
ATB_LED2,
ATB_LED3,
ATB_LED4
};
enum LED_TRIGGER {
LED_TRIGGER_NONE = 1,
LED_TRIGGER_TIMER,
LED_TRIGGER_DEFAULT_ON
};
enum DEVICE_TYPE {
EVENT_DEVICE_BARCODEREADER,
EVENT_DEVICE_TOUCHSCREEN,
EVENT_DEVICE_GPIO_KEYBOARD,
EVENT_DEVICE_KEYBOARD,
EVENT_DEVICE_RFIDREADER,
EVENT_DEVICE_USBMOUSE
};
static QString getEventDeviceName(DEVICE_TYPE type);
static quint8 setupInductionLoops();
void dbus_permitSuspend();
void dbus_preventSuspend();
void dbus_DimHighPermanent();
void dbus_DimControlStart();
void dbus_wakeSystem();
signals:
/* emitted, after waking up from suspend...
*/
void wakeUp();
public slots:
void executeSystemCommand(quint16 cmd, QByteArray data);
void DimHigh();
void DimLow();
void Dim(quint8 value);
void DimStart();
void DimStop();
void Beep();
void BeepStop();
void setDateTime(const QString &dateTimeString);
void onConfigLED(LED_NAME LED, LED_TRIGGER trigger, quint16 delayOn = 0, quint16 delayOff = 0);
void switchBlinkButtonOn();
void switchBlinkButtonOff();
void onWakeVMC();
void halt();
void reboot();
};
#endif // ATB_SYSTEM_H