--- a/IDEFrame.py Tue Aug 28 18:06:30 2018 +0300
+++ b/IDEFrame.py Wed Aug 29 18:53:02 2018 +0300
@@ -93,106 +93,6 @@
] = [wx.NewId() for _init_coll_DefaultEditorToolBar_Items in range(18)]
-# Define behaviour of each Toolbar item according to current POU body type
-# Informations meaning are in this order:
-# - Item is toggled
-# - PLCOpenEditor mode where item is displayed (could be more then one)
-# - Item id
-# - Item callback function name
-# - Item icon filename
-# - Item tooltip text
-EditorToolBarItems = {
- "FBD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
- "move", _("Move the view")),
- (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment", _("Create a new comment")),
- (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable", _("Create a new variable")),
- (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block", _("Create a new block")),
- (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection", _("Create a new connection"))],
- "LD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
- "move", _("Move the view")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment", _("Create a new comment")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
- "add_powerrail", _("Create a new power rail")),
- (False, DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool",
- "add_rung", _("Create a new rung")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool",
- "add_coil", _("Create a new coil")),
- (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool",
- "add_contact", _("Create a new contact")),
- (False, DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool",
- "add_branch", _("Create a new branch")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable", _("Create a new variable")),
- (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block", _("Create a new block")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection", _("Create a new connection"))],
- "SFC": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
- "move", _("Move the view")),
- (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment", _("Create a new comment")),
- (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool",
- "add_initial_step", _("Create a new initial step")),
- (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool",
- "add_step", _("Create a new step")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool",
- "add_transition", _("Create a new transition")),
- (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool",
- "add_action", _("Create a new action block")),
- (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool",
- "add_divergence", _("Create a new divergence")),
- (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool",
- "add_jump", _("Create a new jump")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable", _("Create a new variable")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block", _("Create a new block")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection", _("Create a new connection")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
- "add_powerrail", _("Create a new power rail")),
- (True, FREEDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool",
- "add_contact", _("Create a new contact"))],
- "ST": [],
- "IL": [],
- "debug": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
- ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
- "move", _("Move the view"))],
-}
-
# -------------------------------------------------------------------------------
# Helper Functions
# -------------------------------------------------------------------------------
@@ -331,12 +231,114 @@
return tabs
-UNEDITABLE_NAMES_DICT = dict([(_(n), n) for n in UNEDITABLE_NAMES])
-
-
class IDEFrame(wx.Frame):
"""IDEFrame Base Class"""
+ def InitEditorToolbarItems(self):
+ """
+ Initialize dictionary with lists of elements that need to be shown
+ if POU in particular programming language is edited.
+ """
+ # Define behaviour of each Toolbar item according to current POU body type
+ # Informations meaning are in this order:
+ # - Item is toggled
+ # - PLCOpenEditor mode where item is displayed (could be more then one)
+ # - Item id
+ # - Item callback function name
+ # - Item icon filename
+ # - Item tooltip text
+ self.EditorToolBarItems = {
+ "FBD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
+ "move", _("Move the view")),
+ (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
+ "add_comment", _("Create a new comment")),
+ (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
+ "add_variable", _("Create a new variable")),
+ (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
+ "add_block", _("Create a new block")),
+ (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
+ "add_connection", _("Create a new connection"))],
+ "LD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
+ "move", _("Move the view")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
+ "add_comment", _("Create a new comment")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
+ "add_powerrail", _("Create a new power rail")),
+ (False, DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool",
+ "add_rung", _("Create a new rung")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool",
+ "add_coil", _("Create a new coil")),
+ (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool",
+ "add_contact", _("Create a new contact")),
+ (False, DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool",
+ "add_branch", _("Create a new branch")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
+ "add_variable", _("Create a new variable")),
+ (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
+ "add_block", _("Create a new block")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
+ "add_connection", _("Create a new connection"))],
+ "SFC": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
+ "move", _("Move the view")),
+ (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
+ "add_comment", _("Create a new comment")),
+ (True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool",
+ "add_initial_step", _("Create a new initial step")),
+ (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool",
+ "add_step", _("Create a new step")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool",
+ "add_transition", _("Create a new transition")),
+ (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool",
+ "add_action", _("Create a new action block")),
+ (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool",
+ "add_divergence", _("Create a new divergence")),
+ (False, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool",
+ "add_jump", _("Create a new jump")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
+ "add_variable", _("Create a new variable")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
+ "add_block", _("Create a new block")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
+ "add_connection", _("Create a new connection")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
+ "add_powerrail", _("Create a new power rail")),
+ (True, FREEDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool",
+ "add_contact", _("Create a new contact"))],
+ "ST": [],
+ "IL": [],
+ "debug": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
+ "move", _("Move the view"))],
+ }
+
def _init_coll_MenuBar_Menus(self, parent):
parent.Append(menu=self.FileMenu, title=_(u'&File'))
parent.Append(menu=self.EditMenu, title=_(u'&Edit'))
@@ -672,10 +674,13 @@
size=wx.Size(1000, 600),
style=wx.DEFAULT_FRAME_STYLE)
+ self.UNEDITABLE_NAMES_DICT = dict([(_(n), n) for n in UNEDITABLE_NAMES])
+
self.Controler = None
self.Config = wx.ConfigBase.Get()
self.EnableDebug = enable_debug
+ self.InitEditorToolbarItems()
self._init_ctrls(parent)
# Define Tree item icon list
@@ -1891,7 +1896,7 @@
if item_infos["type"] == ITEM_PROJECT:
name = "Project"
else:
- name = UNEDITABLE_NAMES_DICT[name]
+ name = self.UNEDITABLE_NAMES_DICT[name]
if name == "Data Types":
menu = wx.Menu(title='')
@@ -2155,7 +2160,7 @@
self.CurrentEditorToolBar = []
EditorToolBar = self.Panes["EditorToolBar"]
if EditorToolBar:
- for radio, modes, id, method, picture, help in EditorToolBarItems[menu]:
+ for radio, modes, id, method, picture, help in self.EditorToolBarItems[menu]:
if modes & self.DrawingMode:
if radio or self.DrawingMode == FREEDRAWING_MODE:
EditorToolBar.AddRadioTool(id, GetBitmap(picture), wx.NullBitmap, help)
@@ -2420,7 +2425,7 @@
if self.ProjectTree.GetPyData(selected)["type"] != ITEM_PROJECT:
pou_type = self.ProjectTree.GetItemText(selected)
- pou_type = UNEDITABLE_NAMES_DICT[pou_type] # one of 'Functions', 'Function Blocks' or 'Programs'
+ pou_type = self.UNEDITABLE_NAMES_DICT[pou_type] # one of 'Functions', 'Function Blocks' or 'Programs'
pou_type = {'Functions': 'function', 'Function Blocks': 'functionBlock', 'Programs': 'program'}[pou_type]
else:
pou_type = None
--- a/controls/DebugVariablePanel/DebugVariablePanel.py Tue Aug 28 18:06:30 2018 +0300
+++ b/controls/DebugVariablePanel/DebugVariablePanel.py Wed Aug 29 18:53:02 2018 +0300
@@ -50,14 +50,6 @@
HOUR = 60 * MINUTE # Number of nanosecond in a hour
DAY = 24 * HOUR # Number of nanosecond in a day
-# List of values possible for graph range
-# Format is [(time_in_plain_text, value_in_nanosecond),...]
-RANGE_VALUES = \
- [(_("%dms") % i, i * MILLISECOND) for i in (10, 20, 50, 100, 200, 500)] + \
- [(_("%ds") % i, i * SECOND) for i in (1, 2, 5, 10, 20, 30)] + \
- [(_("%dm") % i, i * MINUTE) for i in (1, 2, 5, 10, 20, 30)] + \
- [(_("%dh") % i, i * HOUR) for i in (1, 2, 3, 6, 12, 24)]
-
# Scrollbar increment in pixel
SCROLLBAR_UNIT = 10
@@ -189,6 +181,13 @@
"""
wx.Panel.__init__(self, parent, style=wx.SP_3D | wx.TAB_TRAVERSAL)
+ # List of values possible for graph range
+ # Format is [(time_in_plain_text, value_in_nanosecond),...]
+ self.RANGE_VALUES = [(_("%dms") % i, i * MILLISECOND) for i in (10, 20, 50, 100, 200, 500)] + \
+ [(_("%ds") % i, i * SECOND) for i in (1, 2, 5, 10, 20, 30)] + \
+ [(_("%dm") % i, i * MINUTE) for i in (1, 2, 5, 10, 20, 30)] + \
+ [(_("%dh") % i, i * HOUR) for i in (1, 2, 3, 6, 12, 24)]
+
# Save Reference to Beremiz frame
self.ParentWindow = window
@@ -233,7 +232,7 @@
self.CanvasRange.Clear()
default_range_idx = 0
- for idx, (text, _value) in enumerate(RANGE_VALUES):
+ for idx, (text, _value) in enumerate(self.RANGE_VALUES):
self.CanvasRange.Append(text)
if _value == 1000000000:
default_range_idx = idx
@@ -307,7 +306,7 @@
self.Ticktime = MILLISECOND
# Calculate range to apply to data
- self.CurrentRange = RANGE_VALUES[
+ self.CurrentRange = self.RANGE_VALUES[
self.CanvasRange.GetSelection()][1] / self.Ticktime
def SetDataProducer(self, producer):
@@ -614,10 +613,10 @@
def ChangeRange(self, dir, tick=None):
current_range = self.CurrentRange
current_range_idx = self.CanvasRange.GetSelection()
- new_range_idx = max(0, min(current_range_idx + dir, len(RANGE_VALUES) - 1))
+ new_range_idx = max(0, min(current_range_idx + dir, len(self.RANGE_VALUES) - 1))
if new_range_idx != current_range_idx:
self.CanvasRange.SetSelection(new_range_idx)
- self.CurrentRange = RANGE_VALUES[new_range_idx][1] / self.Ticktime
+ self.CurrentRange = self.RANGE_VALUES[new_range_idx][1] / self.Ticktime
if len(self.Ticks) > 0:
if tick is None:
tick = self.StartTick + self.CurrentRange / 2.
@@ -639,7 +638,7 @@
def OnRangeChanged(self, event):
try:
- self.CurrentRange = RANGE_VALUES[self.CanvasRange.GetSelection()][1] / self.Ticktime
+ self.CurrentRange = self.RANGE_VALUES[self.CanvasRange.GetSelection()][1] / self.Ticktime
except ValueError:
self.CanvasRange.SetValue(str(self.CurrentRange))
wx.CallAfter(self.RefreshRange)