Compare commits

...

8 Commits

12 changed files with 283 additions and 36 deletions

View File

@@ -90,7 +90,9 @@ HEADERS += \
$${PWD}/include/sendWRcmd.h \ $${PWD}/include/sendWRcmd.h \
$${PWD}/include/storeINdata.h \ $${PWD}/include/storeINdata.h \
$${PWD}/include/tslib.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 += \ SOURCES += \
$${PWD}/src/datei.cpp \ $${PWD}/src/datei.cpp \
@@ -101,7 +103,9 @@ SOURCES += \
$${PWD}/src/sendWRcmd.cpp \ $${PWD}/src/sendWRcmd.cpp \
$${PWD}/src/storeINdata.cpp \ $${PWD}/src/storeINdata.cpp \
$${PWD}/src/tslib.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 # INTERFACE = DeviceController

199
dCArun/CArun.cpp Normal file
View 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
View 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

View File

@@ -41,6 +41,7 @@ DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\" DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
SOURCES += \ SOURCES += \
CArun.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
tslib.cpp \ tslib.cpp \
@@ -48,6 +49,7 @@ SOURCES += \
datei.cpp datei.cpp
HEADERS += \ HEADERS += \
CArun.h \
guidefs.h \ guidefs.h \
mainwindow.h \ mainwindow.h \
stepList.h \ stepList.h \

View File

@@ -1,15 +1,14 @@
#include "mainwindow.h" #include "CArun.h"
//#include "message_handler.h" //#include "message_handler.h"
#include <QApplication> #include <QCoreApplication>
int thisisglobal;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret; QCoreApplication myapp(argc, argv);
QApplication myapp(argc, argv);
QApplication::setApplicationName("CArunGui"); QCoreApplication::setOrganizationName("ATB");
QApplication::setApplicationVersion(APP_VERSION); QCoreApplication::setApplicationName("CArun");
QCoreApplication::setApplicationVersion(APP_VERSION);
/* /*
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
@@ -18,16 +17,9 @@ int main(int argc, char *argv[])
//setDebugLevel(QtMsgType::QtDebugMsg); //setDebugLevel(QtMsgType::QtDebugMsg);
} }
*/ */
MainWindow myMainWin; CArun carun;
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();
ret=myapp.exec(); return myapp.exec();
return ret;
} }

View File

@@ -1384,9 +1384,7 @@ signals:
void hwapi_doorCBinAndAllDoorsClosed(void) const override; void hwapi_doorCBinAndAllDoorsClosed(void) const override;
void hwapi_doorAllDoorsClosed(void) const override; void hwapi_doorAllDoorsClosed(void) const override;
void hwapi_coinAttached() const override;
private slots: private slots:
//void hwapi_slotPrintFinished_OK(void); //void hwapi_slotPrintFinished_OK(void);
@@ -1414,8 +1412,7 @@ signals:
void sub_slotCoin15(void); void sub_slotCoin15(void);
void sub_slotCoin16(void); void sub_slotCoin16(void);
void coinAttached();
}; };

View File

@@ -2390,6 +2390,7 @@ signals:
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0; virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
virtual void hwapi_doorAllDoorsClosed(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. // NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
/* GH Version, bringt Fehler /* GH Version, bringt Fehler

View File

@@ -15,6 +15,7 @@
#include <QDebug> #include <QDebug>
#include "datIf.h" #include "datIf.h"
#include <QSharedMemory> #include <QSharedMemory>
#include <atomic>
#include "sendWRcmd.h" #include "sendWRcmd.h"
#include "controlBus.h" #include "controlBus.h"
#include "storeINdata.h" #include "storeINdata.h"
@@ -35,6 +36,10 @@ class T_runProc : public QObject
void restoreDeviceParameter(struct T_devices *deviceSettings); void restoreDeviceParameter(struct T_devices *deviceSettings);
#ifndef THIS_IS_CA_MASTER
std::atomic_bool m_coinAttached{false};
#endif
private slots: private slots:
void runProc_slotProcess(void); void runProc_slotProcess(void);
bool bl_performComplStart(void); bool bl_performComplStart(void);
@@ -80,6 +85,7 @@ signals:
void runProc_doorCBinAndAllDoorsClosed(void); void runProc_doorCBinAndAllDoorsClosed(void);
void runProc_doorAllDoorsClosed(void); void runProc_doorAllDoorsClosed(void);
void runProc_coinAttached();
}; };

View File

@@ -5,14 +5,12 @@ VERSION="1.0.1"
HEADERS += \ HEADERS += \
../include/com.h \ ../include/com.h \
../include/datIf.h \ ../include/datIf.h \
../include/prot.h \ ../include/prot.h
../include/download_thread.h
SOURCES += \ SOURCES += \
../src/com.cpp \ ../src/com.cpp \
../src/datIf.cpp \ ../src/datIf.cpp \
../src/prot.cpp \ ../src/prot.cpp
../src/download_thread.cpp
include(../DCLibraries.pri) include(../DCLibraries.pri)

View File

@@ -2,12 +2,6 @@ TEMPLATE = lib
TARGET = CAslave TARGET = CAslave
VERSION="1.0.1" VERSION="1.0.1"
HEADERS += \
../include/reporting_thread.h
SOURCES += \
../src/reporting_thread.cpp
include(../DCLibraries.pri) include(../DCLibraries.pri)
win32 { win32 {

View File

@@ -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_doorCoinBoxInserted()), this, SLOT(sub_slotCoin14())); // hwapi_doorCoinBoxInserted()));
connect(runProcess, SIGNAL(runProc_doorCBinAndAllDoorsClosed()), this, SLOT(sub_slotCoin15())); // hwapi_doorCBinAndAllDoorsClosed())); 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_doorAllDoorsClosed()), this, SLOT(sub_slotCoin16())); // hwapi_doorAllDoorsClosed()));
connect(runProcess, SIGNAL(runProc_coinAttached()), this, SLOT(coinAttached()));
} }
void hwapi::hwapi_slotPayProc(void) void hwapi::hwapi_slotPayProc(void)
@@ -227,6 +226,9 @@ void hwapi::sub_slotCoin16(void)
emit hwapi_doorAllDoorsClosed(); emit hwapi_doorAllDoorsClosed();
} }
void hwapi::coinAttached() {
emit hwapi_coinAttached();
}
/* /*

View File

@@ -48,6 +48,16 @@ T_runProc::T_runProc()
void T_runProc::runProc_slotProcess(void) void T_runProc::runProc_slotProcess(void)
{ {
#ifndef THIS_IS_CA_MASTER #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(); cash_paymentProcessing();
doors_supervise(); doors_supervise();
bl_performComplStart(); // neu 1.12.23 bl_performComplStart(); // neu 1.12.23