Compare commits

...

3 Commits

Author SHA1 Message Date
2efdbe2d68 Extend getString(). 2023-11-17 11:46:29 +01:00
38994ac192 connect() wakeup line. 2023-11-17 11:45:50 +01:00
f6238e5a36 integrate wakeup line 2023-11-17 11:44:51 +01:00
3 changed files with 84 additions and 10 deletions

View File

@ -91,6 +91,8 @@ PLUGIN_STATE ATBVMCPlugin::initVMCPlugin(QObject *appControl,
connect(m_vmc, SIGNAL(setMachineNr(QString)), hmiConfig, SLOT(setMachineNr(QString)), Qt::QueuedConnection); connect(m_vmc, SIGNAL(setMachineNr(QString)), hmiConfig, SLOT(setMachineNr(QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(setDefaultLanguage(quint8)), hmiConfig, SLOT(setDefaultLanguage(quint8)), Qt::QueuedConnection); connect(m_vmc, SIGNAL(setDefaultLanguage(quint8)), hmiConfig, SLOT(setDefaultLanguage(quint8)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(wakeVMC()), m_vmc, SLOT(onWakeVMC()), Qt::QueuedConnection);
return PLUGIN_STATE::INITIALIZED; return PLUGIN_STATE::INITIALIZED;
} }
@ -110,8 +112,6 @@ QString const &ATBVMCPlugin::getLastErrorDescription() {
return m_errorDescription; return m_errorDescription;
} }
// helpers e.g. for debug / log // helpers e.g. for debug / log
QString const &ATBVMCPlugin::getString(RESULT_STATE resultState) { QString const &ATBVMCPlugin::getString(RESULT_STATE resultState) {
static QString str; static QString str;
@ -135,6 +135,15 @@ QString const &ATBVMCPlugin::getString(RESULT_STATE resultState) {
case RESULT_STATE::INFO: case RESULT_STATE::INFO:
str = QString("RESULT_STATE::INFO"); str = QString("RESULT_STATE::INFO");
break; break;
case RESULT_STATE::ERROR_NETWORK:
str = QString("RESULT_STATE::ERROR_NETWORK");
break;
case RESULT_STATE::ERROR_BUSY:
str = QString("RESULT_STATE::ERROR_BUSY");
break;
case RESULT_STATE::ERROR_STATE:
str = QString("RESULT_STATE::ERROR_STATE");
break;
} }
return str; return str;
} }

View File

