APservice/mainwindow.cpp

1276 lines
43 KiB
C++
Executable File

#include "mainwindow.h"
/*
* Mainwindow is establishing special TS Layout which can be used alternatively to QtabWidget
* Mainwindow is setting up all necessary screen-layouts and make the complete navigation
* The real needed customers screens can be find in class "subwindows" or other external classes
* All screens have the same size and the same place
* A naviation bar at bottom side calls all screens successively
* Window 0 (=home) offers short links to the most important windows (main menu)
* introduced in CatGui in 2021, dec. 6.
*/
#include "version.h"
char MainWindow::loadPlugIn(char lade1_entlade2)
{
//const auto staticInstances=QPluginLoader::staticInstances();
//Pfad lässt sich verändern und die enthaltenen Dateien anzeigen
//wird aber von QPluginLoader dann nicht verwendet, also müßig
plugInDir.cd("plugins");
QPluginLoader *pluginLoader = new QPluginLoader();
// select system:
#if defined (ARCH_WINDOWS)
// Windows DT
pluginLoader->setFileName("../../SlavePlug/CAslave.dll"); // for windows
#elif defined (ARCH_DesktopLinux)
pluginLoader->setFileName("../../SlavePlug/libCAslave.so");
#elif defined (ARCH_PTU5)
pluginLoader->setFileName("/usr/lib/libCAslave.so"); // for PTU5
#endif
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;
}
// find HWsettings in subwindows.cpp line 630
#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);
frame02 = new QGroupBox;
frame02->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame02->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay02 = new QVBoxLayout;
frame02->setLayout(smallLay02);
// insert an instance of an external app class:
myFenster02 = new T_win02(HWaccess);
smallLay02->addWidget(myFenster02);
frame03 = new QGroupBox;
frame03->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame03->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay03 = new QVBoxLayout;
frame03->setLayout(smallLay03);
myFenster03 = new T_win03(HWaccess);
smallLay03->addWidget(myFenster03);
frame04 = new QGroupBox;
frame04->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame04->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay04 = new QVBoxLayout;
frame04->setLayout(smallLay04);
myFenster04 = new T_win04(HWaccess);
smallLay04->addWidget(myFenster04);
frame05 = new QGroupBox;
frame05->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame05->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay05 = new QVBoxLayout;
frame05->setLayout(smallLay05);
myFenster05 = new T_win05(HWaccess);
smallLay05->addWidget(myFenster05);
frame06 = new QGroupBox;
frame06->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame06->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay06 = new QVBoxLayout;
frame06->setLayout(smallLay06);
myFenster06 = new T_win06(HWaccess);
smallLay06->addWidget(myFenster06);
frame07 = new QGroupBox;
frame07->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame07->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay07 = new QVBoxLayout;
frame07->setLayout(smallLay07);
myFenster07 = new T_win07(HWaccess);
smallLay07->addWidget(myFenster07);
frame08 = new QGroupBox;
frame08->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame08->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay08 = new QVBoxLayout;
frame08->setLayout(smallLay08);
myFenster08 = new T_win08(HWaccess);
smallLay08->addWidget(myFenster08);
frame09 = new QGroupBox;
frame09->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame09->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay09 = new QVBoxLayout;
frame09->setLayout(smallLay09);
myFenster09 = new T_win09(HWaccess);
smallLay09->addWidget(myFenster09);
frame10 = new QGroupBox;
frame10->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame10->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay10 = new QVBoxLayout;
frame10->setLayout(smallLay10);
myFenster10 = new T_win10(HWaccess);
smallLay10->addWidget(myFenster10);
frame11 = new QGroupBox;
frame11->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame11->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay11 = new QVBoxLayout;
frame11->setLayout(smallLay11);
myFenster11 = new T_win11(HWaccess);
smallLay11->addWidget(myFenster11);
frame12 = new QGroupBox;
frame12->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame12->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay12 = new QVBoxLayout;
frame12->setLayout(smallLay12);
myFenster12 = new T_win12(HWaccess);
smallLay12->addWidget(myFenster12);
frame13 = new QGroupBox;
frame13->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame13->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay13 = new QVBoxLayout;
frame13->setLayout(smallLay13);
myFenster13 = new T_win13(HWaccess);
smallLay13->addWidget(myFenster13);
frame14 = new QGroupBox;
frame14->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame14->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay14 = new QVBoxLayout;
frame14->setLayout(smallLay14);
myFenster14 = new T_win14(HWaccess);
smallLay14->addWidget(myFenster14);
frame15 = new QGroupBox;
frame15->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame15->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay15 = new QVBoxLayout;
frame15->setLayout(smallLay15);
myFenster15 = new T_win15(HWaccess);
smallLay15->addWidget(myFenster15);
frame16 = new QGroupBox;
frame16->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame16->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay16 = new QVBoxLayout;
frame16->setLayout(smallLay16);
myFenster16 = new T_win16(HWaccess);
smallLay16->addWidget(myFenster16);
frame17 = new QGroupBox;
frame17->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame17->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay17 = new QVBoxLayout;
frame17->setLayout(smallLay17);
myFenster17 = new T_win17(HWaccess);
smallLay17->addWidget(myFenster17);
frame18 = new QGroupBox;
frame18->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame18->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay18 = new QVBoxLayout;
frame18->setLayout(smallLay18);
myFenster18 = new T_win18(HWaccess);
smallLay18->addWidget(myFenster18);
frame19 = new QGroupBox;
frame19->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame19->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay19 = new QVBoxLayout;
frame19->setLayout(smallLay19);
myFenster19 = new T_win19(HWaccess);
smallLay19->addWidget(myFenster19);
frame20 = new QGroupBox;
frame20->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame20->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay20 = new QVBoxLayout;
frame20->setLayout(smallLay20);
myFenster20 = new T_win20(HWaccess);
smallLay20->addWidget(myFenster20);
/*
frame21 = new QGroupBox;
frame21->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame21->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay21 = new QVBoxLayout;
frame21->setLayout(smallLay21);
myFenster21 = new T_win21(HWaccess);
smallLay21->addWidget(myFenster21);
frame22 = new QGroupBox;
frame22->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame22->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay22 = new QVBoxLayout;
frame22->setLayout(smallLay22);
myFenster22 = new T_win22(HWaccess);
smallLay22->addWidget(myFenster22);
frame23 = new QGroupBox;
frame23->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame23->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay23 = new QVBoxLayout;
frame23->setLayout(smallLay23);
myFenster23 = new T_win23(HWaccess);
smallLay23->addWidget(myFenster23);
frame24 = new QGroupBox;
frame24->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame24->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay24 = new QVBoxLayout;
frame24->setLayout(smallLay24);
myFenster24 = new T_win_pwrDo(HWaccess);
smallLay24->addWidget(myFenster24);
frame25 = new QGroupBox;
frame25->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame25->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay25 = new QVBoxLayout;
frame25->setLayout(smallLay25);
myFenster25 = new T_win_barrAux(HWaccess);
smallLay25->addWidget(myFenster25);
frame26 = new QGroupBox;
frame26->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame26->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay26 = new QVBoxLayout;
frame26->setLayout(smallLay26);
myFenster26 = new T_fenster26(HWaccess);
smallLay26->addWidget(myFenster26);
frame27 = new QGroupBox;
frame27->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame27->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay27 = new QVBoxLayout;
frame27->setLayout(smallLay27);
myFenster27 = new T_fenster27(HWaccess);
smallLay27->addWidget(myFenster27);
frame28 = new QGroupBox;
frame28->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame28->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay28 = new QVBoxLayout;
frame28->setLayout(smallLay28);
myFenster28 = new T_fenster28(HWaccess);
smallLay28->addWidget(myFenster28);
frame29 = new QGroupBox;
frame29->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame29->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay29 = new QVBoxLayout;
frame29->setLayout(smallLay29);
myFenster29 = new T_fenster29(HWaccess);
smallLay29->addWidget(myFenster29);
frame30 = new QGroupBox;
frame30->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame30->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay30 = new QVBoxLayout;
frame30->setLayout(smallLay30);
myFenster30 = new T_fenster30(HWaccess);
smallLay30->addWidget(myFenster30);
*/
// ##########################################################################################
// 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);
bigLayout->addWidget(frame02);
bigLayout->addWidget(frame03);
bigLayout->addWidget(frame04);
bigLayout->addWidget(frame05);
bigLayout->addWidget(frame06);
bigLayout->addWidget(frame07);
bigLayout->addWidget(frame08);
bigLayout->addWidget(frame09);
bigLayout->addWidget(frame10);
bigLayout->addWidget(frame11);
bigLayout->addWidget(frame12);
bigLayout->addWidget(frame13);
bigLayout->addWidget(frame14);
bigLayout->addWidget(frame15);
bigLayout->addWidget(frame16);
bigLayout->addWidget(frame17);
bigLayout->addWidget(frame18);
bigLayout->addWidget(frame19);
bigLayout->addWidget(frame20);
/*
bigLayout->addWidget(frame21);
bigLayout->addWidget(frame22);
bigLayout->addWidget(frame23);
bigLayout->addWidget(frame24);
bigLayout->addWidget(frame25);
bigLayout->addWidget(frame26);
bigLayout->addWidget(frame27);
bigLayout->addWidget(frame28);
bigLayout->addWidget(frame29);
bigLayout->addWidget(frame30);
*/
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() ), this, SLOT( goBack() ));
//connect(pBback, SIGNAL( clicked() ), myFenster01, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster02, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster03, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster04, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster05, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster06, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster07, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster08, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster09, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster10, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster11, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster12, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster13, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster14, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster15, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster16, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster17, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster18, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster19, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster20, SLOT( Nav_back()));
/*
connect(pBback, SIGNAL( clicked() ), myFenster21, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster22, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster23, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster24, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster25, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster26, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster27, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster28, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster29, SLOT( Nav_back()));
connect(pBback, SIGNAL( clicked() ), myFenster30, 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()));
connect(pBhome, SIGNAL( clicked() ), myFenster02, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster03, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster04, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster05, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster06, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster07, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster08, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster09, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster10, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster11, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster12, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster13, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster14, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster15, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster16, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster17, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster18, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster19, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster20, SLOT( Nav_home()));
/*
connect(pBhome, SIGNAL( clicked() ), myFenster21, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster22, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster23, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster24, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster25, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster26, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster27, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster28, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster29, SLOT( Nav_home()));
connect(pBhome, SIGNAL( clicked() ), myFenster30, 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()));
connect(pBforward, SIGNAL( clicked() ), myFenster02, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster03, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster04, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster05, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster06, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster07, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster08, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster09, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster10, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster11, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster12, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster13, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster14, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster15, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster16, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster17, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster18, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster19, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster20, SLOT( Nav_next()));
/*
connect(pBforward, SIGNAL( clicked() ), myFenster21, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster21, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster22, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster23, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster24, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster25, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster26, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster27, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster28, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster29, SLOT( Nav_next()));
connect(pBforward, SIGNAL( clicked() ), myFenster30, 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);
//QLabel *bottomSpace = new QLabel(" ");
//bigLayout->addLayout(bottomSpace); // Zeile unter den Tasten
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);
frame02->setEnabled(false);
frame03->setEnabled(false);
frame04->setEnabled(false);
frame05->setEnabled(false);
frame06->setEnabled(false);
frame07->setEnabled(false);
frame08->setEnabled(false);
frame09->setEnabled(false);
frame10->setEnabled(false);
frame11->setEnabled(false);
frame12->setEnabled(false);
frame13->setEnabled(false);
frame14->setEnabled(false);
frame15->setEnabled(false);
frame16->setEnabled(false);
frame17->setEnabled(false);
frame18->setEnabled(false);
frame19->setEnabled(false);
frame20->setEnabled(false);
/*
frame21->setEnabled(false);
frame22->setEnabled(false);
frame23->setEnabled(false);
frame24->setEnabled(false);
frame25->setEnabled(false);
frame26->setEnabled(false);
frame27->setEnabled(false);
frame28->setEnabled(false);
frame29->setEnabled(false);
frame30->setEnabled(false);
*/
frame01->setVisible(false);
frame02->setVisible(false);
frame03->setVisible(false);
frame04->setVisible(false);
frame05->setVisible(false);
frame06->setVisible(false);
frame07->setVisible(false);
frame08->setVisible(false);
frame09->setVisible(false);
frame10->setVisible(false);
frame11->setVisible(false);
frame12->setVisible(false);
frame13->setVisible(false);
frame14->setVisible(false);
frame15->setVisible(false);
frame16->setVisible(false);
frame17->setVisible(false);
frame18->setVisible(false);
frame19->setVisible(false);
frame20->setVisible(false);
/*
frame21->setVisible(false);
frame22->setVisible(false);
frame23->setVisible(false);
frame24->setVisible(false);
frame25->setVisible(false);
frame26->setVisible(false);
frame27->setVisible(false);
frame28->setVisible(false);
frame29->setVisible(false);
frame30->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;
case 2:
frame02->setEnabled(true);
frame02->setVisible(true);
break;
case 3:
frame03->setEnabled(true);
frame03->setVisible(true);
break;
case 4:
frame04->setEnabled(true);
frame04->setVisible(true);
break;
case 5:
frame05->setEnabled(true);
frame05->setVisible(true);
break;
case 6:
frame06->setEnabled(true);
frame06->setVisible(true);
break;
case 7:
frame07->setEnabled(true);
frame07->setVisible(true);
break;
case 8:
frame08->setEnabled(true);
frame08->setVisible(true);
break;
case 9:
frame09->setEnabled(true);
frame09->setVisible(true);
break;
case 10:
frame10->setEnabled(true);
frame10->setVisible(true);
break;
case 11:
frame11->setEnabled(true);
frame11->setVisible(true);
break;
case 12:
frame12->setEnabled(true);
frame12->setVisible(true);
break;
case 13:
frame13->setEnabled(true);
frame13->setVisible(true);
break;
case 14:
frame14->setEnabled(true);
frame14->setVisible(true);
break;
case 15:
frame15->setEnabled(true);
frame15->setVisible(true);
break;
case 16:
frame16->setEnabled(true);
frame16->setVisible(true);
break;
case 17:
frame17->setEnabled(true);
frame17->setVisible(true);
break;
case 18:
frame18->setEnabled(true);
frame18->setVisible(true);
break;
case 19:
frame19->setEnabled(true);
frame19->setVisible(true);
break;
case 20:
frame20->setEnabled(true);
frame20->setVisible(true);
break;
/*
case 21:
frame21->setEnabled(true);
frame21->setVisible(true);
break;
case 22:
frame22->setEnabled(true);
frame22->setVisible(true);
break;
case 23:
frame23->setEnabled(true);
frame23->setVisible(true);
break;
case 24:
frame24->setEnabled(true);
frame24->setVisible(true);
break;
case 25:
frame25->setEnabled(true);
frame25->setVisible(true);
break;
case 26:
frame26->setEnabled(true);
frame26->setVisible(true);
break;
case 27:
frame27->setEnabled(true);
frame27->setVisible(true);
break;
case 28:
frame28->setEnabled(true);
frame28->setVisible(true);
break;
case 29:
frame29->setEnabled(true);
frame29->setVisible(true);
break;
case 30:
frame30->setEnabled(true);
frame30->setVisible(true);
break;
*/
default:
//fenster00->setEnabled(true);
//fenster00->setVisible(true);
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
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
basics: the complete work flow is organized in a step chain (Finite State Machine)
The MainWindowClass (here) always starts with screen number 1 which decides about the next starting steps
Every workingStep (step of the chain) has it's one Frame (with the same number) in MainWindow
Every workingStep has it's own subClass where it processes all work and designes it's own screen
Every workingStep comes back with the request of the next step (& it's screen) once needed which is switched here.
The MainFrame (here) offers three navigation buttons which are forwarded into all subclasses
After a subclass desires a step change the appropriate work-ini function is called one time.
24.12.2021TS
*/
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;
static uint32_t offlineCtr;
// call permanent functions here:
//mifCard->working();
//diary->working();
//conf->working();
//qDebug()<<"mainwin chaincontrol calling mif";
if (HWaccess->sys_areDCdataValid()==false)
{
qDebug()<<"mainwin: lost connection to DC "<<offlineCtr;
offlineCtr++;
}
// 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;
}
//qDebug()<<"chain control step: "<< chainCurrentStep<<" "<<chain_stepIni;
if (chainCurrentStep==1)
{
//if (chain_stepIni)
// busy=myFenster01->work_ini(&nextScreen, &useNavi);
//else
// busy=myFenster01->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==2)
{
if (chain_stepIni)
busy=myFenster02->work_ini(&nextScreen, &useNavi);
else
busy=myFenster02->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==3)
{
if (chain_stepIni)
busy=myFenster03->work_ini(&nextScreen, &useNavi);
else
busy=myFenster03->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==4)
{
if (chain_stepIni)
busy=myFenster04->work_ini(&nextScreen, &useNavi);
else
busy=myFenster04->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==5)
{
if (chain_stepIni)
busy=myFenster05->work_ini(&nextScreen, &useNavi);
else
busy=myFenster05->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==6)
{
if (chain_stepIni)
busy=myFenster06->work_ini(&nextScreen, &useNavi);
else
busy=myFenster06->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==7)
{
if (chain_stepIni)
busy=myFenster07->work_ini(&nextScreen, &useNavi);
else
busy=myFenster07->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==8)
{
if (chain_stepIni)
busy=myFenster08->work_ini(&nextScreen, &useNavi);
else
busy=myFenster08->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==9)
{
if (chain_stepIni)
busy=myFenster09->work_ini(&nextScreen, &useNavi);
else
busy=myFenster09->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==10)
{
if (chain_stepIni)
busy=myFenster10->work_ini(&nextScreen, &useNavi);
else
busy=myFenster10->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==11)
{
if (chain_stepIni)
busy=myFenster11->work_ini(&nextScreen, &useNavi);
else
busy=myFenster11->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==12)
{
if (chain_stepIni)
busy=myFenster12->work_ini(&nextScreen, &useNavi);
else
busy=myFenster12->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==13)
{
if (chain_stepIni)
busy=myFenster13->work_ini(&nextScreen, &useNavi);
else
busy=myFenster13->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==14)
{
if (chain_stepIni)
busy=myFenster14->work_ini(&nextScreen, &useNavi);
else
busy=myFenster14->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==15)
{
if (chain_stepIni)
busy=myFenster15->work_ini(&nextScreen, &useNavi);
else
busy=myFenster15->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==16)
{
if (chain_stepIni)
busy=myFenster16->work_ini(&nextScreen, &useNavi);
else
busy=myFenster16->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==17)
{
if (chain_stepIni)
busy=myFenster17->work_ini(&nextScreen, &useNavi);
else
busy=myFenster17->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==18)
{
if (chain_stepIni)
busy=myFenster18->work_ini(&nextScreen, &useNavi);
else
busy=myFenster18->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==19)
{
if (chain_stepIni)
busy=myFenster19->work_ini(&nextScreen, &useNavi);
else
busy=myFenster19->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==20)
{
if (chain_stepIni)
busy=myFenster20->work_ini(&nextScreen, &useNavi);
else
busy=myFenster20->working(&nextScreen, &useNavi);
} else
/*
if (chainCurrentStep==21)
{
if (chain_stepIni)
busy=myFenster21->work_ini(&nextScreen, &useNavi);
else
busy=myFenster21->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==22)
{
if (chain_stepIni)
busy=myFenster22->work_ini(&nextScreen, &useNavi);
else
busy=myFenster22->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==23)
{
if (chain_stepIni)
busy=myFenster23->work_ini(&nextScreen, &useNavi);
else
busy=myFenster23->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==24)
{
if (chain_stepIni)
busy=myFenster24->work_ini(&nextScreen, &useNavi);
else
busy=myFenster24->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==25)
{
if (chain_stepIni)
busy=myFenster25->work_ini(&nextScreen, &useNavi);
else
busy=myFenster25->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==26)
{
if (chain_stepIni)
busy=myFenster26->work_ini(&nextScreen, &useNavi);
else
busy=myFenster26->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==27)
{
if (chain_stepIni)
busy=myFenster27->work_ini(&nextScreen, &useNavi);
else
busy=myFenster27->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==28)
{
if (chain_stepIni)
busy=myFenster28->work_ini(&nextScreen, &useNavi);
else
busy=myFenster28->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==29)
{
if (chain_stepIni)
busy=myFenster29->work_ini(&nextScreen, &useNavi);
else
busy=myFenster29->working(&nextScreen, &useNavi);
} else
if (chainCurrentStep==30)
{
if (chain_stepIni)
busy=myFenster30->work_ini(&nextScreen, &useNavi);
else
busy=myFenster30->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
}
//qDebug()<<"chain control retvals "<<nextScreen<<" "<<useNavi<<" "<<busy;
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();
}