author | Lolitech |
Fri, 04 Jun 2010 14:59:11 +0200 | |
changeset 556 | 1ad4e7f1e89e |
parent 555 | 7b08cc1ea55a |
child 559 | 0f5544587037 |
permissions | -rw-r--r-- |
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 |
|
9 |
from types import TupleType, StringType, UnicodeType |
|
10 |
||
11 |
CWD = os.path.split(os.path.realpath(__file__))[0] |
|
12 |
||
13 |
def Bpath(*args): |
|
14 |
return os.path.join(CWD,*args) |
|
15 |
||
16 |
if __name__ == '__main__': |
|
17 |
def usage(): |
|
18 |
print "\nUsage of LPCBeremiz.py :" |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
19 |
print "\n %s Projectpath Buildpath port\n"%sys.argv[0] |
442 | 20 |
|
21 |
try: |
|
22 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
|
23 |
except getopt.GetoptError: |
|
24 |
# print help information and exit: |
|
25 |
usage() |
|
26 |
sys.exit(2) |
|
27 |
||
28 |
for o, a in opts: |
|
29 |
if o in ("-h", "--help"): |
|
30 |
usage() |
|
31 |
sys.exit() |
|
32 |
||
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
33 |
if len(args) != 3: |
442 | 34 |
usage() |
35 |
sys.exit() |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
36 |
else: |
442 | 37 |
projectOpen = args[0] |
38 |
buildpath = args[1] |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
39 |
try: |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
40 |
port = int(args[2]) |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
41 |
except: |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
42 |
usage() |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
43 |
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
|
44 |
|
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 |
app = wx.PySimpleApp() |
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
|
46 |
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
|
47 |
wx.InitAllImageHandlers() |
442 | 48 |
|
49 |
# Import module for internationalization |
|
50 |
import gettext |
|
51 |
import __builtin__ |
|
52 |
||
53 |
if __name__ == '__main__': |
|
54 |
__builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation |
|
55 |
||
56 |
from Beremiz import * |
|
492 | 57 |
from plugger import PluginsRoot, PlugTemplate, opjimg, connectors |
442 | 58 |
from plcopen.structures import LOCATIONDATATYPES |
59 |
from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP,\ |
|
60 |
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
|
61 |
from PLCOpenEditor import IDEFrame, ProjectDialog |
442 | 62 |
|
63 |
#------------------------------------------------------------------------------- |
|
512
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
64 |
# CANFESTIVAL PLUGIN HACK |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
65 |
#------------------------------------------------------------------------------- |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
66 |
from plugins.canfestival import canfestival |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
67 |
class LPC_canfestival_config: |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
68 |
def getCFLAGS(self, *args): |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
69 |
return "" |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
70 |
|
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
71 |
def getLDFLAGS(self, *args): |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
72 |
return "" |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
73 |
|
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
74 |
canfestival.local_canfestival_config = LPC_canfestival_config() |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
510
diff
changeset
|
75 |
#------------------------------------------------------------------------------- |
442 | 76 |
# LPCModule Class |
77 |
#------------------------------------------------------------------------------- |
|
78 |
||
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
79 |
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
|
80 |
"Q": LOCATION_VAR_OUTPUT, |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
81 |
"M": LOCATION_VAR_MEMORY} |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
82 |
|
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
83 |
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
|
84 |
|
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
85 |
LOCATION_SIZES = {} |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
86 |
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
|
87 |
for type in types: |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
88 |
LOCATION_SIZES[type] = size |
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
89 |
|
442 | 90 |
def _GetModuleChildren(module): |
91 |
children = [] |
|
92 |
for child in module["children"]: |
|
93 |
if child["type"] == LOCATION_GROUP: |
|
94 |
children.extend(child["children"]) |
|
95 |
else: |
|
96 |
children.append(child) |
|
97 |
return children |
|
98 |
||
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
99 |
def _GetVariables(module): |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
100 |
variables = [] |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
101 |
for child in module["children"]: |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
102 |
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
|
103 |
variables.extend(_GetVariables(child)) |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
104 |
else: |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
105 |
variables.append(child) |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
106 |
return variables |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
107 |
|
442 | 108 |
def _GetLastModuleGroup(module): |
109 |
group = module |
|
110 |
for child in module["children"]: |
|
111 |
if child["type"] == LOCATION_GROUP: |
|
112 |
group = child |
|
113 |
return group["children"] |
|
114 |
||
115 |
def _GetModuleBySomething(module, something, toks): |
|
116 |
for child in _GetModuleChildren(module): |
|
117 |
if child.get(something) == toks[0]: |
|
118 |
if len(toks) > 1: |
|
119 |
return _GetModuleBySomething(child, something, toks[1:]) |
|
120 |
return child |
|
121 |
return None |
|
122 |
||
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
123 |
def _GetModuleVariable(module, location, direction): |
442 | 124 |
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
|
125 |
if child["location"] == location and child["type"] == LOCATION_TYPES[direction]: |
442 | 126 |
return child |
127 |
return None |
|
128 |
||
129 |
def _RemoveModuleChild(module, child): |
|
130 |
if child in module["children"]: |
|
131 |
module["children"].remove(child) |
|
132 |
else: |
|
133 |
for group in module["children"]: |
|
134 |
if group["type"] == LOCATION_GROUP and child in group["children"]: |
|
135 |
group["children"].remove(child) |
|
136 |
||
137 |
BUS_TEXT = """/* Code generated by LPCBus plugin */ |
|
138 |
||
139 |
/* LPCBus plugin includes */ |
|
140 |
#include "app_glue.h" |
|
141 |
#ifdef _WINDOWS_H |
|
142 |
#include "iec_types.h" |
|
143 |
#else |
|
144 |
#include "iec_std_lib.h" |
|
145 |
#endif |
|
146 |
||
553 | 147 |
%(declare_code)s |
148 |
||
442 | 149 |
/* LPCBus plugin user variables definition */ |
150 |
%(var_decl)s |
|
151 |
||
152 |
/* LPCBus plugin functions */ |
|
153 |
int __init_%(location_str)s(int argc,char **argv) |
|
154 |
{ |
|
553 | 155 |
%(init_code)s |
442 | 156 |
return 0; |
157 |
} |
|
158 |
||
159 |
void __cleanup_%(location_str)s(void) |
|
160 |
{ |
|
161 |
} |
|
162 |
||
163 |
void __retrieve_%(location_str)s(void) |
|
164 |
{ |
|
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
165 |
%(retrieve_code)s |
442 | 166 |
} |
167 |
||
168 |
void __publish_%(location_str)s(void) |
|
169 |
{ |
|
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
170 |
%(publish_code)s |
442 | 171 |
} |
172 |
""" |
|
173 |
||
174 |
class LPCBus(object): |
|
175 |
||
176 |
def __init__(self): |
|
177 |
self.VariableLocationTree = [] |
|
178 |
self.ResetUsedLocations() |
|
179 |
self.Icon = None |
|
180 |
||
181 |
def __getitem__(self, key): |
|
182 |
if key == "children": |
|
183 |
return self.VariableLocationTree |
|
184 |
raise KeyError, "Only 'children' key is available" |
|
185 |
||
186 |
def SetIcon(self, icon): |
|
187 |
self.Icon = icon |
|
188 |
||
189 |
def _GetChildBySomething(self, something, toks): |
|
190 |
return _GetModuleBySomething({"children" : self.VariableLocationTree}, something, toks) |
|
191 |
||
192 |
def GetBaseTypes(self): |
|
193 |
return self.GetPlugRoot().GetBaseTypes() |
|
194 |
||
195 |
def GetSizeOfType(self, type): |
|
196 |
return LOCATION_SIZES[self.GetPlugRoot().GetBaseType(type)] |
|
197 |
||
198 |
def _GetVariableLocationTree(self, current_location, infos): |
|
199 |
if infos["type"] == LOCATION_MODULE: |
|
200 |
location = current_location + (infos["IEC_Channel"],) |
|
201 |
return {"name": infos["name"], |
|
202 |
"type": infos["type"], |
|
203 |
"location": ".".join(map(str, location + ("x",))), |
|
204 |
"icon": infos["icon"], |
|
205 |
"children": [self._GetVariableLocationTree(location, child) for child in infos["children"]]} |
|
206 |
elif infos["type"] == LOCATION_GROUP: |
|
207 |
return {"name": infos["name"], |
|
208 |
"type": infos["type"], |
|
209 |
"location": "", |
|
210 |
"icon": infos["icon"], |
|
211 |
"children": [self._GetVariableLocationTree(current_location, child) for child in infos["children"]]} |
|
212 |
else: |
|
213 |
size = self.GetSizeOfType(infos["IEC_type"]) |
|
214 |
location = "%" + LOCATION_DIRS[infos["type"]] + size + ".".join(map(str, current_location + infos["location"])) |
|
215 |
return {"name": infos["name"], |
|
216 |
"type": infos["type"], |
|
217 |
"size": size, |
|
218 |
"IEC_type": infos["IEC_type"], |
|
219 |
"location": location, |
|
220 |
"description": infos["description"], |
|
221 |
"children": []} |
|
222 |
||
223 |
def GetVariableLocationTree(self): |
|
224 |
return {"name": self.BaseParams.getName(), |
|
225 |
"type": LOCATION_PLUGIN, |
|
226 |
"location": self.GetFullIEC_Channel(), |
|
227 |
"icon": self.Icon, |
|
228 |
"children": [self._GetVariableLocationTree(self.GetCurrentLocation(), child) |
|
229 |
for child in self.VariableLocationTree]} |
|
230 |
||
231 |
def PlugTestModified(self): |
|
232 |
return False |
|
233 |
||
234 |
def PlugMakeDir(self): |
|
235 |
pass |
|
236 |
||
237 |
def PlugRequestSave(self): |
|
238 |
return None |
|
239 |
||
240 |
def ResetUsedLocations(self): |
|
241 |
self.UsedLocations = {} |
|
242 |
||
243 |
def _AddUsedLocation(self, parent, location): |
|
244 |
num = location.pop(0) |
|
245 |
if not parent.has_key(num): |
|
246 |
parent[num] = {"used": False, "children": {}} |
|
247 |
if len(location) > 0: |
|
248 |
self._AddUsedLocation(parent[num]["children"], location) |
|
249 |
else: |
|
250 |
parent[num]["used"] = True |
|
251 |
||
252 |
def AddUsedLocation(self, location): |
|
253 |
if len(location) > 0: |
|
254 |
self._AddUsedLocation(self.UsedLocations, list(location)) |
|
255 |
||
256 |
def _CheckLocationConflicts(self, parent, location): |
|
257 |
num = location.pop(0) |
|
258 |
if not parent.has_key(num): |
|
259 |
return False |
|
260 |
if len(location) > 0: |
|
261 |
if parent[num]["used"]: |
|
262 |
return True |
|
263 |
return self._CheckLocationConflicts(parent[num]["children"], location) |
|
264 |
elif len(parent[num]["children"]) > 0: |
|
265 |
return True |
|
266 |
return False |
|
267 |
||
268 |
def CheckLocationConflicts(self, location): |
|
269 |
if len(location) > 0: |
|
270 |
return self._CheckLocationConflicts(self.UsedLocations, list(location)) |
|
271 |
return False |
|
272 |
||
273 |
def PlugGenerate_C(self, buildpath, locations): |
|
274 |
""" |
|
275 |
Generate C code |
|
276 |
@param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) |
|
277 |
@param locations: List of complete variables locations \ |
|
278 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
|
279 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
|
280 |
"DIR" : direction "Q","I" or "M" |
|
281 |
"SIZE" : size "X", "B", "W", "D", "L" |
|
282 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
|
283 |
}, ...] |
|
284 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
|
285 |
""" |
|
286 |
current_location = self.GetCurrentLocation() |
|
287 |
# define a unique name for the generated C file |
|
288 |
location_str = "_".join(map(str, current_location)) |
|
289 |
||
290 |
code_str = {"location_str": location_str, |
|
291 |
"var_decl": "", |
|
292 |
"declare_code": "", |
|
553 | 293 |
"init_code": "", |
442 | 294 |
"retrieve_code": "", |
295 |
"publish_code": "", |
|
296 |
} |
|
297 |
||
553 | 298 |
for module in _GetModuleChildren(self): |
299 |
if module["init"] != "": |
|
300 |
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
|
301 |
|
442 | 302 |
# Adding variables |
303 |
vars = [] |
|
304 |
self.ResetUsedLocations() |
|
305 |
for location in locations: |
|
306 |
loc = location["LOC"][len(current_location):] |
|
307 |
group = next = self |
|
308 |
i = 0 |
|
309 |
while next is not None and i < len(loc): |
|
310 |
next = self._GetChildBySomething("IEC_Channel", loc[:i + 1]) |
|
311 |
if next is not None: |
|
312 |
i += 1 |
|
313 |
group = next |
|
314 |
var_loc = loc[i:] |
|
530 | 315 |
for variable in _GetModuleChildren(group): |
442 | 316 |
if variable["location"] == var_loc: |
543
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
317 |
# 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
|
318 |
# 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
|
319 |
# 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
|
320 |
# raise Exception, "Type conflict in variable definition" |
442 | 321 |
if location["DIR"] == "Q": |
322 |
if self.CheckLocationConflicts(location["LOC"]): |
|
323 |
raise Exception, "BYTE and BIT from the same BYTE can't be used together" |
|
324 |
self.AddUsedLocation(location["LOC"]) |
|
325 |
vars.append({"location": location["NAME"], |
|
326 |
"Type": variable["IEC_type"], |
|
327 |
"Retrieve": variable["retrieve"], |
|
328 |
"Publish": variable["publish"], |
|
329 |
}) |
|
330 |
break |
|
331 |
base_types = self.GetPlugRoot().GetBaseTypes() |
|
332 |
for var in vars: |
|
333 |
prefix = "" |
|
334 |
if var["Type"] in base_types: |
|
335 |
prefix = "IEC_" |
|
336 |
code_str["var_decl"] += "%s%s beremiz%s;\n"%(prefix, var["Type"], var["location"]) |
|
337 |
code_str["var_decl"] += "%s%s *%s = &beremiz%s;\n"%(prefix, var["Type"], var["location"], var["location"]) |
|
338 |
if var["Retrieve"] != "": |
|
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
339 |
code_str["retrieve_code"] += " " + var["Retrieve"] % ("*" + var["location"]) + "\n" |
442 | 340 |
if var["Publish"] != "": |
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
549
diff
changeset
|
341 |
code_str["publish_code"] += " " + var["Publish"] % ("*" + var["location"]) + "\n" |
442 | 342 |
|
553 | 343 |
Gen_Module_path = os.path.join(buildpath, "Bus_%s.c"%location_str) |
442 | 344 |
module = open(Gen_Module_path,'w') |
345 |
module.write(BUS_TEXT % code_str) |
|
346 |
module.close() |
|
347 |
||
348 |
matiec_flags = '"-I%s"'%os.path.abspath(self.GetPlugRoot().GetIECLibPath()) |
|
349 |
return [(Gen_Module_path, matiec_flags)],"",True |
|
350 |
||
351 |
#------------------------------------------------------------------------------- |
|
352 |
# LPCPluginsRoot Class |
|
353 |
#------------------------------------------------------------------------------- |
|
354 |
||
355 |
def mycopytree(src, dst): |
|
356 |
""" |
|
357 |
Copy content of a directory to an other, omit hidden files |
|
358 |
@param src: source directory |
|
359 |
@param dst: destination directory |
|
360 |
""" |
|
361 |
for i in os.listdir(src): |
|
362 |
if not i.startswith('.'): |
|
363 |
srcpath = os.path.join(src,i) |
|
364 |
dstpath = os.path.join(dst,i) |
|
365 |
if os.path.isdir(srcpath): |
|
503 | 366 |
if os.path.exists(dstpath): |
367 |
shutil.rmtree(dstpath) |
|
368 |
os.makedirs(dstpath) |
|
442 | 369 |
mycopytree(srcpath, dstpath) |
370 |
elif os.path.isfile(srcpath): |
|
371 |
shutil.copy2(srcpath, dstpath) |
|
372 |
||
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
373 |
[SIMULATION_MODE, TRANSFER_MODE] = range(2) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
374 |
|
442 | 375 |
class LPCPluginsRoot(PluginsRoot): |
376 |
||
377 |
PluginMethods = [ |
|
492 | 378 |
{"bitmap" : opjimg("Debug"), |
379 |
"name" : _("Simulate"), |
|
380 |
"tooltip" : _("Simulate PLC"), |
|
381 |
"method" : "_Simulate"}, |
|
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
382 |
{"bitmap" : opjimg("Run"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
383 |
"name" : _("Run"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
384 |
"shown" : False, |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
385 |
"tooltip" : _("Start PLC"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
386 |
"method" : "_Run"}, |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
387 |
{"bitmap" : opjimg("Stop"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
388 |
"name" : _("Stop"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
389 |
"shown" : False, |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
390 |
"tooltip" : _("Stop Running PLC"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
391 |
"method" : "_Stop"}, |
541 | 392 |
{"bitmap" : opjimg("Build"), |
393 |
"name" : _("Build"), |
|
394 |
"tooltip" : _("Build project into build folder"), |
|
395 |
"method" : "_build"}, |
|
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
396 |
{"bitmap" : opjimg("Transfer"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
397 |
"name" : _("Transfer"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
398 |
"shown" : False, |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
399 |
"tooltip" : _("Transfer PLC"), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
400 |
"method" : "_Transfer"}, |
442 | 401 |
] |
402 |
||
478 | 403 |
def __init__(self, frame, logger): |
404 |
PluginsRoot.__init__(self, frame, logger) |
|
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
405 |
|
478 | 406 |
self.PlugChildsTypes += [("LPCBus", LPCBus, "LPC bus")] |
407 |
||
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
408 |
self.OnlineMode = "OFF" |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
409 |
self.LPCConnector = False |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
410 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
411 |
self.CurrentMode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
412 |
self.previous_mode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
413 |
|
492 | 414 |
self.SimulationBuildPath = None |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
415 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
416 |
self.AbortTransferTimer = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
417 |
|
442 | 418 |
def GetProjectName(self): |
419 |
return self.Project.getname() |
|
420 |
||
510
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
421 |
def GetDefaultTargetName(self): |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
422 |
if self.CurrentMode == SIMULATION_MODE: |
510
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
423 |
return PluginsRoot.GetDefaultTargetName(self) |
492 | 424 |
else: |
510
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
425 |
return "LPC" |
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
426 |
|
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
427 |
def GetTarget(self): |
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
428 |
target = PluginsRoot.GetTarget(self) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
429 |
if self.CurrentMode != SIMULATION_MODE: |
510
8038c08b9874
Getting default target when no target defined fixed
laurent
parents:
503
diff
changeset
|
430 |
target.getcontent()["value"].setBuildPath(self.BuildPath) |
442 | 431 |
return target |
492 | 432 |
|
433 |
def _getBuildPath(self): |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
434 |
if self.CurrentMode == SIMULATION_MODE: |
492 | 435 |
if self.SimulationBuildPath is None: |
436 |
self.SimulationBuildPath = os.path.join(tempfile.mkdtemp(), os.path.basename(self.ProjectPath), "build") |
|
437 |
return self.SimulationBuildPath |
|
438 |
else: |
|
494
9e4263099427
Bug when opening with not empty buildpath parameter fixed
laurent
parents:
492
diff
changeset
|
439 |
return PluginsRoot._getBuildPath(self) |
503 | 440 |
|
441 |
def _build(self): |
|
442 |
if self.BuildPath is not None: |
|
443 |
mycopytree(self.OrigBuildPath, self.BuildPath) |
|
444 |
PluginsRoot._build(self) |
|
492 | 445 |
|
442 | 446 |
def SetProjectName(self, name): |
447 |
return self.Project.setname(name) |
|
448 |
||
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
449 |
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
|
450 |
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
|
451 |
self.OnlineMode = mode.upper() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
452 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
453 |
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
|
454 |
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
|
455 |
try: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
456 |
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
|
457 |
except Exception, msg: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
458 |
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
|
459 |
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
|
460 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
461 |
# Did connection success ? |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
462 |
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
|
463 |
# Oups. |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
464 |
self.logger.write_error(_("Connection failed to %s!\n")%uri) |
492 | 465 |
|
466 |
else: |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
467 |
self.LPCConnector = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
468 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
469 |
self.ApplyOnlineMode() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
470 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
471 |
def ApplyOnlineMode(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
472 |
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
|
473 |
self.KillDebugThread() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
474 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
475 |
self._connector = self.LPCConnector |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
476 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
477 |
# 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
|
478 |
self.UpdateMethodsFromPLCStatus() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
479 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
480 |
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
|
481 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
482 |
self.CompareLocalAndRemotePLC() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
483 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
484 |
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
|
485 |
status = _(self.previous_plcstate) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
486 |
else: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
487 |
status = "" |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
488 |
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
|
489 |
|
543
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
490 |
if self.StatusTimer and not self.StatusTimer.IsRunning(): |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
491 |
# Start the status Timer |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
492 |
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
|
493 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
494 |
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
|
495 |
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
|
496 |
self.logger.write(_("Debug connect matching running PLC\n")) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
497 |
self._connect_debug() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
498 |
else: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
499 |
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
|
500 |
|
543
3dec6ff88620
Disabled boring standard conformance checks, fixed possible race condition with StatusTimer, fixed warning message in AbortTransfer
Lolitech
parents:
541
diff
changeset
|
501 |
elif self.StatusTimer and self.StatusTimer.IsRunning(): |
492 | 502 |
self.StatusTimer.Stop() |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
503 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
504 |
if self.CurrentMode == TRANSFER_MODE: |
492 | 505 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
506 |
if self.OnlineMode == "BOOTLOADER": |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
507 |
self.BeginTransfer() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
508 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
509 |
elif self.OnlineMode == "APPLICATION": |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
510 |
self.CurrentMode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
511 |
self.AbortTransferTimer.Stop() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
512 |
self.AbortTransferTimer = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
513 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
514 |
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
|
515 |
|
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
|
516 |
# 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
|
517 |
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
|
518 |
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
|
519 |
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
|
520 |
|
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
|
521 |
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
|
522 |
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
|
523 |
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
|
524 |
|
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
|
525 |
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
|
526 |
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
|
527 |
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
|
528 |
|
442 | 529 |
def LoadProject(self, ProjectPath, BuildPath=None): |
530 |
""" |
|
478 | 531 |
Load a project contained in a folder |
532 |
@param ProjectPath: path of the project folder |
|
442 | 533 |
""" |
478 | 534 |
if os.path.basename(ProjectPath) == "": |
535 |
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
|
536 |
|
478 | 537 |
# Verify that project contains a PLCOpen program |
538 |
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
|
539 |
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
|
540 |
# 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
|
541 |
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
|
542 |
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
|
543 |
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
|
544 |
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
|
545 |
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
|
546 |
"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
|
547 |
"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
|
548 |
"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
|
549 |
"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
|
550 |
"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
|
551 |
|
442 | 552 |
# Change XSD into class members |
553 |
self._AddParamsMembers() |
|
554 |
self.PluggedChilds = {} |
|
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
|
555 |
|
442 | 556 |
# Keep track of the root plugin (i.e. project path) |
557 |
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
|
558 |
|
478 | 559 |
self.BuildPath = self._getBuildPath() |
503 | 560 |
self.OrigBuildPath = BuildPath |
442 | 561 |
if BuildPath is not None: |
562 |
mycopytree(BuildPath, self.BuildPath) |
|
563 |
||
478 | 564 |
# If dir have already be made, and file exist |
565 |
if os.path.isdir(self.PlugPath()) and os.path.isfile(self.PluginXmlFilePath()): |
|
566 |
#Load the plugin.xml file into parameters members |
|
567 |
result = self.LoadXMLParams() |
|
568 |
if result: |
|
569 |
return result |
|
570 |
#Load and init all the childs |
|
571 |
self.LoadChilds() |
|
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
|
572 |
|
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
|
573 |
if self.PlugTestModified(): |
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
|
574 |
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
|
575 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
576 |
if wx.GetApp() is None: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
577 |
self.RefreshPluginsBlockLists() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
578 |
else: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
579 |
wx.CallAfter(self.RefreshPluginsBlockLists) |
478 | 580 |
|
581 |
return None |
|
442 | 582 |
|
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
583 |
############# Real PLC object access ############# |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
584 |
def UpdateMethodsFromPLCStatus(self): |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
585 |
# Get PLC state : Running or Stopped |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
586 |
# 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
|
587 |
if self.OnlineMode == "OFF": |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
588 |
status = "Disconnected" |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
589 |
elif self.OnlineMode == "BOOTLOADER": |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
590 |
status = "Connected" |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
591 |
else: |
492 | 592 |
if self._connector is not None: |
593 |
status = self._connector.GetPLCstatus() |
|
594 |
else: |
|
595 |
status = "Disconnected" |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
596 |
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
|
597 |
simulating = self.CurrentMode == SIMULATION_MODE |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
598 |
for args in { |
492 | 599 |
"Started" : [("_Simulate", False), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
600 |
("_Run", False), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
601 |
("_Stop", True), |
541 | 602 |
("_build", False), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
603 |
("_Transfer", False)], |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
604 |
"Stopped" : [("_Simulate", True), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
605 |
("_Run", True), |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
606 |
("_Stop", False), |
541 | 607 |
("_build", False), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
608 |
("_Transfer", False)], |
492 | 609 |
"Connected" : [("_Simulate", not simulating), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
610 |
("_Run", False), |
492 | 611 |
("_Stop", simulating), |
541 | 612 |
("_build", False), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
613 |
("_Transfer", True)], |
492 | 614 |
"Disconnected" :[("_Simulate", not simulating), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
615 |
("_Run", False), |
492 | 616 |
("_Stop", simulating), |
541 | 617 |
("_build", True), |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
618 |
("_Transfer", False)], |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
619 |
}.get(status,[]): |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
620 |
self.ShowMethod(*args) |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
621 |
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
|
622 |
self.previous_mode = self.CurrentMode |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
623 |
return True |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
624 |
return False |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
625 |
|
492 | 626 |
def Generate_plc_declare_locations(self): |
627 |
""" |
|
628 |
Declare used locations in order to simulatePLC in a black box |
|
629 |
""" |
|
630 |
return """#include "iec_types_all.h" |
|
631 |
||
632 |
#define __LOCATED_VAR(type, name, ...) \ |
|
633 |
type beremiz_##name;\ |
|
634 |
type *name = &beremiz_##name; |
|
635 |
||
636 |
#include "LOCATED_VARIABLES.h" |
|
637 |
||
638 |
#undef __LOCATED_VAR |
|
639 |
||
640 |
""" |
|
641 |
||
642 |
def _Simulate(self): |
|
643 |
""" |
|
644 |
Method called by user to Simulate PLC |
|
645 |
""" |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
646 |
self.CurrentMode = SIMULATION_MODE |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
647 |
|
492 | 648 |
uri = "LOCAL://" |
649 |
try: |
|
650 |
self._connector = connectors.ConnectorFactory(uri, self) |
|
651 |
except Exception, msg: |
|
652 |
self.logger.write_error(_("Exception while connecting %s!\n")%uri) |
|
653 |
self.logger.write_error(traceback.format_exc()) |
|
654 |
||
655 |
# Did connection success ? |
|
656 |
if self._connector is None: |
|
657 |
# Oups. |
|
658 |
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
|
659 |
self.StopSimulation() |
492 | 660 |
return False |
661 |
||
662 |
buildpath = self._getBuildPath() |
|
663 |
||
664 |
# Eventually create build dir |
|
665 |
if not os.path.exists(buildpath): |
|
666 |
os.makedirs(buildpath) |
|
667 |
||
668 |
# Generate SoftPLC IEC code |
|
669 |
IECGenRes = self._Generate_SoftPLC() |
|
670 |
||
671 |
# If IEC code gen fail, bail out. |
|
672 |
if not IECGenRes: |
|
673 |
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
|
674 |
self.StopSimulation() |
492 | 675 |
return False |
676 |
||
677 |
# Reset variable and program list that are parsed from |
|
678 |
# CSV file generated by IEC2C compiler. |
|
679 |
self.ResetIECProgramsAndVariables() |
|
680 |
||
681 |
gen_result = self.PlugGenerate_C(buildpath, self.PLCGeneratedLocatedVars) |
|
682 |
PlugCFilesAndCFLAGS, PlugLDFLAGS, DoCalls = gen_result[:3] |
|
683 |
# if some files have been generated put them in the list with their location |
|
684 |
if PlugCFilesAndCFLAGS: |
|
685 |
self.LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), PlugCFilesAndCFLAGS, DoCalls)] |
|
686 |
else: |
|
687 |
self.LocationCFilesAndCFLAGS = [] |
|
688 |
||
689 |
# plugin asks for some LDFLAGS |
|
690 |
if PlugLDFLAGS: |
|
691 |
# LDFLAGS can be either string |
|
692 |
if type(PlugLDFLAGS)==type(str()): |
|
693 |
self.LDFLAGS=[PlugLDFLAGS] |
|
694 |
#or list of strings |
|
695 |
elif type(PlugLDFLAGS)==type(list()): |
|
696 |
self.LDFLAGS=PlugLDFLAGS[:] |
|
697 |
else: |
|
698 |
self.LDFLAGS=[] |
|
699 |
||
700 |
# Template based part of C code generation |
|
701 |
# files are stacked at the beginning, as files of plugin tree root |
|
702 |
for generator, filename, name in [ |
|
703 |
# debugger code |
|
704 |
(self.Generate_plc_debugger, "plc_debugger.c", "Debugger"), |
|
705 |
# init/cleanup/retrieve/publish, run and align code |
|
706 |
(self.Generate_plc_common_main,"plc_common_main.c","Common runtime"), |
|
707 |
# declare located variables for simulate in a black box |
|
708 |
(self.Generate_plc_declare_locations,"plc_declare_locations.c","Declare Locations")]: |
|
709 |
try: |
|
710 |
# Do generate |
|
711 |
code = generator() |
|
712 |
if code is None: |
|
713 |
raise |
|
714 |
code_path = os.path.join(buildpath,filename) |
|
715 |
open(code_path, "w").write(code) |
|
716 |
# Insert this file as first file to be compiled at root plugin |
|
717 |
self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
|
718 |
except Exception, exc: |
|
719 |
self.logger.write_error(name+_(" generation failed !\n")) |
|
720 |
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
|
721 |
self.StopSimulation() |
492 | 722 |
return False |
723 |
||
724 |
# Get simulation builder |
|
725 |
builder = self.GetBuilder() |
|
726 |
if builder is None: |
|
727 |
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
|
728 |
self.StopSimulation() |
492 | 729 |
return False |
730 |
||
731 |
# Build |
|
732 |
try: |
|
733 |
if not builder.build() : |
|
734 |
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
|
735 |
self.StopSimulation() |
492 | 736 |
return False |
737 |
except Exception, exc: |
|
738 |
self.logger.write_error(_("C Build crashed !\n")) |
|
739 |
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
|
740 |
self.StopSimulation() |
492 | 741 |
return False |
742 |
||
743 |
data = builder.GetBinaryCode() |
|
744 |
if data is not None : |
|
745 |
if self._connector.NewPLC(builder.GetBinaryCodeMD5(), data, []): |
|
746 |
if self.AppFrame is not None: |
|
747 |
self.AppFrame.CloseDebugTabs() |
|
748 |
self.AppFrame.RefreshInstancesTree() |
|
749 |
self.UnsubscribeAllDebugIECVariable() |
|
750 |
self.ProgramTransferred() |
|
751 |
self.logger.write(_("Transfer completed successfully.\n")) |
|
752 |
else: |
|
753 |
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
|
754 |
self.StopSimulation() |
492 | 755 |
return False |
756 |
||
757 |
self._Run() |
|
758 |
||
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
759 |
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
|
760 |
# Start the status Timer |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
761 |
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
|
762 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
763 |
def StopSimulation(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
764 |
self.CurrentMode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
765 |
self.ApplyOnlineMode() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
766 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
767 |
def _Stop(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
768 |
PluginsRoot._Stop(self) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
769 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
770 |
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
|
771 |
self.StopSimulation() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
772 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
773 |
def _Transfer(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
774 |
if self.CurrentMode is None and self.OnlineMode != "OFF": |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
775 |
self.CurrentMode = TRANSFER_MODE |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
776 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
777 |
PluginsRoot._build(self) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
778 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
779 |
ID_ABORTTRANSFERTIMER = wx.NewId() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
780 |
self.AbortTransferTimer = wx.Timer(self.AppFrame, ID_ABORTTRANSFERTIMER) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
781 |
self.AppFrame.Bind(wx.EVT_TIMER, self.AbortTransfer, self.AbortTransferTimer) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
782 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
783 |
if self.OnlineMode == "BOOTLOADER": |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
784 |
self.BeginTransfer() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
785 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
786 |
else: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
787 |
self.logger.write(_("Resetting PLC\n")) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
788 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
789 |
self.LPCConnector.ResetPLC() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
790 |
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
|
791 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
792 |
def BeginTransfer(self): |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
793 |
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
|
794 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
795 |
self.AbortTransferTimer.Stop() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
796 |
PluginsRoot._Transfer(self) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
797 |
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
|
798 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
799 |
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
|
800 |
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
|
801 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
802 |
self.CurrentMode = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
803 |
self.AbortTransferTimer.Stop() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
804 |
self.AbortTransferTimer = None |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
805 |
event.Skip() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
806 |
|
442 | 807 |
#------------------------------------------------------------------------------- |
808 |
# LPCBeremiz Class |
|
809 |
#------------------------------------------------------------------------------- |
|
549 | 810 |
lpcberemiz_cmd=None |
442 | 811 |
|
812 |
class LPCBeremiz(Beremiz): |
|
813 |
||
814 |
def _init_coll_FileMenu_Items(self, parent): |
|
815 |
AppendMenu(parent, help='', id=wx.ID_SAVE, |
|
816 |
kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S')) |
|
817 |
AppendMenu(parent, help='', id=wx.ID_CLOSE, |
|
818 |
kind=wx.ITEM_NORMAL, text=_(u'Close Tab\tCTRL+W')) |
|
819 |
parent.AppendSeparator() |
|
820 |
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
|
821 |
kind=wx.ITEM_NORMAL, text=_(u'Page Setup')) |
|
822 |
AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
|
823 |
kind=wx.ITEM_NORMAL, text=_(u'Preview')) |
|
824 |
AppendMenu(parent, help='', id=wx.ID_PRINT, |
|
825 |
kind=wx.ITEM_NORMAL, text=_(u'Print')) |
|
826 |
parent.AppendSeparator() |
|
827 |
AppendMenu(parent, help='', id=wx.ID_PROPERTIES, |
|
828 |
kind=wx.ITEM_NORMAL, text=_(u'Properties')) |
|
829 |
parent.AppendSeparator() |
|
830 |
AppendMenu(parent, help='', id=wx.ID_EXIT, |
|
831 |
kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q')) |
|
832 |
||
833 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
|
834 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) |
|
835 |
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
|
836 |
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
|
837 |
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
|
838 |
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
|
839 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
|
840 |
||
841 |
def _init_ctrls(self, prnt): |
|
842 |
IDEFrame._init_ctrls(self, prnt) |
|
843 |
||
844 |
self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=ID_BEREMIZINSPECTOR) |
|
845 |
accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR)]) |
|
846 |
self.SetAcceleratorTable(accel) |
|
847 |
||
848 |
self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG, |
|
849 |
name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0), |
|
850 |
size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL) |
|
851 |
self.PLCConfig.SetBackgroundColour(wx.WHITE) |
|
852 |
self.PLCConfig.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
|
853 |
self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow) |
|
854 |
self.LeftNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True) |
|
855 |
||
856 |
self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
|
857 |
name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0), |
|
858 |
size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
|
859 |
self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick) |
|
860 |
self.BottomNoteBook.AddPage(self.LogConsole, _("Log Console")) |
|
861 |
||
862 |
self._init_beremiz_sizers() |
|
863 |
||
864 |
def OnCloseFrame(self, event): |
|
519
3a5faff52e5c
Adding message to standard output to signal when LPCBeremiz is closed
laurent
parents:
517
diff
changeset
|
865 |
global frame |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
866 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
867 |
frame.Hide() |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
868 |
|
442 | 869 |
self.PluginRoot.ResetAppFrame(lpcberemiz_cmd.Log) |
492 | 870 |
if self.PluginRoot.OnlineMode == 0: |
871 |
self.PluginRoot._connector = None |
|
872 |
||
873 |
self.PluginRoot.KillDebugThread() |
|
442 | 874 |
self.KillLocalRuntime() |
875 |
||
552 | 876 |
lpcberemiz_cmd.Log.write("Closed\n") |
519
3a5faff52e5c
Adding message to standard output to signal when LPCBeremiz is closed
laurent
parents:
517
diff
changeset
|
877 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
878 |
event.Veto() |
442 | 879 |
|
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
|
880 |
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
|
881 |
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
|
882 |
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
|
883 |
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
|
884 |
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
|
885 |
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
|
886 |
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
|
887 |
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
|
888 |
self.Controler.SetProjectProperties(None, new_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
|
889 |
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, |
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
|
890 |
TYPESTREE, INSTANCESTREE, 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
|
891 |
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
|
892 |
|
442 | 893 |
def RefreshFileMenu(self): |
894 |
if self.PluginRoot is not None: |
|
895 |
selected = self.TabsOpened.GetSelection() |
|
896 |
if selected >= 0: |
|
897 |
graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer) |
|
898 |
else: |
|
899 |
graphic_viewer = False |
|
900 |
if self.TabsOpened.GetPageCount() > 0: |
|
901 |
self.FileMenu.Enable(wx.ID_CLOSE, True) |
|
902 |
if graphic_viewer: |
|
903 |
self.FileMenu.Enable(wx.ID_PREVIEW, True) |
|
904 |
self.FileMenu.Enable(wx.ID_PRINT, True) |
|
905 |
else: |
|
906 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
907 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
908 |
else: |
|
909 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
|
910 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
911 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
912 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
|
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
|
913 |
self.FileMenu.Enable(wx.ID_SAVE, self.PluginRoot.PlugTestModified()) |
442 | 914 |
self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
915 |
else: |
|
916 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
|
917 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
|
918 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
919 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
920 |
self.FileMenu.Enable(wx.ID_SAVE, False) |
|
921 |
self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
|
922 |
||
923 |
def RefreshPLCParams(self): |
|
924 |
self.Freeze() |
|
925 |
self.ClearSizer(self.PLCParamsSizer) |
|
926 |
||
927 |
if self.PluginRoot is not None: |
|
928 |
plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
|
929 |
if self.PluginRoot.PlugTestModified(): |
|
930 |
bkgdclr = CHANGED_TITLE_COLOUR |
|
931 |
else: |
|
932 |
bkgdclr = TITLE_COLOUR |
|
933 |
||
934 |
if self.PluginRoot not in self.PluginInfos: |
|
935 |
self.PluginInfos[self.PluginRoot] = {"right_visible" : False} |
|
936 |
||
937 |
plcwindow.SetBackgroundColour(TITLE_COLOUR) |
|
938 |
plcwindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
|
939 |
self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW) |
|
940 |
||
941 |
plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
942 |
plcwindow.SetSizer(plcwindowsizer) |
|
943 |
||
944 |
st = wx.StaticText(plcwindow, -1) |
|
945 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
|
946 |
st.SetLabel(self.PluginRoot.GetProjectName()) |
|
947 |
plcwindowsizer.AddWindow(st, 0, border=5, flag=wx.ALL|wx.ALIGN_CENTER) |
|
948 |
||
949 |
plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
|
950 |
plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL) |
|
951 |
||
952 |
plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
953 |
plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER) |
|
954 |
||
955 |
msizer = self.GenerateMethodButtonSizer(self.PluginRoot, plcwindow, not self.PluginInfos[self.PluginRoot]["right_visible"]) |
|
956 |
plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
|
957 |
||
958 |
self.PLCConfigMainSizer.Layout() |
|
959 |
self.RefreshScrollBars() |
|
960 |
self.Thaw() |
|
961 |
||
962 |
def GenerateTreeBranch(self, plugin): |
|
963 |
leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
|
964 |
if plugin.PlugTestModified(): |
|
965 |
bkgdclr=CHANGED_WINDOW_COLOUR |
|
966 |
else: |
|
967 |
bkgdclr=WINDOW_COLOUR |
|
968 |
||
969 |
leftwindow.SetBackgroundColour(bkgdclr) |
|
970 |
||
971 |
if plugin not in self.PluginInfos: |
|
972 |
self.PluginInfos[plugin] = {"expanded" : False, "left_visible" : False, "right_visible" : False} |
|
973 |
||
974 |
self.PluginInfos[plugin]["children"] = plugin.IECSortedChilds() |
|
975 |
plugin_infos = plugin.GetVariableLocationTree() |
|
976 |
plugin_locations = [] |
|
977 |
if len(self.PluginInfos[plugin]["children"]) == 0: |
|
978 |
plugin_locations = plugin_infos["children"] |
|
979 |
if not self.PluginInfos[plugin].has_key("locations_infos"): |
|
980 |
self.PluginInfos[plugin]["locations_infos"] = {"root": {"expanded" : False}} |
|
981 |
||
982 |
self.PluginInfos[plugin]["locations_infos"]["root"]["children"] = [] |
|
983 |
||
984 |
self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) |
|
985 |
||
986 |
leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
987 |
leftwindow.SetSizer(leftwindowsizer) |
|
988 |
||
989 |
st = wx.StaticText(leftwindow, -1) |
|
990 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
|
991 |
st.SetLabel(plugin.GetFullIEC_Channel()) |
|
992 |
leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT) |
|
993 |
||
994 |
expandbutton_id = wx.NewId() |
|
995 |
expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')), |
|
996 |
name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0), |
|
997 |
size=wx.Size(13, 13), style=wx.NO_BORDER) |
|
998 |
expandbutton.labelDelta = 0 |
|
999 |
expandbutton.SetBezelWidth(0) |
|
1000 |
expandbutton.SetUseFocusIndicator(False) |
|
1001 |
expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png'))) |
|
1002 |
||
1003 |
if len(self.PluginInfos[plugin]["children"]) > 0: |
|
1004 |
expandbutton.SetToggle(self.PluginInfos[plugin]["expanded"]) |
|
1005 |
def togglebutton(event): |
|
1006 |
if expandbutton.GetToggle(): |
|
1007 |
self.ExpandPlugin(plugin) |
|
1008 |
else: |
|
1009 |
self.CollapsePlugin(plugin) |
|
1010 |
self.PluginInfos[plugin]["expanded"] = expandbutton.GetToggle() |
|
1011 |
self.PLCConfigMainSizer.Layout() |
|
1012 |
self.RefreshScrollBars() |
|
1013 |
event.Skip() |
|
1014 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
|
1015 |
elif len(plugin_locations) > 0: |
|
1016 |
locations_infos = self.PluginInfos[plugin]["locations_infos"] |
|
1017 |
expandbutton.SetToggle(locations_infos["root"]["expanded"]) |
|
1018 |
def togglebutton(event): |
|
1019 |
if expandbutton.GetToggle(): |
|
1020 |
self.ExpandLocation(locations_infos, "root") |
|
1021 |
else: |
|
1022 |
self.CollapseLocation(locations_infos, "root") |
|
1023 |
self.PluginInfos[plugin]["expanded"] = expandbutton.GetToggle() |
|
1024 |
locations_infos["root"]["expanded"] = expandbutton.GetToggle() |
|
1025 |
self.PLCConfigMainSizer.Layout() |
|
1026 |
self.RefreshScrollBars() |
|
1027 |
event.Skip() |
|
1028 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
|
1029 |
else: |
|
1030 |
expandbutton.Enable(False) |
|
1031 |
leftwindowsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
|
1032 |
||
1033 |
sb = wx.StaticBitmap(leftwindow, -1) |
|
1034 |
icon = plugin_infos.get("icon", None) |
|
1035 |
if icon is None: |
|
1036 |
icon = os.path.join(base_folder, "plcopeneditor", 'Images', '%s.png' % self.LOCATION_BITMAP[plugin_infos["type"]]) |
|
1037 |
sb.SetBitmap(wx.Bitmap(icon)) |
|
1038 |
leftwindowsizer.AddWindow(sb, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
|
1039 |
||
1040 |
st_id = wx.NewId() |
|
1041 |
st = wx.StaticText(leftwindow, st_id, size=wx.DefaultSize, style=wx.NO_BORDER) |
|
1042 |
st.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
|
1043 |
st.SetLabel(plugin.MandatoryParams[1].getName()) |
|
1044 |
leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
|
1045 |
||
1046 |
rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
|
1047 |
rightwindow.SetBackgroundColour(bkgdclr) |
|
1048 |
||
1049 |
self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
|
1050 |
||
1051 |
self.PluginInfos[plugin]["left"] = leftwindow |
|
1052 |
self.PluginInfos[plugin]["right"] = rightwindow |
|
1053 |
for child in self.PluginInfos[plugin]["children"]: |
|
1054 |
self.GenerateTreeBranch(child) |
|
1055 |
if not self.PluginInfos[child]["expanded"]: |
|
1056 |
self.CollapsePlugin(child) |
|
1057 |
if len(plugin_locations) > 0: |
|
1058 |
locations_infos = self.PluginInfos[plugin]["locations_infos"] |
|
1059 |
for location in plugin_locations: |
|
1060 |
locations_infos["root"]["children"].append("root.%s" % location["name"]) |
|
1061 |
self.GenerateLocationTreeBranch(locations_infos, "root", location) |
|
1062 |
if not locations_infos["root"]["expanded"]: |
|
1063 |
self.CollapseLocation(locations_infos, "root") |
|
1064 |
||
1065 |
class StdoutPseudoFile: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1066 |
|
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1067 |
def __init__(self, port): |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1068 |
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
|
1069 |
self.socket.connect(('localhost', port)) |
552 | 1070 |
self.Buffer = "" |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1071 |
|
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1072 |
def __del__(self): |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1073 |
self.socket.close() |
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1074 |
|
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1075 |
def readline(self): |
552 | 1076 |
idx = self.Buffer.find("\n") |
1077 |
if idx == -1: |
|
1078 |
self.Buffer += self.socket.recv(2048) |
|
1079 |
idx = self.Buffer.find("\n") |
|
1080 |
if idx != -1: |
|
1081 |
line = self.Buffer[:idx+1] |
|
1082 |
self.Buffer = self.Buffer[idx+1:] |
|
1083 |
return line |
|
1084 |
return "" |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1085 |
|
442 | 1086 |
""" Base class for file like objects to facilitate StdOut for the Shell.""" |
1087 |
def write(self, s, style = None): |
|
1088 |
if s != '': |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1089 |
self.socket.send(s) |
442 | 1090 |
|
1091 |
def write_warning(self, s): |
|
1092 |
self.write(s) |
|
1093 |
||
1094 |
def write_error(self, s): |
|
1095 |
self.write(s) |
|
1096 |
||
1097 |
def flush(self): |
|
1098 |
pass |
|
1099 |
||
1100 |
def isatty(self): |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1101 |
return False |
442 | 1102 |
|
1103 |
if __name__ == '__main__': |
|
1104 |
||
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
|
1105 |
from threading import Thread, Timer, Semaphore |
442 | 1106 |
import cmd |
1107 |
||
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
|
1108 |
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
|
1109 |
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
|
1110 |
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
|
1111 |
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
|
1112 |
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
|
1113 |
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
|
1114 |
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
|
1115 |
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
|
1116 |
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
|
1117 |
|
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
|
1118 |
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
|
1119 |
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
|
1120 |
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
|
1121 |
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
|
1122 |
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
|
1123 |
|
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
|
1124 |
# Command log for debug, for viewing from wxInspector |
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
|
1125 |
__builtins__.cmdlog = [] |
555 | 1126 |
#cmdlogf=open("bmzcmdlog.txt","w") |
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
|
1127 |
|
442 | 1128 |
class LPCBeremiz_Cmd(cmd.Cmd): |
1129 |
||
1130 |
prompt = "" |
|
1131 |
RefreshTimer = None |
|
1132 |
||
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
|
1133 |
def __init__(self, PluginRoot, Log): |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1134 |
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
|
1135 |
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
|
1136 |
self.Log = Log |
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
|
1137 |
self.PluginRoot = PluginRoot |
442 | 1138 |
|
1139 |
def RestartTimer(self): |
|
1140 |
if self.RefreshTimer is not None: |
|
1141 |
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
|
1142 |
self.RefreshTimer = Timer(0.1, wx.CallAfter, args = [self.Refresh]) |
442 | 1143 |
self.RefreshTimer.start() |
1144 |
||
1145 |
def Exit(self): |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1146 |
global frame, app |
442 | 1147 |
self.Close() |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1148 |
app.ExitMainLoop() |
442 | 1149 |
return True |
1150 |
||
1151 |
def do_EOF(self, line): |
|
1152 |
return self.Exit() |
|
1153 |
||
1154 |
def Show(self): |
|
445 | 1155 |
global frame |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1156 |
if frame is not None: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1157 |
self.PluginRoot.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
|
1158 |
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
|
1159 |
frame.Raise() |
442 | 1160 |
|
1161 |
def Refresh(self): |
|
1162 |
global frame |
|
1163 |
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
|
1164 |
frame._Refresh(TITLE, INSTANCESTREE, FILEMENU, EDITMENU) |
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
|
1165 |
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
|
1166 |
frame.RefreshAll() |
442 | 1167 |
|
1168 |
def Close(self): |
|
1169 |
global frame |
|
1170 |
||
1171 |
self.PluginRoot.ResetAppFrame(self.Log) |
|
1172 |
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
|
1173 |
frame.Hide() |
442 | 1174 |
|
1175 |
def Compile(self): |
|
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
|
1176 |
self.PluginRoot._build() |
442 | 1177 |
|
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
|
1178 |
def SetProjectProperties(self, projectname, productname, productversion, 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
|
1179 |
properties = self.PluginRoot.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
|
1180 |
properties["projectName"] = 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
|
1181 |
properties["productName"] = 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
|
1182 |
properties["productVersion"] = 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
|
1183 |
properties["companyName"] = 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
|
1184 |
self.PluginRoot.SetProjectProperties(properties=properties) |
442 | 1185 |
self.RestartTimer() |
1186 |
||
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
1187 |
def SetOnlineMode(self, mode, path=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
|
1188 |
self.PluginRoot.SetOnlineMode(mode, path) |
487
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
1189 |
self.RestartTimer() |
1df4a28d3586
Adding support for receiving PLC state from LPCComposer
laurent
parents:
478
diff
changeset
|
1190 |
|
442 | 1191 |
def AddBus(self, iec_channel, name, icon=None): |
1192 |
for child in self.PluginRoot.IterChilds(): |
|
1193 |
if child.BaseParams.getName() == name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1194 |
return "Error: A bus named %s already exists\n" % name |
442 | 1195 |
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
|
1196 |
return "Error: A bus with IEC_channel %d already exists\n" % iec_channel |
442 | 1197 |
bus = self.PluginRoot.PlugAddChild(name, "LPCBus", iec_channel) |
1198 |
if bus is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1199 |
return "Error: Unable to create bus\n" |
442 | 1200 |
bus.SetIcon(icon) |
1201 |
self.RestartTimer() |
|
1202 |
||
1203 |
def RenameBus(self, iec_channel, name): |
|
1204 |
bus = self.PluginRoot.GetChildByIECLocation((iec_channel,)) |
|
1205 |
if bus is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1206 |
return "Error: No bus found\n" |
442 | 1207 |
for child in self.PluginRoot.IterChilds(): |
1208 |
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
|
1209 |
return "Error: A bus named %s already exists\n" % name |
442 | 1210 |
bus.BaseParams.setName(name) |
1211 |
self.RestartTimer() |
|
1212 |
||
1213 |
def ChangeBusIECChannel(self, old_iec_channel, new_iec_channel): |
|
1214 |
bus = self.PluginRoot.GetChildByIECLocation((old_iec_channel,)) |
|
1215 |
if bus is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1216 |
return "Error: No bus found\n" |
442 | 1217 |
for child in self.PluginRoot.IterChilds(): |
1218 |
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
|
1219 |
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
|
1220 |
if wx.GetApp() is None: |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1221 |
self.PluginRoot.UpdateProjectVariableLocation(str(old_iec_channel), |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1222 |
str(new_iec_channel)) |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1223 |
else: |
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
|
1224 |
self.PluginRoot.UpdateProjectVariableLocation( |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1225 |
str(old_iec_channel), |
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
530
diff
changeset
|
1226 |
str(new_iec_channel)) |
442 | 1227 |
bus.BaseParams.setIEC_Channel(new_iec_channel) |
1228 |
self.RestartTimer() |
|
1229 |
||
1230 |
def RemoveBus(self, iec_channel): |
|
1231 |
bus = self.PluginRoot.GetChildByIECLocation((iec_channel,)) |
|
1232 |
if bus is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1233 |
return "Error: No bus 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
|
1234 |
self.PluginRoot.RemoveProjectVariableByFilter(str(iec_channel)) |
442 | 1235 |
self.PluginRoot.PluggedChilds["LPCBus"].remove(bus) |
1236 |
self.RestartTimer() |
|
1237 |
||
553 | 1238 |
def AddModule(self, parent, iec_channel, name, icode, icon=None): |
442 | 1239 |
module = self.PluginRoot.GetChildByIECLocation(parent) |
1240 |
if module is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1241 |
return "Error: No parent found\n" |
442 | 1242 |
for child in _GetModuleChildren(module): |
1243 |
if child["name"] == name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1244 |
return "Error: A module named %s already exists\n" % name |
442 | 1245 |
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
|
1246 |
return "Error: A module with IEC_channel %d already exists\n" % iec_channel |
442 | 1247 |
_GetLastModuleGroup(module).append({"name": name, |
1248 |
"type": LOCATION_MODULE, |
|
1249 |
"IEC_Channel": iec_channel, |
|
1250 |
"icon": icon, |
|
553 | 1251 |
"init": icode, |
442 | 1252 |
"children": []}) |
1253 |
self.RestartTimer() |
|
1254 |
||
1255 |
def RenameModule(self, iec_location, name): |
|
1256 |
module = self.PluginRoot.GetChildByIECLocation(iec_location) |
|
1257 |
if module is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1258 |
return "Error: No module found\n" |
442 | 1259 |
parent = self.PluginRoot.GetChildByIECLocation(iec_location[:-1]) |
1260 |
if parent is self.PluginRoot: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1261 |
return "Error: No module found\n" |
442 | 1262 |
if module["name"] != name: |
1263 |
for child in _GetModuleChildren(parent): |
|
1264 |
if child["name"] == name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1265 |
return "Error: A module named %s already exists\n" % name |
442 | 1266 |
module["name"] = name |
1267 |
self.RestartTimer() |
|
1268 |
||
1269 |
def ChangeModuleIECChannel(self, old_iec_location, new_iec_channel): |
|
1270 |
module = self.PluginRoot.GetChildByIECLocation(old_iec_location) |
|
1271 |
if module is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1272 |
return "Error: No module found\n" |
442 | 1273 |
parent = self.PluginRoot.GetChildByIECLocation(old_iec_location[:-1]) |
1274 |
if parent is self.PluginRoot: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1275 |
return "Error: No module found\n" |
442 | 1276 |
if module["IEC_Channel"] != new_iec_channel: |
1277 |
for child in _GetModuleChildren(parent): |
|
1278 |
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
|
1279 |
return "Error: A module with IEC_channel %d already exists\n" % new_iec_channel |
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
|
1280 |
self.PluginRoot.UpdateProjectVariableLocation(".".join(map(str, old_iec_location)), ".".join(map(str, old_iec_location[:1] + (new_iec_channel,)))) |
442 | 1281 |
module["IEC_Channel"] = new_iec_channel |
1282 |
self.RestartTimer() |
|
553 | 1283 |
|
1284 |
def ChangeModuleInitCode(self, iec_location, icode): |
|
1285 |
module = self.PluginRoot.GetChildByIECLocation(iec_location) |
|
1286 |
if module is None: |
|
1287 |
return "Error: No module found\n" |
|
1288 |
module["init"] = icode |
|
1289 |
||
442 | 1290 |
def RemoveModule(self, parent, iec_channel): |
1291 |
module = self.PluginRoot.GetChildByIECLocation(parent) |
|
1292 |
if module is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1293 |
return "Error: No parent found\n" |
442 | 1294 |
child = _GetModuleBySomething(module, "IEC_Channel", (iec_channel,)) |
1295 |
if child is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1296 |
return "Error: No module 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
|
1297 |
self.PluginRoot.RemoveProjectVariableByFilter(".".join(map(str, parent + (iec_channel,)))) |
442 | 1298 |
_RemoveModuleChild(module, child) |
1299 |
self.RestartTimer() |
|
1300 |
||
1301 |
def StartGroup(self, parent, name, icon=None): |
|
1302 |
module = self.PluginRoot.GetChildByIECLocation(parent) |
|
1303 |
if module is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1304 |
return "Error: No parent found\n" |
442 | 1305 |
for child in module["children"]: |
1306 |
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
|
1307 |
return "Error: A group named %s already exists\n" % name |
442 | 1308 |
module["children"].append({"name": name, |
1309 |
"type": LOCATION_GROUP, |
|
1310 |
"icon": icon, |
|
1311 |
"children": []}) |
|
1312 |
self.RestartTimer() |
|
1313 |
||
553 | 1314 |
def AddVariable(self, parent, location, name, direction, type, rcode, pcode, description=""): |
442 | 1315 |
module = self.PluginRoot.GetChildByIECLocation(parent) |
1316 |
if module is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1317 |
return "Error: No parent found\n" |
442 | 1318 |
for child in _GetModuleChildren(module): |
1319 |
if child["name"] == name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1320 |
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
|
1321 |
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
|
1322 |
return "Error: A variable with location %s already exists\n" % ".".join(map(str, location)) |
442 | 1323 |
_GetLastModuleGroup(module).append({"name": name, |
1324 |
"location": location, |
|
1325 |
"type": LOCATION_TYPES[direction], |
|
1326 |
"IEC_type": type, |
|
1327 |
"description": description, |
|
1328 |
"retrieve": rcode, |
|
1329 |
"publish": pcode}) |
|
1330 |
self.RestartTimer() |
|
1331 |
||
553 | 1332 |
def ChangeVariableParams(self, parent, location, new_name, new_direction, new_type, new_rcode, new_pcode, new_description=None): |
442 | 1333 |
module = self.PluginRoot.GetChildByIECLocation(parent) |
1334 |
if module is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1335 |
return "Error: No parent found\n" |
442 | 1336 |
variable = None |
1337 |
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
|
1338 |
if child["location"] == location and child["type"] == LOCATION_TYPES[new_direction]: |
442 | 1339 |
variable = child |
1340 |
elif child["name"] == new_name: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1341 |
return "Error: A variable named %s already exists\n" % new_name |
442 | 1342 |
if variable is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1343 |
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
|
1344 |
if variable["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
|
1345 |
self.PluginRoot.UpdateProjectVariableName(variable["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
|
1346 |
variable["name"] = new_name |
442 | 1347 |
variable["type"] = LOCATION_TYPES[new_direction] |
1348 |
variable["IEC_type"] = new_type |
|
1349 |
variable["retrieve"] = new_rcode |
|
1350 |
variable["publish"] = new_pcode |
|
1351 |
if new_description is not None: |
|
1352 |
variable["description"] = new_description |
|
1353 |
self.RestartTimer() |
|
1354 |
||
472
80eb3bde98e3
Adding support for defining input and output with the same location in LPCBeremiz
laurent
parents:
445
diff
changeset
|
1355 |
def RemoveVariable(self, parent, location, direction): |
442 | 1356 |
module = self.PluginRoot.GetChildByIECLocation(parent) |
1357 |
if module is None: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1358 |
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
|
1359 |
child = _GetModuleVariable(module, location, direction) |
442 | 1360 |
if child is None: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1361 |
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
|
1362 |
size = LOCATION_SIZES[self.PluginRoot.GetBaseType(child["IEC_type"])] |
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
|
1363 |
address = "%" + LOCATION_DIRS[child["type"]] + size + ".".join(map(str, parent + location)) |
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
|
1364 |
self.PluginRoot.RemoveProjectVariableByAddress(address) |
442 | 1365 |
_RemoveModuleChild(module, child) |
1366 |
self.RestartTimer() |
|
1367 |
||
1368 |
def location(loc): |
|
1369 |
return tuple(map(int, loc.split("."))) |
|
1370 |
||
1371 |
def GetCmdFunction(function, arg_types, opt=0): |
|
1372 |
arg_number = len(arg_types) |
|
1373 |
def CmdFunction(self, line): |
|
1374 |
args_toks = line.split('"') |
|
1375 |
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
|
1376 |
self.Log.write("Error: Invalid command\n") |
526 | 1377 |
sys.stdout.flush() |
442 | 1378 |
return |
1379 |
args = [] |
|
1380 |
for num, arg in enumerate(args_toks): |
|
1381 |
if num % 2 == 0: |
|
1382 |
stripped = arg.strip() |
|
1383 |
if stripped: |
|
1384 |
args.extend(stripped.split(" ")) |
|
1385 |
else: |
|
1386 |
args.append(arg) |
|
1387 |
number = None |
|
1388 |
extra = "" |
|
1389 |
if opt == 0 and len(args) != arg_number: |
|
1390 |
number = arg_number |
|
1391 |
elif len(args) > arg_number: |
|
1392 |
number = arg_number |
|
1393 |
extra = " at most" |
|
1394 |
elif len(args) < arg_number - opt: |
|
1395 |
number = arg_number - opt |
|
1396 |
extra = " at least" |
|
1397 |
if number is not None: |
|
1398 |
if number == 0: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1399 |
self.Log.write("Error: No argument%s expected\n" % extra) |
442 | 1400 |
elif number == 1: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1401 |
self.Log.write("Error: 1 argument%s expected\n" % extra) |
442 | 1402 |
else: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1403 |
self.Log.write("Error: %d arguments%s expected\n" % (number, extra)) |
526 | 1404 |
sys.stdout.flush() |
442 | 1405 |
return |
1406 |
for num, arg in enumerate(args): |
|
1407 |
try: |
|
1408 |
args[num] = arg_types[num](arg) |
|
1409 |
except: |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1410 |
self.Log.write("Error: Invalid value for argument %d\n" % (num + 1)) |
526 | 1411 |
sys.stdout.flush() |
442 | 1412 |
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
|
1413 |
|
555 | 1414 |
#cmdlogf.write(str((function,line))+'\n') |
1415 |
#cmdlogf.flush() |
|
1416 |
||
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
|
1417 |
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
|
1418 |
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
|
1419 |
|
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
|
1420 |
# Keep log for debug |
555 | 1421 |
#cmdlogf.write("--->"+str(res)+'\n') |
1422 |
#cmdlogf.flush() |
|
1423 |
||
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 |
cmdlog.append((function,line,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
|
1425 |
if len(cmdlog) > 100: #prevent debug log to grow too much |
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
|
1426 |
cmdlog.pop(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
|
1427 |
|
442 | 1428 |
if isinstance(res, (StringType, UnicodeType)): |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1429 |
self.Log.write(res) |
442 | 1430 |
return False |
1431 |
else: |
|
1432 |
return res |
|
1433 |
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
|
1434 |
|
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
|
1435 |
def CmdThreadProc(PluginRoot, Log): |
549 | 1436 |
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
|
1437 |
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
|
1438 |
"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
|
1439 |
"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
|
1440 |
"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
|
1441 |
"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
|
1442 |
"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
|
1443 |
"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
|
1444 |
"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
|
1445 |
"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
|
1446 |
"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
|
1447 |
"RemoveBus": ([int], 0), |
553 | 1448 |
"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
|
1449 |
"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
|
1450 |
"ChangeModuleIECChannel": ([location, int], 0), |
553 | 1451 |
"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
|
1452 |
"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
|
1453 |
"StartGroup": ([location, str, str], 1), |
553 | 1454 |
"AddVariable": ([location, location, str, str, str, str, str, str], 1), |
1455 |
"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
|
1456 |
"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
|
1457 |
|
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
|
1458 |
setattr(LPCBeremiz_Cmd, "do_%s" % function, GetCmdFunction(function, arg_types, opt)) |
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
|
1459 |
lpcberemiz_cmd = LPCBeremiz_Cmd(PluginRoot, Log) |
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
|
1460 |
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
|
1461 |
|
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1462 |
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
|
1463 |
|
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
|
1464 |
PluginRoot = LPCPluginsRoot(None, Log) |
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
|
1465 |
if projectOpen is not None and os.path.isdir(projectOpen): |
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
|
1466 |
result = PluginRoot.LoadProject(projectOpen, buildpath) |
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
|
1467 |
if result: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1468 |
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
|
1469 |
else: |
551
d18e86b603bc
Adding support for command line communication by socket instead of stdin/stdout
laurent
parents:
550
diff
changeset
|
1470 |
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
|
1471 |
|
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
|
1472 |
cmd_thread=Thread(target=CmdThreadProc, args=[PluginRoot, Log]) |
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
|
1473 |
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
|
1474 |
|
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
|
1475 |
# 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
|
1476 |
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
|
1477 |
|
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
|
1478 |
frame = LPCBeremiz(None, plugin_root=PluginRoot, debug=True) |
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
|
1479 |
|
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
|
1480 |
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
|
1481 |