@ -13,6 +13,13 @@
VMC::VMC(QObject *appControl, QSettings const *settings, VMC::VMC(QObject *appControl, QSettings const *settings,
QObject *parent) QObject *parent)
: QObject(parent) { : QObject(parent) {
this->REMOTE_OUT_gpio_outstream = nullptr;
this->REMOTE_OUT_gpio = nullptr;
this->sendBuffer = nullptr;
this->receiveBuffer = nullptr;
this->com_interface = nullptr;
this->flag_blockVMCScreen = 0; this->flag_blockVMCScreen = 0;
this->currentCachedScreen = VMC_CMD_SCREEN_START; this->currentCachedScreen = VMC_CMD_SCREEN_START;
@ -23,6 +30,8 @@ VMC::VMC(QObject *appControl, QSettings const *settings,
this->receiveBuffer = new ReceiveBuffer(com_interface, this); this->receiveBuffer = new ReceiveBuffer(com_interface, this);
this->sendBuffer = new SendBuffer(com_interface, this); this->sendBuffer = new SendBuffer(com_interface, this);
this->privateInit_REMOTE_OUT();
connect(receiveBuffer, SIGNAL(ReceiveResponse(quint8)), sendBuffer, SLOT(onReceiveResponse(quint8))); connect(receiveBuffer, SIGNAL(ReceiveResponse(quint8)), sendBuffer, SLOT(onReceiveResponse(quint8)));
com_interface->open(settings->value("VMC/serialPort", "ttymxc2").toString(), com_interface->open(settings->value("VMC/serialPort", "ttymxc2").toString(),
@ -41,11 +50,59 @@ VMC::VMC(QObject *appControl, QSettings const *settings,
VMC::~VMC() { VMC::~VMC() {
delete(this->sendBuffer); if (this->REMOTE_OUT_gpio_outstream) {
delete(this->receiveBuffer); delete(this->REMOTE_OUT_gpio_outstream);
delete(this->com_interface); }
if (this->REMOTE_OUT_gpio) {
delete(this->REMOTE_OUT_gpio);
}
if (this->sendBuffer) {
delete(this->sendBuffer);
}
if (this->receiveBuffer) {
delete(this->receiveBuffer);
}
if (this->com_interface) {
delete(this->com_interface);
}
} }
/*****************************************************************************
* functions for wake vmc
*/
void VMC::onWakeVMC() {
this->privateWakeVMC();
}
void VMC::privateWakeVMC() {
QTimer::singleShot (100, this, SLOT(privateSuspendVMC()));
this->privateSet_REMOTE_OUT(true);
}
void VMC::privateSuspendVMC() {
this->privateSet_REMOTE_OUT(false);
}
void VMC::privateSet_REMOTE_OUT(bool state) {
if (state) { *(this->REMOTE_OUT_gpio_outstream) << "1"; }
else { *(this->REMOTE_OUT_gpio_outstream) << "0"; }
this->REMOTE_OUT_gpio_outstream->flush();
}
void VMC::privateInit_REMOTE_OUT() {
QString sysfs_remout_out("/sys/class/leds/REMOTE_OUT/brightness");
this->REMOTE_OUT_gpio = new QFile(sysfs_remout_out);
if (!REMOTE_OUT_gpio->open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "ATB_system::privateInit_REMOTE_OUT() cannot open file: " << sysfs_remout_out;
qDebug() << " file.errorString() = " << REMOTE_OUT_gpio->errorString();
return;
}
this->REMOTE_OUT_gpio_outstream = new QTextStream(this->REMOTE_OUT_gpio);
}
/******************************************************************************** /********************************************************************************
* S E N D M E S S A G E S t o V M C * S E N D M E S S A G E S t o V M C

View File

@ -11,6 +11,8 @@
#include <QTimer> #include <QTimer>
#include <QList> #include <QList>
#include <QSettings> #include <QSettings>
#include <QFile>
#include <QTextStream>
#define VMC_RECEIVE_TIMEOUT 1000 #define VMC_RECEIVE_TIMEOUT 1000
@ -147,11 +149,8 @@ class SendBuffer;
using FormatedStringList = QList<QByteArray>; using FormatedStringList = QList<QByteArray>;
class VMC : public QObject class VMC : public QObject {
{
Q_OBJECT Q_OBJECT
private: private:
QObject *m_appControl; QObject *m_appControl;
COM_interface *com_interface; COM_interface *com_interface;
@ -159,6 +158,9 @@ private:
SendBuffer *sendBuffer; SendBuffer *sendBuffer;
QSettings const *m_settings; QSettings const *m_settings;
QFile *REMOTE_OUT_gpio;
QTextStream *REMOTE_OUT_gpio_outstream;
// internal: write a ByteArray to com-port: // internal: write a ByteArray to com-port:
int SendMessage(QByteArray ba, bool enqueue = false); int SendMessage(QByteArray ba, bool enqueue = false);
@ -185,10 +187,14 @@ private:
quint8 flag_blockVMCScreen; quint8 flag_blockVMCScreen;
quint16 currentCachedScreen; quint16 currentCachedScreen;
void privateInit_REMOTE_OUT();
private slots: private slots:
void onDelayedMessageTimerTimeout(); void onDelayedMessageTimerTimeout();
void skipDiscount(); void skipDiscount();
void privateSet_REMOTE_OUT(bool state);
void privateWakeVMC();
void privateSuspendVMC();
public: public:
explicit VMC(QObject *eventReceiver, QSettings const *settings, explicit VMC(QObject *eventReceiver, QSettings const *settings,
@ -387,6 +393,8 @@ public slots:
void ccStartTransactionRequest(); // called to start/restart a CC transaction void ccStartTransactionRequest(); // called to start/restart a CC transaction
void ccStartConfirmTransaction(); // called to start confirmation void ccStartConfirmTransaction(); // called to start confirmation
void ccPrintReceipt(QString receipt); // called to send receipt to vmc void ccPrintReceipt(QString receipt); // called to send receipt to vmc
void onWakeVMC();
}; };
#endif // VMC_H #endif // VMC_H