-Modification du widget de connexion Ethernet
-Ajout d'une connexion pour l'historien
This commit is contained in:
parent
a6683e2058
commit
6500e25bd5
BIN
Images/connexion_rouge.png
Executable file
BIN
Images/connexion_rouge.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
Images/connexion_vert.png
Executable file
BIN
Images/connexion_vert.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
6
ZT.pro
6
ZT.pro
@ -115,7 +115,8 @@ SOURCES += \
|
||||
sources/Modbus/ModbusRepository.cpp \
|
||||
sources/Modbus/ModbusCCMgr.cpp \
|
||||
sources/Modbus/ModbusTKTransport.cpp \
|
||||
sources/Stations/DuCollege.cpp
|
||||
sources/Stations/DuCollege.cpp \
|
||||
sources/GuiElements/EthConnWidget.cpp
|
||||
|
||||
HEADERS += \
|
||||
sources/MainPanel.h \
|
||||
@ -230,7 +231,8 @@ HEADERS += \
|
||||
sources/Modbus/ModbusCCMgr.h \
|
||||
sources/Modbus/ModbusCCDefs.h \
|
||||
sources/Modbus/ModbusTKTransport.h \
|
||||
sources/Stations/DuCollege.h
|
||||
sources/Stations/DuCollege.h \
|
||||
sources/GuiElements/EthConnWidget.h
|
||||
|
||||
#QMAKE_LIBDIR += ./ExtLib
|
||||
#QT += network
|
||||
|
||||
78
sources/GuiElements/EthConnWidget.cpp
Normal file
78
sources/GuiElements/EthConnWidget.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Affiche un bitmap d'une DEL verte (allumée ou éteinte).
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131024 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
|
||||
#include "EthConnWidget.h"
|
||||
#include <QFontMetrics>
|
||||
|
||||
CEthConnWidget::CEthConnWidget(QString Label,QGraphicsItem *Parent)
|
||||
{
|
||||
|
||||
setParentItem(Parent);
|
||||
mLabel = new QGraphicsTextItem(this);
|
||||
mEthOnPixmap = new QGraphicsPixmapItem(this);
|
||||
mEthONImage.load("./Images/connexion_vert.png");
|
||||
|
||||
mEthOffPixmap = new QGraphicsPixmapItem(this);
|
||||
mEthOFFImage.load("./Images/connexion_rouge.png");
|
||||
|
||||
mLabel->setPlainText(Label);
|
||||
mLabel->adjustSize();
|
||||
|
||||
EthOFF();
|
||||
|
||||
resize(25,25);
|
||||
|
||||
}
|
||||
|
||||
void CEthConnWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
mEthOnPixmap->setPixmap(QPixmap().fromImage(mEthONImage).scaled(boundingRect().width(),boundingRect().height()));
|
||||
mEthOffPixmap->setPixmap(QPixmap().fromImage(mEthOFFImage).scaled(boundingRect().width(),boundingRect().height()));
|
||||
//mLabel->setPos((boundingRect().width()/2) - ((QFontMetrics(mLabel->font()).width(mLabel->toPlainText())/2)),boundingRect().height()-10);
|
||||
mLabel->setPos((boundingRect().width()/2) - (mLabel->boundingRect().width()/2),mEthOnPixmap->boundingRect().bottom()-9);
|
||||
}
|
||||
|
||||
void CEthConnWidget::EthOFF()
|
||||
{
|
||||
mEthOnPixmap->hide();
|
||||
mEthOffPixmap->show();
|
||||
}
|
||||
|
||||
void CEthConnWidget::EthON()
|
||||
{
|
||||
mEthOnPixmap->show();
|
||||
mEthOffPixmap->hide();
|
||||
}
|
||||
|
||||
void CEthConnWidget::SetEth(bool ON)
|
||||
{
|
||||
if(ON == true)
|
||||
EthON();
|
||||
else
|
||||
EthOFF();
|
||||
}
|
||||
25
sources/GuiElements/EthConnWidget.h
Normal file
25
sources/GuiElements/EthConnWidget.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef ETHCONNWIDGET_H
|
||||
#define ETHCONNWIDGET_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
class CEthConnWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CEthConnWidget(QString Label,QGraphicsItem *Parent = 0);
|
||||
|
||||
QGraphicsTextItem *mLabel;
|
||||
QImage mEthONImage,mEthOFFImage;
|
||||
QGraphicsPixmapItem *mEthOnPixmap,*mEthOffPixmap;
|
||||
|
||||
void EthON();
|
||||
void EthOFF();
|
||||
void SetEth(bool ON);
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
};
|
||||
|
||||
#endif // ETHCONNWIDGET_H
|
||||
@ -32,8 +32,9 @@
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
CStatusBar::CStatusBar(QGraphicsItem *Parent):
|
||||
mCCModbusONOFF("",this),
|
||||
mSEIModbusONOFF("",this)
|
||||
mCCModbusONOFF("CC",this),
|
||||
mSEIModbusONOFF("SEI",this),
|
||||
mHistorienModbusONOFF("HIS",this)
|
||||
{
|
||||
|
||||
setParentItem(Parent);
|
||||
@ -46,17 +47,24 @@ CStatusBar::CStatusBar(QGraphicsItem *Parent):
|
||||
|
||||
mZT1Status = mZT2Status = SB_ZT_INACTIVE_STATUS;
|
||||
mCCModbusState = SB_MODBUS_NOT_PRESENT;
|
||||
mSEIModbusState = SB_MODBUS_NOT_PRESENT;
|
||||
mSEIModbusState = SB_MODBUS_CONNECTED;//SB_MODBUS_NOT_PRESENT;
|
||||
mHistoModbusState = SB_MODBUS_CONNECTED;
|
||||
|
||||
mCCModbusONOFF.setParentItem(this);
|
||||
mCCModbusONOFF.setPos(760,0);
|
||||
mCCModbusONOFF.LedOFF();
|
||||
mCCModbusONOFF.setPos(730,0);
|
||||
mCCModbusONOFF.EthOFF();
|
||||
mCCModbusONOFF.hide();
|
||||
|
||||
mSEIModbusONOFF.setParentItem(this);
|
||||
mSEIModbusONOFF.setPos(845,0);
|
||||
mSEIModbusONOFF.LedOFF();
|
||||
mSEIModbusONOFF.setPos(765,0);
|
||||
mSEIModbusONOFF.EthOFF();
|
||||
mSEIModbusONOFF.hide();
|
||||
|
||||
mHistorienModbusONOFF.setParentItem(this);
|
||||
mHistorienModbusONOFF.setPos(800,0);
|
||||
mHistorienModbusONOFF.EthOFF();
|
||||
mHistorienModbusONOFF.hide();
|
||||
|
||||
// QGraphicsRectItem *temprect = new QGraphicsRectItem(this);
|
||||
// temprect->setRect(boundingRect());
|
||||
// temprect->show();
|
||||
@ -181,7 +189,7 @@ void CStatusBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
|
||||
if(mCCModbusState == SB_MODBUS_CONNECTED)
|
||||
/* if(mCCModbusState == SB_MODBUS_CONNECTED)
|
||||
{
|
||||
painter->setPen(Qt::darkGreen);
|
||||
Text.clear();
|
||||
@ -217,7 +225,7 @@ void CStatusBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
TextRect.adjust(50,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
@ -255,12 +263,12 @@ unsigned int CStatusBar::SetCCModbusState(unsigned int State)
|
||||
mCCModbusState = State;
|
||||
if(State == SB_MODBUS_CONNECTED)
|
||||
{
|
||||
mCCModbusONOFF.LedON();
|
||||
mCCModbusONOFF.EthON();
|
||||
mCCModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_DISCONNECTED)
|
||||
{
|
||||
mCCModbusONOFF.LedOFF();
|
||||
mCCModbusONOFF.EthOFF();
|
||||
mCCModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_NOT_PRESENT)
|
||||
@ -277,12 +285,12 @@ unsigned int CStatusBar::SetSEIModbusState(unsigned int State)
|
||||
mSEIModbusState = State;
|
||||
if(State == SB_MODBUS_CONNECTED)
|
||||
{
|
||||
mSEIModbusONOFF.LedON();
|
||||
mSEIModbusONOFF.EthON();
|
||||
mSEIModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_DISCONNECTED)
|
||||
{
|
||||
mSEIModbusONOFF.LedOFF();
|
||||
mSEIModbusONOFF.EthOFF();
|
||||
mSEIModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_NOT_PRESENT)
|
||||
@ -293,3 +301,25 @@ unsigned int CStatusBar::SetSEIModbusState(unsigned int State)
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CStatusBar::SetHistorienModbusState(unsigned int State)
|
||||
{
|
||||
mHistoModbusState = State;
|
||||
if(State == SB_MODBUS_CONNECTED)
|
||||
{
|
||||
mHistorienModbusONOFF.EthON();
|
||||
mHistorienModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_DISCONNECTED)
|
||||
{
|
||||
mHistorienModbusONOFF.EthOFF();
|
||||
mHistorienModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_NOT_PRESENT)
|
||||
{
|
||||
mHistorienModbusONOFF.hide();
|
||||
}
|
||||
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "LedWidget.h"
|
||||
#include "EthConnWidget.h"
|
||||
|
||||
enum eZTStatus
|
||||
{
|
||||
@ -61,13 +62,16 @@ public:
|
||||
unsigned int SetNbTriggers(unsigned int Value);
|
||||
unsigned int SetCCModbusState(unsigned int State);
|
||||
unsigned int SetSEIModbusState(unsigned int State);
|
||||
unsigned int SetHistorienModbusState(unsigned int State);
|
||||
|
||||
private:
|
||||
QString mZT1StatusString, mZT2StatusString;
|
||||
unsigned int mZT1Status, mZT2Status;
|
||||
unsigned int mNbTrainsPass, mNbTriggers;
|
||||
unsigned int mCCModbusState, mSEIModbusState;
|
||||
CLedWidget mCCModbusONOFF, mSEIModbusONOFF;
|
||||
unsigned int mCCModbusState, mSEIModbusState, mHistoModbusState;
|
||||
CEthConnWidget mCCModbusONOFF, mSEIModbusONOFF, mHistorienModbusONOFF;
|
||||
//CLedWidget mCCModbusONOFF, mSEIModbusONOFF;
|
||||
|
||||
};
|
||||
|
||||
#endif // STATUSBAR_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user