Modbus dev...
This commit is contained in:
@@ -31,7 +31,9 @@
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
CStatusBar::CStatusBar(QGraphicsItem *Parent)
|
||||
CStatusBar::CStatusBar(QGraphicsItem *Parent):
|
||||
mCCModbusONOFF("",this),
|
||||
mSEIModbusONOFF("",this)
|
||||
{
|
||||
|
||||
setParentItem(Parent);
|
||||
@@ -45,6 +47,16 @@ CStatusBar::CStatusBar(QGraphicsItem *Parent)
|
||||
mZT1Status = mZT2Status = SB_ZT_INACTIVE_STATUS;
|
||||
mCCModbusState = SB_MODBUS_NOT_PRESENT;
|
||||
mSEIModbusState = SB_MODBUS_NOT_PRESENT;
|
||||
|
||||
mCCModbusONOFF.setParentItem(this);
|
||||
mCCModbusONOFF.setPos(760,0);
|
||||
mCCModbusONOFF.LedOFF();
|
||||
mCCModbusONOFF.hide();
|
||||
|
||||
mSEIModbusONOFF.setParentItem(this);
|
||||
mSEIModbusONOFF.setPos(845,0);
|
||||
mSEIModbusONOFF.LedOFF();
|
||||
mSEIModbusONOFF.hide();
|
||||
// QGraphicsRectItem *temprect = new QGraphicsRectItem(this);
|
||||
// temprect->setRect(boundingRect());
|
||||
// temprect->show();
|
||||
@@ -173,7 +185,7 @@ void CStatusBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
{
|
||||
painter->setPen(Qt::darkGreen);
|
||||
Text.clear();
|
||||
Text.sprintf("CC[Connecté]");
|
||||
Text.sprintf("CC:");
|
||||
TextRect.adjust(5,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
@@ -182,7 +194,7 @@ void CStatusBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
{
|
||||
painter->setPen(Qt::red);
|
||||
Text.clear();
|
||||
Text.sprintf("CC[Déconnecté]");
|
||||
Text.sprintf("CC:");
|
||||
TextRect.adjust(5,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
@@ -192,8 +204,8 @@ void CStatusBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
{
|
||||
painter->setPen(Qt::darkGreen);
|
||||
Text.clear();
|
||||
Text.sprintf("SEI[Connecté]");
|
||||
TextRect.adjust(20,0,0,0);
|
||||
Text.sprintf("SEI:");
|
||||
TextRect.adjust(50,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
}
|
||||
@@ -201,8 +213,8 @@ void CStatusBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
{
|
||||
painter->setPen(Qt::red);
|
||||
Text.clear();
|
||||
Text.sprintf("SEI[Déconnecté]");
|
||||
TextRect.adjust(20,0,0,0);
|
||||
Text.sprintf("SEI:");
|
||||
TextRect.adjust(50,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
}
|
||||
@@ -241,12 +253,43 @@ unsigned int CStatusBar::SetZT2Status(unsigned int Status)
|
||||
unsigned int CStatusBar::SetCCModbusState(unsigned int State)
|
||||
{
|
||||
mCCModbusState = State;
|
||||
if(State == SB_MODBUS_CONNECTED)
|
||||
{
|
||||
mCCModbusONOFF.LedON();
|
||||
mCCModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_DISCONNECTED)
|
||||
{
|
||||
mCCModbusONOFF.LedOFF();
|
||||
mCCModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_NOT_PRESENT)
|
||||
{
|
||||
mCCModbusONOFF.hide();
|
||||
}
|
||||
|
||||
update(boundingRect());
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
unsigned int CStatusBar::SetSEIModbusState(unsigned int State)
|
||||
{
|
||||
mSEIModbusState = State;
|
||||
if(State == SB_MODBUS_CONNECTED)
|
||||
{
|
||||
mSEIModbusONOFF.LedON();
|
||||
mSEIModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_DISCONNECTED)
|
||||
{
|
||||
mSEIModbusONOFF.LedOFF();
|
||||
mSEIModbusONOFF.show();
|
||||
}
|
||||
else if(State == SB_MODBUS_NOT_PRESENT)
|
||||
{
|
||||
mSEIModbusONOFF.hide();
|
||||
}
|
||||
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "LedWidget.h"
|
||||
|
||||
enum eZTStatus
|
||||
{
|
||||
@@ -66,6 +67,7 @@ private:
|
||||
unsigned int mZT1Status, mZT2Status;
|
||||
unsigned int mNbTrainsPass, mNbTriggers;
|
||||
unsigned int mCCModbusState, mSEIModbusState;
|
||||
CLedWidget mCCModbusONOFF, mSEIModbusONOFF;
|
||||
};
|
||||
|
||||
#endif // STATUSBAR_H
|
||||
|
||||
Reference in New Issue
Block a user