Merge branch 'carun_removeWidgets'

This commit is contained in:
Siegfried Siegert 2024-03-02 12:16:02 +01:00
commit d5021c8269
Signed by untrusted user: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
15 changed files with 246 additions and 1471 deletions

View File

@ -1,6 +1,6 @@
CONFIG += plugin
QT -= gui
QT += widgets serialport
QT += serialport
win32 {

170
dCArun/CArun.cpp Normal file
View File

@ -0,0 +1,170 @@
#include "CArun.h"
#include "datei.h"
CArun::CArun(QObject *parent)
: QObject(parent)
, setupStep(SETUP_STEP::INIT)
{
this->timerChainCtrl = new QTimer(this);
this->connect(timerChainCtrl, SIGNAL(timeout()), this, SLOT(chainControl()));
this->timerChainCtrl->setSingleShot(true);
this->timerChainCtrl->setInterval(100);
loadPlugIn(1);
// Start setup-steps:
qCritical() << "CArun: start setup...";
this->timerChainCtrl->start();
}
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())
{
qCritical() << "CArun: cannot load plugin";
} else
qCritical() << "CArun: plugin loaded: " << pluginLoader->fileName();
if (!pluginLoader->isLoaded())
{
qCritical() << "CArun: ERROR loading plugin: " << 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
qCritical() << "CArun: ERROR cannot start instance";
return 0;
}
this->HWaccess = qobject_cast<hwinf *>(plugin);
// make instance to class "hwinf" in dll_HWapi.h over "interfaces.h"
return 0;
}
void CArun::openSerialPort()
{
#define FILENAME_COMPORT "../comport.csv" // TODO: use absolute path
// use settings (ini-file)
// comport.csv wird mit installiert in: /opt/app/
// k.A., ob "../comport.csv" gefunden wird.
qCritical() << "CArun: open serial port...";
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
this->HWaccess->dc_openSerial(br,bs,cn,1);
} else
{
// vermutlich wird dies hier ausgeführt?
// open with default settings
qCritical() << "CArun: open serial with default values";
bs="115200";
br=5;
//cn="COM14"; // Windows
cn="ttymxc2"; // PTU5
ci=2;
HWaccess->dc_openSerial(br,bs,cn,1);
}
}
void CArun::chainControl(void)
{
switch (this->setupStep) {
case SETUP_STEP::INIT:
qCritical() << "CArun: SETUP_STEP::INIT";
this->setupStep = SETUP_STEP::OPEN_SERIAL_PORT;
this->timerChainCtrl->start();
break;
case SETUP_STEP::OPEN_SERIAL_PORT:
qCritical() << "CArun: SETUP_STEP::OPEN_SERIAL_PORT";
this->openSerialPort();
this->setupStep = SETUP_STEP::CHECK_VALID_DATA;
this->timerChainCtrl->start();
break;
case SETUP_STEP::TEST_OPEN_PORT:
qCritical() << "CArun: SETUP_STEP::TEST_OPEN_PORT";
if (this->HWaccess->dc_isPortOpen()) {
this->setupStep = SETUP_STEP::TEST_RESPONSE_REQUEST;
}
else {
qCritical() << "CArun: port is still closed, restarting..";
this->setupStep = SETUP_STEP::INIT;
}
this->timerChainCtrl->start();
break;
case SETUP_STEP::TEST_RESPONSE_REQUEST:
qCritical() << "CArun: SETUP_STEP::TEST_RESPONSE_REQUEST";
this->HWaccess->dc_requTestResponse();
this->setupStep = SETUP_STEP::TEST_RESPONSE_CHECK;
this->timerChainCtrl->start();
break;
case SETUP_STEP::TEST_RESPONSE_CHECK:
qCritical() << "CArun: SETUP_STEP::TEST_RESPONSE_CHECK";
if (this->HWaccess->dc_readAnswTestResponse()) {
// response was correct
this->setupStep = SETUP_STEP::SETUP_AUTOREQEUST;
}
else {
qCritical() << "CArun: got no answer from DC, retry..";
this->setupStep = SETUP_STEP::INIT;
}
this->timerChainCtrl->start();
break;
case SETUP_STEP::SETUP_AUTOREQEUST:
qCritical() << "CArun: SETUP_STEP::SETUP_AUTOREQEUST";
this->HWaccess->dc_autoRequest(1);
this->setupStep = SETUP_STEP::CHECK_VALID_DATA;
this->timerChainCtrl->start();
break;
case SETUP_STEP::CHECK_VALID_DATA:
qCritical() << "CArun: SETUP_STEP::CHECK_VALID_DATA";
if (this->HWaccess->sys_areDCdataValid()) {
qCritical() << "CArun: DC is connected";
// do not start timer again
}
else {
qCritical() << "CArun: auto request is not running, retry...";
this->setupStep = SETUP_STEP::INIT;
this->timerChainCtrl->start();
}
break;
default:
qCritical() << "CArun: invalid setup step";
break;
}
}

56
dCArun/CArun.h Normal file
View File

@ -0,0 +1,56 @@
#ifndef CARUN_H
#define CARUN_H
#include <QObject>
#include <QTimer>
#include <QDebug>
#include <QDateTime>
#include <QPluginLoader>
#include <QDir>
#include "plugin.h"
enum class SETUP_STEP {
INIT,
OPEN_SERIAL_PORT,
TEST_OPEN_PORT,
TEST_RESPONSE_REQUEST,
TEST_RESPONSE_CHECK,
SETUP_AUTOREQEUST,
CHECK_VALID_DATA
};
class CArun : public QObject
{
Q_OBJECT
public:
explicit CArun(QObject *parent = nullptr);
QTimer *timerChainCtrl;
char loadPlugIn(char lade1_entlade2);
QDir plugInDir;
private:
hwinf *HWaccess=nullptr; // global pointer to plugin-class
SETUP_STEP setupStep;
void openSerialPort();
signals:
private slots:
void chainControl();
};
#endif // CARUN_H

View File

