APservice/win05_doors.cpp

619 lines
18 KiB
C++
Raw Normal View History

2023-11-14 09:32:56 +01:00
#include "win05_doors.h"
#define TIME_DISPLAY_SIGNALS_MS 5000
T_win05::T_win05(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
{
this->HWaccess = HWaccess;
myLayout = new QGridLayout;
QFont myTabFont;
myTabFont.setPixelSize(PIXELSIZE_LABEL);
lab1 =new QLabel(tr("Doors"));
lab1->setFont(myTabFont);
myLayout->addWidget(lab1,0,0);
// -----------------------------------------------------------------------------------------------------
// Spalten anlegen
QLabel *EncLabEmpty = new QLabel(" ");
QLabel *EncLabWide = new QLabel(" ");
//myLayout->addWidget(EncLabEmpty, 0,9);
myLayout->addWidget(EncLabWide, 0,1);
myLayout->addWidget(EncLabEmpty, 0,2);
myLayout->addWidget(EncLabEmpty, 0,3);
myLayout->addWidget(EncLabWide, 0,4);
myLayout->addWidget(EncLabWide, 0,5);
myLayout->addWidget(EncLabEmpty, 0,6);
myLayout->addWidget(EncLabWide, 0,7);
myLayout->addWidget(EncLabWide, 7,0);
// linke Spalte Tür- und Kassenschalter
myTabFont.setPixelSize(PIXELSIZE_LABEL);
QLabel *lab_swPow = new QLabel("Power4switches");
lab_swPow->setFont(myTabFont);
myLayout->addWidget(lab_swPow, 1,0);
LEDpwrOn = new QLabel(tr(" "));
LEDpwrOn->setFrameStyle(QFrame::Panel | QFrame::Raised);
LEDpwrOn->setLineWidth(3); // 1,2,3
LEDpwrOn->setFont(myTabFont);
LEDpwrOn->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot
myLayout->addWidget(LEDpwrOn, 1,1);
// obere Tür
QLabel *EncLab2 = new QLabel(tr("Upper Door"));
EncLab2->setFont(myTabFont);
myLayout->addWidget(EncLab2, 2,0);
EncDoorUp = new QLabel(tr("opened"));
EncDoorUp->setFrameStyle(QFrame::Panel | QFrame::Raised);
EncDoorUp->setLineWidth(3); // 1,2,3
EncDoorUp->setFont(myTabFont);
EncDoorUp->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot
myLayout->addWidget(EncDoorUp, 2,1);
// mittlere Tür
QLabel *EncLab3 = new QLabel(tr("Vault Door"));
EncLab3->setFont(myTabFont);
myLayout->addWidget(EncLab3, 3,0);
EncDoorMid = new QLabel("opened");
EncDoorMid->setFrameStyle(QFrame::Panel | QFrame::Raised);
EncDoorMid->setLineWidth(3); // 1,2,3
EncDoorMid->setFont(myTabFont);
EncDoorMid->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot
myLayout->addWidget(EncDoorMid, 3,1);
// Bill box
QLabel *EncLab5 = new QLabel(tr("Bill Box"));
EncLab5->setFont(myTabFont);
myLayout->addWidget(EncLab5, 4,0);
EncBillBox = new QLabel("missed");
EncBillBox->setFrameStyle(QFrame::Box | QFrame::Raised);
EncBillBox->setLineWidth(3); // 1,2,3
//EncBillBox->setMaximumWidth(60);
EncBillBox->setFont(myTabFont);
EncBillBox->setStyleSheet("background-color: white");
myLayout->addWidget(EncBillBox, 4,1);
// Coin box
QLabel *EncLab6 = new QLabel(tr("Coin Box"));
EncLab6->setFont(myTabFont);
myLayout->addWidget(EncLab6, 5,0);
EncCoinBox = new QLabel("missed");
EncCoinBox->setFrameStyle(QFrame::Box | QFrame::Raised);
EncCoinBox->setLineWidth(3); // 1,2,3
//EncCoinBox->setMaximumWidth(60);
EncCoinBox->setFont(myTabFont);
EncCoinBox->setStyleSheet("background-color: white");
myLayout->addWidget(EncCoinBox, 5,1);
// untere Tür
QLabel *EncLab4 = new QLabel(tr("Lower Door"));
EncLab4->setFont(myTabFont);
myLayout->addWidget(EncLab4, 6,0);
EncDoorDn = new QLabel("opened");
EncDoorDn->setFrameStyle(QFrame::Panel | QFrame::Raised);
EncDoorDn->setLineWidth(3); // 1,2,3
EncDoorDn->setFont(myTabFont);
EncDoorDn->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot
myLayout->addWidget(EncDoorDn, 6,1);
// mittlere Spalte: Tasten
// QLabel *EncLab11 = new QLabel(tr("lock/unlock doors"));
// EncLab11->setFont(myTabFont);
// myLayout->addWidget(EncLab11, 0,3);
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
PB_uplockOpen = new QPushButton(tr("open\n"));
myLayout->addWidget(PB_uplockOpen, 2,3);
PB_uplockOpen->setFont(myTabFont);
connect(PB_uplockOpen, SIGNAL(clicked()), this, SLOT(ua_osd()));
/* nur PSA2020
PB_uplockClos = new QPushButton(tr("close\n"));
myLayout->addWidget(PB_uplockClos, 2,4);
PB_uplockClos->setFont(myTabFont);
connect(PB_uplockClos, SIGNAL(clicked()), this, SLOT(ua_csd()));
*/
PB_lowlockOpen = new QPushButton(tr("open\n"));
PB_lowlockOpen->setFont(myTabFont);
myLayout->addWidget(PB_lowlockOpen, 3,3);
connect(PB_lowlockOpen, SIGNAL(clicked()), this, SLOT(ua_obd()));
PB_vaultDoor = new QPushButton(tr("open safe\n"));
PB_vaultDoor->setFont(myTabFont);
myLayout->addWidget(PB_vaultDoor, 4,3);
connect(PB_vaultDoor, SIGNAL(clicked()), this, SLOT(ua_vd()));
PB_siren = new QPushButton(tr("alarm\nsiren"));
PB_siren->setCheckable(false); // true = toggle button
PB_siren->setFont(myTabFont);
myLayout->addWidget(PB_siren, 6,3);
connect(PB_siren, SIGNAL(clicked()), this, SLOT(switchSiren()));
/* nur PSA2020
// 3. Spalte nur für PSA2020 - Riegelleisten
QLabel *EncLab10 = new QLabel(tr("PSA2020\nLockbars"));
EncLab10->setFont(myTabFont);
myLayout->addWidget(EncLab10, 0,6);
PB_uplockForw = new QPushButton(tr("upper motor\nforward"));
PB_uplockForw->setFont(myTabFont);
myLayout->addWidget(PB_uplockForw, 1,6);
connect(PB_uplockForw, SIGNAL(clicked()), this, SLOT(ua_ulu()));
PB_uplockStop = new QPushButton(tr("upper motor\n stopp"));
PB_uplockStop->setFont(myTabFont);
myLayout->addWidget(PB_uplockStop, 2,6);
connect(PB_uplockStop, SIGNAL(clicked()), this, SLOT(ua_uls()));
PB_uplockRev = new QPushButton(tr("upper motor\nreverse"));
PB_uplockRev->setFont(myTabFont);
myLayout->addWidget(PB_uplockRev, 3,6);
connect(PB_uplockRev, SIGNAL(clicked()), this, SLOT(ua_uld()));
PB_lowlockForw = new QPushButton(tr("lower motor\nforward"));
PB_lowlockForw->setFont(myTabFont);
myLayout->addWidget(PB_lowlockForw, 5,6);
connect(PB_lowlockForw, SIGNAL(clicked()), this, SLOT(ua_llu()));
PB_lowlockStop = new QPushButton(tr("lower motor\n stopp"));
PB_lowlockStop->setFont(myTabFont);
myLayout->addWidget(PB_lowlockStop, 6,6);
connect(PB_lowlockStop, SIGNAL(clicked()), this, SLOT(ua_lls()));
// display Lock-bar contacts, upper lock up
lockbarContactUU = new QLabel("ulu");
lockbarContactUU->setFrameStyle(QFrame::Panel | QFrame::Raised);
lockbarContactUU->setLineWidth(3); // 1,2,3
lockbarContactUU->setMaximumWidth(40);
lockbarContactUU->setMaximumHeight(25);
lockbarContactUU->setFont(myTabFont);
lockbarContactUU->setStyleSheet("background-color: white");
myLayout->addWidget(lockbarContactUU, 1,7);
// upper lock down
lockbarContactUD = new QLabel("uld");
lockbarContactUD->setFrameStyle(QFrame::Panel | QFrame::Raised);
lockbarContactUD->setLineWidth(3); // 1,2,3
lockbarContactUD->setMaximumWidth(40);
lockbarContactUD->setMaximumHeight(25);
lockbarContactUD->setFont(myTabFont);
lockbarContactUD->setStyleSheet("background-color: yellow");
myLayout->addWidget(lockbarContactUD, 3,7);
lockbarContactDU = new QLabel("lld");
lockbarContactDU->setFrameStyle(QFrame::Panel | QFrame::Raised);
lockbarContactDU->setLineWidth(3); // 1,2,3
lockbarContactDU->setMaximumWidth(40);
lockbarContactDU->setMaximumHeight(25);
lockbarContactDU->setFont(myTabFont);
lockbarContactDU->setStyleSheet("background-color: white");
myLayout->addWidget(lockbarContactDU, 5,7);
*/
connect( dynamic_cast<QObject*>(HWaccess), SIGNAL(hwapi_doorServiceDoorOpened()), this, SLOT(door_slotUpOpen()));
connect( dynamic_cast<QObject*>(HWaccess), SIGNAL(hwapi_doorVaultDoorOpened()), this, SLOT(door_slotLowOpen()));
connect( dynamic_cast<QObject*>(HWaccess), SIGNAL(hwapi_doorCoinBoxRemoved()), this, SLOT(door_slotBoxOut()));
connect( dynamic_cast<QObject*>(HWaccess), SIGNAL(hwapi_doorCoinBoxInserted()), this, SLOT(door_slotBoxIn()));
connect( dynamic_cast<QObject*>(HWaccess), SIGNAL(hwapi_doorCBinAndAllDoorsClosed()), this, SLOT(door_slotCBin_AllClosed()));
connect( dynamic_cast<QObject*>(HWaccess), SIGNAL(hwapi_doorAllDoorsClosed()), this, SLOT(door_slotAllClosed()));
myTabFont.setPixelSize(PIXELSIZE_DATA);
showSignals = new QLineEdit();
showSignals->setFrame(true);
showSignals->setText(" ");
showSignals->setReadOnly(true);
showSignals->setFont(myTabFont);
showSignals->setStyleSheet("background-color: white");
myLayout->addWidget(showSignals,1,4);
timerClrDisp = new QTimer();
timerClrDisp->setSingleShot(true);
//timerClrDisp->start(1000);
connect(timerClrDisp, SIGNAL(timeout()), this, SLOT(door_slotClrSig()));
setLayout(myLayout);
myNextStep=0;
myStep=0;
myTO = new QTimer();
myTO->setSingleShot(true);
myTO->start(TIME_DISPLAY_SIGNALS_MS);
}
void T_win05::door_slotUpOpen(void)
{
showSignals->setText("signal service door was opened");
timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen
}
void T_win05::door_slotLowOpen(void)
{
showSignals->setText("signal middlee door was opened");
timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen
}
void T_win05::door_slotBoxOut(void)
{
showSignals->setText("signal coinBox was removed");
timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen
}
void T_win05::door_slotBoxIn(void)
{
showSignals->setText("signal coinBox was inserted");
timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen
}
void T_win05::door_slotCBin_AllClosed(void)
{
showSignals->setText("signal all doors was closed with box in");
timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen
}
void T_win05::door_slotAllClosed(void)
{
showSignals->setText("signal all doors was closed");
timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen
}
void T_win05::door_slotClrSig(void)
{
showSignals->clear();
}
T_win05::~T_win05()
{
close();
}
void T_win05::Nav_back(void)
{
myNextStep=WCS_WIN05BAK;
}
void T_win05::Nav_home(void)
{
myNextStep=WCS_WIN05MID;
}
void T_win05::Nav_next(void)
{
myNextStep=WCS_WIN05FWD;
}
bool T_win05::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_ON | SWITCH_HOME_ON | SWITCH_NEXT_ON;
myNextStep=0;
return false;
}
bool T_win05::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"
*nextScreen=0; // 0=no change
*useNavi=0;
// Türen: EncDoorUp EncDoorMid EncDoorDn
// LEDpwrOn; EncDoorUp;EncDoorMid;EncBillBox;EncCoinBox;EncDoorDn;
if (HWaccess->door_isContactPowerOn())
LEDpwrOn->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün
else
LEDpwrOn->setStyleSheet("background-color: white");
if (HWaccess->door_isUpperDoorOpen())
{
// Tür oben offen
EncDoorUp->setText(" open ");
EncDoorUp->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot
} else
{
// Tür oben zu
EncDoorUp->setText("closed");
EncDoorUp->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün
}
if (HWaccess->vault_isVaultDoorOpen())
{
// Tür Mitte (Tresor) offen:
EncDoorMid->setText(" open ");
EncDoorMid->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot
} else
{
EncDoorMid->setText("closed");
EncDoorMid->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün
}
if (HWaccess->door_isLowerDoorOpen())
{
// EncDoorDn->setText(" o\n p\n e\n n");
EncDoorDn->setText(" open ");
EncDoorDn->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot
//qDebug() << "batt door is open";
} else
{
// EncDoorDn->setText(" c\n l\n o\n s\n e\n d");
EncDoorDn->setText("closed");
EncDoorDn->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün
//qDebug() << "batt door is closed";
}
if (HWaccess->vault_isBillVaultIn())
{
// Bill box drin
// EncBillBox->setText(" B\n I\n L\n L");
EncBillBox->setText(" IN");
EncBillBox->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün
} else
{
EncBillBox->setText("OUT");
EncBillBox->setStyleSheet("background-color: white");
}
if (HWaccess->vault_isCoinVaultIn())
{
// Bill box drin
EncCoinBox->setText(" IN");
EncCoinBox->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün
} else
{
EncCoinBox->setText("OUT");
EncCoinBox->setStyleSheet("background-color: white");
}
/* nur PSA2020
uint8_t ret=HWaccess->door_getLocks();
// retval bit0: upper lever is up
// bit1: upper lever is down
// bit2: lower lever is up
// bit3: lower lever is down
if (ret & 1)
{
lockbarContactUU->setStyleSheet("background-color: yellow");
} else
{
lockbarContactUU->setStyleSheet("background-color: white");
}
if (ret & 2)
lockbarContactUD->setStyleSheet("background-color: yellow");
else
lockbarContactUD->setStyleSheet("background-color: white");
if (ret & 8) // 4 gibts nicht
lockbarContactDU->setStyleSheet("background-color: yellow");
else
lockbarContactDU->setStyleSheet("background-color: white");
// if (ret & 8)
// lockbarContactDD->setStyleSheet("background-color: yellow");
// else
// lockbarContactDD->setStyleSheet("background-color: white");
if (HWaccess->door_upperDoorIsUnlocked())
LedUdoorIsOpen->setStyleSheet("background-color: yellow");
else
LedUdoorIsOpen->setStyleSheet("background-color: white");
if (HWaccess->door_upperDoorIsLocked())
LedUdoorIsClosed->setStyleSheet("background-color: yellow");
else
LedUdoorIsClosed->setStyleSheet("background-color: white");
// if (HWaccess->door_lowerDoorIsUnlocked()) // dennSchalter gibt's nicht!
if (HWaccess->door_lowerDoorIsLocked())
LedLdoorIsOpen->setStyleSheet("background-color: yellow");
else
LedLdoorIsOpen->setStyleSheet("background-color: white");
// if (HWaccess->door_lowerDoorIsLocked())
// LedLdoorIsClosed->setStyleSheet("background-color: yellow");
// else
// LedLdoorIsClosed->setStyleSheet("background-color: white");
*/
/*
// crash
// safe door cannot be opened if printer fuse is blown, display:
uint8_t fuseState=HWaccess->prn_PrnFuseIsOk();
//retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off
if (fuseState==0)
dispFuse->setText("cannot open, \nprinter fuse blown!");
else
dispFuse->setText("cannot open, \nprinter fuse OK!");
*/
/*
if (myStep==0)
{
myTO->start(); // restart
} else
if (myStep==1)
{
if (!myTO->isActive())
{
// time out
}
} else
if (myStep==2)
{
} else
if (myStep==3)
{
} else
if (myStep==4)
{
} else
if (myStep==5)
{
} else
if (myStep==6)
{
} else
if (myStep==7)
{
} else
{
}
*/
if (myNextStep)
{
*nextScreen=myNextStep;
myNextStep=0;
}
return false;
}
// %%%%%%%%%%%%%%%%%%%% aus TabDoors
/* nur 2020
void T_win05::ua_ulu(void)
{
// user action (=button pressed)
// upper lock up = forward
HWaccess->lock_switchUpperLock(1);
}
void T_win05::ua_uld(void)
{
// upper lock down = reverse
HWaccess->lock_switchUpperLock(2);
}
void T_win05::ua_uls(void)
{
// upper lock stop
HWaccess->lock_switchUpperLock(0);
}
void T_win05::ua_llu(void)
{
// user action (=button pressed)
// upper lock up = forward
HWaccess->lock_switchLowerLock(1);
}
*/
/* void T_win05::ua_lld(void)
{
// upper lock down = reverse
HWaccess->lock_switchLowerLock(2);
}*/
/* nur 2020
void T_win05::ua_lls(void)
{
// upper lock stop
HWaccess->lock_switchLowerLock(0);
}*/
void T_win05::ua_osd(void)
{
// open service door
HWaccess->lock_triggerUpperSolenoid();
}
/* nur 2020
void T_win05::ua_csd(void)
{
// clsoe service door
HWaccess->lock_closeUpperDoor();
}*/
void T_win05::ua_obd(void)
{
// open battery/lower door
HWaccess->lock_triggerLowerSolenoid();
}
/*
void T_win05::ua_cbd(void)
{
HWaccess->lock_closeLowerDoor();
}*/
void T_win05::ua_vd(void)
{
//qDebug() << "GUI: button open vault";
HWaccess->lock_switchVaultDoor();
}
void T_win05::switchPwr(void)
{
if (PB_lockPwr->isChecked() )
HWaccess->lock_switchContactPower(1);
else
HWaccess->lock_switchContactPower(0);
}
void T_win05::switchSiren(void)
{
// if (PB_siren->isChecked() )
HWaccess->alarm_switchSiren(1);
// else
// HWaccess->alarm_switchSiren(0);
}