author | Edouard Tisserant |
Sat, 19 May 2012 12:41:48 +0200 | |
changeset 731 | 4fc681ed0c61 |
parent 730 | 4480b7da6bea |
permissions | -rwxr-xr-x |
442 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
503 | 3 |
import shutil |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
4 |
import socket |
442 | 5 |
|
6 |
__version__ = "$Revision$" |
|
7 |
||
8 |
import os, sys, getopt, wx, tempfile |
|
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
9 |
import __builtin__ |
442 | 10 |
from types import TupleType, StringType, UnicodeType |
11 |
||
12 |
CWD = os.path.split(os.path.realpath(__file__))[0] |
|
13 |
||
14 |
def Bpath(*args): |
|
15 |
return os.path.join(CWD,*args) |
|
16 |
||
17 |
if __name__ == '__main__': |
|
18 |
def usage(): |
|
19 |
print "\nUsage of LPCBeremiz.py :" |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
20 |
print "\n %s Projectpath Buildpath port\n"%sys.argv[0] |
442 | 21 |
|
22 |
try: |
|
23 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
|
24 |
except getopt.GetoptError: |
|
25 |
# print help information and exit: |
|
26 |
usage() |
|
27 |
sys.exit(2) |
|
28 |
||
29 |
for o, a in opts: |
|
30 |
if o in ("-h", "--help"): |
|
31 |
usage() |
|
32 |
sys.exit() |
|
33 |
||
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
34 |
if len(args) != 3: |
442 | 35 |
usage() |
36 |
sys.exit() |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
37 |
else: |
442 | 38 |
projectOpen = args[0] |
39 |
buildpath = args[1] |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
40 |
try: |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
41 |
port = int(args[2]) |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
42 |
except: |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
43 |
usage() |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
44 |
sys.exit() |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
45 |
|
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
46 |
if os.path.exists("LPC_DEBUG"): |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
47 |
__builtin__.__dict__["BMZ_DBG"] = True |
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
48 |
else : |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
49 |
__builtin__.__dict__["BMZ_DBG"] = False |
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
50 |
|
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
51 |
app = wx.PySimpleApp(redirect=BMZ_DBG) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
52 |
app.SetAppName('beremiz') |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
53 |
wx.InitAllImageHandlers() |
442 | 54 |
|
55 |
# Import module for internationalization |
|
56 |
import gettext |
|
57 |
||
58 |
if __name__ == '__main__': |
|
59 |
__builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation |
|
60 |
||
61 |
from Beremiz import * |
|
725 | 62 |
from ProjectController import ProjectController |
63 |
from ConfigTreeNode import ConfigTreeNode |
|
64 |
import connectors |
|
65 |
from util import opjimg |
|
442 | 66 |
from plcopen.structures import LOCATIONDATATYPES |
717 | 67 |
from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP,\ |
442 | 68 |
LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
69 |
from PLCOpenEditor import IDEFrame, ProjectDialog |
442 | 70 |
|
691 | 71 |
havecanfestival = False |
72 |
try: |
|
721 | 73 |
from canfestival import RootClass as CanOpenRootClass |
74 |
from canfestival.canfestival import _SlaveCTN, _NodeListCTN, NodeManager |
|
691 | 75 |
havecanfestival = True |
76 |
except: |
|
77 |
havecanfestival = False |
|
78 |
||
79 |
||
442 | 80 |
#------------------------------------------------------------------------------- |
717 | 81 |
# CANFESTIVAL CONFNODE HACK |
512
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
82 |
#------------------------------------------------------------------------------- |
721 | 83 |
# from canfestival import canfestival |
629
61347cc521d1
fix unnecessary CanFestival plugin load in lpcberemiz
Edouard Tisserant
parents:
625
diff
changeset
|
84 |
# class LPC_canfestival_config: |
61347cc521d1
fix unnecessary CanFestival plugin load in lpcberemiz
Edouard Tisserant
parents:
625
diff
changeset
|
85 |
# def getCFLAGS(self, *args): |
61347cc521d1
fix unnecessary CanFestival plugin load in lpcberemiz
Edouard Tisserant
parents:
625
diff
changeset
|
86 |
# return "" |
61347cc521d1
fix unnecessary CanFestival plugin load in lpcberemiz
Edouard Tisserant
parents:
625
diff
changeset
|
87 |
# |
61347cc521d1
fix unnecessary CanFestival plugin load in lpcberemiz
Edouard Tisserant
parents:
625
diff
changeset
|
88 |
# def getLDFLAGS(self, *args): |
61347cc521d1
fix unnecessary CanFestival plugin load in lpcberemiz
Edouard Tisserant
parents:
625
diff
changeset
|
89 |
# return "" |
61347cc521d1
fix unnecessary CanFestival plugin load in lpcberemiz
Edouard Tisserant
parents:
625
diff
changeset
|
90 |
# |
61347cc521d1
fix unnecessary CanFestival plugin load in lpcberemiz
Edouard Tisserant
parents:
625
diff
changeset
|
91 |
# canfestival.local_canfestival_config = LPC_canfestival_config() |
512
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
92 |
#------------------------------------------------------------------------------- |
442 | 93 |
# LPCModule Class |
94 |
#------------------------------------------------------------------------------- |
|
95 |
||
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
96 |
LOCATION_TYPES = {"I": LOCATION_VAR_INPUT, |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
97 |
"Q": LOCATION_VAR_OUTPUT, |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
98 |
"M": LOCATION_VAR_MEMORY} |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
99 |
|
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
100 |
LOCATION_DIRS = dict([(dir, size) for size, dir in LOCATION_TYPES.iteritems()]) |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
101 |
|
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
102 |
LOCATION_SIZES = {} |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
103 |
for size, types in LOCATIONDATATYPES.iteritems(): |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
104 |
for type in types: |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
105 |
LOCATION_SIZES[type] = size |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
106 |
|
442 | 107 |
def _GetModuleChildren(module): |
108 |
children = [] |
|
109 |
for child in module["children"]: |
|
110 |
if child["type"] == LOCATION_GROUP: |
|
111 |
children.extend(child["children"]) |
|
112 |
else: |
|
113 |
children.append(child) |
|
114 |
return children |
|
115 |
||
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
116 |
def _GetVariables(module): |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
117 |
variables = [] |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
118 |
for child in module["children"]: |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
119 |
if child["type"] in [LOCATION_GROUP, LOCATION_MODULE]: |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
120 |
variables.extend(_GetVariables(child)) |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
121 |
else: |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
122 |
variables.append(child) |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
123 |
return variables |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
124 |
|
442 | 125 |
def _GetLastModuleGroup(module): |
126 |
group = module |
|
127 |
for child in module["children"]: |
|
128 |
if child["type"] == LOCATION_GROUP: |
|
129 |
group = child |
|
130 |
return group["children"] |
|
131 |
||
132 |
def _GetModuleBySomething(module, something, toks): |
|
133 |
for child in _GetModuleChildren(module): |
|
134 |
if child.get(something) == toks[0]: |
|
135 |
if len(toks) > 1: |
|
136 |
return _GetModuleBySomething(child, something, toks[1:]) |
|
137 |
return child |
|
138 |
return None |
|
139 |
||
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
140 |
def _GetModuleVariable(module, location, direction): |
442 | 141 |
for child in _GetModuleChildren(module): |
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
142 |
if child["location"] == location and child["type"] == LOCATION_TYPES[direction]: |
442 | 143 |
return child |
144 |
return None |
|
145 |
||
146 |
def _RemoveModuleChild(module, child): |
|
147 |
if child in module["children"]: |
|
148 |
module["children"].remove(child) |
|
149 |
else: |
|
150 |
for group in module["children"]: |
|
151 |
if group["type"] == LOCATION_GROUP and child in group["children"]: |
|
152 |
group["children"].remove(child) |
|
153 |
||
717 | 154 |
BUS_TEXT = """/* Code generated by LPCBus confnode */ |
155 |
||
156 |
/* LPCBus confnode includes */ |
|
442 | 157 |
#include "app_glue.h" |
158 |
#ifdef _WINDOWS_H |
|
159 |
#include "iec_types.h" |
|
160 |
#else |
|
161 |
#include "iec_std_lib.h" |
|
162 |
#endif |
|
163 |
||
553 | 164 |
%(declare_code)s |
165 |
||
717 | 166 |
/* LPCBus confnode user variables definition */ |
442 | 167 |
%(var_decl)s |
168 |
||
717 | 169 |
/* LPCBus confnode functions */ |
442 | 170 |
int __init_%(location_str)s(int argc,char **argv) |
171 |
{ |
|
553 | 172 |
%(init_code)s |
442 | 173 |
return 0; |
174 |
} |
|
175 |
||
176 |
void __cleanup_%(location_str)s(void) |
|
177 |
{ |
|
178 |
} |
|
179 |
||
180 |
void __retrieve_%(location_str)s(void) |
|
181 |
{ |
|
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
182 |
%(retrieve_code)s |
442 | 183 |
} |
184 |
||
185 |
void __publish_%(location_str)s(void) |
|
186 |
{ |
|
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
187 |
%(publish_code)s |
442 | 188 |
} |
189 |
""" |
|
190 |
||
191 |
class LPCBus(object): |
|
192 |
||
193 |
def __init__(self): |
|
194 |
self.VariableLocationTree = [] |
|
195 |
self.ResetUsedLocations() |
|
196 |
self.Icon = None |
|
197 |
||
198 |
def __getitem__(self, key): |
|
199 |
if key == "children": |
|
200 |
return self.VariableLocationTree |
|
201 |
raise KeyError, "Only 'children' key is available" |
|
202 |
||
718 | 203 |
def CTNEnabled(self): |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
204 |
return None |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
205 |
|
442 | 206 |
def SetIcon(self, icon): |
207 |
self.Icon = icon |
|
208 |
||
209 |
def _GetChildBySomething(self, something, toks): |
|
210 |
return _GetModuleBySomething({"children" : self.VariableLocationTree}, something, toks) |
|
211 |
||
212 |
def GetBaseTypes(self): |
|
718 | 213 |
return self.GetCTRoot().GetBaseTypes() |
442 | 214 |
|
215 |
def GetSizeOfType(self, type): |
|
718 | 216 |
return LOCATION_SIZES[self.GetCTRoot().GetBaseType(type)] |
442 | 217 |
|
218 |
def _GetVariableLocationTree(self, current_location, infos): |
|
219 |
if infos["type"] == LOCATION_MODULE: |
|
220 |
location = current_location + (infos["IEC_Channel"],) |
|
221 |
return {"name": infos["name"], |
|
222 |
"type": infos["type"], |
|
223 |
"location": ".".join(map(str, location + ("x",))), |
|
224 |
"icon": infos["icon"], |
|
225 |
"children": [self._GetVariableLocationTree(location, child) for child in infos["children"]]} |
|
226 |
elif infos["type"] == LOCATION_GROUP: |
|
227 |
return {"name": infos["name"], |
|
228 |
"type": infos["type"], |
|
229 |
"location": "", |
|
230 |
"icon": infos["icon"], |
|
231 |
"children": [self._GetVariableLocationTree(current_location, child) for child in infos["children"]]} |
|
232 |
else: |
|
233 |
size = self.GetSizeOfType(infos["IEC_type"]) |
|
234 |
location = "%" + LOCATION_DIRS[infos["type"]] + size + ".".join(map(str, current_location + infos["location"])) |
|
235 |
return {"name": infos["name"], |
|
236 |
"type": infos["type"], |
|
237 |
"size": size, |
|
238 |
"IEC_type": infos["IEC_type"], |
|
659
71a824446673
Adding support for drag'n dropping located variables from topology panel to configurations and resources variable panel for declaring global located variables
laurent
parents:
652
diff
changeset
|
239 |
"var_name": infos["name"], |
442 | 240 |
"location": location, |
241 |
"description": infos["description"], |
|
242 |
"children": []} |
|
243 |
||
244 |
def GetVariableLocationTree(self): |
|
245 |
return {"name": self.BaseParams.getName(), |
|
717 | 246 |
"type": LOCATION_CONFNODE, |
442 | 247 |
"location": self.GetFullIEC_Channel(), |
248 |
"icon": self.Icon, |
|
249 |
"children": [self._GetVariableLocationTree(self.GetCurrentLocation(), child) |
|
250 |
for child in self.VariableLocationTree]} |
|
251 |
||
718 | 252 |
def CTNTestModified(self): |
442 | 253 |
return False |
254 |
||
718 | 255 |
def CTNMakeDir(self): |
442 | 256 |
pass |
257 |
||
718 | 258 |
def CTNRequestSave(self): |
442 | 259 |
return None |
260 |
||
261 |
def ResetUsedLocations(self): |
|
262 |
self.UsedLocations = {} |
|
263 |
||
264 |
def _AddUsedLocation(self, parent, location): |
|
265 |
num = location.pop(0) |
|
266 |
if not parent.has_key(num): |
|
267 |
parent[num] = {"used": False, "children": {}} |
|
268 |
if len(location) > 0: |
|
269 |
self._AddUsedLocation(parent[num]["children"], location) |
|
270 |
else: |
|
271 |
parent[num]["used"] = True |
|
272 |
||
273 |
def AddUsedLocation(self, location): |
|
274 |
if len(location) > 0: |
|
275 |
self._AddUsedLocation(self.UsedLocations, list(location)) |
|
276 |
||
277 |
def _CheckLocationConflicts(self, parent, location): |
|
278 |
num = location.pop(0) |
|
279 |
if not parent.has_key(num): |
|
280 |
return False |
|
281 |
if len(location) > 0: |
|
282 |
if parent[num]["used"]: |
|
283 |
return True |
|
284 |
return self._CheckLocationConflicts(parent[num]["children"], location) |
|
285 |
elif len(parent[num]["children"]) > 0: |
|
286 |
return True |
|
287 |
return False |
|
288 |
||
289 |
def CheckLocationConflicts(self, location): |
|
290 |
if len(location) > 0: |
|
291 |
return self._CheckLocationConflicts(self.UsedLocations, list(location)) |
|
292 |
return False |
|
293 |
||
718 | 294 |
def CTNGenerate_C(self, buildpath, locations): |
442 | 295 |
""" |
296 |
Generate C code |
|
717 | 297 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
442 | 298 |
@param locations: List of complete variables locations \ |
299 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
|
300 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
|
301 |
"DIR" : direction "Q","I" or "M" |
|
302 |
"SIZE" : size "X", "B", "W", "D", "L" |
|
303 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
|
304 |
}, ...] |
|
305 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
|
306 |
""" |
|
307 |
current_location = self.GetCurrentLocation() |
|
308 |
# define a unique name for the generated C file |
|
309 |
location_str = "_".join(map(str, current_location)) |
|
310 |
||
311 |
code_str = {"location_str": location_str, |
|
312 |
"var_decl": "", |
|
313 |
"declare_code": "", |
|
553 | 314 |
"init_code": "", |
442 | 315 |
"retrieve_code": "", |
316 |
"publish_code": "", |
|
317 |
} |
|
318 |
||
553 | 319 |
for module in _GetModuleChildren(self): |
320 |
if module["init"] != "": |
|
321 |
code_str["init_code"] += " %s\n" % module["init"] |
|
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
322 |
|
442 | 323 |
# Adding variables |
324 |
vars = [] |
|
325 |
self.ResetUsedLocations() |
|
326 |
for location in locations: |
|
327 |
loc = location["LOC"][len(current_location):] |
|
328 |
group = next = self |
|
329 |
i = 0 |
|
330 |
while next is not None and i < len(loc): |
|
331 |
next = self._GetChildBySomething("IEC_Channel", loc[:i + 1]) |
|
332 |
if next is not None: |
|
333 |
i += 1 |
|
334 |
group = next |
|
335 |
var_loc = loc[i:] |
|
530 | 336 |
for variable in _GetModuleChildren(group): |
566
657900299557
Fix bug in LPCBeremiz that use input retrieve and publish code for ouput with the same location
laurent
parents:
561
diff
changeset
|
337 |
if variable["location"] == var_loc and location["DIR"] == LOCATION_DIRS[variable["type"]]: |
543
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
338 |
# if location["DIR"] != LOCATION_DIRS[variable["type"]]: |
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
339 |
# raise Exception, "Direction conflict in variable definition" |
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
340 |
# if location["IEC_TYPE"] != variable["IEC_type"]: |
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
341 |
# raise Exception, "Type conflict in variable definition" |
442 | 342 |
if location["DIR"] == "Q": |
343 |
if self.CheckLocationConflicts(location["LOC"]): |
|
344 |
raise Exception, "BYTE and BIT from the same BYTE can't be used together" |
|
345 |
self.AddUsedLocation(location["LOC"]) |
|
346 |
vars.append({"location": location["NAME"], |
|
347 |
"Type": variable["IEC_type"], |
|
348 |
"Retrieve": variable["retrieve"], |
|
349 |
"Publish": variable["publish"], |
|
350 |
}) |
|
351 |
break |
|
718 | 352 |
base_types = self.GetCTRoot().GetBaseTypes() |
442 | 353 |
for var in vars: |
354 |
prefix = "" |
|
355 |
if var["Type"] in base_types: |
|
356 |
prefix = "IEC_" |
|
357 |
code_str["var_decl"] += "%s%s beremiz%s;\n"%(prefix, var["Type"], var["location"]) |
|
358 |
code_str["var_decl"] += "%s%s *%s = &beremiz%s;\n"%(prefix, var["Type"], var["location"], var["location"]) |
|
359 |
if var["Retrieve"] != "": |
|
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
360 |
code_str["retrieve_code"] += " " + var["Retrieve"] % ("*" + var["location"]) + "\n" |
442 | 361 |
if var["Publish"] != "": |
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
362 |
code_str["publish_code"] += " " + var["Publish"] % ("*" + var["location"]) + "\n" |
442 | 363 |
|
553 | 364 |
Gen_Module_path = os.path.join(buildpath, "Bus_%s.c"%location_str) |
442 | 365 |
module = open(Gen_Module_path,'w') |
366 |
module.write(BUS_TEXT % code_str) |
|
367 |
module.close() |
|
368 |
||
718 | 369 |
matiec_flags = '"-I%s"'%os.path.abspath(self.GetCTRoot().GetIECLibPath()) |
442 | 370 |
return [(Gen_Module_path, matiec_flags)],"",True |
371 |
||
372 |
#------------------------------------------------------------------------------- |
|
717 | 373 |
# LPC CanFestival ConfNode Class |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
374 |
#------------------------------------------------------------------------------- |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
375 |
|
691 | 376 |
if havecanfestival: |
377 |
||
378 |
DEFAULT_SETTINGS = { |
|
379 |
"CAN_Baudrate": "125K", |
|
380 |
"Slave_NodeId": 2, |
|
381 |
"Master_NodeId": 1, |
|
382 |
} |
|
383 |
||
718 | 384 |
class LPCCanOpenSlave(_SlaveCTN): |
691 | 385 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
386 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
387 |
<xsd:element name="CanFestivalSlaveNode"> |
|
388 |
<xsd:complexType> |
|
389 |
<xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/> |
|
390 |
<xsd:attribute name="NodeId" type="xsd:string" use="optional" default="%(Slave_NodeId)d"/> |
|
391 |
<xsd:attribute name="Sync_Align" type="xsd:integer" use="optional" default="0"/> |
|
392 |
<xsd:attribute name="Sync_Align_Ratio" use="optional" default="50"> |
|
393 |
<xsd:simpleType> |
|
394 |
<xsd:restriction base="xsd:integer"> |
|
395 |
<xsd:minInclusive value="1"/> |
|
396 |
<xsd:maxInclusive value="99"/> |
|
397 |
</xsd:restriction> |
|
398 |
</xsd:simpleType> |
|
399 |
</xsd:attribute> |
|
400 |
</xsd:complexType> |
|
401 |
</xsd:element> |
|
402 |
</xsd:schema> |
|
403 |
""" % DEFAULT_SETTINGS |
|
404 |
||
405 |
def __init__(self): |
|
406 |
# TODO change netname when name change |
|
407 |
NodeManager.__init__(self) |
|
408 |
odfilepath = self.GetSlaveODPath() |
|
409 |
if(os.path.isfile(odfilepath)): |
|
410 |
self.OpenFileInCurrent(odfilepath) |
|
411 |
else: |
|
412 |
self.CreateNewNode("SlaveNode", # Name - will be changed at build time |
|
413 |
0x00, # NodeID - will be changed at build time |
|
414 |
"slave", # Type |
|
415 |
"", # description |
|
416 |
"None", # profile |
|
417 |
"", # prfile filepath |
|
418 |
"heartbeat", # NMT |
|
419 |
[]) # options |
|
718 | 420 |
self.OnCTNSave() |
691 | 421 |
|
422 |
def GetCanDevice(self): |
|
423 |
return str(self.BaseParams.getIEC_Channel()) |
|
424 |
||
718 | 425 |
class LPCCanOpenMaster(_NodeListCTN): |
691 | 426 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
427 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
428 |
<xsd:element name="CanFestivalNode"> |
|
429 |
<xsd:complexType> |
|
430 |
<xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/> |
|
431 |
<xsd:attribute name="NodeId" type="xsd:string" use="optional" default="%(Master_NodeId)d"/> |
|
432 |
<xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/> |
|
433 |
</xsd:complexType> |
|
434 |
</xsd:element> |
|
435 |
</xsd:schema> |
|
436 |
""" % DEFAULT_SETTINGS |
|
437 |
||
438 |
def GetCanDevice(self): |
|
439 |
return str(self.BaseParams.getIEC_Channel()) |
|
440 |
||
441 |
class LPCCanOpen(CanOpenRootClass): |
|
442 |
XSD = None |
|
718 | 443 |
CTNChildrenTypes = [("CanOpenNode",LPCCanOpenMaster, "CanOpen Master"), |
691 | 444 |
("CanOpenSlave",LPCCanOpenSlave, "CanOpen Slave")] |
445 |
||
446 |
def GetCanDriver(self): |
|
447 |
return "" |
|
448 |
||
718 | 449 |
def LoadChildren(self): |
450 |
ConfigTreeNode.LoadChildren(self) |
|
691 | 451 |
|
452 |
if self.GetChildByName("Master") is None: |
|
718 | 453 |
master = self.CTNAddChild("Master", "CanOpenNode", 0) |
691 | 454 |
master.BaseParams.setEnabled(False) |
455 |
||
456 |
if self.GetChildByName("Slave") is None: |
|
718 | 457 |
slave = self.CTNAddChild("Slave", "CanOpenSlave", 1) |
691 | 458 |
slave.BaseParams.setEnabled(False) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
459 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
460 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
461 |
#------------------------------------------------------------------------------- |
725 | 462 |
# LPCProjectController Class |
442 | 463 |
#------------------------------------------------------------------------------- |
464 |
||
465 |
def mycopytree(src, dst): |
|
466 |
""" |
|
467 |
Copy content of a directory to an other, omit hidden files |
|
468 |
@param src: source directory |
|
469 |
@param dst: destination directory |
|
470 |
""" |
|
471 |
for i in os.listdir(src): |
|
652
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
472 |
if not i.startswith('.') and i != "pous.xml": |
442 | 473 |
srcpath = os.path.join(src,i) |
474 |
dstpath = os.path.join(dst,i) |
|
475 |
if os.path.isdir(srcpath): |
|
503 | 476 |
if os.path.exists(dstpath): |
477 |
shutil.rmtree(dstpath) |
|
478 |
os.makedirs(dstpath) |
|
442 | 479 |
mycopytree(srcpath, dstpath) |
480 |
elif os.path.isfile(srcpath): |
|
481 |
shutil.copy2(srcpath, dstpath) |
|
482 |
||
572
c965548cb6f7
Fixed MD5 computation for makefile based toolchain, helps avoiding unnecessary builds
edouard
parents:
571
diff
changeset
|
483 |
[SIMULATION_MODE, TRANSFER_MODE] = range(2) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
484 |
|
725 | 485 |
class LPCProjectController(ProjectController): |
717 | 486 |
|
487 |
ConfNodeMethods = [ |
|
492 | 488 |
{"bitmap" : opjimg("Debug"), |
489 |
"name" : _("Simulate"), |
|
490 |
"tooltip" : _("Simulate PLC"), |
|
491 |
"method" : "_Simulate"}, |
|
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
492 |
{"bitmap" : opjimg("Run"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
493 |
"name" : _("Run"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
494 |
"shown" : False, |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
495 |
"tooltip" : _("Start PLC"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
496 |
"method" : "_Run"}, |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
497 |
{"bitmap" : opjimg("Stop"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
498 |
"name" : _("Stop"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
499 |
"shown" : False, |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
500 |
"tooltip" : _("Stop Running PLC"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
501 |
"method" : "_Stop"}, |
541 | 502 |
{"bitmap" : opjimg("Build"), |
503 |
"name" : _("Build"), |
|
504 |
"tooltip" : _("Build project into build folder"), |
|
625
08d4cc1ceb9b
Fixed LPCBeremiz to refect recent root plugin build method name to change
Edouard Tisserant
parents:
599
diff
changeset
|
505 |
"method" : "_Build"}, |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
506 |
{"bitmap" : opjimg("Transfer"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
507 |
"name" : _("Transfer"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
508 |
"shown" : False, |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
509 |
"tooltip" : _("Transfer PLC"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
510 |
"method" : "_Transfer"}, |
442 | 511 |
] |
512 |
||
652
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
513 |
def __init__(self, frame, logger, buildpath): |
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
514 |
self.OrigBuildPath = buildpath |
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
515 |
|
725 | 516 |
ProjectController.__init__(self, frame, logger) |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
517 |
|
691 | 518 |
if havecanfestival: |
718 | 519 |
self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus"), ("CanOpen", LPCCanOpen, "CanOpen bus")] |
691 | 520 |
else: |
718 | 521 |
self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus")] |
522 |
self.CTNType = "LPC" |
|
652
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
523 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
524 |
self.OnlineMode = "OFF" |
561 | 525 |
self.LPCConnector = None |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
526 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
527 |
self.CurrentMode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
528 |
self.previous_mode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
529 |
|
492 | 530 |
self.SimulationBuildPath = None |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
531 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
532 |
self.AbortTransferTimer = None |
652
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
533 |
|
717 | 534 |
def ConfNodeLibraryFilePath(self): |
652
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
535 |
if self.OrigBuildPath is not None: |
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
536 |
return os.path.join(self.OrigBuildPath, "pous.xml") |
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
537 |
else: |
725 | 538 |
return ProjectController.ConfNodeLibraryFilePath(self) |
652
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
539 |
|
442 | 540 |
def GetProjectName(self): |
541 |
return self.Project.getname() |
|
542 |
||
510
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
543 |
def GetDefaultTargetName(self): |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
544 |
if self.CurrentMode == SIMULATION_MODE: |
725 | 545 |
return ProjectController.GetDefaultTargetName(self) |
492 | 546 |
else: |
510
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
547 |
return "LPC" |
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
548 |
|
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
549 |
def GetTarget(self): |
725 | 550 |
target = ProjectController.GetTarget(self) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
551 |
if self.CurrentMode != SIMULATION_MODE: |
510
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
552 |
target.getcontent()["value"].setBuildPath(self.BuildPath) |
442 | 553 |
return target |
492 | 554 |
|
555 |
def _getBuildPath(self): |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
556 |
if self.CurrentMode == SIMULATION_MODE: |
492 | 557 |
if self.SimulationBuildPath is None: |
558 |
self.SimulationBuildPath = os.path.join(tempfile.mkdtemp(), os.path.basename(self.ProjectPath), "build") |
|
559 |
return self.SimulationBuildPath |
|
560 |
else: |
|
725 | 561 |
return ProjectController._getBuildPath(self) |
503 | 562 |
|
625
08d4cc1ceb9b
Fixed LPCBeremiz to refect recent root plugin build method name to change
Edouard Tisserant
parents:
599
diff
changeset
|
563 |
def _Build(self): |
599 | 564 |
save = self.ProjectTestModified() |
565 |
if save: |
|
566 |
self.SaveProject() |
|
567 |
self.AppFrame._Refresh(TITLE, FILEMENU) |
|
503 | 568 |
if self.BuildPath is not None: |
569 |
mycopytree(self.OrigBuildPath, self.BuildPath) |
|
725 | 570 |
ProjectController._Build(self) |
599 | 571 |
if save: |
572 |
wx.CallAfter(self.AppFrame.RefreshAll) |
|
492 | 573 |
|
442 | 574 |
def SetProjectName(self, name): |
575 |
return self.Project.setname(name) |
|
576 |
||
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
577 |
def SetOnlineMode(self, mode, path=None): |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
578 |
if self.OnlineMode != mode.upper(): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
579 |
self.OnlineMode = mode.upper() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
580 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
581 |
if self.OnlineMode != "OFF": |
543
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
582 |
uri = "LPC://%s/%s" % (self.OnlineMode,path) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
583 |
try: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
584 |
self.LPCConnector = connectors.ConnectorFactory(uri, self) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
585 |
except Exception, msg: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
586 |
self.logger.write_error(_("Exception while connecting %s!\n")%uri) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
587 |
self.logger.write_error(traceback.format_exc()) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
588 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
589 |
# Did connection success ? |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
590 |
if self.LPCConnector is None: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
591 |
# Oups. |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
592 |
self.logger.write_error(_("Connection failed to %s!\n")%uri) |
492 | 593 |
|
594 |
else: |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
595 |
self.LPCConnector = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
596 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
597 |
self.ApplyOnlineMode() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
598 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
599 |
def ApplyOnlineMode(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
600 |
if self.CurrentMode != SIMULATION_MODE: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
601 |
self.KillDebugThread() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
602 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
603 |
self._connector = self.LPCConnector |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
604 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
605 |
# Init with actual PLC status and print it |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
606 |
self.UpdateMethodsFromPLCStatus() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
607 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
608 |
if self.LPCConnector is not None and self.OnlineMode == "APPLICATION": |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
609 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
610 |
self.CompareLocalAndRemotePLC() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
611 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
612 |
if self.previous_plcstate is not None: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
613 |
status = _(self.previous_plcstate) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
614 |
else: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
615 |
status = "" |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
616 |
self.logger.write(_("PLC is %s\n")%status) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
617 |
|
575
6765adf58711
Removed status polling for LPC, as status cannot change by itself, fixed MD5 comparison in app mode
edouard
parents:
574
diff
changeset
|
618 |
#if self.StatusTimer and not self.StatusTimer.IsRunning(): |
6765adf58711
Removed status polling for LPC, as status cannot change by itself, fixed MD5 comparison in app mode
edouard
parents:
574
diff
changeset
|
619 |
# # Start the status Timer |
6765adf58711
Removed status polling for LPC, as status cannot change by itself, fixed MD5 comparison in app mode
edouard
parents:
574
diff
changeset
|
620 |
# self.StatusTimer.Start(milliseconds=2000, oneShot=False) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
621 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
622 |
if self.previous_plcstate=="Started": |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
623 |
if self.DebugAvailable() and self.GetIECProgramsAndVariables(): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
624 |
self.logger.write(_("Debug connect matching running PLC\n")) |
576
7fcdc0d3d8d9
Some typo fixes to make debug related methods in LPCAppOject stop throwing exceptions, less agressive error message when unplugging LPC
edouard
parents:
575
diff
changeset
|
625 |
self._connect_debug() |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
626 |
else: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
627 |
self.logger.write_warning(_("Debug do not match PLC - stop/transfert/start to re-enable\n")) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
628 |
|
543
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
629 |
elif self.StatusTimer and self.StatusTimer.IsRunning(): |
492 | 630 |
self.StatusTimer.Stop() |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
631 |
|
572
c965548cb6f7
Fixed MD5 computation for makefile based toolchain, helps avoiding unnecessary builds
edouard
parents:
571
diff
changeset
|
632 |
if self.CurrentMode == TRANSFER_MODE: |
492 | 633 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
634 |
if self.OnlineMode == "BOOTLOADER": |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
635 |
self.BeginTransfer() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
636 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
637 |
elif self.OnlineMode == "APPLICATION": |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
638 |
self.CurrentMode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
639 |
self.AbortTransferTimer.Stop() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
640 |
self.AbortTransferTimer = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
641 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
642 |
self.logger.write(_("PLC transferred successfully\n")) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
643 |
|
444
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
644 |
# Update a PLCOpenEditor Pou variable name |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
645 |
def UpdateProjectVariableName(self, old_name, new_name): |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
646 |
self.Project.updateElementName(old_name, new_name) |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
647 |
self.BufferProject() |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
648 |
|
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
649 |
def RemoveProjectVariableByAddress(self, address): |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
650 |
self.Project.removeVariableByAddress(address) |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
651 |
self.BufferProject() |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
652 |
|
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
653 |
def RemoveProjectVariableByFilter(self, leading): |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
654 |
self.Project.removeVariableByFilter(leading) |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
655 |
self.BufferProject() |
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
656 |
|
442 | 657 |
def LoadProject(self, ProjectPath, BuildPath=None): |
658 |
""" |
|
478 | 659 |
Load a project contained in a folder |
660 |
@param ProjectPath: path of the project folder |
|
442 | 661 |
""" |
478 | 662 |
if os.path.basename(ProjectPath) == "": |
663 |
ProjectPath = os.path.dirname(ProjectPath) |
|
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
664 |
|
478 | 665 |
# Verify that project contains a PLCOpen program |
666 |
plc_file = os.path.join(ProjectPath, "plc.xml") |
|
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
667 |
if os.path.isfile(plc_file): |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
668 |
# Load PLCOpen file |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
669 |
result = self.OpenXMLFile(plc_file) |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
670 |
if result: |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
671 |
return result |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
672 |
else: |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
673 |
self.CreateNewProject({"companyName": "", |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
674 |
"productName": "", |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
675 |
"productVersion": "", |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
676 |
"projectName": "", |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
677 |
"pageSize": (0, 0), |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
678 |
"scaling": {}}) |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
679 |
|
442 | 680 |
# Change XSD into class members |
681 |
self._AddParamsMembers() |
|
718 | 682 |
self.Children = {} |
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
683 |
|
717 | 684 |
# Keep track of the root confnode (i.e. project path) |
442 | 685 |
self.ProjectPath = ProjectPath |
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
686 |
|
478 | 687 |
self.BuildPath = self._getBuildPath() |
652
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
688 |
if self.OrigBuildPath is not None: |
eb2d9f2b3567
Adding support for loading specific POUs library in LPCBeremiz
laurent
parents:
650
diff
changeset
|
689 |
mycopytree(self.OrigBuildPath, self.BuildPath) |
442 | 690 |
|
478 | 691 |
# If dir have already be made, and file exist |
718 | 692 |
if os.path.isdir(self.CTNPath()) and os.path.isfile(self.ConfNodeXmlFilePath()): |
717 | 693 |
#Load the confnode.xml file into parameters members |
478 | 694 |
result = self.LoadXMLParams() |
695 |
if result: |
|
696 |
return result |
|
718 | 697 |
#Load and init all the children |
698 |
self.LoadChildren() |
|
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
699 |
|
691 | 700 |
if havecanfestival and self.GetChildByName("CanOpen") is None: |
718 | 701 |
canopen = self.CTNAddChild("CanOpen", "CanOpen", 0) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
702 |
canopen.BaseParams.setEnabled(False) |
718 | 703 |
canopen.LoadChildren() |
704 |
||
705 |
if self.CTNTestModified(): |
|
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
706 |
self.SaveProject() |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
707 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
708 |
if wx.GetApp() is None: |
717 | 709 |
self.RefreshConfNodesBlockLists() |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
710 |
else: |
717 | 711 |
wx.CallAfter(self.RefreshConfNodesBlockLists) |
478 | 712 |
|
713 |
return None |
|
442 | 714 |
|
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
715 |
############# Real PLC object access ############# |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
716 |
def UpdateMethodsFromPLCStatus(self): |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
717 |
# Get PLC state : Running or Stopped |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
718 |
# TODO : use explicit status instead of boolean |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
719 |
if self.OnlineMode == "OFF": |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
720 |
status = "Disconnected" |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
721 |
elif self.OnlineMode == "BOOTLOADER": |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
722 |
status = "Connected" |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
723 |
else: |
492 | 724 |
if self._connector is not None: |
725 |
status = self._connector.GetPLCstatus() |
|
726 |
else: |
|
727 |
status = "Disconnected" |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
728 |
if self.previous_plcstate != status or self.previous_mode != self.CurrentMode: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
729 |
simulating = self.CurrentMode == SIMULATION_MODE |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
730 |
for args in { |
492 | 731 |
"Started" : [("_Simulate", False), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
732 |
("_Run", False), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
733 |
("_Stop", True), |
625
08d4cc1ceb9b
Fixed LPCBeremiz to refect recent root plugin build method name to change
Edouard Tisserant
parents:
599
diff
changeset
|
734 |
("_Build", True), |
559 | 735 |
("_Transfer", True)], |
736 |
"Stopped" : [("_Simulate", False), |
|
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
737 |
("_Run", True), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
738 |
("_Stop", False), |
625
08d4cc1ceb9b
Fixed LPCBeremiz to refect recent root plugin build method name to change
Edouard Tisserant
parents:
599
diff
changeset
|
739 |
("_Build", True), |
559 | 740 |
("_Transfer", True)], |
492 | 741 |
"Connected" : [("_Simulate", not simulating), |
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
742 |
("_Run", True), |
492 | 743 |
("_Stop", simulating), |
625
08d4cc1ceb9b
Fixed LPCBeremiz to refect recent root plugin build method name to change
Edouard Tisserant
parents:
599
diff
changeset
|
744 |
("_Build", True), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
745 |
("_Transfer", True)], |
492 | 746 |
"Disconnected" :[("_Simulate", not simulating), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
747 |
("_Run", False), |
492 | 748 |
("_Stop", simulating), |
625
08d4cc1ceb9b
Fixed LPCBeremiz to refect recent root plugin build method name to change
Edouard Tisserant
parents:
599
diff
changeset
|
749 |
("_Build", True), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
750 |
("_Transfer", False)], |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
751 |
}.get(status,[]): |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
752 |
self.ShowMethod(*args) |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
753 |
self.previous_plcstate = status |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
754 |
self.previous_mode = self.CurrentMode |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
755 |
return True |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
756 |
return False |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
757 |
|
492 | 758 |
def Generate_plc_declare_locations(self): |
759 |
""" |
|
760 |
Declare used locations in order to simulatePLC in a black box |
|
761 |
""" |
|
762 |
return """#include "iec_types_all.h" |
|
763 |
||
764 |
#define __LOCATED_VAR(type, name, ...) \ |
|
765 |
type beremiz_##name;\ |
|
766 |
type *name = &beremiz_##name; |
|
767 |
||
768 |
#include "LOCATED_VARIABLES.h" |
|
769 |
||
770 |
#undef __LOCATED_VAR |
|
771 |
||
772 |
""" |
|
773 |
||
708 | 774 |
def Generate_lpc_retain_array_sim(self): |
775 |
""" |
|
776 |
Support for retain array in Simulation |
|
777 |
""" |
|
778 |
return """/* Support for retain array */ |
|
779 |
#define USER_RETAIN_ARRAY_SIZE 2000 |
|
780 |
#define NUM_OF_COLS 3 |
|
781 |
unsigned char readOK = 0; |
|
782 |
unsigned int foundIndex = USER_RETAIN_ARRAY_SIZE; |
|
783 |
unsigned int retainArray[USER_RETAIN_ARRAY_SIZE][NUM_OF_COLS]; |
|
784 |
||
785 |
unsigned int __GetRetainData(unsigned char READ, unsigned int INDEX, unsigned int COLUMN) |
|
786 |
{ |
|
787 |
if(READ == 1) |
|
788 |
{ |
|
789 |
if((0<=INDEX) && (INDEX<USER_RETAIN_ARRAY_SIZE) && (0<=COLUMN) && (COLUMN<NUM_OF_COLS)) |
|
790 |
{ |
|
791 |
readOK = 1; |
|
792 |
return retainArray[INDEX][COLUMN]; |
|
793 |
} |
|
794 |
} |
|
795 |
||
796 |
readOK = 0; |
|
797 |
return 0; |
|
798 |
} |
|
799 |
||
800 |
unsigned char __SetRetainData(unsigned char WRITE, unsigned int INDEX, unsigned int WORD1, unsigned int WORD2, unsigned int WORD3) |
|
801 |
{ |
|
802 |
if(WRITE == 1) |
|
803 |
{ |
|
804 |
if((0<=INDEX) && (INDEX<USER_RETAIN_ARRAY_SIZE)) |
|
805 |
{ |
|
806 |
retainArray[INDEX][0] = WORD1; |
|
807 |
retainArray[INDEX][1] = WORD2; |
|
808 |
retainArray[INDEX][2] = WORD3; |
|
809 |
return 1; |
|
810 |
} |
|
811 |
} |
|
812 |
||
813 |
return 0; |
|
814 |
} |
|
815 |
||
816 |
unsigned char __FindRetainData(unsigned char SEARCH, unsigned int START_IDX, unsigned int END_IDX, unsigned int WORD1, unsigned int WORD2, unsigned int WORD3) |
|
817 |
{ |
|
818 |
unsigned int i; |
|
819 |
||
820 |
if((SEARCH==1) && (0<=START_IDX) && (START_IDX<USER_RETAIN_ARRAY_SIZE) && (START_IDX<=END_IDX) && (END_IDX<USER_RETAIN_ARRAY_SIZE)) |
|
821 |
{ |
|
822 |
for(i=START_IDX;i<=END_IDX;i++) |
|
823 |
{ |
|
824 |
if((retainArray[i][0] == WORD1) && (retainArray[i][1] == WORD2) && (retainArray[i][2] == WORD3)) |
|
825 |
{ |
|
826 |
foundIndex = i; |
|
827 |
return 1; |
|
828 |
} |
|
829 |
} |
|
830 |
} |
|
831 |
||
832 |
foundIndex = USER_RETAIN_ARRAY_SIZE; /* Data not found => return index that is out of array bounds */ |
|
833 |
return 0; |
|
834 |
} |
|
835 |
||
836 |
/* Since Beremiz debugger doesn't like pointer-by-reference stuff or global varibles, separate function is a must */ |
|
837 |
unsigned char __GetReadStatus(unsigned char dummy) |
|
838 |
{ |
|
839 |
return readOK; |
|
840 |
} |
|
841 |
||
842 |
unsigned int __GetFoundIndex(unsigned char dummy) |
|
843 |
{ |
|
844 |
return foundIndex; |
|
845 |
} |
|
846 |
""" |
|
847 |
||
492 | 848 |
def _Simulate(self): |
849 |
""" |
|
850 |
Method called by user to Simulate PLC |
|
851 |
""" |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
852 |
self.CurrentMode = SIMULATION_MODE |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
853 |
|
492 | 854 |
uri = "LOCAL://" |
855 |
try: |
|
856 |
self._connector = connectors.ConnectorFactory(uri, self) |
|
857 |
except Exception, msg: |
|
858 |
self.logger.write_error(_("Exception while connecting %s!\n")%uri) |
|
859 |
self.logger.write_error(traceback.format_exc()) |
|
860 |
||
861 |
# Did connection success ? |
|
862 |
if self._connector is None: |
|
863 |
# Oups. |
|
864 |
self.logger.write_error(_("Connection failed to %s!\n")%uri) |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
865 |
self.StopSimulation() |
492 | 866 |
return False |
867 |
||
868 |
buildpath = self._getBuildPath() |
|
869 |
||
870 |
# Eventually create build dir |
|
871 |
if not os.path.exists(buildpath): |
|
872 |
os.makedirs(buildpath) |
|
873 |
||
874 |
# Generate SoftPLC IEC code |
|
875 |
IECGenRes = self._Generate_SoftPLC() |
|
876 |
||
877 |
# If IEC code gen fail, bail out. |
|
878 |
if not IECGenRes: |
|
879 |
self.logger.write_error(_("IEC-61131-3 code generation failed !\n")) |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
880 |
self.StopSimulation() |
492 | 881 |
return False |
882 |
||
883 |
# Reset variable and program list that are parsed from |
|
884 |
# CSV file generated by IEC2C compiler. |
|
885 |
self.ResetIECProgramsAndVariables() |
|
886 |
||
718 | 887 |
gen_result = self.CTNGenerate_C(buildpath, self.PLCGeneratedLocatedVars) |
888 |
CTNCFilesAndCFLAGS, CTNLDFLAGS, DoCalls = gen_result[:3] |
|
492 | 889 |
# if some files have been generated put them in the list with their location |
718 | 890 |
if CTNCFilesAndCFLAGS: |
891 |
self.LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), CTNCFilesAndCFLAGS, DoCalls)] |
|
492 | 892 |
else: |
893 |
self.LocationCFilesAndCFLAGS = [] |
|
894 |
||
717 | 895 |
# confnode asks for some LDFLAGS |
718 | 896 |
if CTNLDFLAGS: |
492 | 897 |
# LDFLAGS can be either string |
718 | 898 |
if type(CTNLDFLAGS)==type(str()): |
899 |
self.LDFLAGS=[CTNLDFLAGS] |
|
492 | 900 |
#or list of strings |
718 | 901 |
elif type(CTNLDFLAGS)==type(list()): |
902 |
self.LDFLAGS=CTNLDFLAGS[:] |
|
492 | 903 |
else: |
904 |
self.LDFLAGS=[] |
|
905 |
||
906 |
# Template based part of C code generation |
|
717 | 907 |
# files are stacked at the beginning, as files of confnode tree root |
492 | 908 |
for generator, filename, name in [ |
909 |
# debugger code |
|
910 |
(self.Generate_plc_debugger, "plc_debugger.c", "Debugger"), |
|
911 |
# init/cleanup/retrieve/publish, run and align code |
|
912 |
(self.Generate_plc_common_main,"plc_common_main.c","Common runtime"), |
|
913 |
# declare located variables for simulate in a black box |
|
708 | 914 |
(self.Generate_plc_declare_locations,"plc_declare_locations.c","Declare Locations"), |
915 |
# declare located variables for simulate in a black box |
|
916 |
(self.Generate_lpc_retain_array_sim,"lpc_retain_array_sim.c","Retain Array for Simulation")]: |
|
492 | 917 |
try: |
918 |
# Do generate |
|
919 |
code = generator() |
|
920 |
if code is None: |
|
921 |
raise |
|
922 |
code_path = os.path.join(buildpath,filename) |
|
923 |
open(code_path, "w").write(code) |
|
717 | 924 |
# Insert this file as first file to be compiled at root confnode |
492 | 925 |
self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
926 |
except Exception, exc: |
|
927 |
self.logger.write_error(name+_(" generation failed !\n")) |
|
928 |
self.logger.write_error(traceback.format_exc()) |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
929 |
self.StopSimulation() |
492 | 930 |
return False |
931 |
||
932 |
# Get simulation builder |
|
933 |
builder = self.GetBuilder() |
|
934 |
if builder is None: |
|
935 |
self.logger.write_error(_("Fatal : cannot get builder.\n")) |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
936 |
self.StopSimulation() |
492 | 937 |
return False |
938 |
||
939 |
# Build |
|
940 |
try: |
|
941 |
if not builder.build() : |
|
942 |
self.logger.write_error(_("C Build failed.\n")) |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
943 |
self.StopSimulation() |
492 | 944 |
return False |
945 |
except Exception, exc: |
|
946 |
self.logger.write_error(_("C Build crashed !\n")) |
|
947 |
self.logger.write_error(traceback.format_exc()) |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
948 |
self.StopSimulation() |
492 | 949 |
return False |
950 |
||
951 |
data = builder.GetBinaryCode() |
|
952 |
if data is not None : |
|
953 |
if self._connector.NewPLC(builder.GetBinaryCodeMD5(), data, []): |
|
954 |
self.UnsubscribeAllDebugIECVariable() |
|
955 |
self.ProgramTransferred() |
|
697
3e83853081d4
Adding support for not closing debug tabs and remove variable in variable debug panel if instance still exist in newly transfered program
laurent
parents:
691
diff
changeset
|
956 |
if self.AppFrame is not None: |
3e83853081d4
Adding support for not closing debug tabs and remove variable in variable debug panel if instance still exist in newly transfered program
laurent
parents:
691
diff
changeset
|
957 |
self.AppFrame.CloseObsoleteDebugTabs() |
492 | 958 |
self.logger.write(_("Transfer completed successfully.\n")) |
959 |
else: |
|
960 |
self.logger.write_error(_("Transfer failed\n")) |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
961 |
self.StopSimulation() |
492 | 962 |
return False |
963 |
||
964 |
self._Run() |
|
965 |
||
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
966 |
if not self.StatusTimer.IsRunning(): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
967 |
# Start the status Timer |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
968 |
self.StatusTimer.Start(milliseconds=500, oneShot=False) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
969 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
970 |
def StopSimulation(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
971 |
self.CurrentMode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
972 |
self.ApplyOnlineMode() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
973 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
974 |
def _Stop(self): |
725 | 975 |
ProjectController._Stop(self) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
976 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
977 |
if self.CurrentMode == SIMULATION_MODE: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
978 |
self.StopSimulation() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
979 |
|
560
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
980 |
def CompareLocalAndRemotePLC(self): |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
981 |
if self.LPCConnector is None: |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
982 |
return |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
983 |
# We are now connected. Update button status |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
984 |
MD5 = self.GetLastBuildMD5() |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
985 |
# Check remote target PLC correspondance to that md5 |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
986 |
if MD5 is not None and self.LPCConnector.MatchMD5(MD5): |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
987 |
# warns controller that program match |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
988 |
self.ProgramTransferred() |
681fe60443fc
Fix transfer button enable state and build button state
laurent
parents:
559
diff
changeset
|
989 |
|
677
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
990 |
def ResetBuildMD5(self): |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
991 |
builder=self.GetBuilder() |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
992 |
if builder is not None: |
691 | 993 |
builder.ResetBinaryCodeMD5(self.OnlineMode) |
677
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
994 |
|
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
995 |
def GetLastBuildMD5(self): |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
996 |
builder=self.GetBuilder() |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
997 |
if builder is not None: |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
998 |
return builder.GetBinaryCodeMD5(self.OnlineMode) |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
999 |
else: |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1000 |
return None |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1001 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1002 |
def _Transfer(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1003 |
if self.CurrentMode is None and self.OnlineMode != "OFF": |
572
c965548cb6f7
Fixed MD5 computation for makefile based toolchain, helps avoiding unnecessary builds
edouard
parents:
571
diff
changeset
|
1004 |
self.CurrentMode = TRANSFER_MODE |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1005 |
|
725 | 1006 |
if ProjectController._Build(self): |
677
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1007 |
|
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1008 |
ID_ABORTTRANSFERTIMER = wx.NewId() |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1009 |
self.AbortTransferTimer = wx.Timer(self.AppFrame, ID_ABORTTRANSFERTIMER) |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1010 |
self.AppFrame.Bind(wx.EVT_TIMER, self.AbortTransfer, self.AbortTransferTimer) |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1011 |
|
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1012 |
if self.OnlineMode == "BOOTLOADER": |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1013 |
self.BeginTransfer() |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1014 |
|
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1015 |
else: |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1016 |
self.logger.write(_("Resetting PLC\n")) |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1017 |
#self.StatusTimer.Stop() |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1018 |
self.LPCConnector.ResetPLC() |
607731b33026
Fix 'Transfer" button state according to last build result
laurent
parents:
659
diff
changeset
|
1019 |
self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True) |
691 | 1020 |
|
1021 |
else: |
|
1022 |
self.CurrentMode = None |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1023 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1024 |
def BeginTransfer(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1025 |
self.logger.write(_("Start PLC transfer\n")) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1026 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1027 |
self.AbortTransferTimer.Stop() |
725 | 1028 |
ProjectController._Transfer(self) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1029 |
self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1030 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1031 |
def AbortTransfer(self, event): |
543
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
1032 |
self.logger.write_warning(_("Timeout waiting PLC to recover\n")) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1033 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1034 |
self.CurrentMode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1035 |
self.AbortTransferTimer.Stop() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1036 |
self.AbortTransferTimer = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1037 |
event.Skip() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1038 |
|
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1039 |
def _Run(self): |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1040 |
""" |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1041 |
Start PLC |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1042 |
""" |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1043 |
if self.GetIECProgramsAndVariables(): |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1044 |
self._connector.StartPLC() |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1045 |
self.logger.write(_("Starting PLC\n")) |
576
7fcdc0d3d8d9
Some typo fixes to make debug related methods in LPCAppOject stop throwing exceptions, less agressive error message when unplugging LPC
edouard
parents:
575
diff
changeset
|
1046 |
self._connect_debug() |
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1047 |
else: |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1048 |
self.logger.write_error(_("Couldn't start PLC !\n")) |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1049 |
self.UpdateMethodsFromPLCStatus() |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1050 |
|
442 | 1051 |
#------------------------------------------------------------------------------- |
1052 |
# LPCBeremiz Class |
|
1053 |
#------------------------------------------------------------------------------- |
|
549 | 1054 |
lpcberemiz_cmd=None |
442 | 1055 |
|
1056 |
class LPCBeremiz(Beremiz): |
|
1057 |
||
1058 |
def _init_coll_FileMenu_Items(self, parent): |
|
1059 |
AppendMenu(parent, help='', id=wx.ID_SAVE, |
|
1060 |
kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S')) |
|
1061 |
AppendMenu(parent, help='', id=wx.ID_CLOSE, |
|
1062 |
kind=wx.ITEM_NORMAL, text=_(u'Close Tab\tCTRL+W')) |
|
1063 |
parent.AppendSeparator() |
|
1064 |
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
|
1065 |
kind=wx.ITEM_NORMAL, text=_(u'Page Setup')) |
|
1066 |
AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
|
1067 |
kind=wx.ITEM_NORMAL, text=_(u'Preview')) |
|
1068 |
AppendMenu(parent, help='', id=wx.ID_PRINT, |
|
1069 |
kind=wx.ITEM_NORMAL, text=_(u'Print')) |
|
1070 |
parent.AppendSeparator() |
|
1071 |
AppendMenu(parent, help='', id=wx.ID_PROPERTIES, |
|
1072 |
kind=wx.ITEM_NORMAL, text=_(u'Properties')) |
|
1073 |
parent.AppendSeparator() |
|
1074 |
AppendMenu(parent, help='', id=wx.ID_EXIT, |
|
1075 |
kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q')) |
|
1076 |
||
1077 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
|
1078 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) |
|
1079 |
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
|
1080 |
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
|
1081 |
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
|
1082 |
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
|
1083 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
|
1084 |
||
708 | 1085 |
self.AddToMenuToolBar([(wx.ID_SAVE, "save.png", _(u'Save'), None), |
1086 |
(wx.ID_PRINT, "print.png", _(u'Print'), None)]) |
|
706 | 1087 |
|
442 | 1088 |
def _init_ctrls(self, prnt): |
1089 |
IDEFrame._init_ctrls(self, prnt) |
|
1090 |
||
1091 |
self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=ID_BEREMIZINSPECTOR) |
|
1092 |
accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR)]) |
|
1093 |
self.SetAcceleratorTable(accel) |
|
1094 |
||
1095 |
self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG, |
|
1096 |
name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0), |
|
1097 |
size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL) |
|
1098 |
self.PLCConfig.SetBackgroundColour(wx.WHITE) |
|
1099 |
self.PLCConfig.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
|
1100 |
self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow) |
|
1101 |
self.LeftNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True) |
|
1102 |
||
1103 |
self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
|
1104 |
name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0), |
|
1105 |
size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
|
1106 |
self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick) |
|
1107 |
self.BottomNoteBook.AddPage(self.LogConsole, _("Log Console")) |
|
1108 |
||
1109 |
self._init_beremiz_sizers() |
|
1110 |
||
1111 |
def OnCloseFrame(self, event): |
|
519
3a5faff52e5c
Adding message to standard output to signal when LPCBeremiz is closed
laurent
parents:
517
diff
changeset
|
1112 |
global frame |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1113 |
|
596
b36422acae13
Adding warning message on LPCBeremiz when closing frame and program not saved
laurent
parents:
578
diff
changeset
|
1114 |
if self.CheckSaveBeforeClosing(_("Close Application")): |
b36422acae13
Adding warning message on LPCBeremiz when closing frame and program not saved
laurent
parents:
578
diff
changeset
|
1115 |
|
b36422acae13
Adding warning message on LPCBeremiz when closing frame and program not saved
laurent
parents:
578
diff
changeset
|
1116 |
frame.Hide() |
b36422acae13
Adding warning message on LPCBeremiz when closing frame and program not saved
laurent
parents:
578
diff
changeset
|
1117 |
|
717 | 1118 |
self.CTR.ResetAppFrame(lpcberemiz_cmd.Log) |
1119 |
if self.CTR.OnlineMode == 0: |
|
1120 |
self.CTR._connector = None |
|
1121 |
||
1122 |
self.CTR.KillDebugThread() |
|
596
b36422acae13
Adding warning message on LPCBeremiz when closing frame and program not saved
laurent
parents:
578
diff
changeset
|
1123 |
self.KillLocalRuntime() |
b36422acae13
Adding warning message on LPCBeremiz when closing frame and program not saved
laurent
parents:
578
diff
changeset
|
1124 |
|
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
708
diff
changeset
|
1125 |
self.SaveLastState() |
598
6c919bc1551d
Adding support for saving frame size while closing and restore it at next launch
laurent
parents:
597
diff
changeset
|
1126 |
|
596
b36422acae13
Adding warning message on LPCBeremiz when closing frame and program not saved
laurent
parents:
578
diff
changeset
|
1127 |
lpcberemiz_cmd.Log.write("Closed\n") |
b36422acae13
Adding warning message on LPCBeremiz when closing frame and program not saved
laurent
parents:
578
diff
changeset
|
1128 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1129 |
event.Veto() |
442 | 1130 |
|
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1131 |
def ShowProperties(self): |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1132 |
old_values = self.Controler.GetProjectProperties() |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1133 |
dialog = ProjectDialog(self ,False) |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1134 |
dialog.SetValues(old_values) |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1135 |
if dialog.ShowModal() == wx.ID_OK: |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1136 |
new_values = dialog.GetValues() |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1137 |
new_values["creationDateTime"] = old_values["creationDateTime"] |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1138 |
if new_values != old_values: |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1139 |
self.Controler.SetProjectProperties(None, new_values) |
706 | 1140 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, |
730 | 1141 |
PROJECTTREE, POUINSTANCEVARIABLESPANEL, SCALING) |
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1142 |
dialog.Destroy() |
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1143 |
|
442 | 1144 |
def RefreshFileMenu(self): |
708 | 1145 |
MenuToolBar = self.Panes["MenuToolBar"] |
717 | 1146 |
if self.CTR is not None: |
442 | 1147 |
selected = self.TabsOpened.GetSelection() |
1148 |
if selected >= 0: |
|
1149 |
graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer) |
|
1150 |
else: |
|
1151 |
graphic_viewer = False |
|
1152 |
if self.TabsOpened.GetPageCount() > 0: |
|
1153 |
self.FileMenu.Enable(wx.ID_CLOSE, True) |
|
1154 |
if graphic_viewer: |
|
1155 |
self.FileMenu.Enable(wx.ID_PREVIEW, True) |
|
1156 |
self.FileMenu.Enable(wx.ID_PRINT, True) |
|
706 | 1157 |
MenuToolBar.EnableTool(wx.ID_PRINT, True) |
442 | 1158 |
else: |
1159 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
1160 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
706 | 1161 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
442 | 1162 |
else: |
1163 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
|
1164 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
1165 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
706 | 1166 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
442 | 1167 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
717 | 1168 |
project_modified = self.CTR.ProjectTestModified() |
706 | 1169 |
self.FileMenu.Enable(wx.ID_SAVE, project_modified) |
1170 |
MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) |
|
442 | 1171 |
self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
1172 |
else: |
|
1173 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
|
1174 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
|
1175 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
1176 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
706 | 1177 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
442 | 1178 |
self.FileMenu.Enable(wx.ID_SAVE, False) |
706 | 1179 |
MenuToolBar.EnableTool(wx.ID_SAVE, False) |
442 | 1180 |
self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
1181 |
||
1182 |
def RefreshPLCParams(self): |
|
1183 |
self.Freeze() |
|
1184 |
self.ClearSizer(self.PLCParamsSizer) |
|
1185 |
||
717 | 1186 |
if self.CTR is not None: |
442 | 1187 |
plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
718 | 1188 |
if self.CTR.CTNTestModified(): |
442 | 1189 |
bkgdclr = CHANGED_TITLE_COLOUR |
1190 |
else: |
|
1191 |
bkgdclr = TITLE_COLOUR |
|
1192 |
||
717 | 1193 |
if self.CTR not in self.ConfNodeInfos: |
1194 |
self.ConfNodeInfos[self.CTR] = {"right_visible" : False} |
|
442 | 1195 |
|
1196 |
plcwindow.SetBackgroundColour(TITLE_COLOUR) |
|
1197 |
plcwindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
|
1198 |
self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW) |
|
1199 |
||
1200 |
plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
1201 |
plcwindow.SetSizer(plcwindowsizer) |
|
1202 |
||
1203 |
st = wx.StaticText(plcwindow, -1) |
|
1204 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
|
717 | 1205 |
st.SetLabel(self.CTR.GetProjectName()) |
442 | 1206 |
plcwindowsizer.AddWindow(st, 0, border=5, flag=wx.ALL|wx.ALIGN_CENTER) |
1207 |
||
1208 |
plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
|
1209 |
plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL) |
|
1210 |
||
1211 |
plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
1212 |
plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER) |
|
1213 |
||
717 | 1214 |
msizer = self.GenerateMethodButtonSizer(self.CTR, plcwindow, not self.ConfNodeInfos[self.CTR]["right_visible"]) |
442 | 1215 |
plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
1216 |
||
1217 |
self.PLCConfigMainSizer.Layout() |
|
1218 |
self.RefreshScrollBars() |
|
1219 |
self.Thaw() |
|
1220 |
||
717 | 1221 |
def GenerateTreeBranch(self, confnode): |
442 | 1222 |
leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
718 | 1223 |
if confnode.CTNTestModified(): |
442 | 1224 |
bkgdclr=CHANGED_WINDOW_COLOUR |
1225 |
else: |
|
1226 |
bkgdclr=WINDOW_COLOUR |
|
1227 |
||
1228 |
leftwindow.SetBackgroundColour(bkgdclr) |
|
1229 |
||
717 | 1230 |
if confnode not in self.ConfNodeInfos: |
1231 |
self.ConfNodeInfos[confnode] = {"expanded" : False, "left_visible" : False, "right_visible" : False} |
|
1232 |
||
718 | 1233 |
self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChildren() |
717 | 1234 |
confnode_infos = confnode.GetVariableLocationTree() |
1235 |
confnode_locations = [] |
|
1236 |
if len(self.ConfNodeInfos[confnode]["children"]) == 0: |
|
1237 |
confnode_locations = confnode_infos["children"] |
|
1238 |
if not self.ConfNodeInfos[confnode].has_key("locations_infos"): |
|
1239 |
self.ConfNodeInfos[confnode]["locations_infos"] = {"root": {"expanded" : False}} |
|
1240 |
||
1241 |
self.ConfNodeInfos[confnode]["locations_infos"]["root"]["left"] = None |
|
1242 |
self.ConfNodeInfos[confnode]["locations_infos"]["root"]["right"] = None |
|
1243 |
self.ConfNodeInfos[confnode]["locations_infos"]["root"]["children"] = [] |
|
1244 |
||
1245 |
self.ConfNodeTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) |
|
442 | 1246 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
1247 |
leftwindowvsizer = wx.BoxSizer(wx.VERTICAL) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
1248 |
leftwindow.SetSizer(leftwindowvsizer) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
1249 |
|
442 | 1250 |
leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
1251 |
leftwindowvsizer.AddSizer(leftwindowsizer, 0, border=0, flag=0) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
1252 |
|
717 | 1253 |
self.GenerateEnableButton(leftwindow, leftwindowsizer, confnode) |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
678
diff
changeset
|
1254 |
|
442 | 1255 |
st = wx.StaticText(leftwindow, -1) |
1256 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
|
717 | 1257 |
st.SetLabel(confnode.GetFullIEC_Channel()) |
442 | 1258 |
leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT) |
1259 |
||
1260 |
expandbutton_id = wx.NewId() |
|
1261 |
expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')), |
|
1262 |
name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0), |
|
1263 |
size=wx.Size(13, 13), style=wx.NO_BORDER) |
|
1264 |
expandbutton.labelDelta = 0 |
|
1265 |
expandbutton.SetBezelWidth(0) |
|
1266 |
expandbutton.SetUseFocusIndicator(False) |
|
1267 |
expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png'))) |
|
1268 |
||
717 | 1269 |
if len(self.ConfNodeInfos[confnode]["children"]) > 0: |
1270 |
expandbutton.SetToggle(self.ConfNodeInfos[confnode]["expanded"]) |
|
442 | 1271 |
def togglebutton(event): |
1272 |
if expandbutton.GetToggle(): |
|
717 | 1273 |
self.ExpandConfNode(confnode) |
442 | 1274 |
else: |
717 | 1275 |
self.CollapseConfNode(confnode) |
1276 |
self.ConfNodeInfos[confnode]["expanded"] = expandbutton.GetToggle() |
|
442 | 1277 |
self.PLCConfigMainSizer.Layout() |
1278 |
self.RefreshScrollBars() |
|
1279 |
event.Skip() |
|
1280 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
|
717 | 1281 |
elif len(confnode_locations) > 0: |
1282 |
locations_infos = self.ConfNodeInfos[confnode]["locations_infos"] |
|
442 | 1283 |
expandbutton.SetToggle(locations_infos["root"]["expanded"]) |
1284 |
def togglebutton(event): |
|
1285 |
if expandbutton.GetToggle(): |
|
1286 |
self.ExpandLocation(locations_infos, "root") |
|
1287 |
else: |
|
1288 |
self.CollapseLocation(locations_infos, "root") |
|
717 | 1289 |
self.ConfNodeInfos[confnode]["expanded"] = expandbutton.GetToggle() |
442 | 1290 |
locations_infos["root"]["expanded"] = expandbutton.GetToggle() |
1291 |
self.PLCConfigMainSizer.Layout() |
|
1292 |
self.RefreshScrollBars() |
|
1293 |
event.Skip() |
|
1294 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
|
1295 |
else: |
|
1296 |
expandbutton.Enable(False) |
|
1297 |
leftwindowsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
|
1298 |
||
1299 |
sb = wx.StaticBitmap(leftwindow, -1) |
|
717 | 1300 |
icon = confnode_infos.get("icon", None) |
442 | 1301 |
if icon is None: |
717 | 1302 |
icon_bitmap = self.LocationImageList.GetBitmap(self.LocationImageDict[confnode_infos["type"]]) |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1303 |
else: |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1304 |
icon_bitmap = wx.Bitmap(icon) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1305 |
sb.SetBitmap(icon_bitmap) |
442 | 1306 |
leftwindowsizer.AddWindow(sb, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
1307 |
||
1308 |
st_id = wx.NewId() |
|
1309 |
st = wx.StaticText(leftwindow, st_id, size=wx.DefaultSize, style=wx.NO_BORDER) |
|
1310 |
st.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
|
717 | 1311 |
st.SetLabel(confnode.MandatoryParams[1].getName()) |
442 | 1312 |
leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
1313 |
||
717 | 1314 |
rightwindow = self.GenerateParamsPanel(confnode, bkgdclr) |
1315 |
self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
|
1316 |
||
1317 |
self.ConfNodeInfos[confnode]["left"] = leftwindow |
|
1318 |
self.ConfNodeInfos[confnode]["right"] = rightwindow |
|
1319 |
for child in self.ConfNodeInfos[confnode]["children"]: |
|
442 | 1320 |
self.GenerateTreeBranch(child) |
717 | 1321 |
if not self.ConfNodeInfos[child]["expanded"]: |
1322 |
self.CollapseConfNode(child) |
|
1323 |
||
1324 |
if len(confnode_locations) > 0: |
|
1325 |
locations_infos = self.ConfNodeInfos[confnode]["locations_infos"] |
|
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1326 |
treectrl = wx.TreeCtrl(self.PLCConfig, -1, size=wx.DefaultSize, |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1327 |
style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.NO_BORDER|wx.TR_HIDE_ROOT|wx.TR_NO_LINES|wx.TR_LINES_AT_ROOT) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1328 |
treectrl.SetImageList(self.LocationImageList) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1329 |
treectrl.Bind(wx.EVT_TREE_BEGIN_DRAG, self.GenerateLocationBeginDragFunction(locations_infos)) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1330 |
treectrl.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.GenerateLocationExpandCollapseFunction(locations_infos, True)) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1331 |
treectrl.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.GenerateLocationExpandCollapseFunction(locations_infos, False)) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1332 |
|
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1333 |
treectrl.AddRoot("") |
717 | 1334 |
self.ConfNodeTreeSizer.AddWindow(treectrl, 0, border=0, flag=0) |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1335 |
|
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1336 |
rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1337 |
rightwindow.SetBackgroundColour(wx.WHITE) |
717 | 1338 |
self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1339 |
|
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1340 |
locations_infos["root"]["left"] = treectrl |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1341 |
locations_infos["root"]["right"] = rightwindow |
717 | 1342 |
for location in confnode_locations: |
442 | 1343 |
locations_infos["root"]["children"].append("root.%s" % location["name"]) |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1344 |
self.GenerateLocationTreeBranch(treectrl, treectrl.GetRootItem(), locations_infos, "root", location) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1345 |
if locations_infos["root"]["expanded"]: |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
629
diff
changeset
|
1346 |
self.ExpandLocation(locations_infos, "root") |
442 | 1347 |
|
1348 |
class StdoutPseudoFile: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1349 |
|
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1350 |
def __init__(self, port): |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1351 |
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1352 |
self.socket.connect(('localhost', port)) |
552 | 1353 |
self.Buffer = "" |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1354 |
|
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1355 |
def __del__(self): |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1356 |
self.socket.close() |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1357 |
|
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1358 |
def readline(self): |
552 | 1359 |
idx = self.Buffer.find("\n") |
1360 |
if idx == -1: |
|
1361 |
self.Buffer += self.socket.recv(2048) |
|
1362 |
idx = self.Buffer.find("\n") |
|
1363 |
if idx != -1: |
|
1364 |
line = self.Buffer[:idx+1] |
|
1365 |
self.Buffer = self.Buffer[idx+1:] |
|
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1366 |
if BMZ_DBG: |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1367 |
print "command >"+line |
552 | 1368 |
return line |
1369 |
return "" |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1370 |
|
442 | 1371 |
""" Base class for file like objects to facilitate StdOut for the Shell.""" |
1372 |
def write(self, s, style = None): |
|
1373 |
if s != '': |
|
578 | 1374 |
self.socket.send(s.encode('utf8')) |
1375 |
||
1376 |
def writeyield(self, s): |
|
1377 |
self.write(s) |
|
1378 |
||
442 | 1379 |
def write_warning(self, s): |
1380 |
self.write(s) |
|
1381 |
||
1382 |
def write_error(self, s): |
|
1383 |
self.write(s) |
|
1384 |
||
1385 |
def flush(self): |
|
1386 |
pass |
|
1387 |
||
1388 |
def isatty(self): |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1389 |
return False |
442 | 1390 |
|
1391 |
if __name__ == '__main__': |
|
1392 |
||
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1393 |
from threading import Thread, Timer, Semaphore |
442 | 1394 |
import cmd |
1395 |
||
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1396 |
wx_eval_lock = Semaphore(0) |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1397 |
eval_res = None |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1398 |
def wx_evaluator(callable, *args, **kwargs): |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1399 |
global eval_res |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1400 |
eval_res = None |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1401 |
try: |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1402 |
eval_res=callable(*args,**kwargs) |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1403 |
finally: |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1404 |
wx_eval_lock.release() |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1405 |
|
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1406 |
def evaluator(callable, *args, **kwargs): |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1407 |
global eval_res |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1408 |
wx.CallAfter(wx_evaluator,callable,*args,**kwargs) |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1409 |
wx_eval_lock.acquire() |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1410 |
return eval_res |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1411 |
|
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1412 |
# Command log for debug, for viewing from wxInspector |
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1413 |
if BMZ_DBG: |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1414 |
__builtins__.cmdlog = [] |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1415 |
|
442 | 1416 |
class LPCBeremiz_Cmd(cmd.Cmd): |
1417 |
||
1418 |
prompt = "" |
|
1419 |
RefreshTimer = None |
|
1420 |
||
717 | 1421 |
def __init__(self, CTR, Log): |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1422 |
cmd.Cmd.__init__(self, stdin=Log, stdout=Log) |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1423 |
self.use_rawinput = False |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1424 |
self.Log = Log |
717 | 1425 |
self.CTR = CTR |
442 | 1426 |
|
1427 |
def RestartTimer(self): |
|
1428 |
if self.RefreshTimer is not None: |
|
1429 |
self.RefreshTimer.cancel() |
|
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1430 |
self.RefreshTimer = Timer(0.1, wx.CallAfter, args = [self.Refresh]) |
442 | 1431 |
self.RefreshTimer.start() |
1432 |
||
1433 |
def Exit(self): |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1434 |
global frame, app |
442 | 1435 |
self.Close() |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1436 |
app.ExitMainLoop() |
442 | 1437 |
return True |
1438 |
||
1439 |
def do_EOF(self, line): |
|
1440 |
return self.Exit() |
|
1441 |
||
1442 |
def Show(self): |
|
445 | 1443 |
global frame |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1444 |
if frame is not None: |
717 | 1445 |
self.CTR.SetAppFrame(frame, frame.Log) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1446 |
frame.Show() |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1447 |
frame.Raise() |
442 | 1448 |
|
1449 |
def Refresh(self): |
|
1450 |
global frame |
|
1451 |
if frame is not None: |
|
730 | 1452 |
frame._Refresh(TITLE, POUINSTANCEVARIABLESPANEL, FILEMENU, EDITMENU) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1453 |
frame.RefreshEditor() |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1454 |
frame.RefreshAll() |
442 | 1455 |
|
1456 |
def Close(self): |
|
1457 |
global frame |
|
1458 |
||
717 | 1459 |
self.CTR.ResetAppFrame(self.Log) |
442 | 1460 |
if frame is not None: |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1461 |
frame.Hide() |
442 | 1462 |
|
1463 |
def Compile(self): |
|
717 | 1464 |
self.CTR._Build() |
442 | 1465 |
|
500
af7c28de4cc7
Adding support for defining mandatory parameters and creating blank xml file when there is nothing in the folder in LPCBeremiz
laurent
parents:
494
diff
changeset
|
1466 |
def SetProjectProperties(self, projectname, productname, productversion, companyname): |
717 | 1467 |
properties = self.CTR.GetProjectProperties() |
597
6fbfd3bf2927
Fix bug in LPCBeremiz marking any newly opened project as modified
laurent
parents:
596
diff
changeset
|
1468 |
new_properties = properties.copy() |
6fbfd3bf2927
Fix bug in LPCBeremiz marking any newly opened project as modified
laurent
parents:
596
diff
changeset
|
1469 |
new_properties["projectName"] = projectname |
6fbfd3bf2927
Fix bug in LPCBeremiz marking any newly opened project as modified
laurent
parents:
596
diff
changeset
|
1470 |
new_properties["productName"] = productname |
6fbfd3bf2927
Fix bug in LPCBeremiz marking any newly opened project as modified
laurent
parents:
596
diff
changeset
|
1471 |
new_properties["productVersion"] = productversion |
6fbfd3bf2927
Fix bug in LPCBeremiz marking any newly opened project as modified
laurent
parents:
596
diff
changeset
|
1472 |
new_properties["companyName"] = companyname |
6fbfd3bf2927
Fix bug in LPCBeremiz marking any newly opened project as modified
laurent
parents:
596
diff
changeset
|
1473 |
if new_properties != properties: |
717 | 1474 |
self.CTR.SetProjectProperties(properties=new_properties, buffer=False) |
597
6fbfd3bf2927
Fix bug in LPCBeremiz marking any newly opened project as modified
laurent
parents:
596
diff
changeset
|
1475 |
self.RestartTimer() |
442 | 1476 |
|
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
1477 |
def SetOnlineMode(self, mode, path=None): |
717 | 1478 |
self.CTR.SetOnlineMode(mode, path) |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
1479 |
self.RestartTimer() |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
1480 |
|
442 | 1481 |
def AddBus(self, iec_channel, name, icon=None): |
718 | 1482 |
for child in self.CTR.IterChildren(): |
442 | 1483 |
if child.BaseParams.getName() == name: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1484 |
return "Error: A bus named %s already exists\n" % name |
442 | 1485 |
elif child.BaseParams.getIEC_Channel() == iec_channel: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1486 |
return "Error: A bus with IEC_channel %d already exists\n" % iec_channel |
718 | 1487 |
bus = self.CTR.CTNAddChild(name, "LPCBus", iec_channel) |
442 | 1488 |
if bus is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1489 |
return "Error: Unable to create bus\n" |
442 | 1490 |
bus.SetIcon(icon) |
1491 |
self.RestartTimer() |
|
1492 |
||
1493 |
def RenameBus(self, iec_channel, name): |
|
717 | 1494 |
bus = self.CTR.GetChildByIECLocation((iec_channel,)) |
442 | 1495 |
if bus is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1496 |
return "Error: No bus found\n" |
718 | 1497 |
for child in self.CTR.IterChildren(): |
442 | 1498 |
if child != bus and child.BaseParams.getName() == name: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1499 |
return "Error: A bus named %s already exists\n" % name |
442 | 1500 |
bus.BaseParams.setName(name) |
1501 |
self.RestartTimer() |
|
1502 |
||
1503 |
def ChangeBusIECChannel(self, old_iec_channel, new_iec_channel): |
|
717 | 1504 |
bus = self.CTR.GetChildByIECLocation((old_iec_channel,)) |
442 | 1505 |
if bus is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1506 |
return "Error: No bus found\n" |
718 | 1507 |
for child in self.CTR.IterChildren(): |
442 | 1508 |
if child != bus and child.BaseParams.getIEC_Channel() == new_iec_channel: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1509 |
return "Error: A bus with IEC_channel %d already exists\n" % new_iec_channel |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1510 |
if wx.GetApp() is None: |
717 | 1511 |
self.CTR.UpdateProjectVariableLocation(str(old_iec_channel), |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1512 |
str(new_iec_channel)) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1513 |
else: |
717 | 1514 |
self.CTR.UpdateProjectVariableLocation( |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1515 |
str(old_iec_channel), |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1516 |
str(new_iec_channel)) |
442 | 1517 |
bus.BaseParams.setIEC_Channel(new_iec_channel) |
1518 |
self.RestartTimer() |
|
1519 |
||
1520 |
def RemoveBus(self, iec_channel): |
|
717 | 1521 |
bus = self.CTR.GetChildByIECLocation((iec_channel,)) |
442 | 1522 |
if bus is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1523 |
return "Error: No bus found\n" |
717 | 1524 |
self.CTR.RemoveProjectVariableByFilter(str(iec_channel)) |
718 | 1525 |
self.CTR.Children["LPCBus"].remove(bus) |
442 | 1526 |
self.RestartTimer() |
1527 |
||
553 | 1528 |
def AddModule(self, parent, iec_channel, name, icode, icon=None): |
717 | 1529 |
module = self.CTR.GetChildByIECLocation(parent) |
442 | 1530 |
if module is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1531 |
return "Error: No parent found\n" |
442 | 1532 |
for child in _GetModuleChildren(module): |
1533 |
if child["name"] == name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1534 |
return "Error: A module named %s already exists\n" % name |
442 | 1535 |
elif child["IEC_Channel"] == iec_channel: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1536 |
return "Error: A module with IEC_channel %d already exists\n" % iec_channel |
442 | 1537 |
_GetLastModuleGroup(module).append({"name": name, |
1538 |
"type": LOCATION_MODULE, |
|
1539 |
"IEC_Channel": iec_channel, |
|
1540 |
"icon": icon, |
|
553 | 1541 |
"init": icode, |
442 | 1542 |
"children": []}) |
1543 |
self.RestartTimer() |
|
1544 |
||
1545 |
def RenameModule(self, iec_location, name): |
|
717 | 1546 |
module = self.CTR.GetChildByIECLocation(iec_location) |
442 | 1547 |
if module is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1548 |
return "Error: No module found\n" |
717 | 1549 |
parent = self.CTR.GetChildByIECLocation(iec_location[:-1]) |
1550 |
if parent is self.CTR: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1551 |
return "Error: No module found\n" |
442 | 1552 |
if module["name"] != name: |
1553 |
for child in _GetModuleChildren(parent): |
|
1554 |
if child["name"] == name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1555 |
return "Error: A module named %s already exists\n" % name |
442 | 1556 |
module["name"] = name |
1557 |
self.RestartTimer() |
|
1558 |
||
1559 |
def ChangeModuleIECChannel(self, old_iec_location, new_iec_channel): |
|
717 | 1560 |
module = self.CTR.GetChildByIECLocation(old_iec_location) |
442 | 1561 |
if module is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1562 |
return "Error: No module found\n" |
717 | 1563 |
parent = self.CTR.GetChildByIECLocation(old_iec_location[:-1]) |
1564 |
if parent is self.CTR: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1565 |
return "Error: No module found\n" |
442 | 1566 |
if module["IEC_Channel"] != new_iec_channel: |
1567 |
for child in _GetModuleChildren(parent): |
|
1568 |
if child["IEC_Channel"] == new_iec_channel: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1569 |
return "Error: A module with IEC_channel %d already exists\n" % new_iec_channel |
717 | 1570 |
self.CTR.UpdateProjectVariableLocation(".".join(map(str, old_iec_location)), ".".join(map(str, old_iec_location[:1] + (new_iec_channel,)))) |
442 | 1571 |
module["IEC_Channel"] = new_iec_channel |
1572 |
self.RestartTimer() |
|
553 | 1573 |
|
1574 |
def ChangeModuleInitCode(self, iec_location, icode): |
|
717 | 1575 |
module = self.CTR.GetChildByIECLocation(iec_location) |
553 | 1576 |
if module is None: |
1577 |
return "Error: No module found\n" |
|
1578 |
module["init"] = icode |
|
1579 |
||
442 | 1580 |
def RemoveModule(self, parent, iec_channel): |
717 | 1581 |
module = self.CTR.GetChildByIECLocation(parent) |
442 | 1582 |
if module is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1583 |
return "Error: No parent found\n" |
442 | 1584 |
child = _GetModuleBySomething(module, "IEC_Channel", (iec_channel,)) |
1585 |
if child is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1586 |
return "Error: No module found\n" |
717 | 1587 |
self.CTR.RemoveProjectVariableByFilter(".".join(map(str, parent + (iec_channel,)))) |
442 | 1588 |
_RemoveModuleChild(module, child) |
1589 |
self.RestartTimer() |
|
1590 |
||
1591 |
def StartGroup(self, parent, name, icon=None): |
|
717 | 1592 |
module = self.CTR.GetChildByIECLocation(parent) |
442 | 1593 |
if module is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1594 |
return "Error: No parent found\n" |
442 | 1595 |
for child in module["children"]: |
1596 |
if child["type"] == LOCATION_GROUP and child["name"] == name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1597 |
return "Error: A group named %s already exists\n" % name |
442 | 1598 |
module["children"].append({"name": name, |
1599 |
"type": LOCATION_GROUP, |
|
1600 |
"icon": icon, |
|
1601 |
"children": []}) |
|
1602 |
self.RestartTimer() |
|
1603 |
||
553 | 1604 |
def AddVariable(self, parent, location, name, direction, type, rcode, pcode, description=""): |
717 | 1605 |
module = self.CTR.GetChildByIECLocation(parent) |
442 | 1606 |
if module is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1607 |
return "Error: No parent found\n" |
442 | 1608 |
for child in _GetModuleChildren(module): |
1609 |
if child["name"] == name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1610 |
return "Error: A variable named %s already exists\n" % name |
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
1611 |
if child["location"] == location and child["type"] == LOCATION_TYPES[direction]: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1612 |
return "Error: A variable with location %s already exists\n" % ".".join(map(str, location)) |
442 | 1613 |
_GetLastModuleGroup(module).append({"name": name, |
1614 |
"location": location, |
|
1615 |
"type": LOCATION_TYPES[direction], |
|
1616 |
"IEC_type": type, |
|
1617 |
"description": description, |
|
1618 |
"retrieve": rcode, |
|
1619 |
"publish": pcode}) |
|
1620 |
self.RestartTimer() |
|
1621 |
||
553 | 1622 |
def ChangeVariableParams(self, parent, location, new_name, new_direction, new_type, new_rcode, new_pcode, new_description=None): |
717 | 1623 |
module = self.CTR.GetChildByIECLocation(parent) |
442 | 1624 |
if module is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1625 |
return "Error: No parent found\n" |
442 | 1626 |
variable = None |
1627 |
for child in _GetModuleChildren(module): |
|
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
1628 |
if child["location"] == location and child["type"] == LOCATION_TYPES[new_direction]: |
442 | 1629 |
variable = child |
1630 |
elif child["name"] == new_name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1631 |
return "Error: A variable named %s already exists\n" % new_name |
442 | 1632 |
if variable is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1633 |
return "Error: No variable found\n" |
444
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
1634 |
if variable["name"] != new_name: |
717 | 1635 |
self.CTR.UpdateProjectVariableName(variable["name"], new_name) |
444
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
1636 |
variable["name"] = new_name |
442 | 1637 |
variable["type"] = LOCATION_TYPES[new_direction] |
1638 |
variable["IEC_type"] = new_type |
|
1639 |
variable["retrieve"] = new_rcode |
|
1640 |
variable["publish"] = new_pcode |
|
1641 |
if new_description is not None: |
|
1642 |
variable["description"] = new_description |
|
1643 |
self.RestartTimer() |
|
1644 |
||
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
1645 |
def RemoveVariable(self, parent, location, direction): |
717 | 1646 |
module = self.CTR.GetChildByIECLocation(parent) |
442 | 1647 |
if module is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1648 |
return "Error: No parent found\n" |
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
1649 |
child = _GetModuleVariable(module, location, direction) |
442 | 1650 |
if child is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1651 |
return "Error: No variable found\n" |
717 | 1652 |
size = LOCATION_SIZES[self.CTR.GetBaseType(child["IEC_type"])] |
444
8eb1186fc9cf
Adding support for updating or removing located variables by their address or leading address numbers when changing or removing VariableTree element
laurent
parents:
442
diff
changeset
|
1653 |
address = "%" + LOCATION_DIRS[child["type"]] + size + ".".join(map(str, parent + location)) |
717 | 1654 |
self.CTR.RemoveProjectVariableByAddress(address) |
442 | 1655 |
_RemoveModuleChild(module, child) |
1656 |
self.RestartTimer() |
|
1657 |
||
1658 |
def location(loc): |
|
1659 |
return tuple(map(int, loc.split("."))) |
|
1660 |
||
1661 |
def GetCmdFunction(function, arg_types, opt=0): |
|
1662 |
arg_number = len(arg_types) |
|
1663 |
def CmdFunction(self, line): |
|
1664 |
args_toks = line.split('"') |
|
1665 |
if len(args_toks) % 2 == 0: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1666 |
self.Log.write("Error: Invalid command\n") |
526 | 1667 |
sys.stdout.flush() |
442 | 1668 |
return |
1669 |
args = [] |
|
1670 |
for num, arg in enumerate(args_toks): |
|
1671 |
if num % 2 == 0: |
|
1672 |
stripped = arg.strip() |
|
1673 |
if stripped: |
|
1674 |
args.extend(stripped.split(" ")) |
|
1675 |
else: |
|
1676 |
args.append(arg) |
|
1677 |
number = None |
|
1678 |
extra = "" |
|
1679 |
if opt == 0 and len(args) != arg_number: |
|
1680 |
number = arg_number |
|
1681 |
elif len(args) > arg_number: |
|
1682 |
number = arg_number |
|
1683 |
extra = " at most" |
|
1684 |
elif len(args) < arg_number - opt: |
|
1685 |
number = arg_number - opt |
|
1686 |
extra = " at least" |
|
1687 |
if number is not None: |
|
1688 |
if number == 0: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1689 |
self.Log.write("Error: No argument%s expected\n" % extra) |
442 | 1690 |
elif number == 1: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1691 |
self.Log.write("Error: 1 argument%s expected\n" % extra) |
442 | 1692 |
else: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1693 |
self.Log.write("Error: %d arguments%s expected\n" % (number, extra)) |
526 | 1694 |
sys.stdout.flush() |
442 | 1695 |
return |
1696 |
for num, arg in enumerate(args): |
|
1697 |
try: |
|
1698 |
args[num] = arg_types[num](arg) |
|
1699 |
except: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1700 |
self.Log.write("Error: Invalid value for argument %d\n" % (num + 1)) |
526 | 1701 |
sys.stdout.flush() |
442 | 1702 |
return |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1703 |
|
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1704 |
func = getattr(self, function) |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1705 |
res = evaluator(func,*args) |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1706 |
|
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1707 |
if BMZ_DBG: |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1708 |
cmdlog.append((function,line,res)) |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1709 |
if len(cmdlog) > 100: #prevent debug log to grow too much |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
566
diff
changeset
|
1710 |
cmdlog.pop(0) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1711 |
|
442 | 1712 |
if isinstance(res, (StringType, UnicodeType)): |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1713 |
self.Log.write(res) |
442 | 1714 |
return False |
1715 |
else: |
|
1716 |
return res |
|
1717 |
return CmdFunction |
|
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1718 |
|
717 | 1719 |
def CmdThreadProc(CTR, Log): |
549 | 1720 |
global lpcberemiz_cmd |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1721 |
for function, (arg_types, opt) in {"Exit": ([], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1722 |
"Show": ([], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1723 |
"Refresh": ([], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1724 |
"Close": ([], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1725 |
"Compile": ([], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1726 |
"SetProjectProperties": ([str, str, str, str], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1727 |
"SetOnlineMode": ([str, str], 1), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1728 |
"AddBus": ([int, str, str], 1), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1729 |
"RenameBus": ([int, str], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1730 |
"ChangeBusIECChannel": ([int, int], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1731 |
"RemoveBus": ([int], 0), |
553 | 1732 |
"AddModule": ([location, int, str, str, str], 1), |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1733 |
"RenameModule": ([location, str], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1734 |
"ChangeModuleIECChannel": ([location, int], 0), |
553 | 1735 |
"ChangeModuleInitCode": ([location, str], 0), |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1736 |
"RemoveModule": ([location, int], 0), |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1737 |
"StartGroup": ([location, str, str], 1), |
553 | 1738 |
"AddVariable": ([location, location, str, str, str, str, str, str], 1), |
1739 |
"ChangeVariableParams": ([location, location, str, str, str, str, str, str], 1), |
|
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1740 |
"RemoveVariable": ([location, location], 0)}.iteritems(): |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1741 |
|
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1742 |
setattr(LPCBeremiz_Cmd, "do_%s" % function, GetCmdFunction(function, arg_types, opt)) |
717 | 1743 |
lpcberemiz_cmd = LPCBeremiz_Cmd(CTR, Log) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1744 |
lpcberemiz_cmd.cmdloop() |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1745 |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1746 |
Log = StdoutPseudoFile(port) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1747 |
|
725 | 1748 |
CTR = LPCProjectController(None, Log, buildpath) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1749 |
if projectOpen is not None and os.path.isdir(projectOpen): |
717 | 1750 |
result = CTR.LoadProject(projectOpen) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1751 |
if result: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1752 |
Log.write("Error: Invalid project directory", result) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1753 |
else: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1754 |
Log.write("Error: No such file or directory") |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1755 |
|
717 | 1756 |
cmd_thread=Thread(target=CmdThreadProc, args=[CTR, Log]) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1757 |
cmd_thread.start() |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1758 |
|
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1759 |
# Install a exception handle for bug reports |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1760 |
AddExceptHook(os.getcwd(),__version__) |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1761 |
|
717 | 1762 |
frame = LPCBeremiz(None, ctr=CTR, debug=True) |
547
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1763 |
|
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1764 |
app.MainLoop() |
5748d695beee
Reorganization of threading for command line and wx main loops. Commands are now cleanly serialized through calls to wx.CallAfter. wx mainloop now runs on main thread.
Lolitech
parents:
543
diff
changeset
|
1765 |