@ -1,5 +1,5 @@
QT += core gui
QT +=widgets serialport
QT += core
QT += serialport
QT +=network
# for TCP-IP
@ -11,8 +11,6 @@ VERSION = "1.0.0"
DESTDIR=$${_PRO_FILE_PWD_}/../build
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += PTU5
@ -41,18 +39,15 @@ DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
SOURCES += \
CArun.cpp \
main.cpp \
mainwindow.cpp \
tslib.cpp \
win01_com.cpp \
datei.cpp
HEADERS += \
CArun.h \
guidefs.h \
mainwindow.h \
stepList.h \
tslib.h \
versionHistory.txt \
win01_com.h \
datei.h \
plugin.h

View File

@ -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();
}

View File

@ -1,439 +0,0 @@
#include "mainwindow.h"
char MainWindow::loadPlugIn(char lade1_entlade2)
{
plugInDir.cd("plugins");
QPluginLoader *pluginLoader = new QPluginLoader();
// select system:
//pluginLoader->setFileName("../MasterPlug/libCAmaster.so"); // for suse
//pluginLoader->setFileName("../SlavePlug/libCAslave.so"); // for ptu5
//pluginLoader->setFileName("../../MasterPlug/CAmaster.dll"); // for windows
//pluginLoader->setFileName("CAmaster.dll"); // for windows
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;
}
//int rr=hwapi->giveVal(2); funktioniert :))
//qDebug()<<"got value from plugin"<<rr; funktioniert :))
// aber besser globaler pointer:
// im h-file
// hwinf *hwapi=nullptr; // pointer to plugin-class
HWaccess= qobject_cast<hwinf *>(plugin);
// make instance to class "hwinf" in dll_HWapi.h over "interfaces.h"
qDebug()<<"loadPlugIn, HWAccess: " << HWaccess;
return 0;
}
#define WINCTRMIN 0
// 0 is always the home screen
#define WINCTRMAX 30
// number of needed application screens, up to 255
// All screens must be defined below in mainwindow-class first before increasing the nr
// numbers must be consecutively from 0 always, 0 is the home screen always
#define FORMWIDTH 725
//#define FORMWIDTH 690
// this width is the same for ALL windows
#define FORMHEIGHT 440
// this height is the same for ALL windows
#define NAVIBUTTONHEIGHT 70
#define NAVIBUTTONWIDHT 50
#define HOMEPAGE_BACKGROUND_COLOR "background-color: lightgrey"
#define BUTTON_COLOR "background-color: rgb(160,250,190)"
#define ACTIVE_NAVI_COLOR "background-color: rgb(160,250,190)"
#define DISABL_NAVI_COLOR "background-color: grey"
#define APPPAGE_BACKGROUND_COLOR "background-color: lightgrey"
#define UPDATE_PERIOD_MS 100
// period to call chain steps
#define VENDINGTIMEOUT_MS 30000
// after this time without any operation the program returns to idle state
// time in ms, that means 30.000 gives 30seconds
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
loadPlugIn(1);
// define all working moduls (besides gui) here, call ini and working in chainControl() (~Line 1000)
//mifCard = new T_Mifare(HWaccess); // ganz wichtig: HWaccess an sub-Konstruktor übergeben
// sonst crash bei HW-Zugriff!!!!
//diary = new T_lib_diary(); absturz!!!!!!
//conf = new T_lib_config(HWaccess);
timerChainCtrl = new QTimer(this);
connect(timerChainCtrl, SIGNAL(timeout()), this, SLOT(chainControl()));
timerChainCtrl->setSingleShot(0);
timerChainCtrl->start(UPDATE_PERIOD_MS); // 1000: call every 1000ms
timerVendingTimeout = new QTimer(this);
connect(timerVendingTimeout, SIGNAL(timeout()), this, SLOT(vendingTimeout()));
timerVendingTimeout->setSingleShot(true);
timerVendingTimeout->start(VENDINGTIMEOUT_MS); // in ms
// ##########################################################################################
// für jedes anzuzeigende Fenster eine eigene Groupbox mit eigenem Grid anlegen:
frame01 = new QGroupBox;
frame01->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame01->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay01 = new QVBoxLayout;
frame01->setLayout(smallLay01);
// Fensterinhalt aus externer Klasse einfügen:
myFenster01 = new T_winComPort(HWaccess); // HWaccess damit auf das HW-Plugin zugegriffen werden kann, sonst crash
smallLay01->addWidget(myFenster01);
// ##########################################################################################
// draw Mainwindow:
bigGroupbox = new QGroupBox;
bigGroupbox->setStyleSheet("background-color: grey");
bigGroupbox->setMinimumSize(800,480);
// bigLayout = new QVBoxLayout; // navi buttons on bottom side
bigLayout = new QHBoxLayout; // navi buttons right hand
// ##########################################################################################
// add all windows (but display only one)
// display only one: then all windows are shown at the same place
// display more then one: the windows are listed in vertical order
bigLayout->addWidget(frame01);
bigGroupbox->setLayout(bigLayout);
switchScreen(1);
//HideAllWindows();
// ##########################################################################################
// Steuer Leiste
//QHBoxLayout *ButtonLayout = new QHBoxLayout();
QVBoxLayout *ButtonLayout = new QVBoxLayout();
QFont myTabFont;
myTabFont.setPixelSize(26);
pBback = new QPushButton("<"); //b\na\nc\nk");
pBback->setFont(myTabFont);
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
pBback->setMinimumHeight(NAVIBUTTONHEIGHT);
pBback->setMaximumWidth(NAVIBUTTONWIDHT);
connect(pBback, SIGNAL( clicked() ), myFenster01, SLOT( Nav_back()));
myTabFont.setPixelSize(22);
pBhome = new QPushButton("<<"); //h\no\nm\ne");
pBhome->setFont(myTabFont);
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
pBhome->setMinimumHeight(NAVIBUTTONHEIGHT);
pBhome->setMaximumWidth(NAVIBUTTONWIDHT);
connect(pBhome, SIGNAL( clicked() ), myFenster01, SLOT( Nav_home()));
myTabFont.setPixelSize(26);
pBforward = new QPushButton(">"); //n\ne\nx\nt");
pBforward->setFont(myTabFont);
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
pBforward->setMinimumHeight(NAVIBUTTONHEIGHT);
pBforward->setMaximumWidth(NAVIBUTTONWIDHT);
connect(pBforward, SIGNAL( clicked() ), myFenster01, SLOT( Nav_next()));
QLabel *buttonSpace = new QLabel(" ");
ButtonLayout->addWidget(pBback);
ButtonLayout->addWidget(buttonSpace);
//ButtonLayout->addWidget(buttonSpace);
ButtonLayout->addWidget(pBhome);
ButtonLayout->addWidget(buttonSpace);
//ButtonLayout->addWidget(buttonSpace);
ButtonLayout->addWidget(pBforward);
QLabel *bottomSpace = new QLabel(" ");
ButtonLayout->addWidget(bottomSpace);
bigLayout->addLayout(ButtonLayout);
setCentralWidget(bigGroupbox);
// AUTOSTART serial transmission
//HWaccess->dc_openSerial(5,"115200","ttyS0",1); // my suse computer
//HWaccess->dc_openSerial(1,"9600","COM5",1); // my suse computer
//HWaccess->dc_openSerial(5,"115200","ttymxc2",1); // ptu5
//HWaccess->dc_autoRequest(true);
//myFenster01->setButtons4autoStart();
//HWaccess->alarm_switchSiren(0); // test
enableNaviButtons(BACKBUTTON,true);
enableNaviButtons(HOMEBUTTON,true);
enableNaviButtons(FORWBUTTON,true);
this->chainIni();
//connect(myFenster02, SIGNAL(quitMyApp()), this, SLOT(close()));
}
MainWindow::~MainWindow()
{
loadPlugIn(2);
}
void MainWindow::HideAllWindows()
{
// vorsicht: Fenster muss oben definiert sein sonst Programmabsturz ohne Kommentar
frame01->setEnabled(false);
frame01->setVisible(false);
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Call Windows
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void MainWindow::switchScreen(uint16_t winNr) // 0...30
{
HideAllWindows();
//qDebug()<<"switch screen to " << winNr;
switch (winNr)
{
case 1:
frame01->setEnabled(true);
frame01->setVisible(true);
break;
default:
break;
}
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Navigation buttons
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void MainWindow::enableNaviButtons(uint8_t switchBitwise)
{
// switchBitwise=0: no change
// bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back"
if (switchBitwise &1)
{
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBforward->setText("next");
pBforward->setEnabled(true);
} else
if (switchBitwise &2)
{
pBforward->setStyleSheet(DISABL_NAVI_COLOR);
//pBforward->setText(" ");
pBforward->setEnabled(false);
}
if (switchBitwise &4)
{
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBhome->setText("home");
pBhome->setEnabled(true);
} else
if (switchBitwise &8)
{
pBhome->setStyleSheet(DISABL_NAVI_COLOR);
//pBhome->setText(" ");
pBhome->setEnabled(false);
}
if (switchBitwise &16)
{
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBback->setText("back");
pBback->setEnabled(true);
} else
if (switchBitwise &32)
{
pBback->setStyleSheet(DISABL_NAVI_COLOR);
//pBback->setText(" ");
pBback->setEnabled(false);
}
}
void MainWindow::enableNaviButtons(uint8_t buttonNr, bool enabled)
{
if (buttonNr==1)
{
if (enabled)
{
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBback->setText("back");
pBback->setEnabled(true);
} else
{
pBback->setStyleSheet(DISABL_NAVI_COLOR);
//pBback->setText(" ");
pBback->setEnabled(false);
}
} else
if (buttonNr==2)
{
if (enabled)
{
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBhome->setText("home");
pBhome->setEnabled(true);
} else
{
pBhome->setStyleSheet(DISABL_NAVI_COLOR);
//pBhome->setText(" ");
pBhome->setEnabled(false);
}
} else
if (buttonNr==3)
{
if (enabled)
{
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBforward->setText("next");
pBforward->setEnabled(true);
} else
{
pBforward->setStyleSheet(DISABL_NAVI_COLOR);
//pBforward->setText(" ");
pBforward->setEnabled(false);
}
}
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// control work flow by Finite state machine
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
static uint16_t chainCurrentStep, chainNextStep;
static bool chain_stepIni;
void MainWindow::chainIni(void)
{
// called once after power-up by constructor
chainCurrentStep=WCS_STARTSCREEN; // start screen
chainNextStep=chainCurrentStep;
switchScreen(chainCurrentStep);
chain_stepIni=true;
//qDebug()<<"chain ini, call step "<<WCS_STARTUP << " " << chainCurrentStep;
}
void MainWindow::chainControl(void)
{
uint16_t nextScreen=0;
uint8_t useNavi=0;
bool busy=false;
// working step chain:
if (chainCurrentStep != chainNextStep)
{
if (chainNextStep!=WCS_STARTSCREEN)
{
timerVendingTimeout->stop();
timerVendingTimeout->start(VENDINGTIMEOUT_MS);
}
//qDebug()<<"found new sreen";
chainCurrentStep=chainNextStep;
switchScreen(chainCurrentStep);
chain_stepIni=true;
}
if (chainCurrentStep==1)
{
if (chain_stepIni)
busy=myFenster01->work_ini(&nextScreen, &useNavi);
else
busy=myFenster01->working(&nextScreen, &useNavi);
} else
{
// error undefined step
qDebug()<<"error main chain control, wrong step ("<<chainCurrentStep<<") selected";
}
if (chain_stepIni)
{
chain_stepIni=false;
switchScreen(chainCurrentStep); // the mainWindow frame has always the same number as the working step
}
if (nextScreen>0)
{
// call next chain step
//qDebug()<<"chain control: new step selected: "<< nextScreen;
chainNextStep=nextScreen;
}
if (useNavi>0)
{
//qDebug()<<"chain control: navi buttons "<< useNavi;
enableNaviButtons(useNavi);
}
if (busy>0)
{
// reset time-out
timerVendingTimeout->start();
}
}
void MainWindow::vendingTimeout(void)
{
// there was no user operation for 30s so return to start screen
// uint16_t nextScreen=WCS_STARTSCREEN;
// chainNextStep=nextScreen; erstmal stilllegen, stört bei IBN
//qDebug()<<"chain control: vending TO";
timerVendingTimeout->stop();
}

View File

@ -1,72 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTimer>
#include <QGroupBox>
#include <QStyle>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QLabel>
#include <QDebug>
#include <QPushButton>
#include <QDialog>
#include <QWidget>
#include <QApplication>
#include <QObject>
#include <QDateTime>
#include <QDate>
#include <QTime>
#include <QPluginLoader>
#include <QDir>
#include "plugin.h"
#include "stepList.h"
//#include "stepList.h" // define all working chain steps here
#include "win01_com.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
QPushButton *pBback;
QPushButton *pBhome;
QPushButton *pBforward;
QGroupBox *bigGroupbox;
QHBoxLayout *bigLayout;
QTimer *timerChainCtrl;
QTimer *timerVendingTimeout;
QGroupBox *frame01;
T_winComPort *myFenster01;
void HideAllWindows();
void switchScreen(uint16_t winNr);
char loadPlugIn(char lade1_entlade2);
QDir plugInDir;
void chainIni(void);
public:
hwinf *HWaccess=nullptr; // global pointer to plugin-class
MainWindow(QWidget *parent = nullptr);
~MainWindow();
#define BACKBUTTON 1
#define HOMEBUTTON 2
#define FORWBUTTON 3
void enableNaviButtons(uint8_t buttonNr, bool enabled);
void enableNaviButtons(uint8_t switchBitwise);
private slots:
void chainControl();
void vendingTimeout();
};
#endif // MAINWINDOW_H

View File

@ -1,210 +0,0 @@
#ifndef STEPLIST_H
#define STEPLIST_H
// define all working chain steps
// every FSM-Step get's a frame in MainWindow with the same number and a self-designed GUI
// labels are used for switchScreen( label=nr );
// numbers are important: e.g. number 3 calls frame3 and frame3 includes subClass "T_fenster03"
// so best solution: label = same name like class (in example: Fenster03). Label is fixed bound to number, never change!
// numbers are fixed assosiated with the function (e.g. ComPort), can't be changed.
// but screen order can be called in step chain randomly
// Windownumbers for certain function, never change
#define PAGE_COMPORT 1
#define PAGE_SERVICEMAIN 2
#define PAGE_TIMEDATEVERSION 3
#define PAGE_MACHINESTATUS 4
#define PAGE_CHECKDOORS 5
#define PAGE_PRINTER 6
#define PAGE_COINMECHANIC 7
#define PAGE_MIFARE 8
#define PAGE_MODEM 9
#define PAGE_COINPAYMENT 10
#define PAGE_VAULTRECORD 11
#define PAGE_BOOTLOADER 12
#define PAGE_PROG_JSON 13
#define PAGE_COINCHANGER 14
#define PAGE_BILLREADER 15
#define PAGE_NEXT16 16
#define PAGE_NEXT17 17
#define PAGE_NEXT18 18
#define PAGE_NEXT19 19
#define PAGE_NEXT20 20
// fix: customize:
#define WCS_STARTSCREEN PAGE_COMPORT
// PAGE_COMPORT:
#define WCS_WIN01BAK PAGE_COMPORT
#define WCS_WIN01MID PAGE_SERVICEMAIN
#define WCS_WIN01FWD PAGE_SERVICEMAIN
// PAGE_SERVICEMAIN:
#define WCS_WIN02BAK PAGE_COMPORT
#define WCS_WIN02MID PAGE_SERVICEMAIN
#define WCS_WIN02FWD PAGE_TIMEDATEVERSION
// PAGE_TIMEDATEVERSION:
#define WCS_WIN03BAK PAGE_SERVICEMAIN
#define WCS_WIN03MID PAGE_SERVICEMAIN
#define WCS_WIN03FWD PAGE_MACHINESTATUS
// PAGE_MACHINESTATUS:
#define WCS_WIN04BAK PAGE_TIMEDATEVERSION
#define WCS_WIN04MID PAGE_SERVICEMAIN
#define WCS_WIN04FWD PAGE_CHECKDOORS
// PAGE_CHECKDOORS:
#define WCS_WIN05BAK PAGE_MACHINESTATUS
#define WCS_WIN05MID PAGE_SERVICEMAIN
#define WCS_WIN05FWD PAGE_COINMECHANIC
// PAGE_COINMECHANIC:
#define WCS_WIN07BAK PAGE_CHECKDOORS
#define WCS_WIN07MID PAGE_SERVICEMAIN
#define WCS_WIN07FWD PAGE_COINPAYMENT
// PAGE_COINPAYMENT:
#define WCS_WIN10BAK PAGE_COINMECHANIC
#define WCS_WIN10MID PAGE_SERVICEMAIN
#define WCS_WIN10FWD PAGE_COINCHANGER
// PAGE_COINCHANGER:
#define WCS_WIN14BAK PAGE_COINPAYMENT
#define WCS_WIN14MID PAGE_SERVICEMAIN
#define WCS_WIN14FWD PAGE_BILLREADER
// PAGE_BILLREADER:
#define WCS_WIN15BAK PAGE_COINCHANGER
#define WCS_WIN15MID PAGE_SERVICEMAIN
#define WCS_WIN15FWD PAGE_PRINTER
// PAGE_PRINTER:
#define WCS_WIN06BAK PAGE_BILLREADER
#define WCS_WIN06MID PAGE_SERVICEMAIN
#define WCS_WIN06FWD PAGE_MIFARE
// PAGE_MIFARE:
#define WCS_WIN08BAK PAGE_PRINTER
#define WCS_WIN08MID PAGE_SERVICEMAIN
#define WCS_WIN08FWD PAGE_MODEM
// PAGE_MODEM:
#define WCS_WIN09BAK PAGE_MIFARE
#define WCS_WIN09MID PAGE_SERVICEMAIN
#define WCS_WIN09FWD PAGE_VAULTRECORD
// PAGE_VAULTRECORD:
#define WCS_WIN11BAK PAGE_MODEM
#define WCS_WIN11MID PAGE_SERVICEMAIN
#define WCS_WIN11FWD PAGE_PROG_JSON
// PAGE_PROG_JSON:
#define WCS_WIN13BAK PAGE_VAULTRECORD
#define WCS_WIN13MID PAGE_SERVICEMAIN
#define WCS_WIN13FWD PAGE_BOOTLOADER
// PAGE_BOOTLOADER:
#define WCS_WIN12BAK PAGE_PROG_JSON
#define WCS_WIN12MID PAGE_SERVICEMAIN
#define WCS_WIN12FWD PAGE_NEXT16
// PAGE_NEXT16
#define WCS_WIN16BAK PAGE_BOOTLOADER
#define WCS_WIN16MID PAGE_SERVICEMAIN
#define WCS_WIN16FWD PAGE_NEXT17
// PAGE_NEXT17
#define WCS_WIN17BAK PAGE_NEXT16
#define WCS_WIN17MID PAGE_SERVICEMAIN
#define WCS_WIN17FWD PAGE_NEXT18
// PAGE_NEXT18
#define WCS_WIN18BAK PAGE_NEXT17
#define WCS_WIN18MID PAGE_SERVICEMAIN
#define WCS_WIN18FWD PAGE_NEXT19
// PAGE_NEXT19
#define WCS_WIN19BAK PAGE_NEXT18
#define WCS_WIN19MID PAGE_SERVICEMAIN
#define WCS_WIN19FWD PAGE_NEXT20
// PAGE_NEXT20
#define WCS_WIN20BAK PAGE_NEXT19
#define WCS_WIN20MID PAGE_SERVICEMAIN
#define WCS_WIN20FWD PAGE_SERVICEMAIN
// just for Template
#define WCS_WIN99BAK PAGE_SERVICEMAIN
#define WCS_WIN99MID PAGE_SERVICEMAIN
#define WCS_WIN99FWD PAGE_SERVICEMAIN
#define WIN02_LABEL_SHORT01 " Status"
#define WCS_WIN02SHORT01 PAGE_MACHINESTATUS
#define WIN02_LABEL_SHORT02 " Doors "
#define WCS_WIN02SHORT02 PAGE_CHECKDOORS
#define WIN02_LABEL_SHORT03 "Coin mech"
#define WCS_WIN02SHORT03 PAGE_COINMECHANIC
#define WIN02_LABEL_SHORT04 "Payment"
#define WCS_WIN02SHORT04 PAGE_COINPAYMENT
#define WIN02_LABEL_SHORT05 "Changer"
#define WCS_WIN02SHORT05 PAGE_COINCHANGER
#define WIN02_LABEL_SHORT06 " Bill "
#define WCS_WIN02SHORT06 PAGE_BILLREADER
#define WIN02_LABEL_SHORT07 "Printer"
#define WCS_WIN02SHORT07 PAGE_PRINTER
#define WIN02_LABEL_SHORT08 "Program"
#define WCS_WIN02SHORT08 PAGE_VAULTRECORD
#define WIN02_LABEL_SHORT09 " "
#define WCS_WIN02SHORT09 PAGE_SERVICEMAIN
#define WIN02_LABEL_SHORT10 " "
#define WCS_WIN02SHORT10 PAGE_SERVICEMAIN
// set needed navigation buttons, use | to combine more then one:
#define SWITCH_NEXT_ON 1
#define SWITCH_NEXT_OFF 2
#define SWITCH_HOME_ON 4
#define SWITCH_HOME_OFF 8
#define SWITCH_BACK_ON 16
#define SWITCH_BACK_OFF 32
// example: *useNavi=SWITCH_BACK_ON; // change only this one, or set all:
// *useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_ON;
// some defines for Widget design:
#define TS_VALUEBOX_FRAMESTYLE 0x0032
#define TS_VALUEBOX_LINEWIDTH 3
//genDatPort->setFrameStyle(QFrame::Panel | QFrame::Sunken ); funktioniert aber gibt unverständliche Warnung
// QFrame::Panel = 0x0002 QFrame::Sunken=0x0030
//genDatPort->setFrameStyle(0x0032); // funktioniert und gibt keine Warnung
//genDatPort->setFrameStyle(TS_VALUEBOX_FRAMESTYLE); // funktioniert und gibt keine Warnung
#define TS_LED_FRAMESTYLE 0x0031
// QFrame::Box | QFrame::Sunken
#endif // STEPLIST_H

View File

@ -1,609 +0,0 @@
#include "win01_com.h"
#include "stepList.h" // define all working chain steps here
#include "datei.h"
//#include "globVars.h"
// %%%%%%%%%%%%%%%%%%%% TabComPort
Console::Console(QWidget *parent) : QPlainTextEdit(parent)
{
document()->setMaximumBlockCount(100);
QPalette p = palette();
p.setColor(QPalette::Base, Qt::black); //geht nicht weil untergrund schon farbig
p.setColor(QPalette::Text, Qt::blue);
setPalette(p);
}
void Console::putData(const QByteArray &data)
{
insertPlainText(data);
insertPlainText("\n");
QScrollBar *bar = verticalScrollBar();
bar->setValue(bar->maximum());
}
void Console::putText(QString text)
{
insertPlainText(text);
insertPlainText("\n");
QScrollBar *bar = verticalScrollBar();
bar->setValue(bar->maximum());
}
void T_winComPort::subPortInfo()
{
// Port Info Anzeige Feld, 2. Zeile links
QStringList myStringList;
QStringList comboPortList;
const auto infos = QSerialPortInfo::availablePorts();
for (const QSerialPortInfo &info : infos)
{
myStringList.append(QObject::tr(" \n Port: ") + info.portName() );
myStringList.append(QObject::tr("Location: ") + info.systemLocation()); // + "\n");
myStringList.append(QObject::tr("Description: ") + info.description() );
myStringList.append(QObject::tr("Manufacturer: ") + info.manufacturer());
myStringList.append(QObject::tr("Serial number: ") + info.serialNumber());
myStringList.append (QObject::tr("Vendor Id: ") + QString::number(info.vendorIdentifier(), 16));
myStringList.append(QObject::tr("Product Id: ") +QString::number(info.productIdentifier(), 16));
//myStringList.append(QObject::tr("Busy: ") + (info.isBusy() ? QObject::tr("Yes") : QObject::tr("No")));
comboPortList.append(info.portName()); // wenn Comport im System vorhanden dann in die Liste eintragen
}
QListWidget *myListWidget = new QListWidget;
myListWidget->insertItems(0, myStringList);
myListWidget->setMaximumWidth(250);
myTabComLayout->addWidget(myListWidget,1,0);
// ComboBox Comport Nr:
CB_portSel = new QComboBox();
CB_portSel->addItems(comboPortList); // string Liste mit addItems (s am Schluss) !
CB_portSel->setMinimumHeight(30);
CB_portSel->setMaximumWidth(150);
QFont myCBfont;
//myCBfont.setBold(true);
myCBfont.setPixelSize(15);
CB_portSel->setFont(myCBfont);
CB_portSel->setCurrentIndex(2); // default 3. Comport in der Liste = ttymxc2 in PTU5
myTabComLayout->addWidget(CB_portSel, 4,0);
}
void T_winComPort::callOpenSerial()
{
// Taste Connect wurde gedrückt, eine Klasse/einen Slot aus einer übergeordneten Klasse:
// openSerialPort();
// kann man nicht aufrufen. deshalb: speichere ComPort, Baudrate und Startbefehl global.
// Von dort wird mit einem zyklischen Timer ausgelesen
int br, ci;
QString bs, cn;
//br=CB_baudSel->currentIndex();
//bs=CB_baudSel->currentText();
br=5;
bs="115200";
cn=CB_portSel->currentText();
ci=CB_portSel->currentIndex();
// aktuell: br=5 bs=115200 cn=0 (=Com5)
//epi_setSerial(5,"115200","COM5",1);
// epi_setSerial(br, bs, cn, 1);
// new: save values for next time
QByteArray myBA, tmpBA;
myBA.clear(); tmpBA.clear();
myBA.append('s'); // start sign, not used
myBA.append(FILESEPERATOR);
tmpBA.setNum(br,10);
myBA.append(tmpBA);
myBA.append(FILESEPERATOR);
myBA.append(bs.toLatin1());
myBA.append(FILESEPERATOR);
myBA.append(cn.toLatin1());
myBA.append(FILESEPERATOR);
tmpBA.clear();
tmpBA.setNum(ci,10);
myBA.append(tmpBA);
myBA.append(FILESEPERATOR);
datei_clearFile(FILENAME_COMPORT);
datei_writeToFile(FILENAME_COMPORT, myBA);
qDebug() << "winComPort opening serial with: " << br << " " << bs << " " << cn;
HWaccess->dc_openSerial(br, bs, cn, 1);// same function with hwapi
// void dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
// BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
// BaudStr: for exapmle "19200"
// ComName: for example "COM48"
// connect: 0, 1
emit connectButtonPressed();
}
void T_winComPort::callCloseSerial()
{
HWaccess->dc_closeSerial();
// epi_closeSerial(); // same function without hwapi
emit closeButtonPressed();
}
void T_winComPort::callAutoSend()
{
if (AutSendButton->isChecked())
{
HWaccess->dc_autoRequest(1);
emit autoSendButtonIsOn();
} else
{
HWaccess->dc_autoRequest(0);
emit autoSendButtonIsOff();
}
}
void T_winComPort::callRefresh(void)
{
subPortInfo();
}
void T_winComPort::callConnectToggle()
{
if (connectButton->isChecked())
{
//qDebug() << "down";
callOpenSerial();
} else
{
//qDebug() << "released";
callCloseSerial();
}
}
void T_winComPort::getDcTestRS232()
{
//qDebug() << "request test response...";
HWaccess->dc_requTestResponse();
}
void T_winComPort::newBaud(void)
{
qDebug() << "new baud selected...";
}
void T_winComPort::setButtons4autoStart()
{
connectButton->setEnabled(true);
connectButton->setDown(true);
connectButton->setChecked(true);
AutSendButton->setEnabled(true);
AutSendButton->setDown(true);
AutSendButton->setChecked(true);
}
T_winComPort::T_winComPort(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
{
this->HWaccess = HWaccess;
myTabComLayout = new QGridLayout;
//QGridLayout *myGridLayout = new QGridLayout();
// Überschrift linke Spalte
QLabel *portListLabel2 = new QLabel(tr("in System available Ports:"));
myTabComLayout->addWidget(portListLabel2, 0,0);
// Überschrift rechte Spalte
QLabel *lab_headlineR = new QLabel(tr("Serial traffic:"));
myTabComLayout->addWidget(lab_headlineR, 0, 1);
subPortInfo();
// sende-empfangs-Rohdaten-Fenster, 2. Zeile rechts
myDiagWindow = new Console();
myDiagWindow->setReadOnly(true);
myDiagWindow->setEnabled(true);
//myDiagWindow->setLocalEchoEnabled(p.localEchoEnabled);
//myDiagWindow->setMinimumWidth(300);
//myDiagWindow->putData("ongoing serial traffic: ");
myTabComLayout->addWidget(myDiagWindow, 1,1);
// links:
// refresh button:
refreshButton = new QPushButton(tr("&refresh"));
refreshButton->setCheckable(false); // true = toggle button
refreshButton->setAutoDefault(false); // beim start aus
//refreshButton->setMaximumWidth(90);
myTabComLayout->addWidget(refreshButton, 2,0);
//connect(refreshButton, &QAbstractButton::clicked, this, &T_fenster01::callRefresh);
connect(refreshButton, SIGNAL(clicked()), this, SLOT(callRefresh()));
QLabel *Label3 = new QLabel(tr("Port:"));
myTabComLayout->addWidget(Label3, 3,0);
QLabel *Label4 = new QLabel(tr("Baud:"));
myTabComLayout->addWidget(Label4, 5,0);
// ComboBox Baudrate:
QFont my2CBfont;
//my2CBfont.setBold(true);
my2CBfont.setPixelSize(15);
/*
CB_baudSel = new QComboBox();
CB_baudSel->addItem(tr("1200"));
CB_baudSel->addItem(tr("9600"));
CB_baudSel->addItem(tr("19200"));
CB_baudSel->addItem(tr("38400"));
CB_baudSel->addItem(tr("57600"));
CB_baudSel->addItem(tr("115200"));
CB_baudSel->setMinimumHeight(30);
CB_baudSel->setMaximumWidth(150);
CB_baudSel->setFont(my2CBfont);
CB_baudSel->setCurrentIndex(5); // default 115k baud
//CB_baudSel->setCurrentIndex(1); // default 9600 baud
myTabComLayout->addWidget(CB_baudSel, 6,0);
//connect(CB_baudSel, SIGNAL(currentIndexChanged(int)), this, SLOT(newBaud()));
connect(CB_baudSel, SIGNAL(currentIndexChanged(int)), this, SLOT(newBaud()));
*/
// Statuszeile COM Port (serial Port)
LabelComState = new QLabel(tr("not connected"));
myTabComLayout->addWidget(LabelComState, 7,0);
// Connect button:
connectButton = new QPushButton(tr("&Connect"));
connectButton->setCheckable(true); // true = toggle button
connectButton->setAutoDefault(true); // beim start ein
connectButton->setMaximumWidth(90);
connectButton->setMinimumHeight(50);
myTabComLayout->addWidget(connectButton, 8,0);
//connect(connectButton, &QAbstractButton::clicked, this, &T_fenster01::callConnectToggle);
connect(connectButton, SIGNAL(clicked()), this, SLOT(callConnectToggle()));
// rechts:
// test serial line:
TestButton = new QPushButton(tr("test Connection"));
TestButton->setMaximumWidth(150);
myTabComLayout->addWidget(TestButton,2,1);
TestButton->setCheckable(false); // true = toggle button
TestButton->setAutoDefault(false); // beim start aus
// connect(TestButton, &QAbstractButton::clicked, this, &T_fenster01::getDcTestRS232);
connect(TestButton, SIGNAL(clicked()), this, SLOT(getDcTestRS232()));
// I Statuszeile Handshakes (serial Control) flow.cpp
// geht überhaupt was raus? kommt überhaupt was zurück?
//LabelHandshakes = new QLabel(tr("control line"));
LabelHandshakes = new QLabel("HS"); // not used
myTabComLayout->addWidget(LabelHandshakes, 3,1);
// II Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
LabelRecieveFrame = new QLabel(tr("slave receive"));
myTabComLayout->addWidget(LabelRecieveFrame, 4,1);
// III Anzeige der Slave-Results (Datif)
LabelResults = new QLabel(tr("results line"));
myTabComLayout->addWidget(LabelResults, 5,1);
// IV Statuszeile Sende- und Empfangsdaten brauchbar? (Datif)
LabelDataState = new QLabel(tr("datif line"));
myTabComLayout->addWidget(LabelDataState, 6,1);
// V
LabelDatif = new QLabel(tr("datif line"));
myTabComLayout->addWidget(LabelDatif, 7,1);
// Autosend:
AutSendButton = new QPushButton(tr("&Automatic reading")); // &A --> also keycode Alt-A possible
//AutSendButton->setMaximumWidth(90);
myTabComLayout->addWidget(AutSendButton,8,1);
AutSendButton->setCheckable(true); // true = toggle button
AutSendButton->setAutoDefault(true); // beim start aus
AutSendButton->setMinimumHeight(50);
// connect(AutSendButton, &QAbstractButton::clicked, this, &T_fenster01::callAutoSend);
connect(AutSendButton, SIGNAL(clicked()), this, SLOT(callAutoSend()));
setLayout(myTabComLayout);
myNextStep=0;
myStep=0;
callConnectToggle();
callAutoSend();
myTO = new QTimer();
myTO->setSingleShot(true);
myTO->start(2000);
}
// not needed:
T_winComPort::~T_winComPort()
{
close();
}
void T_winComPort::Nav_back(void)
{
myNextStep=WCS_WIN01BAK;
}
void T_winComPort::Nav_home(void)
{
myNextStep=WCS_WIN01MID;
}
void T_winComPort::Nav_next(void)
{
myNextStep=WCS_WIN01FWD;
}
bool T_winComPort::work_ini(uint16_t *nextScreen, uint8_t *useNavi)
{
// one state of the vending/operating FSM
// called ONE time after selecting this state (initialization)
// useNavi=0: no change
// bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back"
*nextScreen=0; // needed 0=no change
// *useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_ON;
*useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_OFF; // bei CArun alle aus
return false;
}
bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
{
// one state of the vending/operating FSM
// called cyclic until this state changes intentionally to another state
// display informations for human operator, react on operators inputs or wait for payment media
// useNavi=0: no change
// bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back"
QString bs, cn;
int br, ci;
this->updateGui();
*nextScreen=0; // 0=no change
*useNavi=0;
if (myStep==0)
{
// 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);
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
connectButton->setChecked(true); // connect Taste "druecken"
} else
{
// 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);
}
myTO->start(100); // restart
myStep++;
} else
if (myStep==1)
{
if (!myTO->isActive())
{
if (HWaccess->dc_isPortOpen())
{
myStep++;
} else
{
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: port is still closed, restarting..";
}
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;
}
void T_winComPort::updateGui(void)
{
QByteArray myBA;
QString ms;
ms=HWaccess->dc_getTxt4RsDiagWin();
if (ms.length()>1) // sonst ständig scrolling
{
myDiagWindow->putText(ms);
HWaccess->dc_clrTxt4RsDiagWin();
}
ms=HWaccess->dc_get2ndTxt4RsDiagWin();
if (ms.length()>1) // sonst ständig scrolling
{
myDiagWindow->putText(ms);
HWaccess->dc_clr2ndTxt4RsDiagWin();
}
// state of the COM Port (open, closed)
ms=HWaccess->dc_getSerialState();
if (ms.length()>1) // sonst ständig scrolling
{
LabelComState->setText(ms);
}
// --------------------------------------------------------------------------
// I Statuszeile Handshakes (serial Control)
ms=HWaccess->dc_getTxt4HsStateLine();
if (!connectButton->isChecked())
ms="";
if (ms.length()>1) // sonst ständig scrolling
{
LabelHandshakes->setText(ms);
HWaccess->dc_clrTxt4HsStateLine();
// clear to avoid multiple displaying
}
// II Master receive state (empfangenes Telgramm OK? crc? length? )
// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
ms=HWaccess->dc_getTxt4masterStateLine();
if (!connectButton->isChecked())
ms="---";
if (ms.length()>1) // sonst ständig scrolling
{
LabelRecieveFrame->setText(ms);
HWaccess->dc_clrTxt4masterStateLine();
}
// III Slave receive (from Master) OK? if then show results, if not then show errors
// entweder Empfangsfehler anzeigen (crc? length?) oder result OUT-OK, OUT_ERR, IN_OK, IN_ERR
// Hintergrund: wenn der Slave Fehler im Master-Telegramm gefunden hat, dann kann er es auch
// nicht verwenden und nichts ausgeben oder einlesen
ms=HWaccess->dc_getTxt4resultStateLine();
if (!connectButton->isChecked())
ms="---";
if (ms.length()>1) // sonst ständig scrolling
{
LabelResults->setText(ms);
HWaccess->dc_clrTxt4resultStateLine();
}
// IV Statuszeile Empfangsdaten
ms=HWaccess->dc_getdataStateLine();
if (!connectButton->isChecked())
ms="---";
if (ms.length()>1) // sonst ständig scrolling
{
LabelDataState->setText(ms);
HWaccess->dc_clrTxt4dataStateLine();
// clear to avoid multiple displaying
}
// 5. Zeile: Datif Ergebnis, Daten brauchbar?
ms=HWaccess->dc_getdatifLine();
if (!connectButton->isChecked())
ms="---";
if (ms.length()>1) // sonst ständig scrolling
{
LabelDatif->setText(ms);
HWaccess->dc_clrTxt4datifLine();
}
// -----------------------------------------------------------------------------
}

View File

@ -1,107 +0,0 @@
#ifndef WINCOMPORT_H
#define WINCOMPORT_H
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QObject>
#include <QTimer>
#include <QDebug>
#include <QTabWidget>
#include <QScrollBar>
#include <QPlainTextEdit>
#include <QComboBox>
#include <QLabel>
#include <QScrollArea>
#include <QSerialPortInfo>
#include <QWidget>
#include <QListWidget>
#include <QGroupBox>
#include <QPushButton>
#include <QRadioButton>
//#include "tslib.h"
//#include "stepList.h" // define all working chain steps here
//#include "datei.h"
#include "plugin.h"
//#include "globVars.h"
class Console : public QPlainTextEdit
{
Q_OBJECT
public:
explicit Console(QWidget *parent = nullptr);
void putData(const QByteArray &data);
void putText(QString text);
};
class T_winComPort : public QWidget // former TabComport
{
Q_OBJECT
Console *myDiagWindow; // Ausgabefenster
QComboBox *CB_portSel;
//QComboBox *CB_baudSel;
QPushButton *connectButton;
QPushButton *AutSendButton;
QPushButton *TestButton;
QPushButton *refreshButton;
QLabel *LabelComState; // Statusanzeige
QLabel *LabelPort;
QLabel *LabelHandshakes;
QLabel *LabelRecieveFrame;
QLabel *LabelResults;
QLabel *LabelDataState;
QLabel *LabelDatif;
QGridLayout *myTabComLayout;
void subPortInfo();
hwinf *HWaccess;
void updateGui(void);
uint16_t myNextStep;
uint8_t myStep;
QTimer *myTO;
private slots:
void callOpenSerial();
void callCloseSerial();
void callAutoSend();
//void tabComTime100ms();
void callConnectToggle();
void getDcTestRS232();
void callRefresh(void);
public:
explicit T_winComPort(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
bool work_ini(uint16_t *nextScreen, uint8_t *useNavi);
// useNavi=0: no change
// bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back"
bool working (uint16_t *nextScreen, uint8_t *useNavi);
~T_winComPort();
void writeRSdiagBytes(const QByteArray &bytarray);
void writeRSdiagText(QString text);
void writeComState(const QString text);
void writeDataState(const QString text);
void setButtons4autoStart();
signals:
void connectButtonPressed();
void closeButtonPressed();
void autoSendButtonIsOn();
void autoSendButtonIsOff();
private slots:
void newBaud(void); // just for test
public slots:
void Nav_back(void);
void Nav_home(void);
void Nav_next(void);
};
#endif

View File

@ -3,7 +3,7 @@
#ifndef SER_H
#define SER_H
#include <stdint.h>
#include <QMainWindow>
#include <QObject>
//#include <QString>
#include <QTimer>
#include <QSerialPort>

View File

@ -27,7 +27,6 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
#define hwapi_H
#include <stdint.h>
//#include <QTabWidget>
#include <QtPlugin>
#include <QTimer>
#include <QObject>
@ -98,7 +97,7 @@ private:
//QTimer *hwapi_triggerBL;
public:
explicit hwapi(QWidget *parent = nullptr);
explicit hwapi(QObject *parent = nullptr);
#ifdef THIS_IS_CA_MASTER

View File

@ -1,7 +1,7 @@
#ifndef SERIAL_FRAME_H
#define SERIAL_FRAME_H
#include <QMainWindow>
#include <QObject>
#include <QString>
#include <QTimer>
#include "tslib.h"
@ -43,7 +43,7 @@
#define STARTSIGN_RECEIVE_LONG 0x5D
class T_prot : public QMainWindow
class T_prot : public QObject
{
Q_OBJECT

View File

@ -3,7 +3,7 @@
#define RUN_PROCESS_H
#include <stdint.h>
#include <QMainWindow>
#include <QObject>
#include <QString>
#include <QTimer>
#include "tslib.h"

View File

@ -37,7 +37,7 @@ static uint8_t bl_startupStep;
hwapi::hwapi(QWidget *parent) : QObject(parent)
hwapi::hwapi(QObject *parent) : QObject(parent)
{
// constructor
qCritical() << " hwapi::hwapi() APP_VERSION:" << APP_VERSION;