--- a/Beremiz.py Mon Oct 14 10:31:32 2013 +0200
+++ b/Beremiz.py Mon Oct 14 10:49:04 2013 +0200
@@ -141,7 +141,6 @@
from editors.EditorPanel import EditorPanel
from editors.Viewer import Viewer
from editors.TextViewer import TextViewer
-from editors.GraphicViewer import GraphicViewer
from editors.ResourceEditor import ConfigurationEditor, ResourceEditor
from editors.DataTypeEditor import DataTypeEditor
from util.MiniTextControler import MiniTextControler
@@ -617,7 +616,6 @@
if (isinstance(tab, EditorPanel) and
not isinstance(tab, (Viewer,
--- a/IDEFrame.py Mon Oct 14 10:31:32 2013 +0200
+++ b/IDEFrame.py Mon Oct 14 10:49:04 2013 +0200
@@ -6,19 +6,11 @@
from editors.EditorPanel import EditorPanel
from editors.SFCViewer import SFC_Viewer
from editors.LDViewer import LD_Viewer
from editors.TextViewer import TextViewer
from editors.Viewer import Viewer, ZOOM_FACTORS
-from editors.GraphicViewer import GraphicViewer
from editors.ResourceEditor import ConfigurationEditor, ResourceEditor
from editors.DataTypeEditor import DataTypeEditor
from PLCControler import *
@@ -27,8 +19,6 @@
from dialogs import ProjectDialog, PouDialog, PouTransitionDialog, PouActionDialog, FindInPouDialog, SearchInProjectDialog
from util.BitmapLibrary import GetBitmap
-PouInstanceVariablesPanel.USE_MPL = USE_MPL
# Define PLCOpenEditor controls id
[ID_PLCOPENEDITOR, ID_PLCOPENEDITORLEFTNOTEBOOK,
ID_PLCOPENEDITORBOTTOMNOTEBOOK, ID_PLCOPENEDITORRIGHTNOTEBOOK,
@@ -1954,11 +1944,7 @@
elif instance_category in ITEMS_VARIABLE:
if self.Controler.IsNumType(instance_type, True):
- self.AddDebugVariable(instance_path, True)
- new_window = GraphicViewer(self.TabsOpened, self, self.Controler, instance_path)
- icon = GetBitmap("GRAPH")
+ self.AddDebugVariable(instance_path, True) bodytype = self.Controler.GetEditedElementBodyType(instance_type, True)
@@ -1998,10 +1984,6 @@
def ResetGraphicViewers(self):
- for i in xrange(self.TabsOpened.GetPageCount()):
- editor = self.TabsOpened.GetPage(i)
- if isinstance(editor, GraphicViewer):
self.DebugVariablePanel.ResetGraphicsValues()
def CloseObsoleteDebugTabs(self):
@@ -2010,12 +1992,10 @@
editor = self.TabsOpened.GetPage(idx)
- if isinstance(editor, (Viewer, GraphicViewer)) and editor.IsDebugging():
+ if isinstance(editor, Viewer) and editor.IsDebugging(): instance_infos = self.Controler.GetInstanceInfos(editor.GetInstancePath(), self.EnableDebug)
if instance_infos is None:
self.TabsOpened.DeletePage(idx)
- elif isinstance(editor, GraphicViewer):
editor.SubscribeAllDataConsumers()
elif editor.IsDebugging():
@@ -2076,7 +2056,7 @@
window = self.TabsOpened.GetPage(selected)
- if isinstance(window, (Viewer, TextViewer, GraphicViewer)):
+ if isinstance(window, (Viewer, TextViewer)): if not window.IsDebugging():
menu = self.Controler.GetEditedElementBodyType(window.GetTagName())
--- a/ProjectController.py Mon Oct 14 10:31:32 2013 +0200
+++ b/ProjectController.py Mon Oct 14 10:49:04 2013 +0200
@@ -1268,8 +1268,7 @@
WeakKeyDictionary(), # Callables
[], # Data storage [(tick, data),...]
"Registered", # Variable status
- buffer_list] # Forced value
self.IECdebug_datas[IECPath] = IECdebug_data
IECdebug_data[0][callableobj]=(args, kwargs)
--- a/controls/DebugVariablePanel/DebugVariableGraphicPanel.py Mon Oct 14 10:31:32 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,958 +0,0 @@
-#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
-#based on the plcopen standard.
-#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD
-#See COPYING file for copyrights details.
-#This library is free software; you can redistribute it and/or
-#modify it under the terms of the GNU General Public
-#License as published by the Free Software Foundation; either
-#version 2.1 of the License, or (at your option) any later version.
-#This library is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-#General Public License for more details.
-#You should have received a copy of the GNU General Public
-#License along with this library; if not, write to the Free Software
-#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from types import TupleType
-import matplotlib.pyplot
-from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
-from editors.DebugViewer import DebugViewer
-from util.BitmapLibrary import GetBitmap
-from DebugVariableItem import DebugVariableItem
-from DebugVariableTextViewer import DebugVariableTextViewer
-from DebugVariableGraphicViewer import *
-MILLISECOND = 1000000 # Number of nanosecond in a millisecond
-SECOND = 1000 * MILLISECOND # Number of nanosecond in a second
-MINUTE = 60 * SECOND # Number of nanosecond in a minute
-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),...]
- [("%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
- return [(xp if xp == yp else "*")
- for xp, yp in zip(x, y)]
-def NextTick(variables):
- for item, data in variables:
- next_tick = (data[0][0]
- else min(next_tick, data[0][0]))
-#-------------------------------------------------------------------------------
-# Debug Variable Graphic Panel Drop Target
-#-------------------------------------------------------------------------------
-Class that implements a custom drop target class for Debug Variable Graphic
-class DebugVariableDropTarget(wx.TextDropTarget):
- def __init__(self, window):
- @param window: Reference to the Debug Variable Panel
- wx.TextDropTarget.__init__(self)
- self.ParentWindow = window
- # Remove reference to Debug Variable Panel
- self.ParentWindow = None
- def OnDragOver(self, x, y, d):
- Function called when mouse is dragged over Drop Target
- @param x: X coordinate of mouse pointer
- @param y: Y coordinate of mouse pointer
- @param d: Suggested default for return value
- # Signal Debug Variable Panel to refresh highlight giving mouse position
- self.ParentWindow.RefreshHighlight(x, y)
- return wx.TextDropTarget.OnDragOver(self, x, y, d)
- def OnDropText(self, x, y, data):
- Function called when mouse is released in Drop Target
- @param x: X coordinate of mouse pointer
- @param y: Y coordinate of mouse pointer
- @param data: Text associated to drag'n drop
- # Signal Debug Variable Panel to reset highlight
- self.ParentWindow.ResetHighlight()
- # Check that data is valid regarding DebugVariablePanel
- if not isinstance(values, TupleType):
- message = _("Invalid value \"%s\" for debug variable")%data
- # Display message if data is invalid
- if message is not None:
- wx.CallAfter(self.ShowMessage, message)
- # Data contain a reference to a variable to debug
- elif values[1] == "debug":
- # Drag'n Drop is an internal is an internal move inside Debug
- if len(values) > 2 and values[2] == "move":
- self.ParentWindow.MoveValue(values[0])
- # Drag'n Drop was initiated by another control of Beremiz
- self.ParentWindow.InsertValue(values[0], force=True)
- Function called when mouse is leave Drop Target
- # Signal Debug Variable Panel to reset highlight
- self.ParentWindow.ResetHighlight()
- return wx.TextDropTarget.OnLeave(self)
- def ShowMessage(self, message):
- Show error message in Error Dialog
- @param message: Error message to display
- dialog = wx.MessageDialog(self.ParentWindow,
-#-------------------------------------------------------------------------------
-# Debug Variable Graphic Panel Class
-#-------------------------------------------------------------------------------
-Class that implements a Viewer that display variable values as a graphs
-class DebugVariableGraphicPanel(wx.Panel, DebugViewer):
- def __init__(self, parent, producer, window):
- @param parent: Reference to the parent wx.Window
- @param producer: Object receiving debug value and dispatching them to
- @param window: Reference to Beremiz frame
- wx.Panel.__init__(self, parent, style=wx.SP_3D|wx.TAB_TRAVERSAL)
- # Save Reference to Beremiz frame
- self.ParentWindow = window
- # Variable storing flag indicating that variable displayed in table
- # received new value and then table need to be refreshed
- self.HasNewData = False
- # Variable storing flag indicating that refresh has been forced, and
- # that next time refresh is possible, it will be done even if no new
- self.SetBackgroundColour(wx.WHITE)
- main_sizer = wx.BoxSizer(wx.VERTICAL)
- self.Ticks = numpy.array([]) # List of tick received
- self.StartTick = 0 # Tick starting range of data displayed
- self.Fixed = False # Flag that range of data is fixed
- self.CursorTick = None # Tick of cursor for displaying values
- self.DraggingAxesPanel = None
- self.DraggingAxesBoundingBox = None
- self.DraggingAxesMousePos = None
- self.VetoScrollEvent = False
- self.VariableNameMask = []
- self.GraphicPanels = []
- graphics_button_sizer = wx.BoxSizer(wx.HORIZONTAL)
- main_sizer.AddSizer(graphics_button_sizer, border=5, flag=wx.GROW|wx.ALL)
- range_label = wx.StaticText(self, label=_('Range:'))
- graphics_button_sizer.AddWindow(range_label, flag=wx.ALIGN_CENTER_VERTICAL)
- self.CanvasRange = wx.ComboBox(self, style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnRangeChanged, self.CanvasRange)
- graphics_button_sizer.AddWindow(self.CanvasRange, 1,
- border=5, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL)
- self.CanvasRange.Clear()
- for idx, (text, value) in enumerate(RANGE_VALUES):
- self.CanvasRange.Append(text)
- default_range_idx = idx
- self.CanvasRange.SetSelection(default_range_idx)
- for name, bitmap, help in [
- ("CurrentButton", "current", _("Go to current value")),
- ("ExportGraphButton", "export_graph", _("Export graph values to clipboard"))]:
- button = wx.lib.buttons.GenBitmapButton(self,
- bitmap=GetBitmap(bitmap),
- size=wx.Size(28, 28), style=wx.NO_BORDER)
- button.SetToolTipString(help)
- setattr(self, name, button)
- self.Bind(wx.EVT_BUTTON, getattr(self, "On" + name), button)
- graphics_button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
- self.CanvasPosition = wx.ScrollBar(self,
- size=wx.Size(0, 16), style=wx.SB_HORIZONTAL)
- self.CanvasPosition.Bind(wx.EVT_SCROLL_THUMBTRACK,
- self.OnPositionChanging, self.CanvasPosition)
- self.CanvasPosition.Bind(wx.EVT_SCROLL_LINEUP,
- self.OnPositionChanging, self.CanvasPosition)
- self.CanvasPosition.Bind(wx.EVT_SCROLL_LINEDOWN,
- self.OnPositionChanging, self.CanvasPosition)
- self.CanvasPosition.Bind(wx.EVT_SCROLL_PAGEUP,
- self.OnPositionChanging, self.CanvasPosition)
- self.CanvasPosition.Bind(wx.EVT_SCROLL_PAGEDOWN,
- self.OnPositionChanging, self.CanvasPosition)
- main_sizer.AddWindow(self.CanvasPosition, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
- self.TickSizer = wx.BoxSizer(wx.HORIZONTAL)
- main_sizer.AddSizer(self.TickSizer, border=5, flag=wx.ALL|wx.GROW)
- self.TickLabel = wx.StaticText(self)
- self.TickSizer.AddWindow(self.TickLabel, border=5, flag=wx.RIGHT)
- self.MaskLabel = wx.TextCtrl(self, style=wx.TE_READONLY|wx.TE_CENTER|wx.NO_BORDER)
- self.TickSizer.AddWindow(self.MaskLabel, 1, border=5, flag=wx.RIGHT|wx.GROW)
- self.TickTimeLabel = wx.StaticText(self)
- self.TickSizer.AddWindow(self.TickTimeLabel)
- self.GraphicsWindow = wx.ScrolledWindow(self, style=wx.HSCROLL|wx.VSCROLL)
- self.GraphicsWindow.SetBackgroundColour(wx.WHITE)
- self.GraphicsWindow.SetDropTarget(DebugVariableDropTarget(self))
- self.GraphicsWindow.Bind(wx.EVT_ERASE_BACKGROUND, self.OnGraphicsWindowEraseBackground)
- self.GraphicsWindow.Bind(wx.EVT_PAINT, self.OnGraphicsWindowPaint)
- self.GraphicsWindow.Bind(wx.EVT_SIZE, self.OnGraphicsWindowResize)
- self.GraphicsWindow.Bind(wx.EVT_MOUSEWHEEL, self.OnGraphicsWindowMouseWheel)
- main_sizer.AddWindow(self.GraphicsWindow, 1, flag=wx.GROW)
- self.GraphicsSizer = wx.BoxSizer(wx.VERTICAL)
- self.GraphicsWindow.SetSizer(self.GraphicsSizer)
- DebugViewer.__init__(self, producer, True)
- self.SetSizer(main_sizer)
- def SetTickTime(self, ticktime=0):
- Set Ticktime for calculate data range according to time range selected
- @param ticktime: Ticktime to apply to range (default: 0)
- self.Ticktime = ticktime
- # Set ticktime to millisecond if undefined
- self.Ticktime = MILLISECOND
- # Calculate range to apply to data
- self.CurrentRange = RANGE_VALUES[
- self.CanvasRange.GetSelection()][1] / self.Ticktime
- def SetDataProducer(self, producer):
- @param producer: Data Producer
- DebugViewer.SetDataProducer(self, producer)
- # Set ticktime if data producer is available
- if self.DataProducer is not None:
- self.SetTickTime(self.DataProducer.GetTicktime())
- def RefreshNewData(self, *args, **kwargs):
- Called to refresh Panel according to values received by variables
- Can receive any parameters (not used here)
- # Refresh graphs if new data is available or refresh is forced
- if self.HasNewData or self.Force:
- self.HasNewData = False
- DebugViewer.RefreshNewData(self, *args, **kwargs)
- def NewDataAvailable(self, ticks, *args, **kwargs):
- Called by DataProducer for each tick captured or by panel to refresh
- @param tick: PLC tick captured
- All other parameters are passed to refresh function
- # Save tick as start tick for range if data is still empty
- if len(self.Ticks) == 0:
- self.StartTick = ticks[0]
- # Add tick to list of ticks received
- self.Ticks = numpy.append(self.Ticks, ticks)
- # Update start tick for range if range follow ticks received
- if not self.Fixed or tick < self.StartTick + self.CurrentRange:
- self.StartTick = max(self.StartTick, tick - self.CurrentRange)
- # Force refresh if graph is fixed because range of data received
- # is too small to fill data range selected
- self.Ticks[-1] - self.Ticks[0] < self.CurrentRange:
- self.HasNewData = False
- DebugViewer.NewDataAvailable(self, ticks, *args, **kwargs)
- def ForceRefresh(self):
- Called to force refresh of graphs
- wx.CallAfter(self.NewDataAvailable, None, True)
- def SetCursorTick(self, cursor_tick):
- Set Cursor for displaying values of items at a tick given
- @param cursor_tick: Tick of cursor
- self.CursorTick = cursor_tick
- self.Fixed = cursor_tick is not None
- self.UpdateCursorTick()
- def MoveCursorTick(self, move):
- if self.CursorTick is not None:
- cursor_tick = max(self.Ticks[0],
- min(self.CursorTick + move,
- cursor_tick_idx = numpy.argmin(numpy.abs(self.Ticks - cursor_tick))
- if self.Ticks[cursor_tick_idx] == self.CursorTick:
- cursor_tick_idx = max(0,
- min(cursor_tick_idx + abs(move) / move,
- self.CursorTick = self.Ticks[cursor_tick_idx]
- self.StartTick = max(self.Ticks[
- numpy.argmin(numpy.abs(self.Ticks -
- self.CursorTick + self.CurrentRange))],
- min(self.StartTick, self.CursorTick))
- self.RefreshCanvasPosition()
- self.UpdateCursorTick()
- def ResetCursorTick(self):
- self.UpdateCursorTick()
- def UpdateCursorTick(self):
- for panel in self.GraphicPanels:
- if isinstance(panel, DebugVariableGraphicViewer):
- panel.SetCursorTick(self.CursorTick)
- def StartDragNDrop(self, panel, item, x_mouse, y_mouse, x_mouse_start, y_mouse_start):
- if len(panel.GetItems()) > 1:
- self.DraggingAxesPanel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
- self.DraggingAxesPanel.SetCursorTick(self.CursorTick)
- width, height = panel.GetSize()
- self.DraggingAxesPanel.SetSize(wx.Size(width, height))
- self.DraggingAxesPanel.ResetGraphics()
- self.DraggingAxesPanel.SetPosition(wx.Point(0, -height))
- self.DraggingAxesPanel = panel
- self.DraggingAxesBoundingBox = panel.GetAxesBoundingBox(parent_coordinate=True)
- self.DraggingAxesMousePos = wx.Point(
- x_mouse_start - self.DraggingAxesBoundingBox.x,
- y_mouse_start - self.DraggingAxesBoundingBox.y)
- self.MoveDragNDrop(x_mouse, y_mouse)
- def MoveDragNDrop(self, x_mouse, y_mouse):
- self.DraggingAxesBoundingBox.x = x_mouse - self.DraggingAxesMousePos.x
- self.DraggingAxesBoundingBox.y = y_mouse - self.DraggingAxesMousePos.y
- self.RefreshHighlight(x_mouse, y_mouse)
- def RefreshHighlight(self, x_mouse, y_mouse):
- for idx, panel in enumerate(self.GraphicPanels):
- x, y = panel.GetPosition()
- width, height = panel.GetSize()
- rect = wx.Rect(x, y, width, height)
- if (rect.InsideXY(x_mouse, y_mouse) or
- idx == 0 and y_mouse < 0 or
- idx == len(self.GraphicPanels) - 1 and y_mouse > panel.GetPosition()[1]):
- panel.RefreshHighlight(x_mouse - x, y_mouse - y)
- panel.SetHighlight(HIGHLIGHT_NONE)
- if wx.Platform == "__WXMSW__":
- def ResetHighlight(self):
- for panel in self.GraphicPanels:
- panel.SetHighlight(HIGHLIGHT_NONE)
- if wx.Platform == "__WXMSW__":
- return self.DraggingAxesPanel is not None
- def GetDraggingAxesClippingRegion(self, panel):
- x, y = panel.GetPosition()
- width, height = panel.GetSize()
- bbox = wx.Rect(x, y, width, height)
- bbox = bbox.Intersect(self.DraggingAxesBoundingBox)
- def GetDraggingAxesPosition(self, panel):
- x, y = panel.GetPosition()
- return wx.Point(self.DraggingAxesBoundingBox.x - x,
- self.DraggingAxesBoundingBox.y - y)
- def StopDragNDrop(self, variable, x_mouse, y_mouse):
- if self.DraggingAxesPanel not in self.GraphicPanels:
- self.DraggingAxesPanel.Destroy()
- self.DraggingAxesPanel = None
- self.DraggingAxesBoundingBox = None
- self.DraggingAxesMousePos = None
- for idx, panel in enumerate(self.GraphicPanels):
- panel.SetHighlight(HIGHLIGHT_NONE)
- xw, yw = panel.GetPosition()
- width, height = panel.GetSize()
- bbox = wx.Rect(xw, yw, width, height)
- if bbox.InsideXY(x_mouse, y_mouse):
- panel.ShowButtons(True)
- merge_type = GRAPH_PARALLEL
- if isinstance(panel, DebugVariableTextViewer) or panel.Is3DCanvas():
- if y_mouse > yw + height / 2:
- wx.CallAfter(self.MoveValue, variable, idx, True)
- rect = panel.GetAxesBoundingBox(True)
- if rect.InsideXY(x_mouse, y_mouse):
- merge_rect = wx.Rect(rect.x, rect.y, rect.width / 2., rect.height)
- if merge_rect.InsideXY(x_mouse, y_mouse):
- merge_type = GRAPH_ORTHOGONAL
- wx.CallAfter(self.MergeGraphs, variable, idx, merge_type, force=True)
- if y_mouse > yw + height / 2:
- wx.CallAfter(self.MoveValue, variable, idx, True)
- width, height = self.GraphicsWindow.GetVirtualSize()
- rect = wx.Rect(0, 0, width, height)
- if rect.InsideXY(x_mouse, y_mouse):
- wx.CallAfter(self.MoveValue, variable, len(self.GraphicPanels), True)
- def RefreshGraphicsSizer(self):
- self.GraphicsSizer.Clear()
- for panel in self.GraphicPanels:
- self.GraphicsSizer.AddWindow(panel, flag=wx.GROW)
- self.GraphicsSizer.Layout()
- self.RefreshGraphicsWindowScrollbars()
- self.RefreshCanvasPosition()
- width, height = self.GraphicsWindow.GetVirtualSize()
- bitmap = wx.EmptyBitmap(width, height)
- dc = wx.BufferedDC(wx.ClientDC(self.GraphicsWindow), bitmap)
- if self.DraggingAxesPanel is not None:
- destBBox = self.DraggingAxesBoundingBox
- srcBBox = self.DraggingAxesPanel.GetAxesBoundingBox()
- srcBmp = _convert_agg_to_wx_bitmap(self.DraggingAxesPanel.get_renderer(), None)
- srcDC.SelectObject(srcBmp)
- dc.Blit(destBBox.x, destBBox.y,
- int(destBBox.width), int(destBBox.height),
- srcDC, srcBBox.x, srcBBox.y)
- if not self.Fixed or self.Force:
- refresh_graphics = True
- refresh_graphics = False
- if self.DraggingAxesPanel is not None and self.DraggingAxesPanel not in self.GraphicPanels:
- self.DraggingAxesPanel.RefreshViewer(refresh_graphics)
- for panel in self.GraphicPanels:
- if isinstance(panel, DebugVariableGraphicViewer):
- panel.RefreshViewer(refresh_graphics)
- if self.CursorTick is not None:
- elif len(self.Ticks) > 0:
- self.TickLabel.SetLabel("Tick: %d" % tick)
- tick_duration = int(tick * self.Ticktime)
- for value, format in [(tick_duration / DAY, "%dd"),
- ((tick_duration % DAY) / HOUR, "%dh"),
- ((tick_duration % HOUR) / MINUTE, "%dm"),
- ((tick_duration % MINUTE) / SECOND, "%ds")]:
- if value > 0 or not_null:
- duration += format % value
- duration += "%gms" % (float(tick_duration % SECOND) / MILLISECOND)
- self.TickTimeLabel.SetLabel("t: %s" % duration)
- self.TickLabel.SetLabel("")
- self.TickTimeLabel.SetLabel("")
- self.TickSizer.Layout()
- def SubscribeAllDataConsumers(self):
- DebugViewer.SubscribeAllDataConsumers(self)
- if self.DataProducer is not None:
- if self.DataProducer is not None:
- self.SetTickTime(self.DataProducer.GetTicktime())
- for panel in self.GraphicPanels[:]:
- panel.SubscribeAllDataConsumers()
- if panel.ItemsIsEmpty():
- self.GraphicPanels.remove(panel)
- self.ResetVariableNameMask()
- self.RefreshGraphicsSizer()
- self.UnsubscribeAllDataConsumers()
- for panel in self.GraphicPanels:
- self.GraphicPanels = []
- self.ResetVariableNameMask()
- self.RefreshGraphicsSizer()
- def SetCanvasPosition(self, tick):
- tick = max(self.Ticks[0], min(tick, self.Ticks[-1] - self.CurrentRange))
- self.StartTick = self.Ticks[numpy.argmin(numpy.abs(self.Ticks - tick))]
- self.RefreshCanvasPosition()
- def RefreshCanvasPosition(self):
- if len(self.Ticks) > 0:
- pos = int(self.StartTick - self.Ticks[0])
- range = int(self.Ticks[-1] - self.Ticks[0])
- self.CanvasPosition.SetScrollbar(pos, self.CurrentRange, range, self.CurrentRange)
- 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))
- if new_range_idx != current_range_idx:
- self.CanvasRange.SetSelection(new_range_idx)
- self.CurrentRange = RANGE_VALUES[new_range_idx][1] / self.Ticktime
- if len(self.Ticks) > 0:
- tick = self.StartTick + self.CurrentRange / 2.
- new_start_tick = min(tick - (tick - self.StartTick) * self.CurrentRange / current_range,
- self.Ticks[-1] - self.CurrentRange)
- self.StartTick = self.Ticks[numpy.argmin(numpy.abs(self.Ticks - new_start_tick))]
- self.Fixed = new_start_tick < self.Ticks[-1] - self.CurrentRange
- def RefreshRange(self):
- if len(self.Ticks) > 0:
- if self.Fixed and self.Ticks[-1] - self.Ticks[0] < self.CurrentRange:
- self.StartTick = min(self.StartTick, self.Ticks[-1] - self.CurrentRange)
- self.StartTick = max(self.Ticks[0], self.Ticks[-1] - self.CurrentRange)
- def OnRangeChanged(self, event):
- self.CurrentRange = RANGE_VALUES[self.CanvasRange.GetSelection()][1] / self.Ticktime
- self.CanvasRange.SetValue(str(self.CurrentRange))
- wx.CallAfter(self.RefreshRange)
- def OnCurrentButton(self, event):
- if len(self.Ticks) > 0:
- self.StartTick = max(self.Ticks[0], self.Ticks[-1] - self.CurrentRange)
- def CopyDataToClipboard(self, variables):
- text = "tick;%s;\n" % ";".join([item.GetVariable() for item, data in variables])
- next_tick = NextTick(variables)
- while next_tick is not None:
- for item, data in variables:
- if next_tick == data[0][0]:
- var_type = item.GetVariableType()
- if var_type in ["STRING", "WSTRING"]:
- value = item.GetRawValue(int(data.pop(0)[2]))
- if var_type == "STRING":
- values.append("'%s'" % value)
- values.append('"%s"' % value)
- values.append("%.3f" % data.pop(0)[1])
- text += "%d;%s;\n" % (next_tick, ";".join(values))
- next_tick = NextTick(variables)
- self.ParentWindow.SetCopyBuffer(text)
- def OnExportGraphButton(self, event):
- items = reduce(lambda x, y: x + y,
- [panel.GetItems() for panel in self.GraphicPanels],
- variables = [(item, [entry for entry in item.GetData()])
- if item.IsNumVariable()]
- wx.CallAfter(self.CopyDataToClipboard, variables)
- def OnPositionChanging(self, event):
- if len(self.Ticks) > 0:
- self.StartTick = self.Ticks[0] + event.GetPosition()
- return self.StartTick, self.StartTick + self.CurrentRange
- def GetViewerIndex(self, viewer):
- if viewer in self.GraphicPanels:
- return self.GraphicPanels.index(viewer)
- def IsViewerFirst(self, viewer):
- return viewer == self.GraphicPanels[0]
- def HighlightPreviousViewer(self, viewer):
- if self.IsViewerFirst(viewer):
- idx = self.GetViewerIndex(viewer)
- self.GraphicPanels[idx-1].SetHighlight(HIGHLIGHT_AFTER)
- def ResetVariableNameMask(self):
- for panel in self.GraphicPanels:
- items.extend(panel.GetItems())
- self.VariableNameMask = reduce(compute_mask,
- [item.GetVariable().split('.') for item in items])
- self.VariableNameMask = items[0].GetVariable().split('.')[:-1] + ['*']
- self.VariableNameMask = []
- self.MaskLabel.ChangeValue(".".join(self.VariableNameMask))
- self.MaskLabel.SetInsertionPoint(self.MaskLabel.GetLastPosition())
- def GetVariableNameMask(self):
- return self.VariableNameMask
- def InsertValue(self, iec_path, idx = None, force=False, graph=False):
- for panel in self.GraphicPanels:
- if panel.GetItem(iec_path) is not None:
- if graph and isinstance(panel, DebugVariableTextViewer):
- self.ToggleViewerType(panel)
- idx = len(self.GraphicPanels)
- item = DebugVariableItem(self, iec_path, True)
- result = self.AddDataConsumer(iec_path.upper(), item)
- if result is not None or force:
- if item.IsNumVariable() and graph:
- panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
- if self.CursorTick is not None:
- panel.SetCursorTick(self.CursorTick)
- panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
- self.GraphicPanels.insert(idx, panel)
- self.GraphicPanels.append(panel)
- self.ResetVariableNameMask()
- self.RefreshGraphicsSizer()
- def MoveValue(self, iec_path, idx = None, graph=False):
- idx = len(self.GraphicPanels)
- for panel in self.GraphicPanels:
- item = panel.GetItem(iec_path)
- if source_panel is not None:
- source_panel_idx = self.GraphicPanels.index(source_panel)
- if (len(source_panel.GetItems()) == 1):
- if source_panel_idx < idx:
- self.GraphicPanels.insert(idx, source_panel)
- self.GraphicPanels.pop(source_panel_idx)
- elif source_panel_idx > idx:
- self.GraphicPanels.pop(source_panel_idx)
- self.GraphicPanels.insert(idx, source_panel)
- source_panel.RemoveItem(item)
- source_size = source_panel.GetSize()
- if item.IsNumVariable() and graph:
- panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
- panel.SetCanvasHeight(source_size.height)
- if self.CursorTick is not None:
- panel.SetCursorTick(self.CursorTick)
- panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
- self.GraphicPanels.insert(idx, panel)
- if source_panel.ItemsIsEmpty():
- if source_panel.HasCapture():
- source_panel.ReleaseMouse()
- self.GraphicPanels.remove(source_panel)
- self.ResetVariableNameMask()
- self.RefreshGraphicsSizer()
- def MergeGraphs(self, source, target_idx, merge_type, force=False):
- for panel in self.GraphicPanels:
- source_item = panel.GetItem(source)
- if source_item is not None:
- if source_item is None:
- item = DebugVariableItem(self, source, True)
- if item.IsNumVariable():
- result = self.AddDataConsumer(source.upper(), item)
- if result is not None or force:
- if source_item is not None and source_item.IsNumVariable():
- if source_panel is not None:
- source_size = source_panel.GetSize()
- target_panel = self.GraphicPanels[target_idx]
- graph_type = target_panel.GraphType
- if target_panel != source_panel:
- if (merge_type == GRAPH_PARALLEL and graph_type != merge_type or
- merge_type == GRAPH_ORTHOGONAL and
- (graph_type == GRAPH_PARALLEL and len(target_panel.Items) > 1 or
- graph_type == GRAPH_ORTHOGONAL and len(target_panel.Items) >= 3)):
- if source_panel is not None:
- source_panel.RemoveItem(source_item)
- if source_panel.ItemsIsEmpty():
- if source_panel.HasCapture():
- source_panel.ReleaseMouse()
- self.GraphicPanels.remove(source_panel)
- elif (merge_type != graph_type and len(target_panel.Items) == 2):
- target_panel.RemoveItem(source_item)
- if target_panel is not None:
- target_panel.AddItem(source_item)
- target_panel.GraphType = merge_type
- size = target_panel.GetSize()
- if merge_type == GRAPH_ORTHOGONAL:
- target_panel.SetCanvasHeight(size.width)
- elif source_size is not None and source_panel != target_panel:
- target_panel.SetCanvasHeight(size.height + source_size.height)
- target_panel.SetCanvasHeight(size.height)
- target_panel.ResetGraphics()
- self.ResetVariableNameMask()
- self.RefreshGraphicsSizer()
- def DeleteValue(self, source_panel, item=None):
- source_idx = self.GetViewerIndex(source_panel)
- if source_idx is not None:
- source_panel.ClearItems()
- self.GraphicPanels.remove(source_panel)
- self.ResetVariableNameMask()
- self.RefreshGraphicsSizer()
- source_panel.RemoveItem(item)
- if source_panel.ItemsIsEmpty():
- self.GraphicPanels.remove(source_panel)
- self.ResetVariableNameMask()
- self.RefreshGraphicsSizer()
- if len(self.GraphicPanels) == 0:
- def ToggleViewerType(self, panel):
- panel_idx = self.GetViewerIndex(panel)
- if panel_idx is not None:
- self.GraphicPanels.remove(panel)
- items = panel.GetItems()
- if isinstance(panel, DebugVariableGraphicViewer):
- for idx, item in enumerate(items):
- new_panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
- self.GraphicPanels.insert(panel_idx + idx, new_panel)
- new_panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, items, GRAPH_PARALLEL)
- self.GraphicPanels.insert(panel_idx, new_panel)
- self.RefreshGraphicsSizer()
- def ResetGraphicsValues(self):
- self.Ticks = numpy.array([])
- for panel in self.GraphicPanels:
- def RefreshGraphicsWindowScrollbars(self):
- xstart, ystart = self.GraphicsWindow.GetViewStart()
- window_size = self.GraphicsWindow.GetClientSize()
- vwidth, vheight = self.GraphicsSizer.GetMinSize()
- posx = max(0, min(xstart, (vwidth - window_size[0]) / SCROLLBAR_UNIT))
- posy = max(0, min(ystart, (vheight - window_size[1]) / SCROLLBAR_UNIT))
- self.GraphicsWindow.Scroll(posx, posy)
- self.GraphicsWindow.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT,
- vwidth / SCROLLBAR_UNIT, vheight / SCROLLBAR_UNIT, posx, posy)
- def OnGraphicsWindowEraseBackground(self, event):
- def OnGraphicsWindowPaint(self, event):
- def OnGraphicsWindowResize(self, event):
- for panel in self.GraphicPanels:
- panel_size = panel.GetSize()
- if (isinstance(panel, DebugVariableGraphicViewer) and
- panel.GraphType == GRAPH_ORTHOGONAL and
- panel_size.width == panel_size.height):
- panel.SetCanvasHeight(size.width)
- self.RefreshGraphicsWindowScrollbars()
- self.GraphicsSizer.Layout()
- def OnGraphicsWindowMouseWheel(self, event):
- if self.VetoScrollEvent:
- self.VetoScrollEvent = False
--- a/controls/DebugVariablePanel/DebugVariableTablePanel.py Mon Oct 14 10:31:32 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,509 +0,0 @@
-#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
-#based on the plcopen standard.
-#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD
-#See COPYING file for copyrights details.
-#This library is free software; you can redistribute it and/or
-#modify it under the terms of the GNU General Public
-#License as published by the Free Software Foundation; either
-#version 2.1 of the License, or (at your option) any later version.
-#This library is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-#General Public License for more details.
-#You should have received a copy of the GNU General Public
-#License along with this library; if not, write to the Free Software
-#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from types import TupleType
-from editors.DebugViewer import DebugViewer
-from controls import CustomGrid, CustomTable
-from dialogs.ForceVariableDialog import ForceVariableDialog
-from util.BitmapLibrary import GetBitmap
-from DebugVariableItem import DebugVariableItem
-def GetDebugVariablesTableColnames():
- Function returning table column header labels
- @return: List of labels [col_label,...]
- return [_("Variable"), _("Value")]
-#-------------------------------------------------------------------------------
-# Debug Variable Table Panel
-#-------------------------------------------------------------------------------
-Class that implements a custom table storing value to display in Debug Variable
-class DebugVariableTable(CustomTable):
- def GetValue(self, row, col):
- if row < self.GetNumberRows():
- return self.GetValueByName(row, self.GetColLabelValue(col, False))
- def SetValue(self, row, col, value):
- if col < len(self.colnames):
- self.SetValueByName(row, self.GetColLabelValue(col, False), value)
- def GetValueByName(self, row, colname):
- if row < self.GetNumberRows():
- if colname == "Variable":
- return self.data[row].GetVariable()
- elif colname == "Value":
- return self.data[row].GetValue()
- def SetValueByName(self, row, colname, value):
- if row < self.GetNumberRows():
- if colname == "Variable":
- self.data[row].SetVariable(value)
- elif colname == "Value":
- self.data[row].SetValue(value)
- def IsForced(self, row):
- if row < self.GetNumberRows():
- return self.data[row].IsForced()
- def _updateColAttrs(self, grid):
- wx.grid.Grid -> update the column attributes to add the
- appropriate renderer given the column name.
- Otherwise default to the default renderer.
- for row in range(self.GetNumberRows()):
- for col in range(self.GetNumberCols()):
- colname = self.GetColLabelValue(col, False)
- grid.SetCellTextColour(row, col, wx.BLUE)
- grid.SetCellTextColour(row, col, wx.BLACK)
- grid.SetReadOnly(row, col, True)
- self.ResizeRow(grid, row)
- def RefreshValues(self, grid):
- for col in xrange(self.GetNumberCols()):
- colname = self.GetColLabelValue(col, False)
- for row in xrange(self.GetNumberRows()):
- grid.SetCellValue(row, col, str(self.data[row].GetValue()))
- grid.SetCellTextColour(row, col, wx.BLUE)
- grid.SetCellTextColour(row, col, wx.BLACK)
- def AppendItem(self, item):
- def InsertItem(self, idx, item):
- self.data.insert(idx, item)
- def RemoveItem(self, item):
- def MoveItem(self, idx, new_idx):
- self.data.insert(new_idx, self.data.pop(idx))
- def GetItem(self, idx):
-#-------------------------------------------------------------------------------
-# Debug Variable Table Panel Drop Target
-#-------------------------------------------------------------------------------
-Class that implements a custom drop target class for Debug Variable Table Panel
-class DebugVariableTableDropTarget(wx.TextDropTarget):
- def __init__(self, parent):
- @param window: Reference to the Debug Variable Panel
- wx.TextDropTarget.__init__(self)
- self.ParentWindow = parent
- # Remove reference to Debug Variable Panel
- self.ParentWindow = None
- def OnDropText(self, x, y, data):
- Function called when mouse is dragged over Drop Target
- @param x: X coordinate of mouse pointer
- @param y: Y coordinate of mouse pointer
- @param data: Text associated to drag'n drop
- # Check that data is valid regarding DebugVariablePanel
- if not isinstance(values, TupleType):
- message = _("Invalid value \"%s\" for debug variable") % data
- # Display message if data is invalid
- if message is not None:
- wx.CallAfter(self.ShowMessage, message)
- # Data contain a reference to a variable to debug
- elif values[1] == "debug":
- grid = self.ParentWindow.VariablesGrid
- # Get row where variable was dropped
- x, y = grid.CalcUnscrolledPosition(x, y)
- row = grid.YToRow(y - grid.GetColLabelSize())
- # If no row found add variable at table end
- if row == wx.NOT_FOUND:
- row = self.ParentWindow.Table.GetNumberRows()
- # Add variable to table
- self.ParentWindow.InsertValue(values[0], row, force=True)
- def ShowMessage(self, message):
- Show error message in Error Dialog
- @param message: Error message to display
- dialog = wx.MessageDialog(self.ParentWindow,
-#-------------------------------------------------------------------------------
-# Debug Variable Table Panel
-#-------------------------------------------------------------------------------
-Class that implements a panel displaying debug variable values in a table
-class DebugVariableTablePanel(wx.Panel, DebugViewer):
- def __init__(self, parent, producer, window):
- @param parent: Reference to the parent wx.Window
- @param producer: Object receiving debug value and dispatching them to
- @param window: Reference to Beremiz frame
- wx.Panel.__init__(self, parent, style=wx.SP_3D|wx.TAB_TRAVERSAL)
- # Save Reference to Beremiz frame
- self.ParentWindow = window
- # Variable storing flag indicating that variable displayed in table
- # received new value and then table need to be refreshed
- self.HasNewData = False
- DebugViewer.__init__(self, producer, True)
- # Construction of window layout by creating controls and sizers
- main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
- main_sizer.AddGrowableCol(0)
- main_sizer.AddGrowableRow(1)
- button_sizer = wx.BoxSizer(wx.HORIZONTAL)
- main_sizer.AddSizer(button_sizer, border=5,
- flag=wx.ALIGN_RIGHT|wx.ALL)
- # Creation of buttons for navigating in table
- for name, bitmap, help in [
- ("DeleteButton", "remove_element", _("Remove debug variable")),
- ("UpButton", "up", _("Move debug variable up")),
- ("DownButton", "down", _("Move debug variable down"))]:
- button = wx.lib.buttons.GenBitmapButton(self,
- bitmap=GetBitmap(bitmap),
- size=wx.Size(28, 28), style=wx.NO_BORDER)
- button.SetToolTipString(help)
- setattr(self, name, button)
- button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
- # Creation of grid and associated table
- self.VariablesGrid = CustomGrid(self,
- size=wx.Size(-1, 150), style=wx.VSCROLL)
- # Define grid drop target
- self.VariablesGrid.SetDropTarget(DebugVariableTableDropTarget(self))
- self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK,
- self.OnVariablesGridCellRightClick)
- self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK,
- self.OnVariablesGridCellLeftClick)
- main_sizer.AddWindow(self.VariablesGrid, flag=wx.GROW)
- self.Table = DebugVariableTable(self, [],
- GetDebugVariablesTableColnames())
- self.VariablesGrid.SetTable(self.Table)
- self.VariablesGrid.SetButtons({"Delete": self.DeleteButton,
- "Down": self.DownButton})
- # Definition of function associated to navigation buttons
- def _AddVariable(new_row):
- return self.VariablesGrid.GetGridCursorRow()
- setattr(self.VariablesGrid, "_AddRow", _AddVariable)
- def _DeleteVariable(row):
- item = self.Table.GetItem(row)
- self.RemoveDataConsumer(item)
- self.Table.RemoveItem(item)
- setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable)
- def _MoveVariable(row, move):
- new_row = max(0, min(row + move, self.Table.GetNumberRows() - 1))
- self.Table.MoveItem(row, new_row)
- setattr(self.VariablesGrid, "_MoveRow", _MoveVariable)
- # Initialization of grid layout
- self.VariablesGrid.SetRowLabelSize(0)
- self.GridColSizes = [200, 100]
- for col in range(self.Table.GetNumberCols()):
- attr = wx.grid.GridCellAttr()
- attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
- self.VariablesGrid.SetColAttr(col, attr)
- self.VariablesGrid.SetColSize(col, self.GridColSizes[col])
- self.Table.ResetView(self.VariablesGrid)
- self.VariablesGrid.RefreshButtons()
- self.SetSizer(main_sizer)
- def RefreshNewData(self, *args, **kwargs):
- Called to refresh Table according to values received by variables
- Can receive any parameters (not used here)
- # Refresh 'Value' column of table if new data have been received since
- self.HasNewData = False
- self.RefreshView(only_values=True)
- DebugViewer.RefreshNewData(self, *args, **kwargs)
- def RefreshView(self, only_values=False):
- Function refreshing table layout and values
- @param only_values: True if only 'Value' column need to be updated
- # Block refresh until table layout and values are completely updated
- # Update only 'value' column from table
- self.Table.RefreshValues(self.VariablesGrid)
- # Update complete table layout refreshing table navigation buttons
- self.Table.ResetView(self.VariablesGrid)
- self.VariablesGrid.RefreshButtons()
- Function removing all variables denugged from table
- @param only_values: True if only 'Value' column need to be updated
- # Unsubscribe all variables debugged
- self.UnsubscribeAllDataConsumers()
- self.Table.ResetView(self.VariablesGrid)
- self.VariablesGrid.RefreshButtons()
- def SubscribeAllDataConsumers(self):
- Function refreshing table layout and values
- @param only_values: True if only 'Value' column need to be updated
- DebugViewer.SubscribeAllDataConsumers(self)
- # Navigate through variable displayed in table, removing those that
- # doesn't exist anymore in PLC
- for item in self.Table.GetData()[:]:
- iec_path = item.GetVariable()
- if self.GetDataType(iec_path) is None:
- self.RemoveDataConsumer(item)
- self.Table.RemoveItem(idx)
- self.AddDataConsumer(iec_path.upper(), item)
- item.RefreshVariableType()
- self.Table.ResetView(self.VariablesGrid)
- self.VariablesGrid.RefreshButtons()
- def GetForceVariableMenuFunction(self, item):
- Function returning callback function for contextual menu 'Force' item
- @param item: Debug Variable item where contextual menu was opened
- @return: Callback function
- def ForceVariableFunction(event):
- # Get variable path and data type
- iec_path = item.GetVariable()
- iec_type = self.GetDataType(iec_path)
- # Return immediately if not data type found
- # Open dialog for entering value to force variable
- dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
- # If valid value entered, force variable
- if dialog.ShowModal() == wx.ID_OK:
- self.ForceDataValue(iec_path.upper(), dialog.GetValue())
- return ForceVariableFunction
- def GetReleaseVariableMenuFunction(self, iec_path):
- Function returning callback function for contextual menu 'Release' item
- @param iec_path: Debug Variable path where contextual menu was opened
- @return: Callback function
- def ReleaseVariableFunction(event):
- self.ReleaseDataValue(iec_path)
- return ReleaseVariableFunction
- def OnVariablesGridCellLeftClick(self, event):
- Called when left mouse button is pressed on a table cell
- @param event: wx.grid.GridEvent
- # Initiate a drag and drop if the cell clicked was in 'Variable' column
- if self.Table.GetColLabelValue(event.GetCol(), False) == "Variable":
- item = self.Table.GetItem(event.GetRow())
- data = wx.TextDataObject(str((item.GetVariable(), "debug")))
- dragSource = wx.DropSource(self.VariablesGrid)
- dragSource.SetData(data)
- dragSource.DoDragDrop()
- def OnVariablesGridCellRightClick(self, event):
- Called when right mouse button is pressed on a table cell
- @param event: wx.grid.GridEvent
- # Open a contextual menu if the cell clicked was in 'Value' column
- if self.Table.GetColLabelValue(event.GetCol(), False) == "Value":
- item = self.Table.GetItem(row)
- iec_path = item.GetVariable().upper()
- # Create contextual menu
- menu = wx.Menu(title='')
- for text, enable, callback in [
- (_("Force value"), True,
- self.GetForceVariableMenuFunction(item)),
- # Release menu item is enabled only if variable is forced
- (_("Release value"), self.Table.IsForced(row),
- self.GetReleaseVariableMenuFunction(iec_path))]:
- menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
- menu.Enable(new_id, enable)
- self.Bind(wx.EVT_MENU, callback, id=new_id)
- # Popup contextual menu
- def InsertValue(self, iec_path, index=None, force=False, graph=False):
- Insert a new variable to debug in table
- @param iec_path: Variable path to debug
- @param index: Row where insert the variable in table (default None,
- insert at last position)
- @param force: Force insertion of variable even if not defined in
- @param graph: Values must be displayed in graph canvas (Do nothing,
- here for compatibility with Debug Variable Graphic Panel)
- # Return immediately if variable is already debugged
- for item in self.Table.GetData():
- if iec_path == item.GetVariable():
- # Insert at last position if index not defined
- index = self.Table.GetNumberRows()
- # Subscribe variable to producer
- item = DebugVariableItem(self, iec_path)
- result = self.AddDataConsumer(iec_path.upper(), item)
- # Insert variable in table if subscription done or insertion forced
- if result is not None or force:
- self.Table.InsertItem(index, item)
- def ResetGraphicsValues(self):
- Called to reset graphics values when PLC is started
- (Nothing to do because no graphic values here. Defined for
- compatibility with Debug Variable Graphic Panel)
\ No newline at end of file
--- a/controls/DebugVariablePanel/__init__.py Mon Oct 14 10:31:32 2013 +0200
+++ b/controls/DebugVariablePanel/__init__.py Mon Oct 14 10:49:04 2013 +0200
@@ -1,4 +1,1 @@
- from DebugVariableGraphicPanel import DebugVariableGraphicPanel as DebugVariablePanel
- from DebugVariableTablePanel import DebugVariableTablePanel as DebugVariablePanel
\ No newline at end of file
+from DebugVariablePanel import DebugVariablePanel \ No newline at end of file
--- a/controls/PouInstanceVariablesPanel.py Mon Oct 14 10:31:32 2013 +0200
+++ b/controls/PouInstanceVariablesPanel.py Mon Oct 14 10:49:04 2013 +0200
@@ -114,8 +114,6 @@
class PouInstanceVariablesPanel(wx.Panel):
def __init__(self, parent, window, controller, debug):
wx.Panel.__init__(self, name='PouInstanceTreePanel',
parent=parent, pos=wx.Point(0, 0),
@@ -154,14 +152,11 @@
self.VariablesList.Bind(wx.EVT_KEY_DOWN, self.OnVariablesListKeyDown)
self.TreeRightImageList = wx.ImageList(24, 24)
- self.InstanceGraphImage = self.TreeRightImageList.Add(GetBitmap("instance_graph"))
self.EditImage = self.TreeRightImageList.Add(GetBitmap("edit"))
self.DebugInstanceImage = self.TreeRightImageList.Add(GetBitmap("debug_instance"))
self.VariablesList.SetRightImageList(self.TreeRightImageList)
- self.InstanceGraphImage: _ButtonCallbacks(
- self.GraphButtonCallback, None),
self.EditImage: _ButtonCallbacks(
self.EditButtonCallback, None),
self.DebugInstanceImage: _ButtonCallbacks(
@@ -246,12 +241,7 @@
- if var_infos.var_class in ITEMS_VARIABLE:
- if (not self.USE_MPL and var_infos.debug and self.Debug and
- (self.Controller.IsOfType(var_infos.type, "ANY_NUM", True) or
- self.Controller.IsOfType(var_infos.type, "ANY_BIT", True))):
- right_images.append(self.InstanceGraphImage)
right_images.append(self.EditImage)
if var_infos.debug and self.Debug:
@@ -356,13 +346,6 @@
- def GraphButtonCallback(self, infos):
- if self.InstanceChoice.GetSelection() != -1:
- if infos.var_class in ITEMS_VARIABLE:
- var_path = "%s.%s" % (self.InstanceChoice.GetStringSelection(),
- self.ParentWindow.OpenDebugViewer(infos.var_class, var_path, infos.type)
def ShowInstanceChoicePopup(self):
self.InstanceChoice.SetFocusFromKbd()
size = self.InstanceChoice.GetSize()