From 2b6a37da9e1e4ffb4b6f797db51b2a4ad07e9749 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 8 Nov 2024 12:57:26 +0100 Subject: [PATCH] checking as provided by thomas --- mainwindow.cpp | 23 +++-- mainwindow.h | 1 + stepList.h | 10 ++- win02_home.cpp | 11 ++- win02_home.h | 2 +- win04_stat.cpp | 23 +++++ win09_gsm.cpp | 58 ++++++++++++ win09_gsm.h | 7 ++ win12_BL.cpp | 237 +++++++++++++++---------------------------------- win12_BL.h | 21 ++--- 10 files changed, 196 insertions(+), 197 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 3dedc84..52b117f 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -591,6 +591,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) connect(myFenster02, SIGNAL(quitMyApp()), this, SLOT(close())); + HWaccess->bl_stopBL(); // 6.11.2024, to be sure about BL-status after DCdiag program start + } MainWindow::~MainWindow() @@ -959,7 +961,7 @@ void MainWindow::chainControl(void) uint16_t nextScreen=0; uint8_t useNavi=0; - bool busy=false; + bool busy=false, nowBL; static uint32_t offlineCtr; // call permanent functions here: @@ -967,19 +969,14 @@ void MainWindow::chainControl(void) //diary->working(); //conf->working(); -//qDebug()<<"mainwin chaincontrol calling mif"; - - - if (HWaccess->sys_areDCdataValid()==false) + nowBL=myFenster12->isBLup(); + if (HWaccess->sys_areDCdataValid()==false && !nowBL) { - qDebug()<<"mainwin: lost connection to DC "<work_ini(&nextScreen, &useNavi); else - busy=myFenster02->working(&nextScreen, &useNavi); + busy=myFenster02->working(&nextScreen, &useNavi, nowBL); } else if (chainCurrentStep==3) { @@ -1271,5 +1268,7 @@ void MainWindow::vendingTimeout(void) timerVendingTimeout->stop(); } - - +bool MainWindow::BLisRunning() +{ + return myFenster12->isBLup(); +} diff --git a/mainwindow.h b/mainwindow.h index c016b7d..95d9992 100755 --- a/mainwindow.h +++ b/mainwindow.h @@ -147,6 +147,7 @@ public: #define FORWBUTTON 3 void enableNaviButtons(uint8_t buttonNr, bool enabled); void enableNaviButtons(uint8_t switchBitwise); + bool BLisRunning(); private slots: void chainControl(); diff --git a/stepList.h b/stepList.h index 6c71b5e..f48d458 100755 --- a/stepList.h +++ b/stepList.h @@ -35,8 +35,9 @@ #define PAGE_NEXT20 20 // fix: customize: -//#define WCS_STARTSCREEN PAGE_COMPORT // if APservice uses masterLib -#define WCS_STARTSCREEN PAGE_SERVICEMAIN // if APservice uses slaveLib +//#define WCS_STARTSCREEN PAGE_COMPORT +//#define WCS_STARTSCREEN PAGE_NEXT16 +#define WCS_STARTSCREEN PAGE_SERVICEMAIN // PAGE_COMPORT: #define WCS_WIN01BAK PAGE_COMPORT @@ -44,6 +45,7 @@ #define WCS_WIN01FWD PAGE_SERVICEMAIN // PAGE_SERVICEMAIN: +//#define WCS_WIN02BAK PAGE_NEXT16 #define WCS_WIN02BAK PAGE_BOOTLOADER #define WCS_WIN02MID PAGE_SERVICEMAIN #define WCS_WIN02FWD PAGE_TIMEDATEVERSION @@ -170,8 +172,8 @@ #define WCS_WIN02SHORT08 PAGE_VAULTRECORD #define WIN02_LABEL_SHORT09 "Program" #define WCS_WIN02SHORT09 PAGE_PROG_JSON -#define WIN02_LABEL_SHORT10 " " -#define WCS_WIN02SHORT10 PAGE_SERVICEMAIN +#define WIN02_LABEL_SHORT10 " B L " +#define WCS_WIN02SHORT10 PAGE_BOOTLOADER diff --git a/win02_home.cpp b/win02_home.cpp index 3b813a7..de3cd38 100755 --- a/win02_home.cpp +++ b/win02_home.cpp @@ -360,7 +360,7 @@ bool T_win02::work_ini(uint16_t *nextScreen, uint8_t *useNavi) } -bool T_win02::working(uint16_t *nextScreen, uint8_t *useNavi) +bool T_win02::working(uint16_t *nextScreen, uint8_t *useNavi, bool isBLup) { // one state of the vending/operating FSM // called cyclic until this state changes intentionally to another state @@ -395,6 +395,13 @@ bool T_win02::working(uint16_t *nextScreen, uint8_t *useNavi) tmpStr.clear(); // update values: + if (HWaccess->bl_isUp()==1) + //if (isBLup) + { + labState->setText(" DC2 Bootloader"); + labState->setStyleSheet(COLOR_RED); + + } else if (HWaccess->sys_areDCdataValid()) { labState->setText(" DC2 connected "); // datenverkehr läuft @@ -431,8 +438,6 @@ bool T_win02::working(uint16_t *nextScreen, uint8_t *useNavi) } labLoc2->setText(myStr); - - if (cunu>0 && manu>0) { myStr.clear(); diff --git a/win02_home.h b/win02_home.h index 107adc2..5972fe2 100755 --- a/win02_home.h +++ b/win02_home.h @@ -90,7 +90,7 @@ public: // 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); + bool working (uint16_t *nextScreen, uint8_t *useNavi, bool isBLup); ~T_win02(); private slots: diff --git a/win04_stat.cpp b/win04_stat.cpp index c441549..e0b3fff 100755 --- a/win04_stat.cpp +++ b/win04_stat.cpp @@ -18,6 +18,7 @@ T_win04::T_win04(hwinf *HWaccess, QWidget *parent) : QWidget(parent) myTabFont.setPixelSize(PIXELSIZE_BUTTONS); pb_refresh = new QPushButton("Refresh"); pb_refresh->setFont(myTabFont); + pb_refresh->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot myLayout->addWidget(pb_refresh,1,1); connect(pb_refresh, SIGNAL(clicked()), this, SLOT(ButtonRefreshClicked())); @@ -99,6 +100,7 @@ void T_win04::Nav_next(void) void T_win04::ButtonRefreshClicked(void) { win04_dataAreValid=0; + pb_refresh->setStyleSheet("background-color: white"); } bool T_win04::work_ini(uint16_t *nextScreen, uint8_t *useNavi) @@ -175,6 +177,27 @@ bool T_win04::working(uint16_t *nextScreen, uint8_t *useNavi) struct T_dynamicCondition myDynMachCond; struct T_devices devPara; // used devices + // neu, 24.7.24 + static bool win04_dcDataAreValid; + bool bget; + + bget=HWaccess->sys_areDCdataValid(); + if (bget && !win04_dcDataAreValid) + { + // DC soeben ANgesteckt + win04_dcDataAreValid=true; + win04_dataAreValid=0; + // genau jetzt die Geräte Stati einlesen, scheinen nicht immer aktuell zu sein + pb_refresh->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + } + if (!bget && win04_dcDataAreValid) + { + // DC soeben ABgesteckt + win04_dcDataAreValid=false; + win04_dataAreValid=0; + pb_refresh->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + } + HWaccess->sys_restoreDeviceParameter(&devPara); if (!win04_dataAreValid) diff --git a/win09_gsm.cpp b/win09_gsm.cpp index 0b8f61f..ab72e09 100755 --- a/win09_gsm.cpp +++ b/win09_gsm.cpp @@ -114,6 +114,37 @@ T_win09::T_win09(hwinf *HWaccess, QWidget *parent) : QWidget(parent) connect(pbCreditWake, SIGNAL(clicked()), this, SLOT(slot_startTest())); */ +/* + pbTest1 = new QPushButton("PTU up"); + pbTest1->setCheckable(false); // true = toggle button + pbTest1->setFont(myTabFont); + pbTest1->setStyleSheet("background-color: yellow"); + myLayout->addWidget(pbTest1, 5, 0); + connect(pbTest1, SIGNAL(clicked()), this, SLOT(slot_pbTest1())); + + pbTest2 = new QPushButton("PTU dn"); + pbTest2->setCheckable(false); // true = toggle button + pbTest2->setFont(myTabFont); + pbTest2->setStyleSheet("background-color: yellow"); + myLayout->addWidget(pbTest2, 6, 0); + connect(pbTest2, SIGNAL(clicked()), this, SLOT(slot_pbTest2())); + + pbTest3 = new QPushButton("DC up"); + pbTest3->setCheckable(false); // true = toggle button + pbTest3->setFont(myTabFont); + pbTest3->setStyleSheet("background-color: yellow"); + myLayout->addWidget(pbTest3, 7, 0); + connect(pbTest3, SIGNAL(clicked()), this, SLOT(slot_pbTest3())); + + pbTest4 = new QPushButton("DC dn"); + pbTest4->setCheckable(false); // true = toggle button + pbTest4->setFont(myTabFont); + pbTest4->setStyleSheet("background-color: yellow"); + myLayout->addWidget(pbTest4, 8, 0); + connect(pbTest4, SIGNAL(clicked()), this, SLOT(slot_pbTest4())); +*/ + + setLayout(myLayout); myNextStep=0; myStep=0; @@ -210,6 +241,33 @@ void T_win09::slot_startTest(void) HWaccess->sys_runCompleteTest(); } +// 8.10.2024 new, control power up/down +/* +void slot_pbTest1(void) +{ + HWaccess->prepareForPowerDown(); + +} + +void slot_pbTest2(void) +{ + HWaccess->justReactivated(); + +} + +void slot_pbTest3(void) +{ + HWaccess->dcNotActive(); + +} + +void slot_pbTest4(void) +{ + HWaccess->dcIsActive(); + +} +*/ + diff --git a/win09_gsm.h b/win09_gsm.h index 378c046..b99fa84 100755 --- a/win09_gsm.h +++ b/win09_gsm.h @@ -37,6 +37,7 @@ class T_win09 : public QWidget QPushButton *pbModemPwr, *pbModemWake, *pbCreditPwr, *pbCreditWake, *pbModemRes; QLabel *showModemCondition; + //QPushButton *pbTest1, *pbTest2, *pbTest3, *pbTest4; public: explicit T_win09(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); @@ -58,6 +59,12 @@ public slots: void slot_CreditWake(void); void slot_startTest(void); void slot_ModemRes(void); +// void slot_pbTest1(void); +// void slot_pbTest2(void); +// void slot_pbTest3(void); +// void slot_pbTest4(void); + + }; diff --git a/win12_BL.cpp b/win12_BL.cpp index a0c06c8..e6db02b 100755 --- a/win12_BL.cpp +++ b/win12_BL.cpp @@ -44,11 +44,11 @@ T_win12::T_win12(hwinf *HWaccess, QWidget *parent) : QWidget(parent) // linke Spalte: controls QLabel *lab7 = new QLabel(" "); lab7->setFont(myTabFont); - myVlayer_left->addWidget(lab7); + myVlayer_right->addWidget(lab7); but9 = new QPushButton("Starting \nBootloader"); - myVlayer_left->addWidget(but9); - connect(but9, SIGNAL(clicked()), this, SLOT(slot_b9())); + myVlayer_right->addWidget(but9); + connect(but9, SIGNAL(clicked()), this, SLOT(slot_startCompleteBL())); but9->setStyleSheet(BUTTONCOLOR0); but9->setFont(myTabFont); @@ -57,8 +57,8 @@ T_win12::T_win12(hwinf *HWaccess, QWidget *parent) : QWidget(parent) myH0layer->addWidget(lab3); but4 = new QPushButton("load Bin-File"); - myVlayer_left->addWidget(but4); - connect(but4, SIGNAL(clicked()), this, SLOT(slot_b4())); + myVlayer_right->addWidget(but4); + connect(but4, SIGNAL(clicked()), this, SLOT(slot_loadBin())); but4->setStyleSheet(BUTTONCOLOR0); but4->setFont(myTabFont); @@ -67,8 +67,8 @@ T_win12::T_win12(hwinf *HWaccess, QWidget *parent) : QWidget(parent) myH0layer->addWidget(lab4); but5 = new QPushButton(" send file to DC"); - myVlayer_left->addWidget(but5); - connect(but5, SIGNAL(clicked()), this, SLOT(slot_b5())); + myVlayer_right->addWidget(but5); + connect(but5, SIGNAL(clicked()), this, SLOT(slot_sendBin())); but5->setStyleSheet(BUTTONCOLOR0); but5->setFont(myTabFont); @@ -76,49 +76,22 @@ T_win12::T_win12(hwinf *HWaccess, QWidget *parent) : QWidget(parent) lab5->setFont(myTabFont); myH0layer->addWidget(lab5); -/* - but6 = new QPushButton(" "); - myVlayer_left->addWidget(but6); - connect(but6, SIGNAL(clicked()), this, SLOT(slot_b6())); - but6->setStyleSheet(BUTTONCOLOR0); - but6->setFont(myTabFont); - - but7 = new QPushButton(" "); - myVlayer_left->addWidget(but7); - connect(but7, SIGNAL(clicked()), this, SLOT(slot_b7())); - but7->setStyleSheet(BUTTONCOLOR0); - but7->setFont(myTabFont); - - but8 = new QPushButton(" "); - myVlayer_left->addWidget(but8); - connect(but8, SIGNAL(clicked()), this, SLOT(slot_b8())); - but8->setStyleSheet(BUTTONCOLOR0); - but8->setFont(myTabFont); -*/ -/* - but9 = new QPushButton("complete start"); - myVlayer_left->addWidget(but9); - connect(but9, SIGNAL(clicked()), this, SLOT(slot_b9())); - but9->setStyleSheet(BUTTONCOLOR0); - but9->setFont(myTabFont); -*/ - myTabFont.setPixelSize(14); - but1 = new QPushButton("restart DC: "); - myVlayer_left->addWidget(but1); - connect(but1, SIGNAL(clicked()), this, SLOT(slot_b1())); + but1 = new QPushButton("restart DC: \n"); + myVlayer_right->addWidget(but1); + connect(but1, SIGNAL(clicked()), this, SLOT(slot_restart())); but1->setStyleSheet(BUTTONCOLOR0); but1->setFont(myTabFont); - but2 = new QPushButton("Start BL: "); - myVlayer_left->addWidget(but2); - connect(but2, SIGNAL(clicked()), this, SLOT(slot_b2())); + but2 = new QPushButton("Start BL: \n"); + myVlayer_right->addWidget(but2); + connect(but2, SIGNAL(clicked()), this, SLOT(slot_startBl())); but2->setStyleSheet(BUTTONCOLOR0); but2->setFont(myTabFont); - but3 = new QPushButton("check BL: "); - myVlayer_left->addWidget(but3); - connect(but3, SIGNAL(clicked()), this, SLOT(slot_b3())); + but3 = new QPushButton("check BL: \n"); + myVlayer_right->addWidget(but3); + connect(but3, SIGNAL(clicked()), this, SLOT(slot_checkBl())); but3->setStyleSheet(BUTTONCOLOR0); but3->setFont(myTabFont); @@ -128,8 +101,8 @@ T_win12::T_win12(hwinf *HWaccess, QWidget *parent) : QWidget(parent) myTabFont.setPixelSize(22); but10 = new QPushButton("stop BL: "); - myVlayer_left->addWidget(but10); - connect(but10, SIGNAL(clicked()), this, SLOT(slot_b10())); + myVlayer_right->addWidget(but10); + connect(but10, SIGNAL(clicked()), this, SLOT(slot_stopBL())); but10->setStyleSheet(BUTTONCOLOR0); but10->setFont(myTabFont); @@ -156,9 +129,10 @@ T_win12::T_win12(hwinf *HWaccess, QWidget *parent) : QWidget(parent) myTO->setSingleShot(true); myTO->start(2); trigger_BLstartup=false; - win12_startProgramming=0; + win12_startProgramming=false; win12_nrOfFWblocks=0; win12_currentBlkNr=0; + APservBLisUp=false; } T_win12::~T_win12() @@ -179,20 +153,29 @@ void T_win12::Nav_next(void) myNextStep=WCS_WIN12FWD; } -void T_win12::slot_b1(void) +void T_win12::slot_startCompleteBL(void) +{ + // replaces the next three single steps restart_DC, start_BL and check_BL + showState->setText(" starting bootloader... "); + showFile->setText(" "); + HWaccess->bl_completeStart(); +} + +// single steps from former version: +void T_win12::slot_restart(void) { showProgress->append(" rebooting"); HWaccess->dc_autoRequest(false); HWaccess->bl_rebootDC(); } -void T_win12::slot_b2(void) +void T_win12::slot_startBl(void) { HWaccess->dc_autoRequest(false); HWaccess->bl_startBL(); } -void T_win12::slot_b3(void) +void T_win12::slot_checkBl(void) { HWaccess->dc_autoRequest(false); showState->setText(" "); @@ -202,17 +185,24 @@ void T_win12::slot_b3(void) myStep=20; } -void T_win12::slot_b4(void) +void T_win12::slot_loadBin(void) { QString myStr; QString fileName; win12_nrOfFWblocks=0; fileName.clear(); + + // bin file im selben folder wie in PTU5: /etc/dc/ fileName = QFileDialog::getOpenFileName(this, ("Select DC firmware file:"), - "C:/own/work2023/PSA1256ptu5/PTU SW", + "/etc/dc", ("binary file(*.bin)")); + // Jsons im selben folder wie in PTU5: /etc/psa_config + //fileName = QFileDialog::getOpenFileName(this, ("Select JSON file:"), + // "/etc/psa_config", + // ("binary file(*.json)")); + //qDebug()<<"T_win12: selected file: "<bl_storeFirmware(fileName); win12_nrOfFWblocks = HWaccess->bl_getNrOfFirmwareBlocks(); @@ -229,42 +219,27 @@ void T_win12::slot_b4(void) showFile->setText(" cannot load file :-( "); } -void T_win12::slot_b5(void) + +void T_win12::slot_sendBin(void) { win12_startProgramming=true; + showProgress->clear(); myStep=5; } -void T_win12::slot_b6(void) -{ -} -void T_win12::slot_b7(void) -{ -} - -void T_win12::slot_b8(void) -{ -} - -void T_win12::slot_b9(void) -{ - showState->setText(" Bootloader is off "); - showFile->setText(" "); - - //trigger_BLstartup=true; - //myStep=0; - - // neu, 29.9: Start-Schrittkette jetzt in HWapi: - HWaccess->bl_completeStart(); -} - -void T_win12::slot_b10(void) +void T_win12::slot_stopBL(void) { showState->setText(" Bootloader is off "); showFile->setText(" "); HWaccess->bl_stopBL(); HWaccess->dc_autoRequest(true); + APservBLisUp=false; +} + +bool T_win12::isBLup() +{ + return APservBLisUp; } bool T_win12::work_ini(uint16_t *nextScreen, uint8_t *useNavi) @@ -295,98 +270,17 @@ bool T_win12::working(uint16_t *nextScreen, uint8_t *useNavi) *nextScreen=0; // 0=no change *useNavi=0; - //int8_t iresult; + int8_t iresult; - if (HWaccess->bl_isUp()) + if (HWaccess->bl_isUp()==1) + APservBLisUp=true; + + if (APservBLisUp) showState->setText(" Bootloader is running"); + else + showState->setText(" - - - "); -/* - if (myStep==0) - { - - if (trigger_BLstartup) - { - HWaccess->dc_autoRequest(false); - myStep++; - } - - } else - - if (myStep==1) - { - //qDebug()<<"win12 chain step 1"; - if (trigger_BLstartup) - { - //qDebug()<<"starting up BL step1"; - trigger_BLstartup=false; - HWaccess->bl_rebootDC(); - myTO->stop(); - myTO->start(1000); // restart - retryCtr=0; - myStep++; - //qDebug()<<"win12 chain step 2"; - } - } else - - if (myStep==2) - { - if (!myTO->isActive()) - { - qDebug()<<"starting BL"; - HWaccess->bl_startBL(); - myTO->stop(); - myTO->start(100); - myStep++; - //qDebug()<<"win12 chain step 3"; - } - } else - - if (myStep==3) - { - if (!myTO->isActive()) - { - HWaccess->bl_checkBL(); - myTO->stop(); - myTO->start(100); - myStep++; - //qDebug()<<"win12 chain step 4"; - } - - } else - - if (myStep==4) - { - if (!myTO->isActive()) - { - //qDebug()<<"starting up BL step4"; - myTO->stop(); - if (HWaccess->bl_isUp()) - { - myStep++; - //qDebug()<<"win12 chain step 5"; - showState->setText(" --- BL is up and running ---"); - //qDebug()<<"BL laeuft!!!"; - } else - { - - retryCtr++; // start again - if (retryCtr>=15) - { - myStep=99; - //qDebug()<<"win12 chain step 99"; - showState->setText(" --- BL error! ---"); - //qDebug()<<"BL error!!!"; - } else - { - myStep=3; - //qDebug()<<"BL retry..."; - //qDebug()<<"win12 chain step 3"; - } - } - } - } else - if (myStep==5) { if (win12_startProgramming) @@ -405,17 +299,26 @@ bool T_win12::working(uint16_t *nextScreen, uint8_t *useNavi) if (myStep==6) { - //qDebug()<<"starting transfer"; + + // ------------------------------------------------------------------- HWaccess->bl_blockAutoLoad(win12_currentBlkNr); - showProgress->append(swl_int2str(win12_currentBlkNr)); + // ------------------------------------------------------------------- + //if (win12_currentBlkNr%10==0) // nur jeden 10. Block anzeigen + // geht auch nicht schneller + showProgress->append(swl_int2str(win12_currentBlkNr)); myStep++; //qDebug()<<"win12 chain step 6->7"; } else if (myStep==7) { + + // ------------------------------------------------------------------- iresult=HWaccess->bl_blockAutoResponse(); // 0: wait 1: OK, blk was sent 2: OK, transfer complete 3: error + // ------------------------------------------------------------------- + + if (iresult==1) { win12_currentBlkNr++; @@ -452,7 +355,7 @@ bool T_win12::working(uint16_t *nextScreen, uint8_t *useNavi) { } - +/* if (myStep==20) { if (!myTO->isActive()) diff --git a/win12_BL.h b/win12_BL.h index ba21a56..23e8296 100755 --- a/win12_BL.h +++ b/win12_BL.h @@ -50,6 +50,7 @@ class T_win12 : public QWidget bool trigger_BLstartup; int retryCtr; QTextEdit *showProgress; + bool APservBLisUp; public: explicit T_win12(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); @@ -61,21 +62,21 @@ public: bool working (uint16_t *nextScreen, uint8_t *useNavi); ~T_win12(); + bool isBLup(); + + public slots: void Nav_back(void); void Nav_home(void); void Nav_next(void); - void slot_b1(void); - void slot_b2(void); - void slot_b3(void); - void slot_b4(void); - void slot_b5(void); - void slot_b6(void); - void slot_b7(void); - void slot_b8(void); - void slot_b9(void); - void slot_b10(void); + void slot_restart(void); + void slot_startBl(void); + void slot_checkBl(void); + void slot_startCompleteBL(void); + void slot_sendBin(void); + void slot_loadBin(void); + void slot_stopBL(void); };