diff --git a/Configuration/ZTSettings.ztc b/Configuration/ZTSettings.ztc index 1383fd4..10ab104 100644 Binary files a/Configuration/ZTSettings.ztc and b/Configuration/ZTSettings.ztc differ diff --git a/sources/Event.cpp b/sources/Event.cpp index beb2bd2..e87e6ce 100644 --- a/sources/Event.cpp +++ b/sources/Event.cpp @@ -28,9 +28,10 @@ #include "Event.h" -CEvent::CEvent(unsigned int EventType, QString EventLabel, bool IsItemAnimated) +CEvent::CEvent(unsigned int EventType, QString EventLabel, bool IsItemAnimated, int Color) { mEventType = EventType; mEventLabel = EventLabel; mItemAnimated = IsItemAnimated; + mEventColor = Color; } diff --git a/sources/Event.h b/sources/Event.h index d6680c5..fc4e1c0 100644 --- a/sources/Event.h +++ b/sources/Event.h @@ -35,11 +35,12 @@ class CEvent { public: - CEvent(unsigned int EventType, QString EventLabel,bool IsItemAnimated); + CEvent(unsigned int EventType, QString EventLabel,bool IsItemAnimated, int Color); unsigned int mEventType; QString mEventLabel; bool mItemAnimated; + int mEventColor; }; #endif // EVENT_H diff --git a/sources/EventMgr.cpp b/sources/EventMgr.cpp index 8f18730..a199af3 100644 --- a/sources/EventMgr.cpp +++ b/sources/EventMgr.cpp @@ -81,6 +81,7 @@ bool CEventMgr::AddEvent(unsigned int EventID) QString Label; bool IsAnimated = false; + int Color = CEventItem::EVENT_ITEM_COLOR_RED; switch(EventID) { case EVENT_FN_HS: @@ -129,9 +130,23 @@ bool CEventMgr::AddEvent(unsigned int EventID) IsAnimated = true; break; } + case EVENT_ZT1_INHIBITION: + { + Label = "Passage ZT1 inhibé"; + IsAnimated = true; + Color = CEventItem::EVENT_ITEM_COLOR_GREEN; + break; + } + case EVENT_ZT2_INHIBITION: + { + Label = "Passage ZT2 inhibé"; + IsAnimated = true; + Color = CEventItem::EVENT_ITEM_COLOR_GREEN; + break; + } } - CEvent *NewEvent = new CEvent(EventID,Label,IsAnimated); + CEvent *NewEvent = new CEvent(EventID,Label,IsAnimated,Color); mEventsList.append(NewEvent); return true; diff --git a/sources/EventMgr.h b/sources/EventMgr.h index ed1ff4d..d3e6ed6 100644 --- a/sources/EventMgr.h +++ b/sources/EventMgr.h @@ -45,6 +45,8 @@ enum eEventTypeID EVENT_CA_PG, EVENT_PEQ1, EVENT_MAINTENANCE, + EVENT_ZT1_INHIBITION, + EVENT_ZT2_INHIBITION, EVENT_MAX_EVENT_ID }; diff --git a/sources/GuiElements/EventItem.cpp b/sources/GuiElements/EventItem.cpp index c083b50..f33c8d6 100644 --- a/sources/GuiElements/EventItem.cpp +++ b/sources/GuiElements/EventItem.cpp @@ -34,13 +34,17 @@ #include "CDV.h" #include -CEventItem::CEventItem(QString Label,bool Animated,QGraphicsItem *Parent) +CEventItem::CEventItem(QString Label, bool Animated, QGraphicsItem *Parent, int Color) { setParentItem(Parent); -// mCDVFreeBrush = new QBrush(Qt::gray); -// mCDVITICommandedBrush = new QBrush(Qt::darkGreen); -// mCDVOccupiedBrush = new QBrush(Qt::yellow); + + if(Color != EVENT_ITEM_COLOR_RED && Color != EVENT_ITEM_COLOR_GREEN) + { + Color = EVENT_ITEM_COLOR_RED; + } + + mColor = Color; setGeometry(0,0,40,25); mCurBrush = new QBrush(Qt::lightGray); @@ -75,7 +79,16 @@ void CEventItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option QRectF EventRect = rect(); if(mAnimated) - mCurBrush->setColor(QColor(255,mAlpha,mAlpha,255)); + { + if(mColor == EVENT_ITEM_COLOR_RED) + { + mCurBrush->setColor(QColor(255,mAlpha,mAlpha,255)); + } + else + { + mCurBrush->setColor(QColor(mAlpha,255,mAlpha,255)); + } + } painter->setBrush(*mCurBrush); painter->setPen(Qt::black); diff --git a/sources/GuiElements/EventItem.h b/sources/GuiElements/EventItem.h index 0508d42..944106b 100644 --- a/sources/GuiElements/EventItem.h +++ b/sources/GuiElements/EventItem.h @@ -39,7 +39,14 @@ class CEventItem : public QGraphicsWidget Q_OBJECT public: - CEventItem(QString Label,bool Animated,QGraphicsItem *Parent = 0); + enum eEventColor + { + EVENT_ITEM_COLOR_RED, + EVENT_ITEM_COLOR_GREEN + }; + + + CEventItem(QString Label,bool Animated,QGraphicsItem *Parent = 0, int Color = EVENT_ITEM_COLOR_RED); ~CEventItem(); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -59,6 +66,7 @@ private: bool mAnimated; QTimeLine *mAnimationTimeline; unsigned int mAlpha; + int mColor; signals: void EventItemRightClicked(CEventItem*); diff --git a/sources/GuiElements/EventsBar.cpp b/sources/GuiElements/EventsBar.cpp index 10a22be..1c111cc 100644 --- a/sources/GuiElements/EventsBar.cpp +++ b/sources/GuiElements/EventsBar.cpp @@ -72,7 +72,7 @@ void CEventsBar::UpdateEventsList() for(int i = 0; i < mEventsList->size(); i++) { - CEventItem *NewItem = new CEventItem(mEventsList->at(i)->mEventLabel,mEventsList->at(i)->mItemAnimated,this); + CEventItem *NewItem = new CEventItem(mEventsList->at(i)->mEventLabel,mEventsList->at(i)->mItemAnimated,this,mEventsList->at(i)->mEventColor); mEventsItemList.append(NewItem); } UpdateDisplay(); diff --git a/sources/ZTStateMachine.cpp b/sources/ZTStateMachine.cpp index 5703513..63746d4 100644 --- a/sources/ZTStateMachine.cpp +++ b/sources/ZTStateMachine.cpp @@ -36,13 +36,16 @@ #include "math.h" #include "MaintenancePage.h" #include "RamMonitor.h" +#include "Zonetest.h" //#include "ModbusCCDefs.h" -CZTStateMachine::CZTStateMachine(QObject *parent) : +CZTStateMachine::CZTStateMachine(CZoneTest *ZTPtr, QObject *parent) : QObject(parent) { QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + mProgramPtr = ZTPtr; + mZT1State = ZT1_WAIT_FOR_CI_STATE; mZT2State = ZT2_WAIT_FOR_CI_STATE; mZTState = ZT_INIT_STATE; @@ -320,10 +323,12 @@ unsigned int CZTStateMachine::ZT1StateMachine(unsigned int Event, unsigned int S if(mCIZT1Active == false) { mZT1State = ZT1_WAIT_FOR_CI_STATE; + mProgramPtr->SetZT1InhibitionState(false); } if(!mZTStationPtr->IsZT1CDVOccupied() && !mZTStationPtr->IsZT1SubsequentCDVOccupied()) { mZT1State = ZT1_WAIT_FOR_TRAIN_STATE; + mProgramPtr->SetZT1InhibitionState(false); } break; @@ -355,8 +360,10 @@ unsigned int CZTStateMachine::ZT1StateMachine(unsigned int Event, unsigned int S mZT1TrainComposition = mModbusCCMgr->GetZT1TrainComposition(); mZTPagePTr->SetZT1TrainData(mTrainTypeDetected,mZT1TrainComposition); } + + mProgramPtr->SetZT1InhibitionState(true); } - } + } if(abort == false) { @@ -1131,6 +1138,8 @@ unsigned int CZTStateMachine::ZT2StateMachine(unsigned int Event, unsigned int S mZT2TrainType = (unsigned)mModbusCCMgr->GetZT2TrainType(); mZT2TrainComposition = mModbusCCMgr->GetZT2TrainComposition(); mZTPagePTr->SetZT2TrainData(mZT2TrainType,mZT2TrainComposition); + + mProgramPtr->SetZT2InhibitionState(true); } } @@ -1203,6 +1212,7 @@ unsigned int CZTStateMachine::ZT2StateMachine(unsigned int Event, unsigned int S { CZTLog::instance()->AddLogString("CDV ZT2 Libéré. ZT2 prête",true); mZT2State = ZT2_WAIT_FOR_CI_STATE; + mProgramPtr->SetZT2InhibitionState(false); } break; } diff --git a/sources/ZTStateMachine.h b/sources/ZTStateMachine.h index c69d061..e250d52 100644 --- a/sources/ZTStateMachine.h +++ b/sources/ZTStateMachine.h @@ -96,13 +96,13 @@ enum ePostDetectionRet RET_POST_DETECTION_MAX_RET }; - +class CZoneTest; class CZTStateMachine : public QObject { Q_OBJECT public: - explicit CZTStateMachine(QObject *parent = 0); + explicit CZTStateMachine(CZoneTest *ZTPtr,QObject *parent = 0); ~CZTStateMachine(); unsigned int ZTStateMachine(unsigned int Event, unsigned int SubEvent = 0); //Exécution de la SM principale void BindPointers(CStation *ptr,CInputModule *InputModule,COutputModule *OutputModule,CZTPage *ZTPagePTr,CPCIIOMgr *PCIIOPtr,CAbstractLazerProbe *PGIntProbePtr, CAbstractLazerProbe *PGExtProbePTr,CLogMgr *LogMgr,CTKTransportInterface *TKTransport,CZTSimulator *ZTSimPtr = 0,CAnalogInputModule *DataQInterface = 0); //Assignation de pointeurs @@ -171,6 +171,7 @@ private: int mAnalogReading; + CZoneTest *mProgramPtr; CStation *mZTStationPtr; CAnalogInputModule *mSDFAnalogMonitorInterface; CInputModule *mInputModule; diff --git a/sources/Zonetest.cpp b/sources/Zonetest.cpp index c18153c..0fb91e6 100644 --- a/sources/Zonetest.cpp +++ b/sources/Zonetest.cpp @@ -76,7 +76,7 @@ CZoneTest::CZoneTest(): connect(mZTStateMachineTimer, SIGNAL(timeout()), this, SLOT(SMTimerExpired())); panel.installEventFilter(this); //Install an event filter for CZoneTest to manage some events from GUI - mZTStateMachine = new CZTStateMachine(); + mZTStateMachine = new CZTStateMachine(this); mZTSimulator = 0; mIOManager = 0; mLazerProbesManager = 0; @@ -1222,6 +1222,32 @@ unsigned int CZoneTest::SetZTFunctionsConfig(const CTCPZTFunctionsStatus &Functi return RET_OK; } +int CZoneTest::SetZT1InhibitionState(bool InhibitionON) +{ + if(InhibitionON) + { + mEventMgr->AddSingleEvent(EVENT_ZT1_INHIBITION); + } + else + { + mEventMgr->RemoveSingleEvent(EVENT_ZT1_INHIBITION); + } + return RET_OK; +} + +int CZoneTest::SetZT2InhibitionState(bool InhibitionON) +{ + if(InhibitionON) + { + mEventMgr->AddSingleEvent(EVENT_ZT2_INHIBITION); + } + else + { + mEventMgr->RemoveSingleEvent(EVENT_ZT2_INHIBITION); + } + return RET_OK; +} + void CZoneTest::ApplicationQuit(bool PowerButton) { diff --git a/sources/Zonetest.h b/sources/Zonetest.h index 5f5b072..c0d42bb 100644 --- a/sources/Zonetest.h +++ b/sources/Zonetest.h @@ -143,7 +143,9 @@ public: unsigned int DeleteZTLogRequest(); unsigned int SetZTFunctionsConfig(const CTCPZTFunctionsStatus &FunctionsConfig); - + //ZTStateMachine requests + int SetZT1InhibitionState(bool InhibitionON); + int SetZT2InhibitionState(bool InhibitionON);