Compare commits
7 Commits
f0762e272f
...
master
Author | SHA1 | Date | |
---|---|---|---|
4b38e2e46e | |||
9fa37d125d | |||
00dbf4485a | |||
88670c1079 | |||
2efdbe2d68 | |||
38994ac192 | |||
f6238e5a36 |
@@ -7,6 +7,9 @@
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
class UnifiedDCVMCInterface;
|
||||
|
||||
template <typename T>
|
||||
struct ATBAPPplugin {
|
||||
enum class PLUGIN_STATE : quint8 {
|
||||
NOT_INITIALIZED = 0,
|
||||
@@ -54,14 +57,14 @@ struct ATBAPPplugin {
|
||||
}
|
||||
};
|
||||
|
||||
using PLUGIN_STATE = ATBAPPplugin::PLUGIN_STATE;
|
||||
using RESULT_STATE = ATBAPPplugin::RESULT_STATE;
|
||||
using CASH_STATE = ATBAPPplugin::CASH_STATE;
|
||||
using TICKET_VARIANT = ATBAPPplugin::TICKET_VARIANT;
|
||||
using STEP = ATBAPPplugin::STEP;
|
||||
using TERMINAL_STATE = ATBAPPplugin::TERMINAL_STATE;
|
||||
using PLUGIN_STATE = ATBAPPplugin<UnifiedDCVMCInterface>::PLUGIN_STATE;
|
||||
using RESULT_STATE = ATBAPPplugin<UnifiedDCVMCInterface>::RESULT_STATE;
|
||||
using CASH_STATE = ATBAPPplugin<UnifiedDCVMCInterface>::CASH_STATE;
|
||||
using TICKET_VARIANT = ATBAPPplugin<UnifiedDCVMCInterface>::TICKET_VARIANT;
|
||||
using STEP = ATBAPPplugin<UnifiedDCVMCInterface>::STEP;
|
||||
using TERMINAL_STATE = ATBAPPplugin<UnifiedDCVMCInterface>::TERMINAL_STATE;
|
||||
|
||||
Q_DECLARE_INTERFACE(ATBAPPplugin,
|
||||
"eu.atb.ptu.plugin.ATBAPPplugin/0.9")
|
||||
//Q_DECLARE_INTERFACE(ATBAPPplugin,
|
||||
// "eu.atb.ptu.plugin.ATBAPPplugin/0.9")
|
||||
|
||||
#endif // ATBAPPPLUGIN_H
|
||||
|
@@ -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(setDefaultLanguage(quint8)), hmiConfig, SLOT(setDefaultLanguage(quint8)), Qt::QueuedConnection);
|
||||
|
||||
connect(m_vmc, SIGNAL(wakeVMC()), m_vmc, SLOT(onWakeVMC()), Qt::QueuedConnection);
|
||||
|
||||
return PLUGIN_STATE::INITIALIZED;
|
||||
}
|
||||
|
||||
@@ -110,8 +112,6 @@ QString const &ATBVMCPlugin::getLastErrorDescription() {
|
||||
return m_errorDescription;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// helpers e.g. for debug / log
|
||||
QString const &ATBVMCPlugin::getString(RESULT_STATE resultState) {
|
||||
static QString str;
|
||||
@@ -135,6 +135,15 @@ QString const &ATBVMCPlugin::getString(RESULT_STATE resultState) {
|
||||
case RESULT_STATE::INFO:
|
||||
str = QString("RESULT_STATE::INFO");
|
||||
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;
|
||||
}
|
||||
@@ -172,6 +181,18 @@ void ATBVMCPlugin::reset() {
|
||||
|
||||
}
|
||||
|
||||
QStringList ATBVMCPlugin::interfaces() const {
|
||||
QStringList result;
|
||||
int const count = this->metaObject()->classInfoCount();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QString const name(QString::fromLatin1(this->metaObject()->classInfo(i).name()));
|
||||
QString const value(QString::fromLatin1(this->metaObject()->classInfo(i).value()));
|
||||
if (name == "Interface") {
|
||||
result << value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
Q_EXPORT_PLUGIN2(ATBVMCPlugin, ATBVMCPlugin)
|
||||
|
@@ -15,6 +15,7 @@ class ATBVMCPlugin : public VMCInterface {
|
||||
Q_OBJECT
|
||||
|
||||
Q_INTERFACES(VMCInterface)
|
||||
Q_CLASSINFO("Interface", "VMCInterface")
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
Q_PLUGIN_METADATA(IID "eu.atb.ptu.plugin.ATBVMCPlugin")
|
||||
@@ -42,6 +43,8 @@ public:
|
||||
// helpers e.g. for debug / log
|
||||
virtual QString const &getString(RESULT_STATE resultState) override;
|
||||
|
||||
QStringList interfaces() const;
|
||||
|
||||
public slots:
|
||||
virtual void onChangedProgramModeToSELL() override;
|
||||
virtual void onChangedProgramModeToSERVICE() override;
|
||||
|
@@ -12,8 +12,9 @@
|
||||
#include "ATBAPPplugin.h"
|
||||
|
||||
|
||||
class UnifiedDCVMCInterface : public ATBAPPplugin {
|
||||
Q_INTERFACES(ATBAPPplugin)
|
||||
class UnifiedDCVMCInterface : public ATBAPPplugin<UnifiedDCVMCInterface> {
|
||||
//Q_INTERFACES(ATBAPPplugin)
|
||||
//Q_CLASSINFO("Interface", "ATBAPPplugin")
|
||||
|
||||
public:
|
||||
explicit UnifiedDCVMCInterface() = default;
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
|
||||
virtual QString const &getString(RESULT_STATE resultState) = 0;
|
||||
|
||||
public slots:
|
||||
//public slots:
|
||||
virtual void onChangedProgramModeToSELL() = 0;
|
||||
virtual void onChangedProgramModeToSERVICE() = 0;
|
||||
virtual void onChangedProgramModeToIDLE() = 0;
|
||||
@@ -56,7 +57,7 @@ public slots:
|
||||
virtual void reset() = 0;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(UnifiedDCVMCInterface,
|
||||
"eu.atb.ptu.plugin.UnifiedDCVMCInterface/1.0")
|
||||
//Q_DECLARE_INTERFACE(UnifiedDCVMCInterface,
|
||||
// "eu.atb.ptu.plugin.UnifiedDCVMCInterface/1.0")
|
||||
|
||||
#endif // UNIFIED_DCVMC_INTERFACE_H_INCLUDED
|
||||
|
@@ -20,8 +20,10 @@ namespace nsVMCInterface {
|
||||
class VMCInterface : public QObject, public UnifiedDCVMCInterface {
|
||||
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(ATBAPPplugin UnifiedDCVMCInterface)
|
||||
|
||||
//Q_INTERFACES(ATBAPPplugin UnifiedDCVMCInterface)
|
||||
//Q_INTERFACES(UnifiedDCVMCInterface)
|
||||
//Q_CLASSINFO("Interface", "ATBAPPplugin")
|
||||
//Q_CLASSINFO("Interface", "UnifiedDCVMCInterface")
|
||||
public:
|
||||
|
||||
explicit VMCInterface(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
@@ -13,6 +13,13 @@
|
||||
VMC::VMC(QObject *appControl, QSettings const *settings,
|
||||
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->currentCachedScreen = VMC_CMD_SCREEN_START;
|
||||
|
||||
@@ -23,6 +30,8 @@ VMC::VMC(QObject *appControl, QSettings const *settings,
|
||||
this->receiveBuffer = new ReceiveBuffer(com_interface, this);
|
||||
this->sendBuffer = new SendBuffer(com_interface, this);
|
||||
|
||||
this->privateInit_REMOTE_OUT();
|
||||
|
||||
connect(receiveBuffer, SIGNAL(ReceiveResponse(quint8)), sendBuffer, SLOT(onReceiveResponse(quint8)));
|
||||
|
||||
com_interface->open(settings->value("VMC/serialPort", "ttymxc2").toString(),
|
||||
@@ -41,11 +50,59 @@ VMC::VMC(QObject *appControl, QSettings const *settings,
|
||||
|
||||
|
||||
VMC::~VMC() {
|
||||
delete(this->sendBuffer);
|
||||
delete(this->receiveBuffer);
|
||||
delete(this->com_interface);
|
||||
if (this->REMOTE_OUT_gpio_outstream) {
|
||||
delete(this->REMOTE_OUT_gpio_outstream);
|
||||
}
|
||||
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
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#include <QTimer>
|
||||
#include <QList>
|
||||
#include <QSettings>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
#define VMC_RECEIVE_TIMEOUT 1000
|
||||
@@ -147,11 +149,8 @@ class SendBuffer;
|
||||
using FormatedStringList = QList<QByteArray>;
|
||||
|
||||
|
||||
class VMC : public QObject
|
||||
{
|
||||
class VMC : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
private:
|
||||
QObject *m_appControl;
|
||||
COM_interface *com_interface;
|
||||
@@ -159,6 +158,9 @@ private:
|
||||
SendBuffer *sendBuffer;
|
||||
QSettings const *m_settings;
|
||||
|
||||
QFile *REMOTE_OUT_gpio;
|
||||
QTextStream *REMOTE_OUT_gpio_outstream;
|
||||
|
||||
// internal: write a ByteArray to com-port:
|
||||
int SendMessage(QByteArray ba, bool enqueue = false);
|
||||
|
||||
@@ -185,10 +187,14 @@ private:
|
||||
quint8 flag_blockVMCScreen;
|
||||
quint16 currentCachedScreen;
|
||||
|
||||
void privateInit_REMOTE_OUT();
|
||||
|
||||
private slots:
|
||||
void onDelayedMessageTimerTimeout();
|
||||
|
||||
void skipDiscount();
|
||||
void privateSet_REMOTE_OUT(bool state);
|
||||
void privateWakeVMC();
|
||||
void privateSuspendVMC();
|
||||
|
||||
public:
|
||||
explicit VMC(QObject *eventReceiver, QSettings const *settings,
|
||||
@@ -387,6 +393,8 @@ public slots:
|
||||
void ccStartTransactionRequest(); // called to start/restart a CC transaction
|
||||
void ccStartConfirmTransaction(); // called to start confirmation
|
||||
void ccPrintReceipt(QString receipt); // called to send receipt to vmc
|
||||
|
||||
void onWakeVMC();
|
||||
};
|
||||
|
||||
#endif // VMC_H
|
||||
|
Reference in New Issue
Block a user