Skip to content

Commit

Permalink
Fix the typo error and added status bar to display the test mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYuancheng committed Jul 21, 2023
1 parent 15ea144 commit 35403e3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
9 changes: 5 additions & 4 deletions src/metroEmuUI/MetroEmuRun.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import railwayPanelMap as pnlMap
import dataMgr as dm

FRAME_SIZE = (1800, 1000)
FRAME_SIZE = (1800, 1030)

#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
Expand All @@ -46,9 +46,11 @@ def __init__(self, parent, id, title):

# Build UI sizer
self.SetSizer(self._buidUISizer())

self.statusbar = self.CreateStatusBar(1)
self.statusbar.SetStatusText('Test mode: %s' %str(gv.gTestMD))
# Set the periodic call back
self.updateLock = False

# Define the data manager parallel thread.
gv.iDataMgr = dm.DataManager(self)
gv.iDataMgr.start()
Expand All @@ -57,7 +59,6 @@ def __init__(self, parent, id, title):
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.periodic)
self.timer.Start(gv.PERIODIC)

self.Bind(wx.EVT_CLOSE, self.onClose)
gv.gDebugPrint("Metro-System real world main frame inited.", logType=gv.LOG_INFO)

Expand Down Expand Up @@ -197,7 +198,7 @@ def onLoadScenario(self, event):
#-----------------------------------------------------------------------------
def onHelp(self, event):
""" Pop-up the Help information window. """
wx.MessageBox(' If there is any bug, please contect: \n\n \
wx.MessageBox(' If there is any bug, please contact: \n\n \
Author: Yuancheng Liu \n \
Email: [email protected] \n \
Created: 2023/05/02 \n \
Expand Down
29 changes: 16 additions & 13 deletions src/metroEmuUI/railwayPanelMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@
#-----------------------------------------------------------------------------
# Name: railWayPanelMap.py
#
# Purpose: This module is used to display the top view of the main railway
# system current state.
# Purpose: This module is used to display the state animation of the railway
# system, such as trains movement, sensors detection state, station
# docking state and singal changes ...
#
# Author: Yuancheng Liu
#
# Version: v0.1
# Version: v0.1.2
# Created: 2023/06/01
# Copyright:
# License:
# Copyright: Copyright (c) 2023 LiuYuancheng
# License: MIT License
#-----------------------------------------------------------------------------

import os
import wx
import math

import metroEmuGobal as gv

DEF_PNL_SIZE = (1600, 900)

#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
class PanelMap(wx.Panel):
""" RailWay top view map"""
""" RailWay system map panel."""
def __init__(self, parent, panelSize=DEF_PNL_SIZE):
wx.Panel.__init__(self, parent, size=panelSize)
self.bgColor = wx.Colour(30, 40, 62)
Expand All @@ -35,18 +34,22 @@ def __init__(self, parent, panelSize=DEF_PNL_SIZE):
# Paint the map
self.Bind(wx.EVT_PAINT, self.onPaint)
# self.Bind(wx.EVT_LEFT_DOWN, self.onLeftClick)
self.SetDoubleBuffered(True) # Set the panel double buffer to void the panel flash during update.
# Set the panel double buffer to void the panel flash during update.
self.SetDoubleBuffered(True)

#-----------------------------------------------------------------------------
def _loadBitMaps(self):
""" load the internal usage bitmaps."""
""" Load the internal usage pictures as bitmaps."""
imgDict = {}
img = os.path.join(gv.IMG_FD, 'Alert.png')
png = wx.Image(img, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
imgDict['alert'] = png
imgPath = os.path.join(gv.IMG_FD, 'Alert.png')
if os.path.exists(imgPath):
png = wx.Image(imgPath, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
imgDict['alert'] = png
return imgDict

#-----------------------------------------------------------------------------
# Define all the _draw() map components paint functions.

def _drawEnvItems(self, dc):
""" Draw the environment items."""
dc.SetPen(self.dcDefPen)
Expand Down
8 changes: 6 additions & 2 deletions src/scadaEmuUI/hmiEmuRun.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import scadaDataMgr as dataMgr

PERIODIC = 500 # update in every 500ms
FRAME_SIZE = (1800, 1020)
FRAME_SIZE = (1800, 1030)

#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
Expand All @@ -42,6 +42,10 @@ def __init__(self, parent, id, title):
self._buildMenuBar()
# Build UI sizer
self.SetSizer(self._buidUISizer())

self.statusbar = self.CreateStatusBar(1)
self.statusbar.SetStatusText('Test mode: %s' %str(gv.TEST_MD))

self.updateLock = False
if not gv.TEST_MD:
gv.idataMgr = dataMgr.DataManager(self, gv.gPlcInfo)
Expand Down Expand Up @@ -214,7 +218,7 @@ def periodic(self, event):
#-----------------------------------------------------------------------------
def onHelp(self, event):
""" Pop-up the Help information window. """
wx.MessageBox(' If there is any bug, please contect: \n\n \
wx.MessageBox(' If there is any bug, please contact: \n\n \
Author: Yuancheng Liu \n \
Email: [email protected] \n \
Created: 2023/05/02 \n \
Expand Down
4 changes: 0 additions & 4 deletions src/trainCtrlUI/trainCtrlRun.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def __init__(self, parent, id, title):
if not gv.TEST_MD:
gv.idataMgr = dataMgr.DataManager(self, gv.gPlcInfo)


self.statusbar = self.CreateStatusBar(1)
self.statusbar.SetStatusText('Test mode: %s' %str(gv.TEST_MD))
# Set the periodic call back
Expand All @@ -51,16 +50,13 @@ def __init__(self, parent, id, title):
self.updateLock = False
self.Bind(wx.EVT_TIMER, self.periodic)
self.timer.Start(PERIODIC) # every 500 ms


self.trainPwrState = [True]*10
TrainTgtPlcID = 'PLC-06'
csIdx, ceIdx = (0, 10)
for idx in range(csIdx, ceIdx):
gv.idataMgr.setPlcCoilsData(TrainTgtPlcID, idx, self.trainPwrState[idx])



#--UIFrame---------------------------------------------------------------------
def _initGlobals(self):
# Init the global parameters used only by this module
Expand Down

0 comments on commit 35403e3

Please sign in to comment.