Compare commits
8 Commits
download-d
...
carun_remo
Author | SHA1 | Date | |
---|---|---|---|
c902bd9a54 | |||
25e7bf056b | |||
8f8947482a
|
|||
42c817ddce
|
|||
2c799e1cd2
|
|||
9cac6a6461 | |||
aa10d3b275 | |||
790c2fd031 |
@@ -90,7 +90,9 @@ HEADERS += \
|
||||
$${PWD}/include/sendWRcmd.h \
|
||||
$${PWD}/include/storeINdata.h \
|
||||
$${PWD}/include/tslib.h \
|
||||
$${PWD}/include/shared_mem_buffer.h
|
||||
$${PWD}/include/shared_mem_buffer.h \
|
||||
$${PWD}/include/reporting_thread.h \
|
||||
$${PWD}/include/download_thread.h
|
||||
|
||||
SOURCES += \
|
||||
$${PWD}/src/datei.cpp \
|
||||
@@ -101,7 +103,9 @@ SOURCES += \
|
||||
$${PWD}/src/sendWRcmd.cpp \
|
||||
$${PWD}/src/storeINdata.cpp \
|
||||
$${PWD}/src/tslib.cpp \
|
||||
$${PWD}/src/shared_mem_buffer.cpp
|
||||
$${PWD}/src/shared_mem_buffer.cpp \
|
||||
$${PWD}/src/reporting_thread.cpp \
|
||||
$${PWD}/src/download_thread.cpp
|
||||
|
||||
|
||||
# INTERFACE = DeviceController
|
||||
|
199
dCArun/CArun.cpp
Normal file
199
dCArun/CArun.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
#include "CArun.h"
|
||||
|
||||
#include "datei.h"
|
||||
|
||||
|
||||
#define UPDATE_PERIOD_MS 100
|
||||
// period to call chain steps
|
||||
|
||||
#define VENDINGTIMEOUT_MS 30000
|
||||
|
||||
|
||||
|
||||
CArun::CArun(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
loadPlugIn(1);
|
||||
|
||||
timerChainCtrl = new QTimer(this);
|
||||
connect(timerChainCtrl, SIGNAL(timeout()), this, SLOT(chainControl()));
|
||||
timerChainCtrl->setSingleShot(0);
|
||||
timerChainCtrl->start(UPDATE_PERIOD_MS); // 1000: call every 1000ms
|
||||
}
|
||||
|
||||
|
||||
char CArun::loadPlugIn(char lade1_entlade2)
|
||||
{
|
||||
plugInDir.cd("plugins");
|
||||
QPluginLoader *pluginLoader = new QPluginLoader();
|
||||
|
||||
pluginLoader->setFileName("/usr/lib/libCAmaster.so"); // for ptu5
|
||||
|
||||
if (lade1_entlade2==2)
|
||||
{
|
||||
pluginLoader->unload();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!pluginLoader->load())
|
||||
{
|
||||
qDebug()<<"cannot load plugin";
|
||||
} else
|
||||
qDebug() <<"loaded plugin: " << pluginLoader->fileName();
|
||||
|
||||
if (!pluginLoader->isLoaded())
|
||||
{
|
||||
qDebug()<<pluginLoader->errorString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
QObject *plugin = pluginLoader->instance();
|
||||
if ( plugin == nullptr)
|
||||
{
|
||||
// make instance of the root component (which can hold more then one clases)
|
||||
// also loads the lib if not yet done
|
||||
qDebug()<<"cannot start instance";
|
||||
return 0;
|
||||
}
|
||||
|
||||
HWaccess= qobject_cast<hwinf *>(plugin);
|
||||
// make instance to class "hwinf" in dll_HWapi.h over "interfaces.h"
|
||||
|
||||
qDebug()<<"loadPlugIn, HWAccess: " << HWaccess;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CArun::chainControl(void)
|
||||
{
|
||||
#define FILENAME_COMPORT "../comport.csv" // TODO: use absolute path
|
||||
// use settings (ini-file)
|
||||
|
||||
QString bs, cn;
|
||||
int br, ci;
|
||||
|
||||
|
||||
// load and use last settings: --------------------
|
||||
QByteArray myBA;
|
||||
myBA=datei_readFromFile(FILENAME_COMPORT);
|
||||
if (myBA.length()>0)
|
||||
{
|
||||
bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
|
||||
br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
|
||||
bs=csv_getEntryAsString(myBA,2); // z.B 115200
|
||||
cn=csv_getEntryAsString(myBA,3); // z.B. COM9
|
||||
ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
|
||||
HWaccess->dc_openSerial(br,bs,cn,1);
|
||||
} else
|
||||
{
|
||||
// vermutlich wird dies hier ausgeführt, weil eine csv-Datei wird nicht installiert
|
||||
|
||||
// open with default settings
|
||||
qDebug()<<"CArunGui: open serial with default values";
|
||||
|
||||
bs="115200";
|
||||
br=5;
|
||||
//cn="COM14"; // Windows
|
||||
cn="ttymxc2"; // PTU5
|
||||
ci=2;
|
||||
HWaccess->dc_openSerial(br,bs,cn,1);
|
||||
}
|
||||
|
||||
// TIMER myTO: hat keinen timeout-slot!
|
||||
// wird nur verwendet, um isActive() abzufragen, d.h. ~x zu warten
|
||||
|
||||
// pruefen, of Port nach x s open:
|
||||
if (HWaccess->dc_isPortOpen())
|
||||
{
|
||||
|
||||
} else
|
||||
{
|
||||
// wenn nicht: step 6
|
||||
}
|
||||
myTO->start(100);
|
||||
}
|
||||
} else
|
||||
|
||||
if (myStep==2)
|
||||
{
|
||||
if (!myTO->isActive())
|
||||
{
|
||||
HWaccess->dc_requTestResponse();
|
||||
myStep++;
|
||||
myTO->start(100);
|
||||
}
|
||||
} else
|
||||
|
||||
if (myStep==3)
|
||||
{
|
||||
if (!myTO->isActive())
|
||||
{
|
||||
if (HWaccess->dc_readAnswTestResponse())
|
||||
myStep++; // response was correct
|
||||
else
|
||||
{
|
||||
myStep=6; // 13.12.23: start Autoconnect cycle
|
||||
qDebug()<<"CArunGui: got no answer from DC, retry..";
|
||||
}
|
||||
myTO->start(100);
|
||||
}
|
||||
|
||||
} else
|
||||
|
||||
if (myStep==4)
|
||||
{
|
||||
HWaccess->dc_autoRequest(1);
|
||||
AutSendButton->setChecked(true); // taste "druecken"
|
||||
myStep++;
|
||||
myTO->start(2000);
|
||||
} else
|
||||
|
||||
if (myStep==5)
|
||||
{
|
||||
if (!myTO->isActive())
|
||||
{
|
||||
if (HWaccess->sys_areDCdataValid())
|
||||
{
|
||||
qDebug()<<"CArunGui: DC is connected";
|
||||
myStep=7; // OK, connection is up and running
|
||||
} else
|
||||
{
|
||||
qDebug()<<"CArunGui: auto request is not running, retry...";
|
||||
myStep++;
|
||||
myTO->start(100);
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
|
||||
if (myStep==6)
|
||||
{
|
||||
// restart autoconnect cycle
|
||||
myTO->start(100); // restart
|
||||
myStep=0;
|
||||
} else
|
||||
|
||||
if (myStep==7)
|
||||
{
|
||||
// stay here, DC connection is up and running
|
||||
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (myNextStep)
|
||||
{
|
||||
*nextScreen=myNextStep;
|
||||
myNextStep=0;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
42
dCArun/CArun.h
Normal file
42
dCArun/CArun.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef CARUN_H
|
||||
#define CARUN_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <QDir>
|
||||
#include "plugin.h"
|
||||
#include "stepList.h"
|
||||
//#include "stepList.h" // define all working chain steps here
|
||||
|
||||
|
||||
class CArun : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CArun(QObject *parent = nullptr);
|
||||
|
||||
QTimer *timerChainCtrl;
|
||||
QTimer *timerVendingTimeout;
|
||||
|
||||
char loadPlugIn(char lade1_entlade2);
|
||||
|
||||
QDir plugInDir;
|
||||
|
||||
private:
|
||||
|
||||
hwinf *HWaccess=nullptr; // global pointer to plugin-class
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void chainControl();
|
||||
void vendingTimeout();
|
||||
|
||||
};
|
||||
|
||||
#endif // CARUN_H
|
@@ -41,6 +41,7 @@ DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
|
||||
SOURCES += \
|
||||
CArun.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
tslib.cpp \
|
||||
@@ -48,6 +49,7 @@ SOURCES += \
|
||||
datei.cpp
|
||||
|
||||
HEADERS += \
|
||||
CArun.h \
|
||||
guidefs.h \
|
||||
mainwindow.h \
|
||||
stepList.h \
|
||||
|
@@ -1,15 +1,14 @@
|
||||
#include "mainwindow.h"
|
||||
#include "CArun.h"
|
||||
//#include "message_handler.h"
|
||||
#include <QApplication>
|
||||
|
||||
int thisisglobal;
|
||||
#include <QCoreApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
QApplication myapp(argc, argv);
|
||||
QApplication::setApplicationName("CArunGui");
|
||||
QApplication::setApplicationVersion(APP_VERSION);
|
||||
QCoreApplication myapp(argc, argv);
|
||||
|
||||
QCoreApplication::setOrganizationName("ATB");
|
||||
QCoreApplication::setApplicationName("CArun");
|
||||
QCoreApplication::setApplicationVersion(APP_VERSION);
|
||||
|
||||
/*
|
||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||
@@ -18,16 +17,9 @@ int main(int argc, char *argv[])
|
||||
//setDebugLevel(QtMsgType::QtDebugMsg);
|
||||
}
|
||||
*/
|
||||
MainWindow myMainWin;
|
||||
QSize myMainSize={800, 480}; // breite, höhe, PTU: 800x440
|
||||
myMainWin.setMinimumSize(myMainSize);
|
||||
myMainWin.setMaximumSize(myMainSize);
|
||||
myMainWin.setWindowTitle("CArun_V4.2 run cash agent master lib");
|
||||
//myMainWin.show();
|
||||
CArun carun;
|
||||
|
||||
ret=myapp.exec();
|
||||
|
||||
return ret;
|
||||
return myapp.exec();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1384,9 +1384,7 @@ signals:
|
||||
void hwapi_doorCBinAndAllDoorsClosed(void) const override;
|
||||
void hwapi_doorAllDoorsClosed(void) const override;
|
||||
|
||||
|
||||
|
||||
|
||||
void hwapi_coinAttached() const override;
|
||||
|
||||
private slots:
|
||||
//void hwapi_slotPrintFinished_OK(void);
|
||||
@@ -1414,8 +1412,7 @@ signals:
|
||||
void sub_slotCoin15(void);
|
||||
void sub_slotCoin16(void);
|
||||
|
||||
|
||||
|
||||
void coinAttached();
|
||||
|
||||
};
|
||||
|
||||
|
@@ -2390,6 +2390,7 @@ signals:
|
||||
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
|
||||
virtual void hwapi_doorAllDoorsClosed(void) const=0;
|
||||
|
||||
virtual void hwapi_coinAttached() const = 0;
|
||||
|
||||
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
|
||||
/* GH Version, bringt Fehler
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <QDebug>
|
||||
#include "datIf.h"
|
||||
#include <QSharedMemory>
|
||||
#include <atomic>
|
||||
#include "sendWRcmd.h"
|
||||
#include "controlBus.h"
|
||||
#include "storeINdata.h"
|
||||
@@ -35,6 +36,10 @@ class T_runProc : public QObject
|
||||
|
||||
void restoreDeviceParameter(struct T_devices *deviceSettings);
|
||||
|
||||
#ifndef THIS_IS_CA_MASTER
|
||||
std::atomic_bool m_coinAttached{false};
|
||||
#endif
|
||||
|
||||
private slots:
|
||||
void runProc_slotProcess(void);
|
||||
bool bl_performComplStart(void);
|
||||
@@ -80,6 +85,7 @@ signals:
|
||||
void runProc_doorCBinAndAllDoorsClosed(void);
|
||||
void runProc_doorAllDoorsClosed(void);
|
||||
|
||||
void runProc_coinAttached();
|
||||
};
|
||||
|
||||
|
||||
|
@@ -5,14 +5,12 @@ VERSION="1.0.1"
|
||||
HEADERS += \
|
||||
../include/com.h \
|
||||
../include/datIf.h \
|
||||
../include/prot.h \
|
||||
../include/download_thread.h
|
||||
../include/prot.h
|
||||
|
||||
SOURCES += \
|
||||
../src/com.cpp \
|
||||
../src/datIf.cpp \
|
||||
../src/prot.cpp \
|
||||
../src/download_thread.cpp
|
||||
../src/prot.cpp
|
||||
|
||||
include(../DCLibraries.pri)
|
||||
|
||||
|
@@ -2,12 +2,6 @@ TEMPLATE = lib
|
||||
TARGET = CAslave
|
||||
VERSION="1.0.1"
|
||||
|
||||
HEADERS += \
|
||||
../include/reporting_thread.h
|
||||
|
||||
SOURCES += \
|
||||
../src/reporting_thread.cpp
|
||||
|
||||
include(../DCLibraries.pri)
|
||||
|
||||
win32 {
|
||||
|
@@ -128,8 +128,7 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
|
||||
connect(runProcess, SIGNAL(runProc_doorCoinBoxInserted()), this, SLOT(sub_slotCoin14())); // hwapi_doorCoinBoxInserted()));
|
||||
connect(runProcess, SIGNAL(runProc_doorCBinAndAllDoorsClosed()), this, SLOT(sub_slotCoin15())); // hwapi_doorCBinAndAllDoorsClosed()));
|
||||
connect(runProcess, SIGNAL(runProc_doorAllDoorsClosed()), this, SLOT(sub_slotCoin16())); // hwapi_doorAllDoorsClosed()));
|
||||
|
||||
|
||||
connect(runProcess, SIGNAL(runProc_coinAttached()), this, SLOT(coinAttached()));
|
||||
}
|
||||
|
||||
void hwapi::hwapi_slotPayProc(void)
|
||||
@@ -227,6 +226,9 @@ void hwapi::sub_slotCoin16(void)
|
||||
emit hwapi_doorAllDoorsClosed();
|
||||
}
|
||||
|
||||
void hwapi::coinAttached() {
|
||||
emit hwapi_coinAttached();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -48,6 +48,16 @@ T_runProc::T_runProc()
|
||||
void T_runProc::runProc_slotProcess(void)
|
||||
{
|
||||
#ifndef THIS_IS_CA_MASTER
|
||||
bool const coinAttached = epi_getDI_CoinAttach();
|
||||
// exchange: (atomically) replaces the underlying value of m_coinAttached
|
||||
// with the value of coinAttached, returns the value of m_coinAttached
|
||||
// before the call
|
||||
if (m_coinAttached.exchange(coinAttached) == false) {
|
||||
if (coinAttached) {
|
||||
// old value was false, and new value is true
|
||||
emit runProc_coinAttached();
|
||||
}
|
||||
}
|
||||
cash_paymentProcessing();
|
||||
doors_supervise();
|
||||
bl_performComplStart(); // neu 1.12.23
|
||||
|
Reference in New Issue
Block a user