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