112 from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU, ITEM_TRANSITION, ITEM_ACTION |
112 from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU, ITEM_TRANSITION, ITEM_ACTION |
113 from util.BitmapLibrary import GetBitmap |
113 from util.BitmapLibrary import GetBitmap |
114 |
114 |
115 class PouInstanceVariablesPanel(wx.Panel): |
115 class PouInstanceVariablesPanel(wx.Panel): |
116 |
116 |
117 USE_MPL = False |
|
118 |
|
119 def __init__(self, parent, window, controller, debug): |
117 def __init__(self, parent, window, controller, debug): |
120 wx.Panel.__init__(self, name='PouInstanceTreePanel', |
118 wx.Panel.__init__(self, name='PouInstanceTreePanel', |
121 parent=parent, pos=wx.Point(0, 0), |
119 parent=parent, pos=wx.Point(0, 0), |
122 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
120 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
123 |
121 |
152 self.OnVariablesListItemActivated) |
150 self.OnVariablesListItemActivated) |
153 self.VariablesList.Bind(wx.EVT_LEFT_DOWN, self.OnVariablesListLeftDown) |
151 self.VariablesList.Bind(wx.EVT_LEFT_DOWN, self.OnVariablesListLeftDown) |
154 self.VariablesList.Bind(wx.EVT_KEY_DOWN, self.OnVariablesListKeyDown) |
152 self.VariablesList.Bind(wx.EVT_KEY_DOWN, self.OnVariablesListKeyDown) |
155 |
153 |
156 self.TreeRightImageList = wx.ImageList(24, 24) |
154 self.TreeRightImageList = wx.ImageList(24, 24) |
157 self.InstanceGraphImage = self.TreeRightImageList.Add(GetBitmap("instance_graph")) |
|
158 self.EditImage = self.TreeRightImageList.Add(GetBitmap("edit")) |
155 self.EditImage = self.TreeRightImageList.Add(GetBitmap("edit")) |
159 self.DebugInstanceImage = self.TreeRightImageList.Add(GetBitmap("debug_instance")) |
156 self.DebugInstanceImage = self.TreeRightImageList.Add(GetBitmap("debug_instance")) |
160 self.VariablesList.SetRightImageList(self.TreeRightImageList) |
157 self.VariablesList.SetRightImageList(self.TreeRightImageList) |
161 |
158 |
162 self.ButtonCallBacks = { |
159 self.ButtonCallBacks = { |
163 self.InstanceGraphImage: _ButtonCallbacks( |
|
164 self.GraphButtonCallback, None), |
|
165 self.EditImage: _ButtonCallbacks( |
160 self.EditImage: _ButtonCallbacks( |
166 self.EditButtonCallback, None), |
161 self.EditButtonCallback, None), |
167 self.DebugInstanceImage: _ButtonCallbacks( |
162 self.DebugInstanceImage: _ButtonCallbacks( |
168 self.DebugButtonCallback, self.DebugButtonDClickCallback)} |
163 self.DebugButtonCallback, self.DebugButtonDClickCallback)} |
169 |
164 |
244 text = "%s (%s)" % (var_infos.name, var_infos.type) |
239 text = "%s (%s)" % (var_infos.name, var_infos.type) |
245 else: |
240 else: |
246 text = var_infos.name |
241 text = var_infos.name |
247 |
242 |
248 right_images = [] |
243 right_images = [] |
249 if var_infos.var_class in ITEMS_VARIABLE: |
244 if var_infos.edit: |
250 if (not self.USE_MPL and var_infos.debug and self.Debug and |
|
251 (self.Controller.IsOfType(var_infos.type, "ANY_NUM", True) or |
|
252 self.Controller.IsOfType(var_infos.type, "ANY_BIT", True))): |
|
253 right_images.append(self.InstanceGraphImage) |
|
254 elif var_infos.edit: |
|
255 right_images.append(self.EditImage) |
245 right_images.append(self.EditImage) |
256 |
246 |
257 if var_infos.debug and self.Debug: |
247 if var_infos.debug and self.Debug: |
258 right_images.append(self.DebugInstanceImage) |
248 right_images.append(self.DebugInstanceImage) |
259 |
249 |
354 "%s.%s" % (self.InstanceChoice.GetStringSelection(), |
344 "%s.%s" % (self.InstanceChoice.GetStringSelection(), |
355 infos.name), |
345 infos.name), |
356 force=True, |
346 force=True, |
357 graph=True) |
347 graph=True) |
358 |
348 |
359 def GraphButtonCallback(self, infos): |
|
360 if self.InstanceChoice.GetSelection() != -1: |
|
361 if infos.var_class in ITEMS_VARIABLE: |
|
362 var_path = "%s.%s" % (self.InstanceChoice.GetStringSelection(), |
|
363 infos.name) |
|
364 self.ParentWindow.OpenDebugViewer(infos.var_class, var_path, infos.type) |
|
365 |
|
366 def ShowInstanceChoicePopup(self): |
349 def ShowInstanceChoicePopup(self): |
367 self.InstanceChoice.SetFocusFromKbd() |
350 self.InstanceChoice.SetFocusFromKbd() |
368 size = self.InstanceChoice.GetSize() |
351 size = self.InstanceChoice.GetSize() |
369 event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType()) |
352 event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType()) |
370 event.m_x = size.width / 2 |
353 event.m_x = size.width / 2 |