integrate wakeup line
This commit is contained in:
		@@ -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