author | lbessard |
Fri, 20 Jul 2007 22:24:39 +0200 | |
changeset 50 | 4610aafc884e |
parent 49 | 1762276019fb |
child 51 | 47c72c77590a |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
|
5 |
#based on the plcopen standard. |
|
6 |
# |
|
7 |
#Copyright (C): Edouard TISSERANT and Laurent BESSARD |
|
8 |
# |
|
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
5 | 12 |
#modify it under the terms of the GNU General Public |
0 | 13 |
#License as published by the Free Software Foundation; either |
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 |
#Lesser General Public License for more details. |
|
20 |
# |
|
5 | 21 |
#You should have received a copy of the GNU General Public |
0 | 22 |
#License along with this library; if not, write to the Free Software |
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
25 |
from wxPython.wx import * |
|
26 |
from wxPython.grid import * |
|
27 |
from time import localtime |
|
28 |
from datetime import datetime |
|
29 |
import wx |
|
30 |
||
31 |
from SFCViewer import * |
|
32 |
from LDViewer import * |
|
33 |
from Viewer import * |
|
27 | 34 |
from TextViewer import * |
35 |
from RessourceEditor import * |
|
0 | 36 |
from PLCControler import * |
37 |
from plcopen import OpenPDFDoc |
|
38 |
||
39 |
import os, re, platform, sys, time, traceback, getopt |
|
40 |
||
41 |
__version__ = "$Revision$" |
|
42 |
||
43 |
def create(parent): |
|
44 |
return PLCOpenEditor(parent) |
|
45 |
||
46 |
def usage(): |
|
47 |
print "\nUsage of PLCOpenEditor.py :" |
|
48 |
print "\n %s [Filepath]\n"%sys.argv[0] |
|
49 |
||
50 |
try: |
|
51 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
|
52 |
except getopt.GetoptError: |
|
53 |
# print help information and exit: |
|
54 |
usage() |
|
55 |
sys.exit(2) |
|
56 |
||
57 |
for o, a in opts: |
|
58 |
if o in ("-h", "--help"): |
|
59 |
usage() |
|
60 |
sys.exit() |
|
61 |
||
62 |
fileOpen = None |
|
63 |
if len(args) > 1: |
|
64 |
usage() |
|
65 |
sys.exit() |
|
66 |
elif len(args) == 1: |
|
67 |
fileOpen = args[0] |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
68 |
CWD = "" |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
69 |
for path in sys.path: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
70 |
if os.path.isfile(os.path.join(path, "PLCOpenEditor.py")): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
71 |
CWD = path |
0 | 72 |
|
73 |
[wxID_PLCOPENEDITOR, wxID_PLCOPENEDITORPROJECTTREE, |
|
6 | 74 |
wxID_PLCOPENEDITORSPLITTERWINDOW1, wxID_PLCOPENEDITOREDITORPANEL, |
75 |
wxID_PLCOPENEDITORTABSOPENED, wxID_PLCOPENEDITORTOOLBAR, |
|
76 |
wxID_PLCOPENEDITORDEFAULTTOOLBAR, wxID_PLCOPENEDITORSFCTOOLBAR, |
|
0 | 77 |
wxID_PLCOPENEDITORFBDTOOLBAR, wxID_PLCOPENEDITORLDTOOLBAR, |
6 | 78 |
] = [wx.NewId() for _init_ctrls in range(10)] |
79 |
||
0 | 80 |
[wxID_PLCOPENEDITORFILEMENUITEMS0, wxID_PLCOPENEDITORFILEMENUITEMS1, |
81 |
wxID_PLCOPENEDITORFILEMENUITEMS2, wxID_PLCOPENEDITORFILEMENUITEMS3, |
|
82 |
wxID_PLCOPENEDITORFILEMENUITEMS5, wxID_PLCOPENEDITORFILEMENUITEMS6, |
|
83 |
wxID_PLCOPENEDITORFILEMENUITEMS7, wxID_PLCOPENEDITORFILEMENUITEMS9, |
|
84 |
wxID_PLCOPENEDITORFILEMENUITEMS11, |
|
85 |
] = [wx.NewId() for _init_coll_FileMenu_Items in range(9)] |
|
86 |
||
87 |
[wxID_PLCOPENEDITORHELPMENUITEMS0, wxID_PLCOPENEDITORHELPMENUITEMS1, |
|
88 |
wxID_PLCOPENEDITORHELPMENUITEMS2, wxID_PLCOPENEDITORHELPMENUITEMS3, |
|
89 |
] = [wx.NewId() for _init_coll_HelpMenu_Items in range(4)] |
|
90 |
||
91 |
[wxID_PLCOPENEDITORSFCMENUITEMS0, wxID_PLCOPENEDITORSFCMENUITEMS1, |
|
92 |
wxID_PLCOPENEDITORSFCMENUITEMS2, wxID_PLCOPENEDITORSFCMENUITEMS3, |
|
93 |
] = [wx.NewId() for _init_coll_HelpMenu_Items in range(4)] |
|
94 |
||
95 |
[wxID_PLCOPENEDITORCONFIGMENUITEMS0, wxID_PLCOPENEDITORCONFIGMENUITEMS1, |
|
96 |
] = [wx.NewId() for _init_coll_HelpMenu_Items in range(2)] |
|
97 |
||
98 |
[wxID_PLCOPENEDITOREDITMENUITEMS0, wxID_PLCOPENEDITOREDITMENUITEMS1, |
|
99 |
wxID_PLCOPENEDITOREDITMENUITEMS11, wxID_PLCOPENEDITOREDITMENUITEMS12, |
|
100 |
wxID_PLCOPENEDITOREDITMENUITEMS2, wxID_PLCOPENEDITOREDITMENUITEMS4, |
|
101 |
wxID_PLCOPENEDITOREDITMENUITEMS5, wxID_PLCOPENEDITOREDITMENUITEMS6, |
|
102 |
wxID_PLCOPENEDITOREDITMENUITEMS8, wxID_PLCOPENEDITOREDITMENUITEMS9, |
|
103 |
] = [wx.NewId() for _init_coll_EditMenu_Items in range(10)] |
|
104 |
||
105 |
[wxID_PLCOPENEDITORSFCMENUITEMS0, wxID_PLCOPENEDITORSFCMENUITEMS1, |
|
106 |
wxID_PLCOPENEDITORSFCMENUITEMS2, wxID_PLCOPENEDITORSFCMENUITEMS3, |
|
107 |
] = [wx.NewId() for _init_coll_SFCMenu_Items in range(4)] |
|
108 |
||
109 |
[wxID_PLCOPENEDITORCONFIGMENUITEMS0, wxID_PLCOPENEDITORCONFIGMENUITEMS1, |
|
110 |
] = [wx.NewId() for _init_coll_ConfigMenu_Items in range(2)] |
|
111 |
||
27 | 112 |
|
113 |
#------------------------------------------------------------------------------- |
|
114 |
# ToolBars definitions |
|
115 |
#------------------------------------------------------------------------------- |
|
116 |
||
117 |
||
118 |
[wxID_PLCOPENEDITORTOOLBARSELECTION, wxID_PLCOPENEDITORTOOLBARCOMMENT, |
|
119 |
wxID_PLCOPENEDITORTOOLBARVARIABLE, wxID_PLCOPENEDITORTOOLBARBLOCK, |
|
120 |
wxID_PLCOPENEDITORTOOLBARCONNECTION, wxID_PLCOPENEDITORTOOLBARWIRE, |
|
121 |
wxID_PLCOPENEDITORTOOLBARPOWERRAIL, wxID_PLCOPENEDITORTOOLBARRUNG, |
|
122 |
wxID_PLCOPENEDITORTOOLBARCOIL, wxID_PLCOPENEDITORTOOLBARCONTACT, |
|
123 |
wxID_PLCOPENEDITORTOOLBARBRANCH, wxID_PLCOPENEDITORTOOLBARINITIALSTEP, |
|
124 |
wxID_PLCOPENEDITORTOOLBARSTEP, wxID_PLCOPENEDITORTOOLBARTRANSITION, |
|
125 |
wxID_PLCOPENEDITORTOOLBARACTIONBLOCK, wxID_PLCOPENEDITORTOOLBARDIVERGENCE, |
|
126 |
wxID_PLCOPENEDITORTOOLBARJUMP, |
|
127 |
] = [wx.NewId() for _init_coll_DefaultToolBar_Items in range(17)] |
|
128 |
||
129 |
ToolBarItems = { |
|
130 |
"FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"), |
|
131 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"), |
|
132 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"), |
|
133 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"), |
|
134 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")], |
|
135 |
"LD" : [(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"), |
|
136 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", "Images/powerrail.png", "Create a new power rail"), |
|
137 |
(False, DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARRUNG, "OnRungTool", "Images/rung.png", "Create a new rung"), |
|
138 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCOIL, "OnCoilTool", "Images/coil.png", "Create a new coil"), |
|
139 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", "Images/contact.png", "Create a new contact"), |
|
140 |
(False, DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARBRANCH, "OnBranchTool", "Images/branch.png", "Create a new branch"), |
|
141 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"), |
|
142 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"), |
|
143 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"), |
|
144 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")], |
|
145 |
"SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"), |
|
146 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARINITIALSTEP, "OnInitialStepTool", "Images/initial_step.png", "Create a new initial step"), |
|
147 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARSTEP, "OnStepTool", "Images/step.png", "Create a new step"), |
|
148 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARTRANSITION, "OnTransitionTool", "Images/transition.png", "Create a new transition"), |
|
149 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", "Images/action.png", "Create a new action block"), |
|
150 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARDIVERGENCE, "OnDivergenceTool", "Images/divergence.png", "Create a new divergence"), |
|
151 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARJUMP, "OnJumpTool", "Images/jump.png", "Create a new jump"), |
|
152 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"), |
|
153 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"), |
|
154 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"), |
|
155 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", "Images/powerrail.png", "Create a new power rail"), |
|
156 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", "Images/contact.png", "Create a new contact"), |
|
157 |
(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")], |
|
158 |
"ST" : [], |
|
159 |
"IL" : [] |
|
160 |
} |
|
161 |
||
0 | 162 |
class PLCOpenEditor(wx.Frame): |
163 |
_custom_classes = {'wx.SashWindow' : ['Viewer']} |
|
164 |
||
165 |
def _init_coll_EditMenu_Items(self, parent): |
|
166 |
# generated method, don't edit |
|
167 |
||
168 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS0, |
|
169 |
kind=wx.ITEM_NORMAL, text=u'Refresh\tCTRL+R') |
|
170 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS1, |
|
171 |
kind=wx.ITEM_NORMAL, text=u'Undo\tCTRL+Z') |
|
172 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS2, |
|
173 |
kind=wx.ITEM_NORMAL, text=u'Redo\tCTRL+Y') |
|
174 |
parent.AppendSeparator() |
|
175 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS4, |
|
176 |
kind=wx.ITEM_NORMAL, text=u'Cut\tCTRL+X') |
|
177 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS5, |
|
178 |
kind=wx.ITEM_NORMAL, text=u'Copy\tCTRL+C') |
|
179 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS6, |
|
180 |
kind=wx.ITEM_NORMAL, text=u'Paste\tCTRL+V') |
|
181 |
parent.AppendSeparator() |
|
182 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS8, |
|
183 |
kind=wx.ITEM_NORMAL, text=u'Add POU') |
|
184 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS9, |
|
185 |
kind=wx.ITEM_NORMAL, text=u'Remove POU') |
|
186 |
parent.AppendSeparator() |
|
187 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS11, |
|
188 |
kind=wx.ITEM_NORMAL, text=u'Add Configuration') |
|
189 |
parent.Append(help='', id=wxID_PLCOPENEDITOREDITMENUITEMS12, |
|
190 |
kind=wx.ITEM_NORMAL, text=u'Remove Configuration') |
|
191 |
self.Bind(wx.EVT_MENU, self.OnRefreshMenu, |
|
192 |
id=wxID_PLCOPENEDITOREDITMENUITEMS0) |
|
193 |
self.Bind(wx.EVT_MENU, self.OnCutMenu, |
|
194 |
id=wxID_PLCOPENEDITOREDITMENUITEMS4) |
|
195 |
self.Bind(wx.EVT_MENU, self.OnCopyMenu, |
|
196 |
id=wxID_PLCOPENEDITOREDITMENUITEMS5) |
|
197 |
self.Bind(wx.EVT_MENU, self.OnPasteMenu, |
|
198 |
id=wxID_PLCOPENEDITOREDITMENUITEMS6) |
|
199 |
self.Bind(wx.EVT_MENU, self.OnAddPouMenu, |
|
200 |
id=wxID_PLCOPENEDITOREDITMENUITEMS8) |
|
201 |
self.Bind(wx.EVT_MENU, self.OnRemovePouMenu, |
|
202 |
id=wxID_PLCOPENEDITOREDITMENUITEMS9) |
|
203 |
self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, |
|
204 |
id=wxID_PLCOPENEDITOREDITMENUITEMS11) |
|
205 |
self.Bind(wx.EVT_MENU, self.OnRemoveConfigurationMenu, |
|
206 |
id=wxID_PLCOPENEDITOREDITMENUITEMS12) |
|
207 |
||
208 |
def _init_coll_menuBar1_Menus(self, parent): |
|
209 |
# generated method, don't edit |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
210 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
211 |
if self.ModeSolo: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
212 |
parent.Append(menu=self.FileMenu, title=u'File') |
0 | 213 |
parent.Append(menu=self.EditMenu, title=u'Edit') |
214 |
parent.Append(menu=self.HelpMenu, title=u'Help') |
|
215 |
||
216 |
def _init_coll_ConfigMenu_Items(self, parent): |
|
217 |
# generated method, don't edit |
|
218 |
||
219 |
parent.Append(help='', id=wxID_PLCOPENEDITORCONFIGMENUITEMS0, |
|
220 |
kind=wx.ITEM_NORMAL, text=u'Add Resource') |
|
221 |
parent.Append(help='', id=wxID_PLCOPENEDITORCONFIGMENUITEMS1, |
|
222 |
kind=wx.ITEM_NORMAL, text=u'Remove Resource') |
|
223 |
self.Bind(wx.EVT_MENU, self.OnAddResourceMenu, |
|
224 |
id=wxID_PLCOPENEDITORCONFIGMENUITEMS0) |
|
225 |
self.Bind(wx.EVT_MENU, self.OnRemoveResourceMenu, |
|
226 |
id=wxID_PLCOPENEDITORCONFIGMENUITEMS1) |
|
227 |
||
228 |
def _init_coll_HelpMenu_Items(self, parent): |
|
229 |
# generated method, don't edit |
|
230 |
||
231 |
parent.Append(help='', id=wxID_PLCOPENEDITORHELPMENUITEMS0, |
|
232 |
kind=wx.ITEM_NORMAL, text=u'PLCOpenEditor\tF1') |
|
233 |
parent.Append(help='', id=wxID_PLCOPENEDITORHELPMENUITEMS1, |
|
234 |
kind=wx.ITEM_NORMAL, text=u'PLCOpen\tF2') |
|
235 |
parent.Append(help='', id=wxID_PLCOPENEDITORHELPMENUITEMS2, |
|
236 |
kind=wx.ITEM_NORMAL, text=u'IEC 61131-3\tF3') |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
237 |
if self.ModeSolo: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
238 |
parent.Append(help='', id=wxID_PLCOPENEDITORHELPMENUITEMS3, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
239 |
kind=wx.ITEM_NORMAL, text=u'About') |
0 | 240 |
self.Bind(wx.EVT_MENU, self.OnPLCOpenMenu, |
241 |
id=wxID_PLCOPENEDITORHELPMENUITEMS1) |
|
242 |
||
243 |
def _init_coll_FileMenu_Items(self, parent): |
|
244 |
# generated method, don't edit |
|
245 |
||
246 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS0, |
|
247 |
kind=wx.ITEM_NORMAL, text=u'New\tCTRL+N') |
|
248 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS1, |
|
249 |
kind=wx.ITEM_NORMAL, text=u'Open\tCTRL+O') |
|
250 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS2, |
|
251 |
kind=wx.ITEM_NORMAL, text=u'Close Tab\tCTRL+W') |
|
252 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS3, |
|
253 |
kind=wx.ITEM_NORMAL, text=u'Close Project') |
|
254 |
parent.AppendSeparator() |
|
255 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS5, |
|
256 |
kind=wx.ITEM_NORMAL, text=u'Save\tCTRL+S') |
|
257 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS6, |
|
258 |
kind=wx.ITEM_NORMAL, text=u'Save As...\tCTRL+SHIFT+S') |
|
259 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS7, |
|
260 |
kind=wx.ITEM_NORMAL, text=u'Generate Program\tCTRL+G') |
|
261 |
parent.AppendSeparator() |
|
262 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS9, |
|
263 |
kind=wx.ITEM_NORMAL, text=u'Properties') |
|
264 |
parent.AppendSeparator() |
|
265 |
parent.Append(help='', id=wxID_PLCOPENEDITORFILEMENUITEMS11, |
|
266 |
kind=wx.ITEM_NORMAL, text=u'Quit\tCTRL+Q') |
|
267 |
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, |
|
268 |
id=wxID_PLCOPENEDITORFILEMENUITEMS0) |
|
269 |
self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, |
|
270 |
id=wxID_PLCOPENEDITORFILEMENUITEMS1) |
|
271 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, |
|
272 |
id=wxID_PLCOPENEDITORFILEMENUITEMS2) |
|
273 |
self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, |
|
274 |
id=wxID_PLCOPENEDITORFILEMENUITEMS3) |
|
275 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, |
|
276 |
id=wxID_PLCOPENEDITORFILEMENUITEMS5) |
|
277 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, |
|
278 |
id=wxID_PLCOPENEDITORFILEMENUITEMS6) |
|
279 |
self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu, |
|
280 |
id=wxID_PLCOPENEDITORFILEMENUITEMS7) |
|
27 | 281 |
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, |
282 |
id=wxID_PLCOPENEDITORFILEMENUITEMS9) |
|
0 | 283 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, |
284 |
id=wxID_PLCOPENEDITORFILEMENUITEMS11) |
|
285 |
||
286 |
def _init_coll_SFCMenu_Items(self, parent): |
|
287 |
# generated method, don't edit |
|
288 |
||
289 |
parent.Append(help='', id=wxID_PLCOPENEDITORSFCMENUITEMS0, |
|
290 |
kind=wx.ITEM_NORMAL, text=u'Add Transition') |
|
291 |
parent.Append(help='', id=wxID_PLCOPENEDITORSFCMENUITEMS1, |
|
292 |
kind=wx.ITEM_NORMAL, text=u'Add Action') |
|
293 |
parent.Append(help='', id=wxID_PLCOPENEDITORSFCMENUITEMS2, |
|
294 |
kind=wx.ITEM_NORMAL, text=u'Remove Transition') |
|
295 |
parent.Append(help='', id=wxID_PLCOPENEDITORSFCMENUITEMS3, |
|
296 |
kind=wx.ITEM_NORMAL, text=u'Remove Action') |
|
297 |
self.Bind(wx.EVT_MENU, self.OnAddPouTransitionMenu, |
|
298 |
id=wxID_PLCOPENEDITORSFCMENUITEMS0) |
|
299 |
self.Bind(wx.EVT_MENU, self.OnAddPouActionMenu, |
|
300 |
id=wxID_PLCOPENEDITORSFCMENUITEMS1) |
|
301 |
self.Bind(wx.EVT_MENU, self.OnRemovePouTransitionMenu, |
|
302 |
id=wxID_PLCOPENEDITORSFCMENUITEMS2) |
|
303 |
self.Bind(wx.EVT_MENU, self.OnRemovePouActionMenu, |
|
304 |
id=wxID_PLCOPENEDITORSFCMENUITEMS3) |
|
305 |
||
306 |
def _init_utils(self): |
|
307 |
# generated method, don't edit |
|
308 |
self.menuBar1 = wx.MenuBar() |
|
309 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
310 |
if self.ModeSolo: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
311 |
self.FileMenu = wx.Menu(title=u'') |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
312 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
313 |
self.FileMenu = None |
0 | 314 |
|
315 |
self.EditMenu = wx.Menu(title=u'') |
|
316 |
||
317 |
self.HelpMenu = wx.Menu(title='') |
|
318 |
||
319 |
self.SFCMenu = wx.Menu(title='') |
|
320 |
||
321 |
self.ConfigMenu = wx.Menu(title='') |
|
322 |
||
323 |
self._init_coll_menuBar1_Menus(self.menuBar1) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
324 |
if self.ModeSolo: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
325 |
self._init_coll_FileMenu_Items(self.FileMenu) |
0 | 326 |
self._init_coll_EditMenu_Items(self.EditMenu) |
327 |
self._init_coll_HelpMenu_Items(self.HelpMenu) |
|
328 |
self._init_coll_SFCMenu_Items(self.SFCMenu) |
|
329 |
self._init_coll_ConfigMenu_Items(self.ConfigMenu) |
|
330 |
||
331 |
def _init_coll_MainGridSizer_Items(self, parent): |
|
332 |
# generated method, don't edit |
|
333 |
||
334 |
parent.AddWindow(self.splitterWindow1, 0, border=0, flag=wxGROW) |
|
335 |
||
6 | 336 |
def _init_coll_EditorGridSizer_Items(self, parent): |
337 |
# generated method, don't edit |
|
338 |
||
339 |
parent.AddWindow(self.ToolBar, 0, border=0, flag=wxGROW) |
|
340 |
parent.AddWindow(self.TabsOpened, 0, border=0, flag=wxGROW) |
|
341 |
||
0 | 342 |
def _init_coll_MainGridSizer_Growables(self, parent): |
343 |
# generated method, don't edit |
|
344 |
||
345 |
parent.AddGrowableCol(0) |
|
346 |
parent.AddGrowableRow(0) |
|
347 |
||
6 | 348 |
def _init_coll_EditorGridSizer_Growables(self, parent): |
349 |
# generated method, don't edit |
|
350 |
||
351 |
parent.AddGrowableCol(0) |
|
352 |
parent.AddGrowableRow(1) |
|
353 |
||
0 | 354 |
def _init_sizers(self): |
355 |
# generated method, don't edit |
|
356 |
self.MainGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=0) |
|
357 |
||
6 | 358 |
self.EditorGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
359 |
||
0 | 360 |
self._init_coll_MainGridSizer_Growables(self.MainGridSizer) |
361 |
self._init_coll_MainGridSizer_Items(self.MainGridSizer) |
|
6 | 362 |
self._init_coll_EditorGridSizer_Growables(self.EditorGridSizer) |
363 |
self._init_coll_EditorGridSizer_Items(self.EditorGridSizer) |
|
364 |
||
0 | 365 |
self.SetSizer(self.MainGridSizer) |
6 | 366 |
self.EditorPanel.SetSizer(self.EditorGridSizer) |
0 | 367 |
|
368 |
def _init_ctrls(self, prnt): |
|
369 |
# generated method, don't edit |
|
370 |
wx.Frame.__init__(self, id=wxID_PLCOPENEDITOR, name=u'PLCOpenEditor', |
|
371 |
parent=prnt, pos=wx.Point(235, 287), size=wx.Size(1000, 600), |
|
372 |
style=wx.DEFAULT_FRAME_STYLE, title=u'PLCOpenEditor') |
|
373 |
self._init_utils() |
|
374 |
self.SetClientSize(wx.Size(1000, 600)) |
|
375 |
self.SetMenuBar(self.menuBar1) |
|
7 | 376 |
|
377 |
self.splitterWindow1 = wx.SplitterWindow(id=wxID_PLCOPENEDITORSPLITTERWINDOW1, |
|
378 |
name='splitterWindow1', parent=self, point=wx.Point(0, 0), |
|
379 |
size=wx.Size(-1, -1), style=wx.SP_3D) |
|
380 |
self.splitterWindow1.SetNeedUpdating(True) |
|
381 |
self.splitterWindow1.SetMinimumPaneSize(1) |
|
382 |
||
383 |
self.EditorPanel = wx.Panel(id=wxID_PLCOPENEDITOREDITORPANEL, |
|
384 |
name='TabPanel', parent=self.splitterWindow1, pos=wx.Point(0, 0), |
|
385 |
size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
|
386 |
||
387 |
self.TabsOpened = wx.Notebook(id=wxID_PLCOPENEDITORTABSOPENED, |
|
388 |
name='TabsOpened', parent=self.EditorPanel, pos=wx.Point(0, |
|
389 |
0), size=wx.Size(-1, -1), style=0) |
|
390 |
self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
|
391 |
self.OnPouSelectedChanged, id=wxID_PLCOPENEDITORTABSOPENED) |
|
392 |
||
393 |
self.ToolBar = wxToolBar(id=wxID_PLCOPENEDITORTOOLBAR, name='ToolBar', |
|
394 |
parent=self.EditorPanel, pos=wx.Point(0, 0), size=wx.Size(0, 40), |
|
395 |
style=wxTB_HORIZONTAL | wxNO_BORDER) |
|
27 | 396 |
self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORTOOLBARSELECTION, |
7 | 397 |
wxBitmap(os.path.join(CWD, 'Images/select.png')), wxNullBitmap, "Select an object") |
398 |
self.Bind(wx.EVT_TOOL, self.OnSelectionTool, |
|
27 | 399 |
id=wxID_PLCOPENEDITORTOOLBARSELECTION) |
7 | 400 |
|
401 |
self.ProjectTree = wx.TreeCtrl(id=wxID_PLCOPENEDITORPROJECTTREE, |
|
402 |
name='treeCtrl1', parent=self.splitterWindow1, pos=wx.Point(0, 0), |
|
403 |
size=wx.Size(-1, -1), |
|
404 |
style=wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
|
27 | 405 |
self.ProjectTree.Bind(wx.EVT_RIGHT_UP, self.OnProjectTreeRightUp) |
7 | 406 |
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnProjectTreeBeginDrag, |
407 |
id=wxID_PLCOPENEDITORPROJECTTREE) |
|
0 | 408 |
self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnProjectTreeItemBeginEdit, |
409 |
id=wxID_PLCOPENEDITORPROJECTTREE) |
|
410 |
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnProjectTreeItemEndEdit, |
|
411 |
id=wxID_PLCOPENEDITORPROJECTTREE) |
|
412 |
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnProjectTreeItemActivated, |
|
413 |
id=wxID_PLCOPENEDITORPROJECTTREE) |
|
414 |
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnProjectTreeItemSelected, |
|
415 |
id=wxID_PLCOPENEDITORPROJECTTREE) |
|
6 | 416 |
self.splitterWindow1.SplitVertically(self.ProjectTree, self.EditorPanel, |
0 | 417 |
200) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
418 |
|
0 | 419 |
self._init_sizers() |
420 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
421 |
def __init__(self, parent, controler = None): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
422 |
self.ModeSolo = controler == None |
0 | 423 |
self._init_ctrls(parent) |
424 |
||
9 | 425 |
self.TreeImageList = wxImageList(16, 16) |
426 |
for language in LANGUAGES: |
|
427 |
self.TreeImageList.Add(wxBitmap(os.path.join(CWD, 'Images/%s.png'%language))) |
|
428 |
self.ProjectTree.SetImageList(self.TreeImageList) |
|
429 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
430 |
if self.ModeSolo: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
431 |
self.Controler = PLCControler() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
432 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
433 |
self.Controler = controler |
0 | 434 |
|
435 |
if fileOpen: |
|
436 |
self.Controler.OpenXMLFile(fileOpen) |
|
437 |
self.RefreshProjectTree() |
|
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
438 |
|
6 | 439 |
self.CurrentToolBar = [] |
27 | 440 |
self.CurrentLanguage = "" |
41 | 441 |
#self.DrawingMode = FREEDRAWING_MODE |
442 |
self.DrawingMode = DRIVENDRAWING_MODE |
|
6 | 443 |
|
0 | 444 |
self.RefreshFileMenu() |
445 |
self.RefreshEditMenu() |
|
446 |
self.RefreshToolBar() |
|
447 |
||
27 | 448 |
def GetDrawingMode(self): |
449 |
return self.DrawingMode |
|
450 |
||
0 | 451 |
def RefreshFileMenu(self): |
9 | 452 |
if self.FileMenu: |
453 |
if self.Controler.HasOpenedProject(): |
|
454 |
if self.TabsOpened.GetPageCount() > 0: |
|
455 |
self.FileMenu.FindItemByPosition(2).Enable(True) |
|
456 |
else: |
|
457 |
self.FileMenu.FindItemByPosition(2).Enable(False) |
|
458 |
self.FileMenu.FindItemByPosition(3).Enable(True) |
|
459 |
self.FileMenu.FindItemByPosition(5).Enable(True) |
|
460 |
self.FileMenu.FindItemByPosition(6).Enable(True) |
|
461 |
self.FileMenu.FindItemByPosition(7).Enable(True) |
|
462 |
self.FileMenu.FindItemByPosition(9).Enable(True) |
|
0 | 463 |
else: |
464 |
self.FileMenu.FindItemByPosition(2).Enable(False) |
|
9 | 465 |
self.FileMenu.FindItemByPosition(3).Enable(False) |
466 |
self.FileMenu.FindItemByPosition(5).Enable(False) |
|
467 |
self.FileMenu.FindItemByPosition(6).Enable(False) |
|
468 |
self.FileMenu.FindItemByPosition(7).Enable(False) |
|
469 |
self.FileMenu.FindItemByPosition(9).Enable(False) |
|
0 | 470 |
|
471 |
def RefreshEditMenu(self): |
|
9 | 472 |
if self.EditMenu: |
473 |
self.EditMenu.FindItemByPosition(1).Enable(False) |
|
474 |
self.EditMenu.FindItemByPosition(2).Enable(False) |
|
475 |
if self.Controler.HasOpenedProject(): |
|
476 |
if self.TabsOpened.GetPageCount() > 0: |
|
477 |
self.EditMenu.FindItemByPosition(0).Enable(True) |
|
478 |
else: |
|
479 |
self.EditMenu.FindItemByPosition(0).Enable(False) |
|
480 |
self.EditMenu.FindItemByPosition(8).Enable(True) |
|
481 |
self.EditMenu.FindItemByPosition(9).Enable(True) |
|
0 | 482 |
else: |
483 |
self.EditMenu.FindItemByPosition(0).Enable(False) |
|
9 | 484 |
self.EditMenu.FindItemByPosition(8).Enable(False) |
485 |
self.EditMenu.FindItemByPosition(9).Enable(False) |
|
486 |
bodytype = self.Controler.GetCurrentElementEditingBodyType() |
|
487 |
if bodytype in ["IL","ST"]: |
|
488 |
self.EditMenu.FindItemByPosition(4).Enable(True) |
|
489 |
self.EditMenu.FindItemByPosition(5).Enable(True) |
|
490 |
self.EditMenu.FindItemByPosition(6).Enable(True) |
|
491 |
else: |
|
492 |
self.EditMenu.FindItemByPosition(4).Enable(False) |
|
493 |
self.EditMenu.FindItemByPosition(5).Enable(False) |
|
0 | 494 |
self.EditMenu.FindItemByPosition(6).Enable(False) |
495 |
||
27 | 496 |
def ShowProperties(self): |
497 |
old_values = self.Controler.GetProjectProperties() |
|
498 |
old_values["projectName"] = self.Controler.GetProjectName() |
|
499 |
dialog = ProjectDialog(self) |
|
500 |
dialog.SetValues(old_values) |
|
501 |
if dialog.ShowModal() == wxID_OK: |
|
502 |
new_values = dialog.GetValues() |
|
503 |
projectname = new_values.pop("projectName") |
|
504 |
new_values["creationDateTime"] = old_values["creationDateTime"] |
|
505 |
self.Controler.SetProjectName(projectname) |
|
506 |
self.Controler.SetProjectProperties(new_values) |
|
507 |
self.RefreshProjectTree() |
|
508 |
dialog.Destroy() |
|
509 |
||
0 | 510 |
def OnNewProjectMenu(self, event): |
511 |
dialog = ProjectDialog(self) |
|
512 |
if dialog.ShowModal() == wxID_OK: |
|
513 |
values = dialog.GetValues() |
|
514 |
projectname = values.pop("projectName") |
|
515 |
values["creationDateTime"] = datetime(*localtime()[:6]) |
|
516 |
self.Controler.CreateNewProject(projectname) |
|
517 |
self.Controler.SetProjectProperties(values) |
|
518 |
self.RefreshFileMenu() |
|
519 |
self.RefreshEditMenu() |
|
520 |
self.RefreshProjectTree() |
|
521 |
event.Skip() |
|
522 |
||
523 |
def OnOpenProjectMenu(self, event): |
|
524 |
filepath = self.Controler.GetFilePath() |
|
525 |
if filepath != "": |
|
526 |
directory = os.path.dirname(filepath) |
|
527 |
else: |
|
528 |
directory = os.getcwd() |
|
529 |
dialog = wxFileDialog(self, "Choose a file", directory, "", "PLCOpen files (*.xml)|*.xml|All files|*.*", wxOPEN) |
|
530 |
if dialog.ShowModal() == wxID_OK: |
|
531 |
filepath = dialog.GetPath() |
|
532 |
if os.path.isfile(filepath): |
|
533 |
self.Controler.OpenXMLFile(filepath) |
|
534 |
self.TabsOpened.DeleteAllPages() |
|
535 |
self.RefreshProjectTree() |
|
536 |
self.RefreshFileMenu() |
|
537 |
self.RefreshEditMenu() |
|
538 |
self.RefreshToolBar() |
|
539 |
dialog.Destroy() |
|
540 |
event.Skip() |
|
541 |
||
542 |
def OnCloseTabMenu(self, event): |
|
543 |
selected = self.TabsOpened.GetSelection() |
|
544 |
if selected >= 0: |
|
545 |
self.Controler.CloseElementEditing() |
|
546 |
self.TabsOpened.DeletePage(selected) |
|
547 |
if self.TabsOpened.GetPageCount() > 0: |
|
548 |
self.TabsOpened.SetSelection(min(selected, self.TabsOpened.GetPageCount() - 1)) |
|
549 |
self.RefreshFileMenu() |
|
550 |
self.RefreshEditMenu() |
|
551 |
self.RefreshToolBar() |
|
552 |
event.Skip() |
|
553 |
||
554 |
def OnCloseProjectMenu(self, event): |
|
555 |
self.Controler.Reset() |
|
556 |
self.TabsOpened.DeleteAllPages() |
|
557 |
self.ProjectTree.DeleteAllItems() |
|
558 |
self.RefreshFileMenu() |
|
559 |
self.RefreshEditMenu() |
|
560 |
self.RefreshToolBar() |
|
561 |
event.Skip() |
|
562 |
||
563 |
def OnSaveProjectMenu(self, event): |
|
564 |
self.SaveProject() |
|
565 |
event.Skip() |
|
566 |
||
567 |
def OnSaveProjectAsMenu(self, event): |
|
568 |
self.SaveProjectAs() |
|
569 |
event.Skip() |
|
570 |
||
571 |
def OnGenerateProgramMenu(self, event): |
|
42 | 572 |
dialog = wxFileDialog(self, "Choose a file", os.getcwd(), self.Controler.GetProgramFilePath(), "ST files (*.st)|*.st|All files|*.*", wxSAVE|wxCHANGE_DIR) |
4
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
573 |
if dialog.ShowModal() == wxID_OK: |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
574 |
filepath = dialog.GetPath() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
575 |
if os.path.isdir(os.path.dirname(filepath)): |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
576 |
result = self.Controler.GenerateProgram(filepath) |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
577 |
if not result: |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
578 |
message = wxMessageDialog(self, "Can't generate program to file %s!"%filepath, "Error", wxOK|wxICON_ERROR) |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
579 |
message.ShowModal() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
580 |
message.Destroy() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
581 |
else: |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
582 |
message = wxMessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wxOK|wxICON_ERROR) |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
583 |
message.ShowModal() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
584 |
message.Destroy() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
585 |
dialog.Destroy() |
0 | 586 |
event.Skip() |
587 |
||
588 |
def SaveProject(self): |
|
589 |
result = self.Controler.SaveXMLFile() |
|
590 |
if not result: |
|
591 |
self.SaveProjectAs() |
|
592 |
||
593 |
def SaveProjectAs(self): |
|
594 |
filepath = self.Controler.GetFilePath() |
|
595 |
if filepath != "": |
|
596 |
directory, filename = os.path.split(filepath) |
|
597 |
else: |
|
27 | 598 |
directory, filename = os.getcwd(), "%s.xml"%self.Controler.GetProjectName() |
0 | 599 |
dialog = wxFileDialog(self, "Choose a file", directory, filename, "PLCOpen files (*.xml)|*.xml|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT) |
600 |
if dialog.ShowModal() == wxID_OK: |
|
601 |
filepath = dialog.GetPath() |
|
602 |
if os.path.isdir(os.path.dirname(filepath)): |
|
603 |
result = self.Controler.SaveXMLFile(filepath) |
|
604 |
if not result: |
|
605 |
message = wxMessageDialog(self, "Can't save project to file %s!"%filepath, "Error", wxOK|wxICON_ERROR) |
|
606 |
message.ShowModal() |
|
607 |
message.Destroy() |
|
608 |
else: |
|
609 |
message = wxMessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wxOK|wxICON_ERROR) |
|
610 |
message.ShowModal() |
|
611 |
message.Destroy() |
|
612 |
dialog.Destroy() |
|
613 |
||
27 | 614 |
def OnPropertiesMenu(self, event): |
615 |
self.ShowProperties() |
|
616 |
event.Skip() |
|
617 |
||
0 | 618 |
def OnQuitMenu(self, event): |
6 | 619 |
self.ToolBar.Reparent(self) |
620 |
self.Controler.Reset() |
|
0 | 621 |
self.Close() |
622 |
event.Skip() |
|
623 |
||
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
624 |
def ResetCurrentMode(self): |
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
625 |
selected = self.TabsOpened.GetSelection() |
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
626 |
if selected != -1: |
6 | 627 |
window = self.TabsOpened.GetPage(selected) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
628 |
window.SetMode(MODE_SELECTION) |
27 | 629 |
self.ToolBar.ToggleTool(wxID_PLCOPENEDITORTOOLBARSELECTION, True) |
6 | 630 |
|
631 |
def ResetToolToggle(self, id): |
|
632 |
tool = self.ToolBar.FindById(id) |
|
633 |
tool.SetToggle(False) |
|
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
634 |
|
0 | 635 |
def OnSelectionTool(self, event): |
636 |
selected = self.TabsOpened.GetSelection() |
|
637 |
if selected != -1: |
|
638 |
self.TabsOpened.GetPage(selected).SetMode(MODE_SELECTION) |
|
639 |
event.Skip() |
|
640 |
||
27 | 641 |
def OnCommentTool(self, event): |
642 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARCOMMENT) |
|
0 | 643 |
selected = self.TabsOpened.GetSelection() |
644 |
if selected != -1: |
|
645 |
self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT) |
|
646 |
event.Skip() |
|
647 |
||
27 | 648 |
def OnVariableTool(self, event): |
649 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARVARIABLE) |
|
0 | 650 |
selected = self.TabsOpened.GetSelection() |
651 |
if selected != -1: |
|
652 |
self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE) |
|
653 |
event.Skip() |
|
654 |
||
27 | 655 |
def OnBlockTool(self, event): |
0 | 656 |
selected = self.TabsOpened.GetSelection() |
657 |
if selected != -1: |
|
658 |
self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK) |
|
659 |
event.Skip() |
|
660 |
||
27 | 661 |
def OnConnectionTool(self, event): |
662 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARCONNECTION) |
|
0 | 663 |
selected = self.TabsOpened.GetSelection() |
664 |
if selected != -1: |
|
665 |
self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION) |
|
666 |
event.Skip() |
|
667 |
||
27 | 668 |
def OnWireTool(self, event): |
669 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARWIRE) |
|
6 | 670 |
selected = self.TabsOpened.GetSelection() |
671 |
if selected != -1: |
|
672 |
self.TabsOpened.GetPage(selected).SetMode(MODE_WIRE) |
|
673 |
event.Skip() |
|
674 |
||
27 | 675 |
def OnPowerRailTool(self, event): |
676 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARPOWERRAIL) |
|
677 |
selected = self.TabsOpened.GetSelection() |
|
678 |
if selected != -1: |
|
679 |
self.TabsOpened.GetPage(selected).SetMode(MODE_POWERRAIL) |
|
680 |
event.Skip() |
|
681 |
||
682 |
def OnRungTool(self, event): |
|
0 | 683 |
selected = self.TabsOpened.GetSelection() |
684 |
if selected != -1: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
685 |
self.TabsOpened.GetPage(selected).Viewer.AddLadderRung() |
0 | 686 |
event.Skip() |
687 |
||
27 | 688 |
def OnCoilTool(self, event): |
689 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARCOIL) |
|
0 | 690 |
selected = self.TabsOpened.GetSelection() |
691 |
if selected != -1: |
|
27 | 692 |
self.TabsOpened.GetPage(selected).SetMode(MODE_COIL) |
693 |
event.Skip() |
|
694 |
||
695 |
def OnContactTool(self, event): |
|
696 |
if self.DrawingMode == FREEDRAWING_MODE: |
|
697 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARCONTACT) |
|
0 | 698 |
selected = self.TabsOpened.GetSelection() |
699 |
if selected != -1: |
|
27 | 700 |
if self.DrawingMode == FREEDRAWING_MODE: |
701 |
self.TabsOpened.GetPage(selected).SetMode(MODE_CONTACT) |
|
702 |
else: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
703 |
self.TabsOpened.GetPage(selected).Viewer.AddLadderContact() |
27 | 704 |
event.Skip() |
705 |
||
706 |
def OnBranchTool(self, event): |
|
0 | 707 |
selected = self.TabsOpened.GetSelection() |
708 |
if selected != -1: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
709 |
self.TabsOpened.GetPage(selected).Viewer.AddLadderBranch() |
27 | 710 |
event.Skip() |
711 |
||
712 |
def OnInitialStepTool(self, event): |
|
713 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARINITIALSTEP) |
|
714 |
selected = self.TabsOpened.GetSelection() |
|
715 |
if selected != -1: |
|
716 |
self.TabsOpened.GetPage(selected).SetMode(MODE_INITIALSTEP) |
|
717 |
event.Skip() |
|
718 |
||
719 |
def OnStepTool(self, event): |
|
720 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
721 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARSTEP) |
|
722 |
selected = self.TabsOpened.GetSelection() |
|
723 |
if selected != -1: |
|
724 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
725 |
self.TabsOpened.GetPage(selected).SetMode(MODE_STEP) |
|
726 |
else: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
727 |
self.TabsOpened.GetPage(selected).Viewer.AddStep() |
27 | 728 |
event.Skip() |
729 |
||
730 |
def OnActionBlockTool(self, event): |
|
731 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
732 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARACTIONBLOCK) |
|
733 |
selected = self.TabsOpened.GetSelection() |
|
734 |
if selected != -1: |
|
735 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
736 |
self.TabsOpened.GetPage(selected).SetMode(MODE_ACTION) |
|
737 |
else: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
738 |
self.TabsOpened.GetPage(selected).Viewer.AddStepAction() |
27 | 739 |
event.Skip() |
740 |
||
741 |
def OnTransitionTool(self, event): |
|
742 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARTRANSITION) |
|
743 |
selected = self.TabsOpened.GetSelection() |
|
744 |
if selected != -1: |
|
745 |
self.TabsOpened.GetPage(selected).SetMode(MODE_TRANSITION) |
|
746 |
event.Skip() |
|
747 |
||
748 |
def OnDivergenceTool(self, event): |
|
749 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
750 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARDIVERGENCE) |
|
751 |
selected = self.TabsOpened.GetSelection() |
|
752 |
if selected != -1: |
|
753 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
754 |
self.TabsOpened.GetPage(selected).SetMode(MODE_DIVERGENCE) |
|
755 |
else: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
756 |
self.TabsOpened.GetPage(selected).Viewer.AddDivergence() |
27 | 757 |
event.Skip() |
758 |
||
759 |
def OnJumpTool(self, event): |
|
760 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
761 |
self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARJUMP) |
|
762 |
selected = self.TabsOpened.GetSelection() |
|
763 |
if selected != -1: |
|
764 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
765 |
self.TabsOpened.GetPage(selected).SetMode(MODE_JUMP) |
|
766 |
else: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
767 |
self.TabsOpened.GetPage(selected).Viewer.AddJump() |
0 | 768 |
event.Skip() |
769 |
||
770 |
def OnPouSelectedChanged(self, event): |
|
771 |
selected = event.GetSelection() |
|
772 |
if selected >= 0: |
|
773 |
self.Controler.RefreshCurrentElementEditing(selected) |
|
774 |
found = False |
|
775 |
name = self.TabsOpened.GetPageText(selected) |
|
776 |
root = self.ProjectTree.GetRootItem() |
|
777 |
item, root_cookie = self.ProjectTree.GetFirstChild(root) |
|
778 |
while item.IsOk() and not found: |
|
779 |
if self.ProjectTree.GetItemText(item) == name: |
|
780 |
self.ProjectTree.SelectItem(item) |
|
781 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
782 |
self.TabsOpened.GetPage(selected).RefreshView() |
0 | 783 |
self.RefreshFileMenu() |
784 |
self.RefreshEditMenu() |
|
785 |
self.RefreshToolBar() |
|
786 |
event.Skip() |
|
787 |
||
7 | 788 |
def OnProjectTreeBeginDrag(self, event): |
789 |
item = event.GetItem() |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
790 |
if self.ProjectTree.GetPyData(item) == ITEM_POU: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
791 |
block_name = self.ProjectTree.GetItemText(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
792 |
block_type = self.Controler.GetPouType(block_name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
793 |
data = wxTextDataObject(str((block_name, block_type))) |
7 | 794 |
dragSource = wxDropSource(self.ProjectTree) |
795 |
dragSource.SetData(data) |
|
796 |
dragSource.DoDragDrop() |
|
797 |
||
0 | 798 |
def OnProjectTreeItemEndEdit(self, event): |
6 | 799 |
message = None |
800 |
abort = False |
|
0 | 801 |
new_name = event.GetLabel() |
802 |
if new_name != "": |
|
6 | 803 |
if not TestIdentifier(new_name): |
804 |
message = "\"%s\" is not a valid identifier!"%new_name |
|
805 |
elif new_name.upper() in IEC_KEYWORDS: |
|
806 |
message = "\"%s\" is a keyword. It can't be used!"%new_name |
|
807 |
else: |
|
0 | 808 |
item = event.GetItem() |
809 |
itemtype = self.ProjectTree.GetPyData(item) |
|
810 |
if itemtype == ITEM_PROJECT: |
|
811 |
self.Controler.SetProjectName(new_name) |
|
812 |
elif itemtype == ITEM_POU: |
|
6 | 813 |
if new_name.upper() in self.Controler.GetProjectPouNames(): |
814 |
message = "\"%s\" pou already exists!"%new_name |
|
815 |
abort = True |
|
816 |
elif new_name.upper() in self.Controler.GetProjectPouVariables(): |
|
817 |
messageDialog = wxMessageDialog(self, "A variable is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wxYES_NO|wxICON_QUESTION) |
|
818 |
if messageDialog.ShowModal() == wxID_NO: |
|
819 |
abort = True |
|
820 |
messageDialog.Destroy() |
|
821 |
if not abort: |
|
822 |
old_name = self.ProjectTree.GetItemText(item) |
|
823 |
self.Controler.ChangePouName(old_name, new_name) |
|
824 |
self.RefreshTabsOpenedTitles() |
|
0 | 825 |
elif itemtype == ITEM_TRANSITION: |
6 | 826 |
category = self.ProjectTree.GetItemParent(item) |
827 |
pou = self.ProjectTree.GetItemParent(category) |
|
828 |
pou_name = self.ProjectTree.GetItemText(pou) |
|
829 |
if new_name.upper() in self.Controler.GetProjectPouNames(): |
|
830 |
message = "A pou with \"%s\" as name exists!"%new_name |
|
831 |
elif new_name.upper() in self.Controler.GetProjectPouVariables(pou_name): |
|
832 |
message = "A variable with \"%s\" as name already exists in this pou!"%new_name |
|
833 |
else: |
|
834 |
old_name = self.ProjectTree.GetItemText(item) |
|
835 |
self.Controler.ChangePouTransitionName(pou_name, old_name, new_name) |
|
836 |
self.RefreshTabsOpenedTitles() |
|
0 | 837 |
elif itemtype == ITEM_ACTION: |
6 | 838 |
category = self.ProjectTree.GetItemParent(item) |
839 |
pou = self.ProjectTree.GetItemParent(category) |
|
840 |
pou_name = self.ProjectTree.GetItemText(pou) |
|
841 |
if new_name.upper() in self.Controler.GetProjectPouNames(): |
|
842 |
message = "A pou with \"%s\" as name exists!"%new_name |
|
843 |
elif new_name.upper() in self.Controler.GetProjectPouVariables(pou_name): |
|
844 |
message = "A variable with \"%s\" as name already exists in this pou!"%new_name |
|
845 |
else: |
|
846 |
old_name = self.ProjectTree.GetItemText(item) |
|
847 |
self.Controler.ChangePouActionName(pou_name, old_name, new_name) |
|
848 |
self.RefreshTabsOpenedTitles() |
|
849 |
elif itemtype == ITEM_VARIABLE: |
|
850 |
category = self.ProjectTree.GetItemParent(item) |
|
851 |
if self.ProjectTree.GetItemText(category) != 'Global': |
|
852 |
category = self.ProjectTree.GetItemParent(category) |
|
853 |
pou = self.ProjectTree.GetItemParent(category) |
|
854 |
pou_name = self.ProjectTree.GetItemText(pou) |
|
855 |
if new_name.upper() in self.Controler.GetProjectPouNames(): |
|
856 |
message = "A pou with \"%s\" as name exists!"%new_name |
|
857 |
elif new_name.upper() in self.Controler.GetProjectPouVariables(pou_name): |
|
858 |
message = "A variable with \"%s\" as name already exists in this pou!"%new_name |
|
859 |
else: |
|
860 |
old_name = self.ProjectTree.GetItemText(item) |
|
861 |
self.Controler.ChangePouVariableName(pou_name, old_name, new_name) |
|
862 |
self.RefreshTabsOpenedTitles() |
|
863 |
if message or abort: |
|
864 |
if message: |
|
865 |
messageDialog = wxMessageDialog(self, message, "Error", wxOK|wxICON_ERROR) |
|
866 |
messageDialog.ShowModal() |
|
867 |
messageDialog.Destroy() |
|
0 | 868 |
item = event.GetItem() |
869 |
wxCallAfter(self.ProjectTree.EditLabel, item) |
|
870 |
event.Veto() |
|
6 | 871 |
else: |
872 |
wxCallAfter(self.RefreshProjectTree) |
|
873 |
event.Skip() |
|
0 | 874 |
|
875 |
def OnProjectTreeItemBeginEdit(self, event): |
|
876 |
selected = event.GetItem() |
|
877 |
if self.ProjectTree.GetPyData(selected) == ITEM_UNEDITABLE: |
|
878 |
event.Veto() |
|
879 |
else: |
|
880 |
event.Skip() |
|
881 |
||
882 |
def OnProjectTreeItemActivated(self, event): |
|
883 |
selected = event.GetItem() |
|
884 |
if self.ProjectTree.IsExpanded(selected): |
|
885 |
self.ProjectTree.Collapse(selected) |
|
886 |
else: |
|
887 |
self.ProjectTree.Expand(selected) |
|
888 |
name = self.ProjectTree.GetItemText(selected) |
|
889 |
data = self.ProjectTree.GetPyData(selected) |
|
890 |
if name == "Properties": |
|
27 | 891 |
self.ShowProperties() |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
892 |
## elif data == ITEM_CLASS: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
893 |
## item = self.ProjectTree.GetItemParent(selected) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
894 |
## item_type = self.ProjectTree.GetPyData(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
895 |
## while item_type not in [ITEM_POU, ITEM_RESOURCE, ITEM_CONFIGURATION] and item.IsOk(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
896 |
## item = self.ProjectTree.GetItemParent(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
897 |
## item_type = self.ProjectTree.GetPyData(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
898 |
## item_name = self.ProjectTree.GetItemText(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
899 |
## if item_type == ITEM_POU: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
900 |
## dialog = EditVariableDialog(self, item_name, self.Controler.GetPouType(item_name), self.Controler.PouIsUsed(item_name), name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
901 |
## dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
902 |
## values = {} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
903 |
## values["returnType"] = self.Controler.GetPouInterfaceReturnTypeByName(item_name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
904 |
## values["data"] = self.Controler.GetPouInterfaceVarsByName(item_name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
905 |
## dialog.SetValues(values) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
906 |
## if dialog.ShowModal() == wxID_OK: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
907 |
## new_values = dialog.GetValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
908 |
## if "returnType" in new_values: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
909 |
## self.Controler.SetPouInterfaceReturnType(item_name, new_values["returnType"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
910 |
## self.Controler.SetPouInterfaceVars(item_name, new_values["data"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
911 |
## pou_names = self.Controler.GetElementsOpenedNames() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
912 |
## if item_name in pou_names: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
913 |
## window = self.TabsOpened.GetPage(pou_names.index(item_name)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
914 |
## if isinstance(window, TextViewer): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
915 |
## varlist = [] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
916 |
## if "returnType" in new_values: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
917 |
## varlist.append(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
918 |
## for var in new_values["data"]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
919 |
## varlist.append(var["Name"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
920 |
## window.SetVariables(varlist) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
921 |
## dialog.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
922 |
## self.RefreshProjectTree() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
923 |
## elif item_type == ITEM_CONFIGURATION: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
924 |
## dialog = EditVariableDialog(self, item_name, None, False, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
925 |
## dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
926 |
## values = {"data" : self.Controler.GetConfigurationGlobalVars(item_name)} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
927 |
## dialog.SetValues(values) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
928 |
## if dialog.ShowModal() == wxID_OK: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
929 |
## new_values = dialog.GetValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
930 |
## self.Controler.SetConfigurationGlobalVars(item_name, new_values["data"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
931 |
## dialog.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
932 |
## self.RefreshProjectTree() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
933 |
## elif item_type == ITEM_RESOURCE: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
934 |
## config = self.ProjectTree.GetItemParent(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
935 |
## config_type = self.ProjectTree.GetPyData(config) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
936 |
## while config_type != ITEM_CONFIGURATION and config.IsOk(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
937 |
## config = self.ProjectTree.GetItemParent(config) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
938 |
## config_type = self.ProjectTree.GetPyData(config) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
939 |
## if config.IsOk(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
940 |
## config_name = self.ProjectTree.GetItemText(config) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
941 |
## dialog = EditVariableDialog(self, item_name, None, False, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
942 |
## values = {"data" : self.Controler.GetConfigurationResourceGlobalVars(config_name, item_name)} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
943 |
## dialog.SetValues(values) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
944 |
## if dialog.ShowModal() == wxID_OK: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
945 |
## new_values = dialog.GetValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
946 |
## self.Controler.SetConfigurationResourceGlobalVars(config_name, item_name, new_values["data"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
947 |
## dialog.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
948 |
## self.RefreshProjectTree() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
949 |
## elif data in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
950 |
## if data == ITEM_POU: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
951 |
## idx = self.Controler.OpenElementEditing(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
952 |
## language = self.Controler.GetPouBodyType(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
953 |
## varlist = [] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
954 |
## returnType = self.Controler.GetPouInterfaceReturnTypeByName(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
955 |
## if returnType: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
956 |
## varlist.append(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
957 |
## vars = self.Controler.GetPouInterfaceVarsByName(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
958 |
## if vars: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
959 |
## for var in vars: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
960 |
## varlist.append(var["Name"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
961 |
## self.EditVariable.SetPou(self.Controler.GetPouType(name), self.Controler.PouIsUsed(name)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
962 |
## self.EditVariable.SetValues({"returnType":returnType,"data":vars}) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
963 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
964 |
## parent = self.ProjectTree.GetItemParent(selected) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
965 |
## parent_name = self.ProjectTree.GetItemText(parent) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
966 |
## grandparent = self.ProjectTree.GetItemParent(parent) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
967 |
## grandparent_name = self.ProjectTree.GetItemText(grandparent) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
968 |
## if data == ITEM_TRANSITION: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
969 |
## idx = self.Controler.OpenPouTransitionEditing(grandparent_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
970 |
## language = self.Controler.GetTransitionBodyType(grandparent_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
971 |
## elif data == ITEM_ACTION: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
972 |
## idx = self.Controler.OpenPouActionEditing(grandparent_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
973 |
## language = self.Controler.GetActionBodyType(grandparent_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
974 |
## varlist = [name] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
975 |
## vars = self.Controler.GetPouInterfaceVarsByName(grandparent_name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
976 |
## if vars: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
977 |
## for var in vars: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
978 |
## varlist.append(var["Name"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
979 |
## self.EditVariable.SetPou(self.Controler.GetPouType(grandparent_name), self.Controler.PouIsUsed(grandparent_name)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
980 |
## self.EditVariable.SetValues({"returnType":returnType,"data":vars}) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
981 |
## if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
982 |
## if language == "FBD": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
983 |
## new_window = Viewer(self.TabsOpened, self, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
984 |
## elif language == "LD": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
985 |
## new_window = LD_Viewer(self.TabsOpened, self, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
986 |
## elif language == "SFC": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
987 |
## new_window = SFC_Viewer(self.TabsOpened, self, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
988 |
## elif language in ["IL", "ST"]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
989 |
## new_window = TextViewer(self.TabsOpened, self, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
990 |
## new_window.SetTextSyntax(language) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
991 |
## if language == "IL": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
992 |
## new_window.SetKeywords(IL_KEYWORDS) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
993 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
994 |
## new_window.SetKeywords(ST_KEYWORDS) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
995 |
## new_window.SetVariables(varlist) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
996 |
## new_window.SetFunctions(self.Controler.GetBlockTypes()) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
997 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
998 |
## return |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
999 |
## new_window.RefreshView() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1000 |
## self.TabsOpened.AddPage(new_window, "") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1001 |
## self.TabsOpened.SetSelection(idx) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1002 |
## self.RefreshTabsOpenedTitles() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1003 |
## self.RefreshFileMenu() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1004 |
## self.RefreshEditMenu() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1005 |
## self.RefreshToolBar() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1006 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1007 |
## if data == ITEM_POU: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1008 |
## idx = self.Controler.ChangeElementEditing(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1009 |
## elif data == ITEM_TRANSITION: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1010 |
## idx = self.Controler.ChangePouTransitionEditing(grandparent_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1011 |
## elif data == ITEM_ACTION: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1012 |
## idx = self.Controler.ChangePouActionEditing(grandparent_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1013 |
## if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1014 |
## self.TabsOpened.SetSelection(idx) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1015 |
## self.RefreshFileMenu() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1016 |
## self.RefreshEditMenu() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1017 |
## self.RefreshToolBar() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1018 |
## elif data == ITEM_RESOURCE: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1019 |
## item = self.ProjectTree.GetItemParent(selected) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1020 |
## item_type = self.ProjectTree.GetPyData(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1021 |
## while item_type != ITEM_CONFIGURATION: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1022 |
## item = self.ProjectTree.GetItemParent(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1023 |
## item_type = self.ProjectTree.GetPyData(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1024 |
## config_name = self.ProjectTree.GetItemText(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1025 |
## idx = self.Controler.OpenConfigurationResourceEditing(config_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1026 |
## if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1027 |
## new_window = ResourceEditor(self.TabsOpened, self, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1028 |
## new_window.RefreshView() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1029 |
## self.TabsOpened.AddPage(new_window, "") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1030 |
## self.TabsOpened.SetSelection(idx) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1031 |
## self.RefreshTabsOpenedTitles() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1032 |
## self.RefreshFileMenu() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1033 |
## self.RefreshEditMenu() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1034 |
## self.RefreshToolBar() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1035 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1036 |
## idx = self.Controler.ChangeConfigurationResourceEditing(parent_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1037 |
## if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1038 |
## self.TabsOpened.SetSelection(idx) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1039 |
## self.RefreshFileMenu() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1040 |
## self.RefreshEditMenu() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1041 |
## self.RefreshToolBar() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1042 |
elif data in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE, ITEM_CONFIGURATION]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1043 |
if data == ITEM_CONFIGURATION: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1044 |
idx = self.Controler.OpenConfigurationEditing(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1045 |
if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1046 |
new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "config", config_name = name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1047 |
self.TabsOpened.AddPage(new_window, "") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1048 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1049 |
idx = self.Controler.ChangeConfigurationEditing(name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1050 |
elif data == ITEM_RESOURCE: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1051 |
item = self.ProjectTree.GetItemParent(selected) |
0 | 1052 |
item_type = self.ProjectTree.GetPyData(item) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1053 |
while item_type != ITEM_CONFIGURATION: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1054 |
item = self.ProjectTree.GetItemParent(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1055 |
item_type = self.ProjectTree.GetPyData(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1056 |
config_name = self.ProjectTree.GetItemText(item) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1057 |
idx = self.Controler.OpenConfigurationResourceEditing(config_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1058 |
if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1059 |
new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "resource", config_name = config_name, resource_name = name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1060 |
self.TabsOpened.AddPage(new_window, "") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1061 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1062 |
idx = self.Controler.ChangeConfigurationResourceEditing(config_name, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1063 |
elif data == ITEM_POU: |
0 | 1064 |
idx = self.Controler.OpenElementEditing(name) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1065 |
if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1066 |
new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, self.Controler.GetPouType(name), pou_name = name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1067 |
self.TabsOpened.AddPage(new_window, "") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1068 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1069 |
idx = self.Controler.ChangeElementEditing(name) |
0 | 1070 |
else: |
1071 |
parent = self.ProjectTree.GetItemParent(selected) |
|
1072 |
parent_name = self.ProjectTree.GetItemText(parent) |
|
1073 |
grandparent = self.ProjectTree.GetItemParent(parent) |
|
1074 |
grandparent_name = self.ProjectTree.GetItemText(grandparent) |
|
1075 |
if data == ITEM_TRANSITION: |
|
1076 |
idx = self.Controler.OpenPouTransitionEditing(grandparent_name, name) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1077 |
if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1078 |
new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "transition", pou_name = grandparent_name, transition_name = name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1079 |
self.TabsOpened.AddPage(new_window, "") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1080 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1081 |
idx = self.Controler.ChangePouTransitionEditing(grandparent_name, name) |
0 | 1082 |
elif data == ITEM_ACTION: |
1083 |
idx = self.Controler.OpenPouActionEditing(grandparent_name, name) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1084 |
if idx != None: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1085 |
new_window = PouEditorPanel(self.TabsOpened, self, self.Controler, "action", pou_name = grandparent_name, action_name = name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1086 |
self.TabsOpened.AddPage(new_window, "") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1087 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1088 |
idx = self.Controler.ChangePouActionEditing(grandparent_name, name) |
0 | 1089 |
if idx != None: |
1090 |
self.TabsOpened.SetSelection(idx) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1091 |
window = self.TabsOpened.GetPage(idx) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1092 |
window.RefreshView() |
0 | 1093 |
self.RefreshTabsOpenedTitles() |
1094 |
self.RefreshFileMenu() |
|
1095 |
self.RefreshEditMenu() |
|
1096 |
self.RefreshToolBar() |
|
1097 |
||
1098 |
def OnProjectTreeRightUp(self, event): |
|
1099 |
selected = self.ProjectTree.GetSelection() |
|
1100 |
if self.ProjectTree.GetPyData(selected) == ITEM_POU: |
|
1101 |
name = self.ProjectTree.GetItemText(selected) |
|
1102 |
if self.Controler.GetPouBodyType(name) == "SFC": |
|
1103 |
self.PopupMenu(self.SFCMenu) |
|
1104 |
elif self.ProjectTree.GetPyData(selected) == ITEM_CONFIGURATION: |
|
1105 |
self.PopupMenu(self.ConfigMenu) |
|
1106 |
event.Skip() |
|
1107 |
||
1108 |
def OnProjectTreeItemSelected(self, event): |
|
1109 |
selected = event.GetItem() |
|
1110 |
name = self.ProjectTree.GetItemText(selected) |
|
1111 |
if self.ProjectTree.GetItemParent(selected) == self.ProjectTree.GetRootItem() and name != "Properties": |
|
1112 |
if self.Controler.IsElementEditing(name): |
|
1113 |
idx = self.Controler.ChangeElementEditing(name) |
|
1114 |
if idx != None: |
|
1115 |
self.TabsOpened.SetSelection(idx) |
|
1116 |
self.RefreshFileMenu() |
|
1117 |
self.RefreshEditMenu() |
|
1118 |
self.RefreshToolBar() |
|
1119 |
else: |
|
1120 |
name = self.ProjectTree.GetItemText(selected) |
|
1121 |
parent = self.ProjectTree.GetItemParent(selected) |
|
1122 |
parent_name = self.ProjectTree.GetItemText(parent) |
|
1123 |
grandparent = self.ProjectTree.GetItemParent(parent) |
|
1124 |
grandparent_name = self.ProjectTree.GetItemText(grandparent) |
|
1125 |
if parent_name == "Transitions": |
|
1126 |
idx = self.Controler.ChangePouTransitionEditing(grandparent_name, name) |
|
1127 |
if idx != None: |
|
1128 |
self.TabsOpened.SetSelection(idx) |
|
1129 |
self.RefreshFileMenu() |
|
1130 |
self.RefreshEditMenu() |
|
1131 |
self.RefreshToolBar() |
|
1132 |
elif parent_name == "Action": |
|
1133 |
idx = self.Controler.ChangePouActionEditing(grandparent_name, name) |
|
1134 |
if idx != None: |
|
1135 |
self.TabsOpened.SetSelection(idx) |
|
1136 |
self.RefreshFileMenu() |
|
1137 |
self.RefreshEditMenu() |
|
1138 |
self.RefreshToolBar() |
|
1139 |
event.Skip() |
|
1140 |
||
1141 |
def RefreshProjectTree(self): |
|
1142 |
infos = self.Controler.GetProjectInfos() |
|
1143 |
root = self.ProjectTree.GetRootItem() |
|
1144 |
self.GenerateTreeBranch(root, infos) |
|
1145 |
self.ProjectTree.Expand(self.ProjectTree.GetRootItem()) |
|
1146 |
||
1147 |
def GenerateTreeBranch(self, root, infos): |
|
1148 |
to_delete = [] |
|
1149 |
if root.IsOk(): |
|
1150 |
self.ProjectTree.SetItemText(root, infos["name"]) |
|
1151 |
else: |
|
1152 |
root = self.ProjectTree.AddRoot(infos["name"]) |
|
1153 |
self.ProjectTree.SetPyData(root, infos["type"]) |
|
9 | 1154 |
if infos["type"] == ITEM_POU: |
1155 |
self.ProjectTree.SetItemImage(root, LANGUAGES.index(self.Controler.GetPouBodyType(infos["name"]))) |
|
0 | 1156 |
item, root_cookie = self.ProjectTree.GetFirstChild(root) |
1157 |
if len(infos["values"]) > 0: |
|
1158 |
for values in infos["values"]: |
|
1159 |
if not item.IsOk(): |
|
1160 |
item = self.ProjectTree.AppendItem(root, "") |
|
1161 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
1162 |
self.GenerateTreeBranch(item, values) |
|
1163 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
1164 |
while item.IsOk(): |
|
1165 |
to_delete.append(item) |
|
27 | 1166 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
0 | 1167 |
for item in to_delete: |
1168 |
self.ProjectTree.Delete(item) |
|
27 | 1169 |
|
6 | 1170 |
def ResetToolBar(self): |
1171 |
for item in self.CurrentToolBar: |
|
27 | 1172 |
self.Unbind(wx.EVT_MENU, id=item) |
6 | 1173 |
self.ToolBar.DeleteTool(item) |
1174 |
||
0 | 1175 |
def RefreshToolBar(self): |
1176 |
language = self.Controler.GetCurrentElementEditingBodyType() |
|
27 | 1177 |
if language and language != self.CurrentLanguage: |
1178 |
self.ResetToolBar() |
|
1179 |
self.CurrentLanguage = language |
|
1180 |
self.CurrentToolBar = [] |
|
1181 |
for radio, modes, id, method, picture, help in ToolBarItems[language]: |
|
1182 |
if modes & self.DrawingMode: |
|
1183 |
if radio or self.DrawingMode == FREEDRAWING_MODE: |
|
1184 |
self.ToolBar.AddRadioTool(id, wxBitmap(os.path.join(CWD, picture)), wxNullBitmap, help) |
|
1185 |
else: |
|
1186 |
self.ToolBar.AddSimpleTool(id, wxBitmap(os.path.join(CWD, picture)), help) |
|
1187 |
self.Bind(wx.EVT_TOOL, getattr(self, method), id=id) |
|
1188 |
self.CurrentToolBar.append(id) |
|
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
1189 |
self.ResetCurrentMode() |
0 | 1190 |
|
1191 |
def RefreshTabsOpenedTitles(self): |
|
1192 |
pous = self.Controler.GetElementsOpenedNames() |
|
1193 |
for i, pou in enumerate(pous): |
|
1194 |
self.TabsOpened.SetPageText(i, pou) |
|
1195 |
||
1196 |
def OnRefreshMenu(self, event): |
|
1197 |
selected = self.TabsOpened.GetSelection() |
|
1198 |
if selected != -1: |
|
1199 |
self.TabsOpened.GetPage(selected).Refresh() |
|
1200 |
event.Skip() |
|
1201 |
||
1202 |
def OnCutMenu(self, event): |
|
1203 |
selected = self.TabsOpened.GetSelection() |
|
1204 |
if selected != -1: |
|
1205 |
self.TabsOpened.GetPage(selected).Cut() |
|
1206 |
event.Skip() |
|
1207 |
||
1208 |
def OnCopyMenu(self, event): |
|
1209 |
selected = self.TabsOpened.GetSelection() |
|
1210 |
if selected != -1: |
|
1211 |
self.TabsOpened.GetPage(selected).Copy() |
|
1212 |
event.Skip() |
|
1213 |
||
1214 |
def OnPasteMenu(self, event): |
|
1215 |
selected = self.TabsOpened.GetSelection() |
|
1216 |
if selected != -1: |
|
1217 |
self.TabsOpened.GetPage(selected).Paste() |
|
1218 |
event.Skip() |
|
1219 |
||
1220 |
def OnAddPouMenu(self, event): |
|
1221 |
dialog = PouDialog(self) |
|
1222 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1223 |
if dialog.ShowModal() == wxID_OK: |
|
1224 |
values = dialog.GetValues() |
|
1225 |
self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"]) |
|
1226 |
self.RefreshProjectTree() |
|
1227 |
dialog.Destroy() |
|
1228 |
event.Skip() |
|
1229 |
||
1230 |
def OnRemovePouMenu(self, event): |
|
1231 |
pous = self.Controler.GetProjectPouNames() |
|
1232 |
dialog = wxSingleChoiceDialog(self, "Select POU to remove:", "POU Remove", pous, wxOK|wxCANCEL) |
|
1233 |
if dialog.ShowModal() == wxID_OK: |
|
1234 |
selected = dialog.GetStringSelection() |
|
1235 |
if not self.Controler.PouIsUsed(selected): |
|
1236 |
self.Controler.ProjectRemovePou(selected) |
|
1237 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
1238 |
if self.TabsOpened.GetPageText(i) == selected: |
|
1239 |
self.TabsOpened.DeletePage(i) |
|
1240 |
self.RefreshProjectTree() |
|
1241 |
self.RefreshToolBar() |
|
1242 |
else: |
|
1243 |
message = wxMessageDialog(self, "%s is used by one or more POUs. It can't be removed!"%selected, "Error", wxOK|wxICON_ERROR) |
|
1244 |
message.ShowModal() |
|
1245 |
message.Destroy() |
|
1246 |
event.Skip() |
|
1247 |
||
1248 |
def OnAddConfigurationMenu(self, event): |
|
1249 |
dialog = wxTextEntryDialog(self, "Enter configuration name:", "Create new configuration", "", wxOK|wxCANCEL) |
|
1250 |
if dialog.ShowModal() == wxID_OK: |
|
1251 |
value = dialog.GetValue() |
|
1252 |
self.Controler.ProjectAddConfiguration(value) |
|
1253 |
self.RefreshProjectTree() |
|
1254 |
dialog.Destroy() |
|
1255 |
event.Skip() |
|
1256 |
||
1257 |
def OnRemoveConfigurationMenu(self, event): |
|
1258 |
configs = self.Controler.GetProjectConfigNames() |
|
46 | 1259 |
dialog = wxSingleChoiceDialog(self, "Select Configuration to remove:", "Remove configuration", configs, wxOK|wxCANCEL) |
0 | 1260 |
if dialog.ShowModal() == wxID_OK: |
1261 |
selected = dialog.GetStringSelection() |
|
1262 |
self.Controler.ProjectRemoveConfiguration(selected) |
|
1263 |
self.RefreshProjectTree() |
|
1264 |
event.Skip() |
|
1265 |
||
1266 |
def OnAddPouTransitionMenu(self, event): |
|
45 | 1267 |
selected = self.ProjectTree.GetSelection() |
1268 |
if self.ProjectTree.GetPyData(selected) == ITEM_POU: |
|
1269 |
pouname = self.ProjectTree.GetItemText(selected) |
|
1270 |
if self.Controler.GetPouBodyType(pouname) == "SFC": |
|
1271 |
dialog = PouTransitionDialog(self) |
|
1272 |
if dialog.ShowModal() == wxID_OK: |
|
1273 |
values = dialog.GetValues() |
|
1274 |
self.Controler.ProjectAddPouTransition(pouname, values["transitionName"], values["language"]) |
|
1275 |
self.RefreshProjectTree() |
|
1276 |
dialog.Destroy() |
|
0 | 1277 |
event.Skip() |
1278 |
||
1279 |
def OnRemovePouTransitionMenu(self, event): |
|
46 | 1280 |
selected = self.ProjectTree.GetSelection() |
1281 |
if self.ProjectTree.GetPyData(selected) == ITEM_POU: |
|
1282 |
pouname = self.ProjectTree.GetItemText(selected) |
|
1283 |
if self.Controler.GetPouBodyType(pouname) == "SFC": |
|
1284 |
transitions = self.Controler.GetPouTransitions(pouname) |
|
1285 |
dialog = wxSingleChoiceDialog(self, "Select Transition to remove:", "Remove transition", transitions, wxOK|wxCANCEL) |
|
1286 |
if dialog.ShowModal() == wxID_OK: |
|
1287 |
selected = dialog.GetStringSelection() |
|
1288 |
self.Controler.ProjectRemovePouTransition(pouname, selected) |
|
1289 |
self.RefreshProjectTree() |
|
1290 |
dialog.Destroy() |
|
0 | 1291 |
event.Skip() |
1292 |
||
1293 |
def OnAddPouActionMenu(self, event): |
|
45 | 1294 |
selected = self.ProjectTree.GetSelection() |
1295 |
if self.ProjectTree.GetPyData(selected) == ITEM_POU: |
|
1296 |
pouname = self.ProjectTree.GetItemText(selected) |
|
1297 |
if self.Controler.GetPouBodyType(pouname) == "SFC": |
|
1298 |
dialog = PouActionDialog(self) |
|
1299 |
if dialog.ShowModal() == wxID_OK: |
|
1300 |
values = dialog.GetValues() |
|
1301 |
self.Controler.ProjectAddPouAction(pouname, values["actionName"], values["language"]) |
|
1302 |
self.RefreshProjectTree() |
|
1303 |
dialog.Destroy() |
|
0 | 1304 |
event.Skip() |
1305 |
||
1306 |
def OnRemovePouActionMenu(self, event): |
|
46 | 1307 |
selected = self.ProjectTree.GetSelection() |
1308 |
if self.ProjectTree.GetPyData(selected) == ITEM_POU: |
|
1309 |
pouname = self.ProjectTree.GetItemText(selected) |
|
1310 |
if self.Controler.GetPouBodyType(pouname) == "SFC": |
|
1311 |
actions = self.Controler.GetPouActions(pouname) |
|
1312 |
dialog = wxSingleChoiceDialog(self, "Select Action to remove:", "Remove action", actions, wxOK|wxCANCEL) |
|
1313 |
if dialog.ShowModal() == wxID_OK: |
|
1314 |
selected = dialog.GetStringSelection() |
|
1315 |
self.Controler.ProjectRemovePouAction(pouname, selected) |
|
1316 |
self.RefreshProjectTree() |
|
1317 |
dialog.Destroy() |
|
0 | 1318 |
event.Skip() |
1319 |
||
1320 |
def OnAddResourceMenu(self, event): |
|
1321 |
selected = self.ProjectTree.GetSelection() |
|
1322 |
if self.ProjectTree.GetPyData(selected) == ITEM_CONFIGURATION: |
|
1323 |
config_name = self.ProjectTree.GetItemText(selected) |
|
1324 |
dialog = wxTextEntryDialog(self, "Enter Resource name:", "Create new Resource", "", wxOK|wxCANCEL) |
|
1325 |
if dialog.ShowModal() == wxID_OK: |
|
1326 |
value = dialog.GetValue() |
|
1327 |
self.Controler.ProjectAddConfigurationResource(config_name, value) |
|
1328 |
self.RefreshProjectTree() |
|
1329 |
dialog.Destroy() |
|
1330 |
event.Skip() |
|
1331 |
||
1332 |
def OnRemoveResourceMenu(self, event): |
|
1333 |
selected = self.ProjectTree.GetSelection() |
|
1334 |
if self.ProjectTree.GetPyData(selected) == ITEM_CONFIGURATION: |
|
1335 |
config_name = self.ProjectTree.GetItemText(selected) |
|
1336 |
infos = self.Controler.GetProjectInfos() |
|
1337 |
resources = [] |
|
1338 |
for config in infos["configs"]: |
|
1339 |
if config["name"] == config_name: |
|
1340 |
resources = config["resources"] |
|
46 | 1341 |
dialog = wxSingleChoiceDialog(self, "Select Resource to remove:", "Remove resource", resources, wxOK|wxCANCEL) |
0 | 1342 |
if dialog.ShowModal() == wxID_OK: |
1343 |
resource = dialog.GetStringSelection() |
|
1344 |
self.Controler.ProjectRemoveConfigurationResource(config_name, resource) |
|
1345 |
self.RefreshProjectTree() |
|
1346 |
dialog.Destroy() |
|
1347 |
event.Skip() |
|
1348 |
||
1349 |
def OnPLCOpenMenu(self, event): |
|
1350 |
result = OpenPDFDoc() |
|
1351 |
if type(result) == StringType: |
|
1352 |
message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR) |
|
1353 |
message.ShowModal() |
|
1354 |
message.Destroy() |
|
1355 |
event.Skip() |
|
1356 |
||
1357 |
current_num = 0 |
|
1358 |
def GetNewNum(): |
|
1359 |
global current_num |
|
1360 |
current_num += 1 |
|
1361 |
return current_num |
|
1362 |
||
1363 |
#------------------------------------------------------------------------------- |
|
1364 |
# Create Project Dialog |
|
1365 |
#------------------------------------------------------------------------------- |
|
1366 |
||
1367 |
[wxID_PROJECTDIALOG, wxID_PROJECTDIALOGMAINPANEL, |
|
1368 |
wxID_PROJECTDIALOGPROJECTNAME, wxID_PROJECTDIALOGCOMPANYNAME, |
|
1369 |
wxID_PROJECTDIALOGCOMPANYURL, wxID_PROJECTDIALOGPRODUCTNAME, |
|
1370 |
wxID_PROJECTDIALOGPRODUCTVERSION, wxID_PROJECTDIALOGPRODUCTRELEASE, |
|
1371 |
wxID_PROJECTDIALOGCONTENTDESCRIPTION, wxID_PROJECTDIALOGSTATICTEXT1, |
|
1372 |
wxID_PROJECTDIALOGSTATICTEXT2, wxID_PROJECTDIALOGSTATICTEXT3, |
|
1373 |
wxID_PROJECTDIALOGSTATICTEXT4, wxID_PROJECTDIALOGSTATICTEXT5, |
|
1374 |
wxID_PROJECTDIALOGSTATICTEXT6, wxID_PROJECTDIALOGSTATICTEXT7, |
|
1375 |
] = [wx.NewId() for _init_ctrls in range(16)] |
|
1376 |
||
1377 |
class ProjectDialog(wx.Dialog): |
|
1378 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
1379 |
# generated method, don't edit |
|
1380 |
||
1381 |
parent.AddWindow(self.MainPanel, 0, border=0, flag=0) |
|
1382 |
||
1383 |
def _init_sizers(self): |
|
1384 |
# generated method, don't edit |
|
1385 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
1386 |
||
1387 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
1388 |
||
1389 |
self.SetSizer(self.flexGridSizer1) |
|
1390 |
||
1391 |
def _init_ctrls(self, prnt): |
|
1392 |
# generated method, don't edit |
|
1393 |
wx.Dialog.__init__(self, id=wxID_PROJECTDIALOG, |
|
1394 |
name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223), |
|
1395 |
size=wx.Size(550, 450), style=wx.DEFAULT_DIALOG_STYLE, |
|
1396 |
title='Create a new project') |
|
1397 |
self.SetClientSize(wx.Size(550, 450)) |
|
1398 |
||
1399 |
self.MainPanel = wx.Panel(id=wxID_PROJECTDIALOGMAINPANEL, |
|
1400 |
name='MainPanel', parent=self, pos=wx.Point(0, 0), |
|
1401 |
size=wx.Size(450, 400), style=wx.TAB_TRAVERSAL) |
|
1402 |
self.MainPanel.SetAutoLayout(True) |
|
1403 |
||
1404 |
self.staticText1 = wx.StaticText(id=wxID_PROJECTDIALOGSTATICTEXT1, |
|
1405 |
label='Project Name (required):', name='staticText1', parent=self.MainPanel, |
|
1406 |
pos=wx.Point(24, 24), size=wx.Size(215, 17), style=0) |
|
1407 |
||
1408 |
self.ProjectName = wx.TextCtrl(id=wxID_PROJECTDIALOGPROJECTNAME, |
|
1409 |
name='ProjectName', parent=self.MainPanel, pos=wx.Point(224, 24), |
|
1410 |
size=wx.Size(295, 24), style=0) |
|
1411 |
||
1412 |
self.staticText2 = wx.StaticText(id=wxID_PROJECTDIALOGSTATICTEXT2, |
|
1413 |
label='Company Name (required):', name='staticText2', parent=self.MainPanel, |
|
1414 |
pos=wx.Point(24, 64), size=wx.Size(215, 17), style=0) |
|
1415 |
||
1416 |
self.CompanyName = wx.TextCtrl(id=wxID_PROJECTDIALOGCOMPANYNAME, |
|
1417 |
name='CompanyName', parent=self.MainPanel, pos=wx.Point(224, 64), |
|
1418 |
size=wx.Size(295, 24), style=0) |
|
1419 |
||
1420 |
self.staticText3 = wx.StaticText(id=wxID_PROJECTDIALOGSTATICTEXT3, |
|
1421 |
label='Company URL (optional):', name='staticText3', parent=self.MainPanel, |
|
1422 |
pos=wx.Point(24, 104), size=wx.Size(215, 17), style=0) |
|
1423 |
||
1424 |
self.CompanyURL = wx.TextCtrl(id=wxID_PROJECTDIALOGCOMPANYURL, |
|
1425 |
name='CompanyURL', parent=self.MainPanel, pos=wx.Point(224, 104), |
|
1426 |
size=wx.Size(295, 24), style=0) |
|
1427 |
||
1428 |
self.staticText4 = wx.StaticText(id=wxID_PROJECTDIALOGSTATICTEXT4, |
|
1429 |
label='Product Name (required):', name='staticText4', parent=self.MainPanel, |
|
1430 |
pos=wx.Point(24, 144), size=wx.Size(215, 17), style=0) |
|
1431 |
||
1432 |
self.ProductName = wx.TextCtrl(id=wxID_PROJECTDIALOGPRODUCTNAME, |
|
1433 |
name='ProductName', parent=self.MainPanel, pos=wx.Point(224, 144), |
|
1434 |
size=wx.Size(295, 24), style=0) |
|
1435 |
||
1436 |
self.staticText5 = wx.StaticText(id=wxID_PROJECTDIALOGSTATICTEXT5, |
|
1437 |
label='Product Version (required):', name='staticText5', parent=self.MainPanel, |
|
1438 |
pos=wx.Point(24, 184), size=wx.Size(215, 17), style=0) |
|
1439 |
||
1440 |
self.ProductVersion = wx.TextCtrl(id=wxID_PROJECTDIALOGPRODUCTVERSION, |
|
1441 |
name='ProductVersion', parent=self.MainPanel, pos=wx.Point(224, 184), |
|
1442 |
size=wx.Size(295, 24), style=0) |
|
1443 |
||
1444 |
self.staticText6 = wx.StaticText(id=wxID_PROJECTDIALOGSTATICTEXT6, |
|
1445 |
label='Product Release (optional):', name='staticText6', parent=self.MainPanel, |
|
1446 |
pos=wx.Point(24, 224), size=wx.Size(215, 17), style=0) |
|
1447 |
||
1448 |
self.ProductRelease = wx.TextCtrl(id=wxID_PROJECTDIALOGPRODUCTRELEASE, |
|
1449 |
name='ProductRelease', parent=self.MainPanel, pos=wx.Point(224, 224), |
|
1450 |
size=wx.Size(295, 24), style=0) |
|
1451 |
||
1452 |
self.staticText7 = wx.StaticText(id=wxID_PROJECTDIALOGSTATICTEXT7, |
|
1453 |
label='Content Description (optional):', name='staticText7', parent=self.MainPanel, |
|
1454 |
pos=wx.Point(24, 264), size=wx.Size(215, 17), style=0) |
|
1455 |
||
1456 |
self.ContentDescription = wx.TextCtrl(id=wxID_PROJECTDIALOGCONTENTDESCRIPTION, |
|
1457 |
name='ProductRelease', parent=self.MainPanel, pos=wx.Point(224, 264), |
|
1458 |
size=wx.Size(295, 120), style=wxTE_MULTILINE) |
|
1459 |
||
1460 |
self._init_sizers() |
|
1461 |
||
1462 |
def __init__(self, parent): |
|
1463 |
self._init_ctrls(parent) |
|
9 | 1464 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
0 | 1465 |
self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
1466 |
||
1467 |
EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
|
1468 |
||
1469 |
def OnOK(self, event): |
|
1470 |
error = [] |
|
1471 |
if self.ProjectName.GetValue() == "": |
|
1472 |
error.append("Project Name") |
|
1473 |
if self.CompanyName.GetValue() == "": |
|
1474 |
error.append("Company Name") |
|
1475 |
if self.ProductName.GetValue() == "": |
|
1476 |
error.append("Product Name") |
|
1477 |
if self.ProductVersion.GetValue() == "": |
|
1478 |
error.append("Product Version") |
|
1479 |
if len(error) > 0: |
|
1480 |
text = "" |
|
1481 |
for i, item in enumerate(error): |
|
1482 |
if i == 0: |
|
1483 |
text += item |
|
1484 |
elif i == len(error) - 1: |
|
1485 |
text += " and %s"%item |
|
1486 |
else: |
|
1487 |
text += ", %s"%item |
|
1488 |
message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR) |
|
1489 |
message.ShowModal() |
|
1490 |
message.Destroy() |
|
1491 |
else: |
|
1492 |
self.EndModal(wxID_OK) |
|
1493 |
||
1494 |
def SetValues(self, values): |
|
1495 |
for item, value in values.items(): |
|
1496 |
if item == "projectName": |
|
1497 |
self.ProjectName.SetValue(value) |
|
1498 |
elif item == "companyName": |
|
1499 |
self.CompanyName.SetValue(value) |
|
1500 |
elif item == "companyURL": |
|
1501 |
self.CompanyURL.SetValue(value) |
|
1502 |
elif item == "productName": |
|
1503 |
self.ProductName.SetValue(value) |
|
1504 |
elif item == "productVersion": |
|
1505 |
self.ProductVersion.SetValue(value) |
|
1506 |
elif item == "productRelease": |
|
1507 |
self.ProductRelease.SetValue(value) |
|
1508 |
elif item == "contentDescription": |
|
1509 |
self.ContentDescription.SetValue(value) |
|
1510 |
||
1511 |
def GetValues(self): |
|
1512 |
values = {} |
|
1513 |
values["projectName"] = self.ProjectName.GetValue() |
|
1514 |
values["companyName"] = self.CompanyName.GetValue() |
|
1515 |
if self.CompanyURL.GetValue() != None: |
|
1516 |
values["companyURL"] = self.CompanyURL.GetValue() |
|
1517 |
values["productName"] = self.ProductName.GetValue() |
|
1518 |
values["productVersion"] = self.ProductVersion.GetValue() |
|
1519 |
if self.ProductRelease.GetValue() != None: |
|
1520 |
values["productRelease"] = self.ProductRelease.GetValue() |
|
1521 |
if self.ProductRelease.GetValue() != None: |
|
1522 |
values["contentDescription"] = self.ContentDescription.GetValue() |
|
1523 |
return values |
|
1524 |
||
1525 |
#------------------------------------------------------------------------------- |
|
1526 |
# Create Pou Dialog |
|
1527 |
#------------------------------------------------------------------------------- |
|
1528 |
||
1529 |
[wxID_POUDIALOG, wxID_POUDIALOGMAINPANEL, wxID_POUDIALOGPOUNAME, |
|
1530 |
wxID_POUDIALOGPOUTYPE, wxID_POUDIALOGLANGUAGE, wxID_POUDIALOGSTATICTEXT1, |
|
1531 |
wxID_POUDIALOGSTATICTEXT2, wxID_POUDIALOGSTATICTEXT3, |
|
1532 |
] = [wx.NewId() for _init_ctrls in range(8)] |
|
1533 |
||
1534 |
class PouDialog(wx.Dialog): |
|
1535 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
1536 |
# generated method, don't edit |
|
1537 |
||
1538 |
parent.AddWindow(self.MainPanel, 0, border=0, flag=0) |
|
1539 |
||
1540 |
def _init_sizers(self): |
|
1541 |
# generated method, don't edit |
|
1542 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
1543 |
||
1544 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
1545 |
||
1546 |
self.SetSizer(self.flexGridSizer1) |
|
1547 |
||
1548 |
def _init_ctrls(self, prnt): |
|
1549 |
# generated method, don't edit |
|
1550 |
wx.Dialog.__init__(self, id=wxID_POUDIALOG, |
|
16 | 1551 |
name='PouDialog', parent=prnt, pos=wx.Point(376, 223), |
0 | 1552 |
size=wx.Size(300, 200), style=wx.DEFAULT_DIALOG_STYLE, |
16 | 1553 |
title='Create a new POU') |
0 | 1554 |
self.SetClientSize(wx.Size(300, 200)) |
1555 |
||
1556 |
self.MainPanel = wx.Panel(id=wxID_POUDIALOGMAINPANEL, |
|
1557 |
name='MainPanel', parent=self, pos=wx.Point(0, 0), |
|
1558 |
size=wx.Size(300, 200), style=wx.TAB_TRAVERSAL) |
|
1559 |
self.MainPanel.SetAutoLayout(True) |
|
1560 |
||
1561 |
self.staticText1 = wx.StaticText(id=wxID_POUDIALOGSTATICTEXT1, |
|
1562 |
label='POU Name:', name='staticText1', parent=self.MainPanel, |
|
1563 |
pos=wx.Point(24, 24), size=wx.Size(95, 17), style=0) |
|
1564 |
||
1565 |
self.PouName = wx.TextCtrl(id=wxID_POUDIALOGPOUNAME, |
|
1566 |
name='POUName', parent=self.MainPanel, pos=wx.Point(104, 24), |
|
1567 |
size=wx.Size(150, 24), style=0) |
|
1568 |
||
1569 |
self.staticText2 = wx.StaticText(id=wxID_POUDIALOGSTATICTEXT2, |
|
1570 |
label='POU Type:', name='staticText2', parent=self.MainPanel, |
|
1571 |
pos=wx.Point(24, 64), size=wx.Size(95, 17), style=0) |
|
1572 |
||
1573 |
self.PouType = wx.Choice(id=wxID_POUDIALOGPOUTYPE, |
|
1574 |
name='POUType', parent=self.MainPanel, pos=wx.Point(104, 64), |
|
1575 |
size=wx.Size(150, 24), style=0) |
|
1576 |
EVT_CHOICE(self, wxID_POUDIALOGPOUTYPE, self.OnTypeChanged) |
|
1577 |
||
1578 |
self.staticText3 = wx.StaticText(id=wxID_POUDIALOGSTATICTEXT3, |
|
1579 |
label='Language:', name='staticText3', parent=self.MainPanel, |
|
1580 |
pos=wx.Point(24, 104), size=wx.Size(95, 17), style=0) |
|
1581 |
||
1582 |
self.Language = wx.Choice(id=wxID_POUDIALOGLANGUAGE, |
|
1583 |
name='Language', parent=self.MainPanel, pos=wx.Point(104, 104), |
|
1584 |
size=wx.Size(150, 24), style=0) |
|
1585 |
||
1586 |
self._init_sizers() |
|
1587 |
||
1588 |
def __init__(self, parent): |
|
1589 |
self._init_ctrls(parent) |
|
9 | 1590 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
0 | 1591 |
self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
1592 |
||
1593 |
for option in ["function","functionBlock","program"]: |
|
1594 |
self.PouType.Append(option) |
|
1595 |
self.RefreshLanguage() |
|
1596 |
||
6 | 1597 |
self.PouNames = [] |
1598 |
||
0 | 1599 |
EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
1600 |
||
1601 |
def OnOK(self, event): |
|
1602 |
error = [] |
|
1603 |
pou_name = self.PouName.GetValue() |
|
1604 |
if pou_name == "": |
|
1605 |
error.append("POU Name") |
|
1606 |
if self.PouType.GetStringSelection() == "": |
|
1607 |
error.append("POU Type") |
|
1608 |
if self.Language.GetStringSelection() == "": |
|
1609 |
error.append("Language") |
|
1610 |
if len(error) > 0: |
|
1611 |
text = "" |
|
1612 |
for i, item in enumerate(error): |
|
1613 |
if i == 0: |
|
1614 |
text += item |
|
1615 |
elif i == len(error) - 1: |
|
1616 |
text += " and %s"%item |
|
1617 |
else: |
|
1618 |
text += ", %s"%item |
|
1619 |
message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR) |
|
1620 |
message.ShowModal() |
|
1621 |
message.Destroy() |
|
1622 |
elif not TestIdentifier(pou_name): |
|
1623 |
message = wxMessageDialog(self, "\"%s\" is not a valid identifier!"%pou_name, "Error", wxOK|wxICON_ERROR) |
|
1624 |
message.ShowModal() |
|
1625 |
message.Destroy() |
|
1626 |
elif pou_name.upper() in IEC_KEYWORDS: |
|
1627 |
message = wxMessageDialog(self, "\"%s\" is a keyword. It can't be used!"%pou_name, "Error", wxOK|wxICON_ERROR) |
|
1628 |
message.ShowModal() |
|
1629 |
message.Destroy() |
|
1630 |
elif pou_name.upper() in self.PouNames: |
|
1631 |
message = wxMessageDialog(self, "\"%s\" pou already exists!"%pou_name, "Error", wxOK|wxICON_ERROR) |
|
1632 |
message.ShowModal() |
|
1633 |
message.Destroy() |
|
1634 |
else: |
|
1635 |
self.EndModal(wxID_OK) |
|
1636 |
||
1637 |
def RefreshLanguage(self): |
|
1638 |
selection = self.Language.GetStringSelection() |
|
1639 |
self.Language.Clear() |
|
1640 |
for option in ["IL","ST","LD","FBD","SFC"]: |
|
1641 |
if option != "SFC" or self.PouType.GetStringSelection() == "program": |
|
1642 |
self.Language.Append(option) |
|
1643 |
if self.Language.FindString(selection) != wxNOT_FOUND: |
|
1644 |
self.Language.SetStringSelection(selection) |
|
1645 |
||
1646 |
def OnTypeChanged(self, event): |
|
1647 |
self.RefreshLanguage() |
|
1648 |
event.Skip() |
|
1649 |
||
1650 |
def SetPouNames(self, pou_names): |
|
1651 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
1652 |
||
1653 |
def SetValues(self, values): |
|
1654 |
for item, value in values.items(): |
|
1655 |
if item == "pouName": |
|
1656 |
self.PouName.SetValue(value) |
|
1657 |
elif item == "pouType": |
|
1658 |
self.PouType.SetStringSelection(value) |
|
1659 |
elif item == "language": |
|
1660 |
self.Language.SetStringSelection(value) |
|
1661 |
||
1662 |
def GetValues(self): |
|
1663 |
values = {} |
|
1664 |
values["pouName"] = self.PouName.GetValue() |
|
1665 |
values["pouType"] = self.PouType.GetStringSelection() |
|
1666 |
values["language"] = self.Language.GetStringSelection() |
|
1667 |
return values |
|
1668 |
||
1669 |
||
1670 |
#------------------------------------------------------------------------------- |
|
1671 |
# Create Pou Transition Dialog |
|
1672 |
#------------------------------------------------------------------------------- |
|
1673 |
||
1674 |
[wxID_POUTRANSITIONDIALOG, wxID_POUTRANSITIONDIALOGMAINPANEL, |
|
45 | 1675 |
wxID_POUTRANSITIONDIALOGTRANSITIONNAME, wxID_POUTRANSITIONDIALOGLANGUAGE, |
1676 |
wxID_POUTRANSITIONDIALOGSTATICTEXT1, wxID_POUTRANSITIONDIALOGSTATICTEXT2, |
|
1677 |
] = [wx.NewId() for _init_ctrls in range(6)] |
|
0 | 1678 |
|
1679 |
class PouTransitionDialog(wx.Dialog): |
|
1680 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
1681 |
# generated method, don't edit |
|
1682 |
||
1683 |
parent.AddWindow(self.MainPanel, 0, border=0, flag=0) |
|
1684 |
||
1685 |
def _init_sizers(self): |
|
1686 |
# generated method, don't edit |
|
1687 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
1688 |
||
1689 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
1690 |
||
1691 |
self.SetSizer(self.flexGridSizer1) |
|
1692 |
||
1693 |
def _init_ctrls(self, prnt): |
|
1694 |
# generated method, don't edit |
|
1695 |
wx.Dialog.__init__(self, id=wxID_POUTRANSITIONDIALOG, |
|
45 | 1696 |
name='PouTransitionDialog', parent=prnt, pos=wx.Point(376, 223), |
0 | 1697 |
size=wx.Size(350, 200), style=wx.DEFAULT_DIALOG_STYLE, |
45 | 1698 |
title='Create a new transition') |
1699 |
self.SetClientSize(wx.Size(350, 160)) |
|
0 | 1700 |
|
1701 |
self.MainPanel = wx.Panel(id=wxID_POUTRANSITIONDIALOGMAINPANEL, |
|
1702 |
name='MainPanel', parent=self, pos=wx.Point(0, 0), |
|
1703 |
size=wx.Size(350, 200), style=wx.TAB_TRAVERSAL) |
|
1704 |
self.MainPanel.SetAutoLayout(True) |
|
1705 |
||
1706 |
self.staticText1 = wx.StaticText(id=wxID_POUTRANSITIONDIALOGSTATICTEXT1, |
|
45 | 1707 |
label='Transition Name:', name='staticText1', parent=self.MainPanel, |
0 | 1708 |
pos=wx.Point(24, 24), size=wx.Size(145, 17), style=0) |
1709 |
||
45 | 1710 |
self.TransitionName = wx.TextCtrl(id=wxID_POUTRANSITIONDIALOGTRANSITIONNAME, |
1711 |
name='TransitionName', parent=self.MainPanel, pos=wx.Point(154, 24), |
|
0 | 1712 |
size=wx.Size(150, 24), style=0) |
1713 |
||
1714 |
self.staticText2 = wx.StaticText(id=wxID_POUTRANSITIONDIALOGSTATICTEXT2, |
|
45 | 1715 |
label='Language:', name='staticText2', parent=self.MainPanel, |
0 | 1716 |
pos=wx.Point(24, 64), size=wx.Size(145, 17), style=0) |
1717 |
||
1718 |
self.Language = wx.Choice(id=wxID_POUTRANSITIONDIALOGLANGUAGE, |
|
45 | 1719 |
name='Language', parent=self.MainPanel, pos=wx.Point(154, 64), |
0 | 1720 |
size=wx.Size(150, 24), style=0) |
1721 |
||
1722 |
self._init_sizers() |
|
1723 |
||
1724 |
def __init__(self, parent): |
|
1725 |
self._init_ctrls(parent) |
|
9 | 1726 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
0 | 1727 |
self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
45 | 1728 |
|
0 | 1729 |
for option in ["IL","ST","LD","FBD"]: |
1730 |
self.Language.Append(option) |
|
1731 |
||
1732 |
EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
|
1733 |
||
1734 |
def OnOK(self, event): |
|
1735 |
error = [] |
|
1736 |
if self.TransitionName.GetValue() == "": |
|
1737 |
error.append("Transition Name") |
|
1738 |
if self.Language.GetStringSelection() == "": |
|
1739 |
error.append("Language") |
|
1740 |
if len(error) > 0: |
|
1741 |
text = "" |
|
1742 |
for i, item in enumerate(error): |
|
1743 |
if i == 0: |
|
1744 |
text += item |
|
1745 |
elif i == len(error) - 1: |
|
1746 |
text += " and %s"%item |
|
1747 |
else: |
|
1748 |
text += ", %s"%item |
|
1749 |
message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR) |
|
1750 |
message.ShowModal() |
|
1751 |
message.Destroy() |
|
1752 |
else: |
|
1753 |
self.EndModal(wxID_OK) |
|
1754 |
||
1755 |
def SetValues(self, values): |
|
1756 |
for item, value in values.items(): |
|
45 | 1757 |
if item == "transitionName": |
0 | 1758 |
self.TransitionName.SetValue(value) |
1759 |
elif item == "language": |
|
1760 |
self.Language.SetStringSelection(value) |
|
1761 |
||
1762 |
def GetValues(self): |
|
1763 |
values = {} |
|
1764 |
values["transitionName"] = self.TransitionName.GetValue() |
|
1765 |
values["language"] = self.Language.GetStringSelection() |
|
1766 |
return values |
|
1767 |
||
1768 |
#------------------------------------------------------------------------------- |
|
1769 |
# Create Pou Action Dialog |
|
1770 |
#------------------------------------------------------------------------------- |
|
1771 |
||
1772 |
[wxID_POUACTIONDIALOG, wxID_POUACTIONDIALOGMAINPANEL, |
|
45 | 1773 |
wxID_POUACTIONDIALOGACTIONNAME, wxID_POUACTIONDIALOGLANGUAGE, |
1774 |
wxID_POUACTIONDIALOGSTATICTEXT1, wxID_POUACTIONDIALOGSTATICTEXT2, |
|
1775 |
] = [wx.NewId() for _init_ctrls in range(6)] |
|
0 | 1776 |
|
1777 |
class PouActionDialog(wx.Dialog): |
|
1778 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
1779 |
# generated method, don't edit |
|
1780 |
||
1781 |
parent.AddWindow(self.MainPanel, 0, border=0, flag=0) |
|
1782 |
||
1783 |
def _init_sizers(self): |
|
1784 |
# generated method, don't edit |
|
1785 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
1786 |
||
1787 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
1788 |
||
1789 |
self.SetSizer(self.flexGridSizer1) |
|
1790 |
||
1791 |
def _init_ctrls(self, prnt): |
|
1792 |
# generated method, don't edit |
|
1793 |
wx.Dialog.__init__(self, id=wxID_POUACTIONDIALOG, |
|
45 | 1794 |
name='PouActionDialog', parent=prnt, pos=wx.Point(376, 223), |
0 | 1795 |
size=wx.Size(320, 200), style=wx.DEFAULT_DIALOG_STYLE, |
45 | 1796 |
title='Create a new action') |
1797 |
self.SetClientSize(wx.Size(320, 160)) |
|
0 | 1798 |
|
1799 |
self.MainPanel = wx.Panel(id=wxID_POUACTIONDIALOGMAINPANEL, |
|
1800 |
name='MainPanel', parent=self, pos=wx.Point(0, 0), |
|
1801 |
size=wx.Size(350, 200), style=wx.TAB_TRAVERSAL) |
|
1802 |
self.MainPanel.SetAutoLayout(True) |
|
1803 |
||
1804 |
self.staticText1 = wx.StaticText(id=wxID_POUACTIONDIALOGSTATICTEXT1, |
|
45 | 1805 |
label='Action Name:', name='staticText1', parent=self.MainPanel, |
0 | 1806 |
pos=wx.Point(24, 24), size=wx.Size(145, 17), style=0) |
1807 |
||
45 | 1808 |
self.ActionName = wx.TextCtrl(id=wxID_POUACTIONDIALOGACTIONNAME, |
1809 |
name='ActionName', parent=self.MainPanel, pos=wx.Point(124, 24), |
|
0 | 1810 |
size=wx.Size(150, 24), style=0) |
1811 |
||
45 | 1812 |
self.staticText3 = wx.StaticText(id=wxID_POUACTIONDIALOGSTATICTEXT2, |
1813 |
label='Language:', name='staticText2', parent=self.MainPanel, |
|
0 | 1814 |
pos=wx.Point(24, 64), size=wx.Size(145, 17), style=0) |
1815 |
||
1816 |
self.Language = wx.Choice(id=wxID_POUACTIONDIALOGLANGUAGE, |
|
45 | 1817 |
name='Language', parent=self.MainPanel, pos=wx.Point(124, 64), |
0 | 1818 |
size=wx.Size(150, 24), style=0) |
1819 |
||
1820 |
self._init_sizers() |
|
1821 |
||
1822 |
def __init__(self, parent): |
|
1823 |
self._init_ctrls(parent) |
|
9 | 1824 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
0 | 1825 |
self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
45 | 1826 |
|
0 | 1827 |
for option in ["IL","ST","LD","FBD"]: |
1828 |
self.Language.Append(option) |
|
1829 |
||
1830 |
EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
|
1831 |
||
1832 |
def OnOK(self, event): |
|
1833 |
error = [] |
|
1834 |
if self.ActionName.GetValue() == "": |
|
1835 |
error.append("Action Name") |
|
1836 |
if self.Language.GetStringSelection() == "": |
|
1837 |
error.append("Language") |
|
1838 |
if len(error) > 0: |
|
1839 |
text = "" |
|
1840 |
for i, item in enumerate(error): |
|
1841 |
if i == 0: |
|
1842 |
text += item |
|
1843 |
elif i == len(error) - 1: |
|
1844 |
text += " and %s"%item |
|
1845 |
else: |
|
1846 |
text += ", %s"%item |
|
1847 |
message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR) |
|
1848 |
message.ShowModal() |
|
1849 |
message.Destroy() |
|
1850 |
else: |
|
1851 |
self.EndModal(wxID_OK) |
|
1852 |
||
1853 |
def SetValues(self, values): |
|
1854 |
for item, value in values.items(): |
|
45 | 1855 |
if item == "actionName": |
0 | 1856 |
self.ActionName.SetValue(value) |
1857 |
elif item == "language": |
|
1858 |
self.Language.SetStringSelection(value) |
|
1859 |
||
1860 |
def GetValues(self): |
|
1861 |
values = {} |
|
1862 |
values["actionName"] = self.ActionName.GetValue() |
|
1863 |
values["language"] = self.Language.GetStringSelection() |
|
1864 |
return values |
|
1865 |
||
1866 |
#------------------------------------------------------------------------------- |
|
1867 |
# Pou Interface Dialog |
|
1868 |
#------------------------------------------------------------------------------- |
|
1869 |
||
1870 |
class VariableTable(wxPyGridTableBase): |
|
1871 |
||
1872 |
""" |
|
1873 |
A custom wxGrid Table using user supplied data |
|
1874 |
""" |
|
1875 |
def __init__(self, parent, data, colnames): |
|
1876 |
# The base class must be initialized *first* |
|
1877 |
wxPyGridTableBase.__init__(self) |
|
1878 |
self.data = data |
|
1879 |
self.colnames = colnames |
|
1880 |
self.Parent = parent |
|
1881 |
# XXX |
|
1882 |
# we need to store the row length and collength to |
|
1883 |
# see if the table has changed size |
|
1884 |
self._rows = self.GetNumberRows() |
|
1885 |
self._cols = self.GetNumberCols() |
|
1886 |
||
1887 |
def GetNumberCols(self): |
|
1888 |
return len(self.colnames) |
|
1889 |
||
1890 |
def GetNumberRows(self): |
|
1891 |
return len(self.data) |
|
1892 |
||
1893 |
def GetColLabelValue(self, col): |
|
1894 |
if col < len(self.colnames): |
|
1895 |
return self.colnames[col] |
|
1896 |
||
1897 |
def GetRowLabelValues(self, row): |
|
1898 |
return row |
|
1899 |
||
1900 |
def GetValue(self, row, col): |
|
1901 |
if row < self.GetNumberRows(): |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1902 |
if col == 0: |
49 | 1903 |
return self.Parent.Values.index(self.data[row]) + 1 |
0 | 1904 |
name = str(self.data[row].get(self.GetColLabelValue(col), "")) |
1905 |
return name |
|
1906 |
||
1907 |
def GetValueByName(self, row, colname): |
|
1908 |
return self.data[row].get(colname) |
|
1909 |
||
1910 |
def SetValue(self, row, col, value): |
|
1911 |
if col < len(self.colnames): |
|
1912 |
self.data[row][self.GetColLabelValue(col)] = value |
|
1913 |
||
1914 |
def ResetView(self, grid): |
|
1915 |
""" |
|
1916 |
(wxGrid) -> Reset the grid view. Call this to |
|
1917 |
update the grid if rows and columns have been added or deleted |
|
1918 |
""" |
|
1919 |
grid.BeginBatch() |
|
1920 |
for current, new, delmsg, addmsg in [ |
|
1921 |
(self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED), |
|
1922 |
(self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED), |
|
1923 |
]: |
|
1924 |
if new < current: |
|
1925 |
msg = wxGridTableMessage(self,delmsg,new,current-new) |
|
1926 |
grid.ProcessTableMessage(msg) |
|
1927 |
elif new > current: |
|
1928 |
msg = wxGridTableMessage(self,addmsg,new-current) |
|
1929 |
grid.ProcessTableMessage(msg) |
|
1930 |
self.UpdateValues(grid) |
|
1931 |
grid.EndBatch() |
|
1932 |
||
1933 |
self._rows = self.GetNumberRows() |
|
1934 |
self._cols = self.GetNumberCols() |
|
1935 |
# update the column rendering scheme |
|
1936 |
self._updateColAttrs(grid) |
|
1937 |
||
1938 |
# update the scrollbars and the displayed part of the grid |
|
1939 |
grid.AdjustScrollbars() |
|
1940 |
grid.ForceRefresh() |
|
1941 |
||
1942 |
def UpdateValues(self, grid): |
|
1943 |
"""Update all displayed values""" |
|
1944 |
# This sends an event to the grid table to update all of the values |
|
1945 |
msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES) |
|
1946 |
grid.ProcessTableMessage(msg) |
|
1947 |
||
1948 |
def _updateColAttrs(self, grid): |
|
1949 |
""" |
|
1950 |
wxGrid -> update the column attributes to add the |
|
1951 |
appropriate renderer given the column name. |
|
1952 |
||
1953 |
Otherwise default to the default renderer. |
|
1954 |
""" |
|
1955 |
||
1956 |
for col in range(self.GetNumberCols()): |
|
1957 |
attr = wxGridCellAttr() |
|
1958 |
attr.SetAlignment(self.Parent.ColAlignements[col], wxALIGN_CENTRE) |
|
1959 |
grid.SetColAttr(col, attr) |
|
1960 |
grid.SetColSize(col, self.Parent.ColSizes[col]) |
|
1961 |
||
1962 |
typelist = None |
|
1963 |
accesslist = None |
|
1964 |
for row in range(self.GetNumberRows()): |
|
1965 |
for col in range(self.GetNumberCols()): |
|
1966 |
editor = None |
|
1967 |
renderer = None |
|
1968 |
colname = self.GetColLabelValue(col) |
|
1969 |
grid.SetReadOnly(row, col, False) |
|
49 | 1970 |
if col == 0: |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1971 |
grid.SetReadOnly(row, col, True) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1972 |
elif colname == "Name": |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1973 |
if self.Parent.PouIsUsed and self.GetValueByName(row, "Class") in ["Input", "Output", "InOut"]: |
0 | 1974 |
grid.SetReadOnly(row, col, True) |
1975 |
else: |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1976 |
editor = wxGridCellTextEditor() |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1977 |
renderer = wxGridCellStringRenderer() |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1978 |
elif colname in ["Initial Value","Location"]: |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1979 |
editor = wxGridCellTextEditor() |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1980 |
renderer = wxGridCellStringRenderer() |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1981 |
elif colname == "Class": |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1982 |
if len(self.Parent.ClassList) == 1 or self.Parent.PouIsUsed and self.GetValueByName(row, "Class") in ["Input", "Output", "InOut"]: |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1983 |
grid.SetReadOnly(row, col, True) |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1984 |
else: |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1985 |
editor = wxGridCellChoiceEditor() |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1986 |
excluded = [] |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1987 |
if self.Parent.PouIsUsed: |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1988 |
excluded.extend(["Input","Output","InOut"]) |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1989 |
editor.SetParameters(",".join([choice for choice in self.Parent.ClassList if choice not in excluded])) |
0 | 1990 |
elif colname == "Type": |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1991 |
if self.Parent.PouIsUsed and self.GetValueByName(row, "Class") in ["Input", "Output", "InOut"]: |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1992 |
grid.SetReadOnly(row, col, True) |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1993 |
else: |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1994 |
editor = wxGridCellChoiceEditor() |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
1995 |
editor.SetParameters(self.Parent.TypeList) |
0 | 1996 |
elif colname in ["Retain", "Constant"]: |
1997 |
editor = wxGridCellChoiceEditor() |
|
1998 |
editor.SetParameters(self.Parent.OptionList) |
|
1999 |
||
2000 |
grid.SetCellEditor(row, col, editor) |
|
2001 |
grid.SetCellRenderer(row, col, renderer) |
|
2002 |
||
2003 |
grid.SetCellBackgroundColour(row, col, wxWHITE) |
|
2004 |
||
2005 |
def SetData(self, data): |
|
2006 |
self.data = data |
|
2007 |
||
2008 |
def GetData(self): |
|
2009 |
return self.data |
|
2010 |
||
2011 |
def GetCurrentIndex(self): |
|
2012 |
return self.CurrentIndex |
|
2013 |
||
2014 |
def SetCurrentIndex(self, index): |
|
2015 |
self.CurrentIndex = index |
|
2016 |
||
2017 |
def AppendRow(self, row_content): |
|
2018 |
self.data.append(row_content) |
|
2019 |
||
2020 |
def RemoveRow(self, row_index): |
|
2021 |
self.data.pop(row_index) |
|
12 | 2022 |
|
2023 |
def GetRow(self, row_index): |
|
2024 |
return self.data[row_index] |
|
0 | 2025 |
|
2026 |
def Empty(self): |
|
2027 |
self.data = [] |
|
2028 |
self.editors = [] |
|
2029 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2030 |
[wxID_POUEDITORPANEL, wxID_POUEDITORPANELVIEWER, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2031 |
wxID_POUEDITORPANELVARIABLESGRID, wxID_POUEDITORPANELRETURNTYPE, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2032 |
wxID_POUEDITORPANELCLASSFILTER, wxID_POUEDITORPANELADDBUTTON, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2033 |
wxID_POUEDITORPANELDELETEBUTTON, wxID_POUEDITORPANELUPBUTTON, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2034 |
wxID_POUEDITORPANELDOWNBUTTON, wxID_POUEDITORPANELSTATICTEXT1, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2035 |
wxID_POUEDITORPANELSTATICTEXT2, wxID_POUEDITORPANELSTATICTEXT3, |
0 | 2036 |
] = [wx.NewId() for _init_ctrls in range(12)] |
2037 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2038 |
class PouEditorPanel(wx.Panel): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2039 |
def _init_coll_MainPanelSizer_Items(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2040 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2041 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2042 |
parent.AddWindow(self.Viewer, 0, border=0, flag=wxGROW) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2043 |
parent.AddSizer(self.VariablePanelSizer, 0, border=0, flag=wxGROW) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2044 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2045 |
def _init_coll_MainPanelSizer_Growables(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2046 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2047 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2048 |
parent.AddGrowableCol(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2049 |
parent.AddGrowableRow(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2050 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2051 |
def _init_coll_VariablePanelSizer_Items(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2052 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2053 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2054 |
parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wxGROW) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2055 |
parent.AddSizer(self.ControlPanelSizer, 0, border=0, flag=wxGROW) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2056 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2057 |
def _init_coll_VariablePanelSizer_Growables(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2058 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2059 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2060 |
parent.AddGrowableCol(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2061 |
parent.AddGrowableRow(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2062 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2063 |
def _init_coll_ControlPanelSizer_Items(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2064 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2065 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2066 |
parent.AddSizer(self.ChoicePanelSizer, 0, border=0, flag=wxGROW) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2067 |
parent.AddSizer(self.ButtonPanelSizer, 0, border=0, flag=wxALIGN_CENTER) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2068 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2069 |
def _init_coll_ControlPanelSizer_Growables(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2070 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2071 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2072 |
parent.AddGrowableCol(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2073 |
parent.AddGrowableRow(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2074 |
parent.AddGrowableRow(1) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2075 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2076 |
def _init_coll_ChoicePanelSizer_Items(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2077 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2078 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2079 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wxALIGN_BOTTOM) |
48 | 2080 |
parent.AddWindow(self.ReturnType, 0, border=0, flag=0) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2081 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wxALIGN_BOTTOM) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2082 |
parent.AddWindow(self.ClassFilter, 0, border=0, flag=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2083 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2084 |
def _init_coll_ButtonPanelSizer_Items(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2085 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2086 |
|
48 | 2087 |
parent.AddWindow(self.UpButton, 0, border=0, flag=0) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2088 |
parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
48 | 2089 |
parent.AddWindow(self.DownButton, 0, border=0, flag=0) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2090 |
parent.AddWindow(self.DeleteButton, 0, border=0, flag=0) |
48 | 2091 |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2092 |
def _init_coll_ButtonPanelSizer_Growables(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2093 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2094 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2095 |
parent.AddGrowableCol(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2096 |
parent.AddGrowableCol(1) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2097 |
parent.AddGrowableCol(2) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2098 |
parent.AddGrowableCol(3) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2099 |
parent.AddGrowableRow(0) |
0 | 2100 |
|
2101 |
def _init_sizers(self): |
|
2102 |
# generated method, don't edit |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2103 |
self.MainPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2104 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2105 |
self.VariablePanelSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2106 |
|
48 | 2107 |
self.ControlPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
2108 |
||
2109 |
self.ChoicePanelSizer = wx.GridSizer(cols=1, hgap=5, rows=4, vgap=5) |
|
2110 |
||
2111 |
self.ButtonPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2112 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2113 |
self._init_coll_MainPanelSizer_Items(self.MainPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2114 |
self._init_coll_MainPanelSizer_Growables(self.MainPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2115 |
self._init_coll_VariablePanelSizer_Items(self.VariablePanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2116 |
self._init_coll_VariablePanelSizer_Growables(self.VariablePanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2117 |
self._init_coll_ControlPanelSizer_Items(self.ControlPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2118 |
self._init_coll_ControlPanelSizer_Growables(self.ControlPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2119 |
self._init_coll_ChoicePanelSizer_Items(self.ChoicePanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2120 |
self._init_coll_ButtonPanelSizer_Items(self.ButtonPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2121 |
self._init_coll_ButtonPanelSizer_Growables(self.ButtonPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2122 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2123 |
self.SetSizer(self.MainPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2124 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2125 |
def _init_ctrls(self, prnt, element_type): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2126 |
# generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2127 |
wx.Panel.__init__(self, id=wxID_POUEDITORPANEL, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2128 |
name='EditVariablePanel', parent=prnt, pos=wx.Point(0, 0), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2129 |
size=wx.Size(-1, -1), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2130 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2131 |
if element_type == "config": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2132 |
self.Viewer = wx.Panel(id=wxID_POUEDITORPANELVIEWER, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2133 |
name='ConfigPanel', parent=self, pos=wx.Point(0, 0), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2134 |
size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2135 |
elif element_type == "resource": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2136 |
self.Viewer = ResourceEditor(self, self.Parent, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2137 |
elif element_type == "FBD": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2138 |
self.Viewer = Viewer(self, self.Parent, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2139 |
elif element_type == "LD": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2140 |
self.Viewer = LD_Viewer(self, self.Parent, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2141 |
elif element_type == "SFC": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2142 |
self.Viewer = SFC_Viewer(self, self.Parent, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2143 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2144 |
self.Viewer = TextViewer(self, self.Parent, self.Controler) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2145 |
self.Viewer.SetTextSyntax(element_type) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2146 |
if element_type == "IL": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2147 |
self.Viewer.SetKeywords(IL_KEYWORDS) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2148 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2149 |
self.Viewer.SetKeywords(ST_KEYWORDS) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2150 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2151 |
self.staticText1 = wx.StaticText(id=wxID_POUEDITORPANELSTATICTEXT1, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2152 |
label='Return Type:', name='staticText1', parent=self, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2153 |
pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2154 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2155 |
self.ReturnType = wx.Choice(id=wxID_POUEDITORPANELRETURNTYPE, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2156 |
name='ReturnType', parent=self, pos=wx.Point(0, 0), |
0 | 2157 |
size=wx.Size(145, 24), style=0) |
2158 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2159 |
self.staticText2 = wx.StaticText(id=wxID_POUEDITORPANELSTATICTEXT2, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2160 |
label='Class Filter:', name='staticText2', parent=self, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2161 |
pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2162 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2163 |
self.ClassFilter = wx.Choice(id=wxID_POUEDITORPANELCLASSFILTER, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2164 |
name='ClassFilter', parent=self, pos=wx.Point(0, 0), |
0 | 2165 |
size=wx.Size(145, 24), style=0) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2166 |
EVT_CHOICE(self, wxID_POUEDITORPANELCLASSFILTER, self.OnClassFilter) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2167 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2168 |
self.VariablesGrid = wx.grid.Grid(id=wxID_POUEDITORPANELVARIABLESGRID, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2169 |
name='VariablesGrid', parent=self, pos=wx.Point(0, 0), |
48 | 2170 |
size=wx.Size(0, 150), style=wxVSCROLL) |
0 | 2171 |
self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
2172 |
'Sans')) |
|
2173 |
self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
|
2174 |
False, 'Sans')) |
|
6 | 2175 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange) |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2176 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnVariablesGridSelectCell) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2177 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2178 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2179 |
self.AddButton = wx.Button(id=wxID_POUEDITORPANELADDBUTTON, label='Add', |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2180 |
name='AddButton', parent=self, pos=wx.Point(345, 340), |
0 | 2181 |
size=wx.Size(72, 32), style=0) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2182 |
EVT_BUTTON(self, wxID_POUEDITORPANELADDBUTTON, self.OnAddButton) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2183 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2184 |
self.DeleteButton = wx.Button(id=wxID_POUEDITORPANELDELETEBUTTON, label='Delete', |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2185 |
name='DeleteButton', parent=self, pos=wx.Point(425, 340), |
0 | 2186 |
size=wx.Size(72, 32), style=0) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2187 |
EVT_BUTTON(self, wxID_POUEDITORPANELDELETEBUTTON, self.OnDeleteButton) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2188 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2189 |
self.UpButton = wx.Button(id=wxID_POUEDITORPANELUPBUTTON, label='^', |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2190 |
name='UpButton', parent=self, pos=wx.Point(505, 340), |
0 | 2191 |
size=wx.Size(32, 32), style=0) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2192 |
EVT_BUTTON(self, wxID_POUEDITORPANELUPBUTTON, self.OnUpButton) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2193 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2194 |
self.DownButton = wx.Button(id=wxID_POUEDITORPANELDOWNBUTTON, label='v', |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2195 |
name='DownButton', parent=self, pos=wx.Point(545, 340), |
0 | 2196 |
size=wx.Size(32, 32), style=0) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2197 |
EVT_BUTTON(self, wxID_POUEDITORPANELDOWNBUTTON, self.OnDownButton) |
0 | 2198 |
|
2199 |
self._init_sizers() |
|
2200 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2201 |
def __init__(self, parent, window, controler, element_type, pou_name = None, transition_name = None, action_name = None, config_name = None, resource_name = None): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2202 |
self.Parent = window |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2203 |
self.Controler = controler |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2204 |
self.ElementType = element_type |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2205 |
self.PouName = pou_name |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2206 |
self.TransitionName = transition_name |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2207 |
self.ActionName = action_name |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2208 |
self.ConfigName = config_name |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2209 |
self.ResourceName = resource_name |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2210 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2211 |
if element_type == "config": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2212 |
self._init_ctrls(parent, "config") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2213 |
pou_type = "config" |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2214 |
elif element_type == "resource": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2215 |
self._init_ctrls(parent, "resource") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2216 |
pou_type = "resource" |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2217 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2218 |
if element_type == "transition": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2219 |
self._init_ctrls(parent, self.Controler.GetTransitionBodyType(pou_name, transition_name)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2220 |
elif element_type == "action": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2221 |
self._init_ctrls(parent, self.Controler.GetActionBodyType(pou_name, action_name)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2222 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2223 |
self._init_ctrls(parent, self.Controler.GetPouBodyType(pou_name)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2224 |
pou_type = self.Controler.GetPouType(pou_name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2225 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2226 |
self.Filter = "All" |
0 | 2227 |
self.FilterChoices = [] |
2228 |
self.FilterChoiceTransfer = {"All" : "All", "Interface" : "Interface", |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2229 |
" Input" : "Input", " Output" : "Output", " InOut" : "InOut", |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2230 |
" External" : "External", "Variables" : "Variables", " Local" : "Local", |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2231 |
" Temp" : "Temp", "Global" : "Global", "Access" : "Access"} |
0 | 2232 |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2233 |
if pou_type in ["config", "resource"]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2234 |
self.DefaultTypes = {"All" : "Global"} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2235 |
self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2236 |
else: |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2237 |
self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"} |
11 | 2238 |
self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"} |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2239 |
if pou_type in ["config", "resource"] or pou_type == "program": |
49 | 2240 |
self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Location", "Initial Value", "Retain", "Constant"]) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2241 |
if pou_type not in ["config", "resource"]: |
0 | 2242 |
self.FilterChoices = ["All","Interface"," Input"," Output"," InOut"," External","Variables"," Local"," Temp","Global","Access"] |
2243 |
else: |
|
2244 |
self.FilterChoices = ["All","Global","Access"] |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2245 |
self.ColSizes = [40, 80, 70, 80, 80, 80, 60, 70] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2246 |
self.ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_CENTER] |
0 | 2247 |
else: |
49 | 2248 |
self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Initial Value", "Retain", "Constant"]) |
0 | 2249 |
self.FilterChoices = ["All","Interface"," Input"," Output"," InOut"," External","Variables"," Local"," Temp"] |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2250 |
self.ColSizes = [40, 120, 70, 80, 120, 60, 70] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2251 |
self.ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_CENTER] |
0 | 2252 |
for choice in self.FilterChoices: |
2253 |
self.ClassFilter.Append(choice) |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2254 |
reverse_transfer = {} |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2255 |
for filter, choice in self.FilterChoiceTransfer.items(): |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2256 |
reverse_transfer[choice] = filter |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2257 |
self.ClassFilter.SetStringSelection(reverse_transfer[self.Filter]) |
0 | 2258 |
self.RefreshTypeList() |
2259 |
||
2260 |
self.OptionList = "Yes,No" |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2261 |
self.TypeList = ",".join([value for value, parent in TypeHierarchy_list if not value.startswith("ANY")]) |
0 | 2262 |
|
2263 |
if pou_type == "function": |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2264 |
for value, parent in TypeHierarchy_list: |
0 | 2265 |
if not value.startswith("ANY"): |
2266 |
self.ReturnType.Append(value) |
|
2267 |
self.ReturnType.Enable(True) |
|
2268 |
else: |
|
2269 |
self.ReturnType.Enable(False) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2270 |
self.staticText1.Hide() |
0 | 2271 |
self.ReturnType.Hide() |
2272 |
||
2273 |
self.VariablesGrid.SetTable(self.Table) |
|
2274 |
self.VariablesGrid.SetRowLabelSize(0) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2275 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2276 |
def SetMode(self, mode): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2277 |
if self.ElementType not in ["resource", "config"]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2278 |
if self.ElementType == "transition": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2279 |
language = self.Controler.GetTransitionBodyType(self.PouName, self.TransitionName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2280 |
elif self.ElementType == "action": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2281 |
language = self.Controler.GetActionBodyType(self.PouName, self.ActionName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2282 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2283 |
language = self.Controler.GetPouBodyType(self.PouName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2284 |
if language not in ["IL", "ST"]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2285 |
self.Viewer.SetMode(mode) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2286 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2287 |
def RefreshView(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2288 |
self.PouNames = self.Controler.GetProjectPouNames() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2289 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2290 |
if self.ElementType == "config": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2291 |
self.PouIsUsed = False |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2292 |
returnType = None |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2293 |
self.Values = self.Controler.GetConfigurationGlobalVars(self.ConfigName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2294 |
elif self.ElementType == "resource": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2295 |
self.PouIsUsed = False |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2296 |
returnType = None |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2297 |
self.Values = self.Controler.GetConfigurationResourceGlobalVars(self.ConfigName, self.ResourceName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2298 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2299 |
self.PouIsUsed = self.Controler.PouIsUsed(self.PouName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2300 |
returnType = self.Controler.GetCurrentElementEditingInterfaceReturnType() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2301 |
self.Values = self.Controler.GetCurrentElementEditingInterfaceVars() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2302 |
varlist = [var["Name"] for var in self.Values] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2303 |
if self.ElementType == "transtion": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2304 |
language = self.Controler.GetTransitionBodyType(self.PouName, self.TransitionName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2305 |
varlist.append(self.ActionName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2306 |
elif self.ElementType == "action": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2307 |
language = self.Controler.GetActionBodyType(self.PouName, self.ActionName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2308 |
varlist.append(self.ActionName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2309 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2310 |
language = self.Controler.GetPouBodyType(self.PouName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2311 |
varlist.append(self.PouName) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2312 |
if language in ["IL", "ST"]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2313 |
self.Viewer.SetVariables(varlist) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2314 |
self.Viewer.SetFunctions(self.Controler.GetBlockTypes()) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2315 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2316 |
if returnType and self.ReturnType.IsEnabled(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2317 |
self.ReturnType.SetStringSelection(returnType) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2318 |
self.RefreshValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2319 |
self.RefreshButtons() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2320 |
if self.ElementType != "config": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2321 |
self.Viewer.RefreshView() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2322 |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2323 |
if self.PouIsUsed: |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2324 |
wxCallAfter(self.WarningMessage, name) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2325 |
|
0 | 2326 |
def OnClassFilter(self, event): |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2327 |
self.Filter = self.FilterChoiceTransfer[self.ClassFilter.GetStringSelection()] |
0 | 2328 |
self.RefreshTypeList() |
2329 |
self.RefreshValues() |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2330 |
self.RefreshButtons() |
0 | 2331 |
event.Skip() |
2332 |
||
2333 |
def RefreshTypeList(self): |
|
2334 |
if self.Filter == "All": |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2335 |
self.ClassList = [self.FilterChoiceTransfer[choice] for choice in self.FilterChoices if self.FilterChoiceTransfer[choice] not in ["All","Interface","Variables"]] |
0 | 2336 |
elif self.Filter == "Interface": |
2337 |
self.ClassList = ["Input","Output","InOut","External"] |
|
2338 |
elif self.Filter == "Variables": |
|
2339 |
self.ClassList = ["Local","Temp"] |
|
2340 |
else: |
|
2341 |
self.ClassList = [self.Filter] |
|
2342 |
||
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2343 |
def RefreshButtons(self): |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2344 |
table_length = len(self.Table.data) |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2345 |
row_class = None |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2346 |
if table_length and self.PouIsUsed: |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2347 |
row = self.VariablesGrid.GetGridCursorRow() |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2348 |
row_class = self.Table.GetValueByName(row, "Class") |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2349 |
self.AddButton.Enable(not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]) |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2350 |
self.DeleteButton.Enable(table_length > 0 and row_class not in ["Input", "Output", "InOut"]) |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2351 |
self.UpButton.Enable(table_length > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]) |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2352 |
self.DownButton.Enable(table_length > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2353 |
|
0 | 2354 |
def OnAddButton(self, event): |
11 | 2355 |
new_row = self.DefaultValue.copy() |
2356 |
if self.Filter in self.DefaultTypes: |
|
2357 |
new_row["Class"] = self.DefaultTypes[self.Filter] |
|
2358 |
else: |
|
2359 |
new_row["Class"] = self.Filter |
|
12 | 2360 |
self.Values.append(new_row) |
2361 |
self.RefreshValues() |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2362 |
self.RefreshButtons() |
0 | 2363 |
event.Skip() |
2364 |
||
2365 |
def OnDeleteButton(self, event): |
|
12 | 2366 |
row = self.Table.GetRow(self.VariablesGrid.GetGridCursorRow()) |
2367 |
self.Values.remove(row) |
|
2368 |
self.RefreshValues() |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2369 |
self.RefreshButtons() |
0 | 2370 |
event.Skip() |
2371 |
||
2372 |
def OnUpButton(self, event): |
|
12 | 2373 |
self.MoveValue(self.VariablesGrid.GetGridCursorRow(), -1) |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2374 |
self.RefreshButtons() |
0 | 2375 |
event.Skip() |
2376 |
||
2377 |
def OnDownButton(self, event): |
|
12 | 2378 |
self.MoveValue(self.VariablesGrid.GetGridCursorRow(), 1) |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2379 |
self.RefreshButtons() |
0 | 2380 |
event.Skip() |
2381 |
||
6 | 2382 |
def OnVariablesGridCellChange(self, event): |
2383 |
row, col = event.GetRow(), event.GetCol() |
|
2384 |
colname = self.Table.GetColLabelValue(col) |
|
2385 |
value = self.Table.GetValue(row, col) |
|
2386 |
if colname == "Name": |
|
2387 |
if not TestIdentifier(value): |
|
2388 |
message = wxMessageDialog(self, "\"%s\" is not a valid identifier!"%value, "Error", wxOK|wxICON_ERROR) |
|
2389 |
message.ShowModal() |
|
2390 |
message.Destroy() |
|
2391 |
event.Veto() |
|
2392 |
elif value.upper() in IEC_KEYWORDS: |
|
2393 |
message = wxMessageDialog(self, "\"%s\" is a keyword. It can't be used!"%value, "Error", wxOK|wxICON_ERROR) |
|
2394 |
message.ShowModal() |
|
2395 |
message.Destroy() |
|
2396 |
event.Veto() |
|
2397 |
elif value.upper() in self.PouNames: |
|
2398 |
message = wxMessageDialog(self, "A pou with \"%s\" as name exists!"%value, "Error", wxOK|wxICON_ERROR) |
|
2399 |
message.ShowModal() |
|
2400 |
message.Destroy() |
|
2401 |
event.Veto() |
|
2402 |
elif value.upper() in [var["Name"].upper() for var in self.Values if var != self.Table.data[row]]: |
|
2403 |
message = wxMessageDialog(self, "A variable with \"%s\" as name exists in this pou!"%value, "Error", wxOK|wxICON_ERROR) |
|
2404 |
message.ShowModal() |
|
2405 |
message.Destroy() |
|
2406 |
event.Veto() |
|
2407 |
else: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2408 |
self.SaveValues() |
6 | 2409 |
event.Skip() |
2410 |
else: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2411 |
self.SaveValues() |
6 | 2412 |
event.Skip() |
2413 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2414 |
def OnVariablesGridCellLeftClick(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2415 |
if event.GetCol() == 0: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2416 |
row = event.GetRow() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2417 |
var_name = self.Table.GetValueByName(row, "Name") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2418 |
var_class = self.Table.GetValueByName(row, "Class") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2419 |
var_type = self.Table.GetValueByName(row, "Type") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2420 |
data = wxTextDataObject(str((var_name, var_class, var_type))) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2421 |
dragSource = wxDropSource(self.VariablesGrid) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2422 |
dragSource.SetData(data) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2423 |
dragSource.DoDragDrop() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2424 |
event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2425 |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2426 |
def OnVariablesGridSelectCell(self, event): |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2427 |
wxCallAfter(self.RefreshButtons) |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2428 |
event.Skip() |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2429 |
|
12 | 2430 |
def MoveValue(self, value_index, move): |
2431 |
new_index = max(0, min(value_index + move, len(self.Values) - 1)) |
|
2432 |
if new_index != value_index: |
|
2433 |
self.Values.insert(new_index, self.Values.pop(value_index)) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2434 |
self.RefreshValues() |
12 | 2435 |
self.VariablesGrid.SetGridCursor(new_index, self.VariablesGrid.GetGridCursorCol()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2436 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2437 |
self.RefreshValues() |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2438 |
self.SaveValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2439 |
|
0 | 2440 |
def RefreshValues(self): |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
2441 |
if len(self.Table.data) > 0: |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2442 |
self.VariablesGrid.SetGridCursor(0, 1) |
0 | 2443 |
data = [] |
2444 |
for variable in self.Values: |
|
2445 |
if variable["Class"] in self.ClassList: |
|
2446 |
data.append(variable) |
|
2447 |
self.Table.SetData(data) |
|
2448 |
self.Table.ResetView(self.VariablesGrid) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2449 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2450 |
def SaveValues(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2451 |
if self.ElementType == "config": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2452 |
self.Controler.SetConfigurationGlobalVars(self.ConfigName, self.Values) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2453 |
elif self.ElementType == "resource": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2454 |
self.Controler.SetConfigurationResourceGlobalVars(self.ConfigName, self.ResourceName, self.Values) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2455 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2456 |
if self.ReturnType.IsEnabled(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2457 |
self.Controler.SetPouInterfaceReturnType(self.PouName, self.ReturnType.GetStringSelection()) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2458 |
self.Controler.SetPouInterfaceVars(self.PouName, self.Values) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2459 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2460 |
##[wxID_EDITVARIABLEDIALOG, wxID_EDITVARIABLEDIALOGMAINPANEL, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2461 |
## wxID_EDITVARIABLEDIALOGVARIABLESGRID, wxID_EDITVARIABLEDIALOGRETURNTYPE, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2462 |
## wxID_EDITVARIABLEDIALOGCLASSFILTER, wxID_EDITVARIABLEDIALOGADDBUTTON, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2463 |
## wxID_EDITVARIABLEDIALOGDELETEBUTTON, wxID_EDITVARIABLEDIALOGUPBUTTON, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2464 |
## wxID_EDITVARIABLEDIALOGDOWNBUTTON, wxID_EDITVARIABLEDIALOGSTATICTEXT1, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2465 |
## wxID_EDITVARIABLEDIALOGSTATICTEXT2, wxID_EDITVARIABLEDIALOGSTATICTEXT3, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2466 |
##] = [wx.NewId() for _init_ctrls in range(12)] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2467 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2468 |
##class EditVariableDialog(wx.Dialog): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2469 |
## def _init_coll_flexGridSizer1_Items(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2470 |
## # generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2471 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2472 |
## parent.AddWindow(self.MainPanel, 0, border=0, flag=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2473 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2474 |
## def _init_sizers(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2475 |
## # generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2476 |
## self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2477 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2478 |
## self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2479 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2480 |
## self.SetSizer(self.flexGridSizer1) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2481 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2482 |
## def _init_ctrls(self, prnt, name): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2483 |
## # generated method, don't edit |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2484 |
## wx.Dialog.__init__(self, id=wxID_EDITVARIABLEDIALOG, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2485 |
## name='EditVariableDialog', parent=prnt, pos=wx.Point(376, 223), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2486 |
## size=wx.Size(600, 440), style=wx.DEFAULT_DIALOG_STYLE, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2487 |
## title='Edit variables of %s'%name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2488 |
## self.SetClientSize(wx.Size(600, 440)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2489 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2490 |
## self.MainPanel = wx.Panel(id=wxID_EDITVARIABLEDIALOGMAINPANEL, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2491 |
## name='MainPanel', parent=self, pos=wx.Point(0, 0), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2492 |
## size=wx.Size(600, 440), style=wx.TAB_TRAVERSAL) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2493 |
## self.MainPanel.SetAutoLayout(True) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2494 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2495 |
## self.staticText1 = wx.StaticText(id=wxID_EDITVARIABLEDIALOGSTATICTEXT1, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2496 |
## label='Return Type:', name='staticText1', parent=self.MainPanel, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2497 |
## pos=wx.Point(24, 29), size=wx.Size(95, 17), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2498 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2499 |
## self.ReturnType = wx.Choice(id=wxID_EDITVARIABLEDIALOGRETURNTYPE, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2500 |
## name='ReturnType', parent=self.MainPanel, pos=wx.Point(124, 24), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2501 |
## size=wx.Size(145, 24), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2502 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2503 |
## self.staticText2 = wx.StaticText(id=wxID_EDITVARIABLEDIALOGSTATICTEXT2, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2504 |
## label='Class Filter:', name='staticText2', parent=self.MainPanel, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2505 |
## pos=wx.Point(324, 29), size=wx.Size(95, 17), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2506 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2507 |
## self.ClassFilter = wx.Choice(id=wxID_EDITVARIABLEDIALOGCLASSFILTER, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2508 |
## name='ClassFilter', parent=self.MainPanel, pos=wx.Point(424, 24), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2509 |
## size=wx.Size(145, 24), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2510 |
## EVT_CHOICE(self, wxID_EDITVARIABLEDIALOGCLASSFILTER, self.OnClassFilter) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2511 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2512 |
## self.staticText3 = wx.StaticText(id=wxID_EDITVARIABLEDIALOGSTATICTEXT3, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2513 |
## label='Variables:', name='staticText3', parent=self.MainPanel, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2514 |
## pos=wx.Point(24, 60), size=wx.Size(95, 17), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2515 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2516 |
## self.VariablesGrid = wx.grid.Grid(id=wxID_EDITVARIABLEDIALOGVARIABLESGRID, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2517 |
## name='VariablesGrid', parent=self.MainPanel, pos=wx.Point(24, 80), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2518 |
## size=wx.Size(550, 250), style=wxVSCROLL) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2519 |
## self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2520 |
## 'Sans')) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2521 |
## self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2522 |
## False, 'Sans')) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2523 |
## self.VariablesGrid.DisableDragGridSize() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2524 |
## self.VariablesGrid.EnableScrolling(False, True) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2525 |
## self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2526 |
## self.VariablesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnVariablesGridSelectCell) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2527 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2528 |
## self.AddButton = wx.Button(id=wxID_EDITVARIABLEDIALOGADDBUTTON, label='Add', |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2529 |
## name='AddButton', parent=self.MainPanel, pos=wx.Point(345, 340), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2530 |
## size=wx.Size(72, 32), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2531 |
## EVT_BUTTON(self, wxID_EDITVARIABLEDIALOGADDBUTTON, self.OnAddButton) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2532 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2533 |
## self.DeleteButton = wx.Button(id=wxID_EDITVARIABLEDIALOGDELETEBUTTON, label='Delete', |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2534 |
## name='DeleteButton', parent=self.MainPanel, pos=wx.Point(425, 340), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2535 |
## size=wx.Size(72, 32), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2536 |
## EVT_BUTTON(self, wxID_EDITVARIABLEDIALOGDELETEBUTTON, self.OnDeleteButton) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2537 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2538 |
## self.UpButton = wx.Button(id=wxID_EDITVARIABLEDIALOGUPBUTTON, label='^', |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2539 |
## name='UpButton', parent=self.MainPanel, pos=wx.Point(505, 340), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2540 |
## size=wx.Size(32, 32), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2541 |
## EVT_BUTTON(self, wxID_EDITVARIABLEDIALOGUPBUTTON, self.OnUpButton) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2542 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2543 |
## self.DownButton = wx.Button(id=wxID_EDITVARIABLEDIALOGDOWNBUTTON, label='v', |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2544 |
## name='DownButton', parent=self.MainPanel, pos=wx.Point(545, 340), |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2545 |
## size=wx.Size(32, 32), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2546 |
## EVT_BUTTON(self, wxID_EDITVARIABLEDIALOGDOWNBUTTON, self.OnDownButton) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2547 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2548 |
## self._init_sizers() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2549 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2550 |
## def __init__(self, parent, name, pou_type, pou_is_used, filter = "All"): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2551 |
## self._init_ctrls(parent, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2552 |
## self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2553 |
## self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2554 |
## self.Filter = filter |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2555 |
## self.PouIsUsed = pou_is_used |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2556 |
## self.FilterChoices = [] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2557 |
## self.FilterChoiceTransfer = {"All" : "All", "Interface" : "Interface", |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2558 |
## " Input" : "Input", " Output" : "Output", " InOut" : "InOut", |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2559 |
## " External" : "External", "Variables" : "Variables", " Local" : "Local", |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2560 |
## " Temp" : "Temp", "Global" : "Global", "Access" : "Access"} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2561 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2562 |
## if pou_type: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2563 |
## self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2564 |
## self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2565 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2566 |
## self.DefaultTypes = {"All" : "Global"} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2567 |
## self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2568 |
## if not pou_type or pou_type == "program": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2569 |
## self.Table = VariableTable(self, [], ["Name", "Class", "Type", "Location", "Initial Value", "Retain", "Constant"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2570 |
## if pou_type: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2571 |
## self.FilterChoices = ["All","Interface"," Input"," Output"," InOut"," External","Variables"," Local"," Temp","Global","Access"] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2572 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2573 |
## self.FilterChoices = ["All","Global","Access"] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2574 |
## self.ColSizes = [80, 70, 80, 80, 80, 60, 70] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2575 |
## self.ColAlignements = [wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_CENTER] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2576 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2577 |
## self.Table = VariableTable(self, [], ["Name", "Class", "Type", "Initial Value", "Retain", "Constant"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2578 |
## self.FilterChoices = ["All","Interface"," Input"," Output"," InOut"," External","Variables"," Local"," Temp"] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2579 |
## self.ColSizes = [120, 70, 80, 120, 60, 70] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2580 |
## self.ColAlignements = [wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_CENTER] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2581 |
## for choice in self.FilterChoices: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2582 |
## self.ClassFilter.Append(choice) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2583 |
## reverse_transfer = {} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2584 |
## for filter, choice in self.FilterChoiceTransfer.items(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2585 |
## reverse_transfer[choice] = filter |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2586 |
## self.ClassFilter.SetStringSelection(reverse_transfer[self.Filter]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2587 |
## self.RefreshTypeList() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2588 |
## self.RefreshButtons() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2589 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2590 |
## self.OptionList = "Yes,No" |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2591 |
## self.TypeList = ",".join([value for value, parent in TypeHierarchy_list if not value.startswith("ANY")]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2592 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2593 |
## if pou_type == "function": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2594 |
## for value, parent in TypeHierarchy_list: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2595 |
## if not value.startswith("ANY"): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2596 |
## self.ReturnType.Append(value) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2597 |
## self.ReturnType.Enable(True) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2598 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2599 |
## self.ReturnType.Enable(False) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2600 |
## self.staticText2.Hide() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2601 |
## self.ReturnType.Hide() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2602 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2603 |
## self.VariablesGrid.SetTable(self.Table) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2604 |
## self.VariablesGrid.SetRowLabelSize(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2605 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2606 |
## self.Table.ResetView(self.VariablesGrid) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2607 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2608 |
## self.PouNames = [] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2609 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2610 |
## if self.PouIsUsed: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2611 |
## wxCallAfter(self.WarningMessage, name) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2612 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2613 |
## EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2614 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2615 |
## def WarningMessage(self, name): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2616 |
## message = wxMessageDialog(self, "\"%s\" is used by one or more POUs. Its interface can't be changed!"%name, "WARNING", wxOK|wxICON_EXCLAMATION) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2617 |
## message.ShowModal() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2618 |
## message.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2619 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2620 |
## def OnOK(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2621 |
## self.VariablesGrid.SetGridCursor(0, 0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2622 |
## error = [] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2623 |
## if self.ReturnType.IsEnabled() and self.ReturnType.GetStringSelection() == "": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2624 |
## error.append("Return Type") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2625 |
## if len(error) > 0: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2626 |
## text = "" |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2627 |
## for i, item in enumerate(error): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2628 |
## if i == 0: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2629 |
## text += item |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2630 |
## elif i == len(error) - 1: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2631 |
## text += " and %s"%item |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2632 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2633 |
## text += ", %s"%item |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2634 |
## message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2635 |
## message.ShowModal() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2636 |
## message.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2637 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2638 |
## self.EndModal(wxID_OK) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2639 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2640 |
## def OnClassFilter(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2641 |
## self.Filter = self.FilterChoiceTransfer[self.ClassFilter.GetStringSelection()] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2642 |
## self.RefreshTypeList() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2643 |
## self.RefreshValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2644 |
## self.RefreshButtons() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2645 |
## event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2646 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2647 |
## def RefreshTypeList(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2648 |
## if self.Filter == "All": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2649 |
## self.ClassList = [self.FilterChoiceTransfer[choice] for choice in self.FilterChoices if self.FilterChoiceTransfer[choice] not in ["All","Interface","Variables"]] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2650 |
## elif self.Filter == "Interface": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2651 |
## self.ClassList = ["Input","Output","InOut","External"] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2652 |
## elif self.Filter == "Variables": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2653 |
## self.ClassList = ["Local","Temp"] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2654 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2655 |
## self.ClassList = [self.Filter] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2656 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2657 |
## def RefreshButtons(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2658 |
## table_length = len(self.Table.data) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2659 |
## row_class = None |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2660 |
## if table_length and self.PouIsUsed: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2661 |
## row = self.VariablesGrid.GetGridCursorRow() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2662 |
## row_class = self.Table.GetValueByName(row, "Class") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2663 |
## self.AddButton.Enable(not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2664 |
## self.DeleteButton.Enable(table_length > 0 and row_class not in ["Input", "Output", "InOut"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2665 |
## self.UpButton.Enable(table_length > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2666 |
## self.DownButton.Enable(table_length > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2667 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2668 |
## def OnAddButton(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2669 |
## new_row = self.DefaultValue.copy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2670 |
## if self.Filter in self.DefaultTypes: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2671 |
## new_row["Class"] = self.DefaultTypes[self.Filter] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2672 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2673 |
## new_row["Class"] = self.Filter |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2674 |
## self.Values.append(new_row) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2675 |
## self.RefreshValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2676 |
## self.RefreshButtons() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2677 |
## event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2678 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2679 |
## def OnDeleteButton(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2680 |
## row = self.Table.GetRow(self.VariablesGrid.GetGridCursorRow()) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2681 |
## self.Values.remove(row) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2682 |
## self.RefreshValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2683 |
## self.RefreshButtons() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2684 |
## event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2685 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2686 |
## def OnUpButton(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2687 |
## self.MoveValue(self.VariablesGrid.GetGridCursorRow(), -1) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2688 |
## self.RefreshButtons() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2689 |
## event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2690 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2691 |
## def OnDownButton(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2692 |
## self.MoveValue(self.VariablesGrid.GetGridCursorRow(), 1) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2693 |
## self.RefreshButtons() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2694 |
## event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2695 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2696 |
## def OnVariablesGridCellChange(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2697 |
## row, col = event.GetRow(), event.GetCol() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2698 |
## colname = self.Table.GetColLabelValue(col) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2699 |
## value = self.Table.GetValue(row, col) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2700 |
## if colname == "Name": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2701 |
## if not TestIdentifier(value): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2702 |
## message = wxMessageDialog(self, "\"%s\" is not a valid identifier!"%value, "Error", wxOK|wxICON_ERROR) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2703 |
## message.ShowModal() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2704 |
## message.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2705 |
## event.Veto() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2706 |
## elif value.upper() in IEC_KEYWORDS: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2707 |
## message = wxMessageDialog(self, "\"%s\" is a keyword. It can't be used!"%value, "Error", wxOK|wxICON_ERROR) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2708 |
## message.ShowModal() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2709 |
## message.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2710 |
## event.Veto() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2711 |
## elif value.upper() in self.PouNames: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2712 |
## message = wxMessageDialog(self, "A pou with \"%s\" as name exists!"%value, "Error", wxOK|wxICON_ERROR) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2713 |
## message.ShowModal() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2714 |
## message.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2715 |
## event.Veto() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2716 |
## elif value.upper() in [var["Name"].upper() for var in self.Values if var != self.Table.data[row]]: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2717 |
## message = wxMessageDialog(self, "A variable with \"%s\" as name exists in this pou!"%value, "Error", wxOK|wxICON_ERROR) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2718 |
## message.ShowModal() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2719 |
## message.Destroy() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2720 |
## event.Veto() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2721 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2722 |
## event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2723 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2724 |
## event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2725 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2726 |
## def OnVariablesGridSelectCell(self, event): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2727 |
## wxCallAfter(self.RefreshButtons) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2728 |
## event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2729 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2730 |
## def SetPouNames(self, pou_names): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2731 |
## self.PouNames = [pou_name.upper() for pou_name in pou_names] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2732 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2733 |
## def SetValues(self, values): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2734 |
## for item, value in values.items(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2735 |
## if item == "returnType" and value and self.ReturnType.IsEnabled(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2736 |
## self.ReturnType.SetStringSelection(value) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2737 |
## if item == "data": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2738 |
## self.Values = value |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2739 |
## self.RefreshValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2740 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2741 |
## def MoveValue(self, value_index, move): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2742 |
## new_index = max(0, min(value_index + move, len(self.Values) - 1)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2743 |
## if new_index != value_index: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2744 |
## self.Values.insert(new_index, self.Values.pop(value_index)) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2745 |
## self.RefreshValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2746 |
## self.VariablesGrid.SetGridCursor(new_index, self.VariablesGrid.GetGridCursorCol()) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2747 |
## else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2748 |
## self.RefreshValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2749 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2750 |
## def RefreshValues(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2751 |
## if len(self.Table.data) > 0: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2752 |
## self.VariablesGrid.SetGridCursor(0, 0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2753 |
## data = [] |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2754 |
## for variable in self.Values: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2755 |
## if variable["Class"] in self.ClassList: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2756 |
## data.append(variable) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2757 |
## self.Table.SetData(data) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2758 |
## self.Table.ResetView(self.VariablesGrid) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2759 |
## |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2760 |
## def GetValues(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2761 |
## values = {} |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2762 |
## if self.ReturnType.IsEnabled(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2763 |
## values["returnType"] = self.ReturnType.GetStringSelection() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2764 |
## values["data"] = self.Values |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
2765 |
## return values |
0 | 2766 |
|
2767 |
#------------------------------------------------------------------------------- |
|
2768 |
# Exception Handler |
|
2769 |
#------------------------------------------------------------------------------- |
|
2770 |
||
2771 |
Max_Traceback_List_Size = 20 |
|
2772 |
||
2773 |
def Display_Exception_Dialog(e_type,e_value,e_tb): |
|
2774 |
trcbck_lst = [] |
|
2775 |
for i,line in enumerate(traceback.extract_tb(e_tb)): |
|
2776 |
trcbck = " " + str(i+1) + ". " |
|
2777 |
if line[0].find(os.getcwd()) == -1: |
|
2778 |
trcbck += "file : " + str(line[0]) + ", " |
|
2779 |
else: |
|
2780 |
trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ", " |
|
2781 |
trcbck += "line : " + str(line[1]) + ", " + "function : " + str(line[2]) |
|
2782 |
trcbck_lst.append(trcbck) |
|
2783 |
||
2784 |
# Allow clicking.... |
|
2785 |
cap = wx.Window_GetCapture() |
|
2786 |
if cap: |
|
2787 |
cap.ReleaseMouse() |
|
2788 |
||
2789 |
dlg = wx.SingleChoiceDialog(None, |
|
2790 |
""" |
|
2791 |
An error happens. |
|
2792 |
||
2793 |
Click on OK for saving an error report. |
|
2794 |
||
2795 |
Please contact LOLITech at: |
|
2796 |
+33 (0)3 29 52 95 67 |
|
2797 |
bugs_PLCOpenEditor@lolitech.fr |
|
2798 |
||
2799 |
||
2800 |
Error: |
|
2801 |
""" + |
|
2802 |
str(e_type) + " : " + str(e_value), |
|
2803 |
"Error", |
|
2804 |
trcbck_lst) |
|
2805 |
try: |
|
2806 |
res = (dlg.ShowModal() == wx.ID_OK) |
|
2807 |
finally: |
|
2808 |
dlg.Destroy() |
|
2809 |
||
2810 |
return res |
|
2811 |
||
2812 |
def Display_Error_Dialog(e_value): |
|
2813 |
message = wxMessageDialog(None, str(e_value), "Error", wxOK|wxICON_ERROR) |
|
2814 |
message.ShowModal() |
|
2815 |
message.Destroy() |
|
2816 |
||
2817 |
def get_last_traceback(tb): |
|
2818 |
while tb.tb_next: |
|
2819 |
tb = tb.tb_next |
|
2820 |
return tb |
|
2821 |
||
2822 |
||
2823 |
def format_namespace(d, indent=' '): |
|
2824 |
return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()]) |
|
2825 |
||
2826 |
||
2827 |
ignored_exceptions = [] # a problem with a line in a module is only reported once per session |
|
2828 |
||
2829 |
def wxAddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
|
2830 |
||
2831 |
def handle_exception(e_type, e_value, e_traceback): |
|
2832 |
traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func |
|
2833 |
last_tb = get_last_traceback(e_traceback) |
|
2834 |
ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno) |
|
2835 |
if str(e_value).startswith("!!!"): |
|
2836 |
Display_Error_Dialog(e_value) |
|
2837 |
elif ex not in ignored_exceptions: |
|
2838 |
result = Display_Exception_Dialog(e_type,e_value,e_traceback) |
|
2839 |
if result: |
|
2840 |
ignored_exceptions.append(ex) |
|
2841 |
info = { |
|
2842 |
'app-title' : wx.GetApp().GetAppName(), # app_title |
|
2843 |
'app-version' : app_version, |
|
2844 |
'wx-version' : wx.VERSION_STRING, |
|
2845 |
'wx-platform' : wx.Platform, |
|
2846 |
'python-version' : platform.python_version(), #sys.version.split()[0], |
|
2847 |
'platform' : platform.platform(), |
|
2848 |
'e-type' : e_type, |
|
2849 |
'e-value' : e_value, |
|
2850 |
'date' : time.ctime(), |
|
2851 |
'cwd' : os.getcwd(), |
|
2852 |
} |
|
2853 |
if e_traceback: |
|
2854 |
info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value) |
|
2855 |
last_tb = get_last_traceback(e_traceback) |
|
2856 |
exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred |
|
2857 |
info['locals'] = format_namespace(exception_locals) |
|
2858 |
if 'self' in exception_locals: |
|
2859 |
info['self'] = format_namespace(exception_locals['self'].__dict__) |
|
2860 |
||
2861 |
output = open(path+os.sep+"bug_report_"+info['date'].replace(':','-').replace(' ','_')+".txt",'w') |
|
2862 |
lst = info.keys() |
|
2863 |
lst.sort() |
|
2864 |
for a in lst: |
|
2865 |
output.write(a+":\n"+str(info[a])+"\n\n") |
|
2866 |
||
2867 |
#sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
|
2868 |
sys.excepthook = handle_exception |
|
2869 |
||
2870 |
if __name__ == '__main__': |
|
2871 |
app = wxPySimpleApp() |
|
2872 |
wxInitAllImageHandlers() |
|
2873 |
||
2874 |
# Install a exception handle for bug reports |
|
2875 |
wxAddExceptHook(os.getcwd(),__version__) |
|
2876 |
||
2877 |
frame = PLCOpenEditor(None) |
|
2878 |
||
2879 |
frame.Show() |
|
2880 |
app.MainLoop() |
|
2881 |