author | Laurent Bessard |
Fri, 07 Sep 2012 18:32:41 +0200 | |
changeset 17 | 7228610e2273 |
parent 16 | 3eaac9927941 |
child 18 | 17e6293e9191 |
permissions | -rwxr-xr-x |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
3 |
import shutil |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
4 |
import socket |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
5 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
6 |
__version__ = "$Revision$" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
7 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
8 |
import os, sys, getopt, wx, tempfile |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
9 |
import __builtin__ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
10 |
from types import TupleType, StringType, UnicodeType |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
11 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
12 |
CWD = os.path.split(os.path.realpath(__file__))[0] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
13 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
14 |
def Bpath(*args): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
15 |
return os.path.join(CWD,*args) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
16 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
17 |
if __name__ == '__main__': |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
18 |
def usage(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
19 |
print "\nUsage of LPCBeremiz.py :" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
20 |
print "\n %s Projectpath Buildpath port\n"%sys.argv[0] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
21 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
22 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
23 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
24 |
except getopt.GetoptError: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
25 |
# print help information and exit: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
26 |
usage() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
27 |
sys.exit(2) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
28 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
29 |
for o, a in opts: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
30 |
if o in ("-h", "--help"): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
31 |
usage() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
32 |
sys.exit() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
33 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
34 |
if len(args) != 3: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
35 |
usage() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
36 |
sys.exit() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
37 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
38 |
projectOpen = args[0] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
39 |
buildpath = args[1] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
40 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
41 |
port = int(args[2]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
42 |
except: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
43 |
usage() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
44 |
sys.exit() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
45 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
46 |
if os.path.exists("LPC_DEBUG"): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
47 |
__builtin__.__dict__["BMZ_DBG"] = True |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
48 |
else : |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
49 |
__builtin__.__dict__["BMZ_DBG"] = False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
50 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
51 |
app = wx.PySimpleApp(redirect=BMZ_DBG) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
52 |
app.SetAppName('beremiz') |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
53 |
wx.InitAllImageHandlers() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
54 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
55 |
# Import module for internationalization |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
56 |
import gettext |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
57 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
58 |
if __name__ == '__main__': |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
59 |
__builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
60 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
61 |
_base_path = os.path.split(__file__)[0] |
3
169d552a345c
Purge libraries to be loaded by beremiz by default
Edouard Tisserant
parents:
2
diff
changeset
|
62 |
import features |
7 | 63 |
from POULibrary import POULibrary |
64 |
||
65 |
class PLCLibrary(POULibrary): |
|
66 |
def GetLibraryPath(self): |
|
67 |
return os.path.join(_base_path, "pous.xml") |
|
68 |
||
69 |
features.libraries=[('LPC', lambda: PLCLibrary)] |
|
70 |
||
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
71 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
72 |
import connectors |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
73 |
from LPCconnector import LPC_connector_factory |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
74 |
connectors.connectors["LPC"]=lambda:LPC_connector_factory |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
75 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
76 |
import targets |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
77 |
from LPCtarget import LPC_target |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
78 |
targets.targets["LPC"] = {"xsd": os.path.join(_base_path, "LPCtarget", "XSD"), |
4
e8a0af6b89d9
Adding support for LPC pous library using new Beremiz extension paradigm
Laurent Bessard
parents:
2
diff
changeset
|
79 |
"class": lambda: LPC_target, |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
80 |
"code": os.path.join(_base_path,"LPCtarget","plc_LPC_main.c")} |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
81 |
targets.toolchains["makefile"] = os.path.join(_base_path, "LPCtarget", "XSD_toolchain_makefile") |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
82 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
83 |
from Beremiz import * |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
84 |
from ProjectController import ProjectController |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
85 |
from ConfigTreeNode import ConfigTreeNode |
17
7228610e2273
Fix import after integration of plcopeneditor into Beremiz
Laurent Bessard
parents:
16
diff
changeset
|
86 |
from editors.ProjectNodeEditor import ProjectNodeEditor |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
87 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
88 |
from plcopen.structures import LOCATIONDATATYPES |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
89 |
from PLCControler import PLCControler, LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP,\ |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
90 |
LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
17
7228610e2273
Fix import after integration of plcopeneditor into Beremiz
Laurent Bessard
parents:
16
diff
changeset
|
91 |
from IDEFrame import IDEFrame |
7228610e2273
Fix import after integration of plcopeneditor into Beremiz
Laurent Bessard
parents:
16
diff
changeset
|
92 |
from dialogs import ProjectDialog |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
93 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
94 |
havecanfestival = False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
95 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
96 |
from canfestival import RootClass as CanOpenRootClass |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
97 |
from canfestival.canfestival import _SlaveCTN, _NodeListCTN, NodeManager |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
98 |
from canfestival.NetworkEditor import NetworkEditor |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
99 |
from canfestival.SlaveEditor import SlaveEditor |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
100 |
havecanfestival = True |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
101 |
except: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
102 |
havecanfestival = False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
103 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
104 |
SCROLLBAR_UNIT = 10 |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
105 |
WINDOW_COLOUR = wx.Colour(240,240,240) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
106 |
TITLE_COLOUR = wx.Colour(200,200,220) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
107 |
CHANGED_TITLE_COLOUR = wx.Colour(220,200,220) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
108 |
CHANGED_WINDOW_COLOUR = wx.Colour(255,240,240) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
109 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
110 |
if wx.Platform == '__WXMSW__': |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
111 |
faces = { 'times': 'Times New Roman', |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
112 |
'mono' : 'Courier New', |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
113 |
'helv' : 'Arial', |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
114 |
'other': 'Comic Sans MS', |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
115 |
'size' : 16, |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
116 |
} |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
117 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
118 |
faces = { 'times': 'Times', |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
119 |
'mono' : 'Courier', |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
120 |
'helv' : 'Helvetica', |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
121 |
'other': 'new century schoolbook', |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
122 |
'size' : 18, |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
123 |
} |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
124 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
125 |
# Some helpers to tweak GenBitmapTextButtons |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
126 |
# TODO: declare customized classes instead. |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
127 |
gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
128 |
gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
129 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
130 |
def make_genbitmaptogglebutton_flat(button): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
131 |
button.GetBackgroundBrush = gen_mini_GetBackgroundBrush(button) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
132 |
button.labelDelta = 0 |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
133 |
button.SetBezelWidth(0) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
134 |
button.SetUseFocusIndicator(False) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
135 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
136 |
# Patch wx.lib.imageutils so that gray is supported on alpha images |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
137 |
import wx.lib.imageutils |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
138 |
from wx.lib.imageutils import grayOut as old_grayOut |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
139 |
def grayOut(anImage): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
140 |
if anImage.HasAlpha(): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
141 |
AlphaData = anImage.GetAlphaData() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
142 |
else : |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
143 |
AlphaData = None |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
144 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
145 |
old_grayOut(anImage) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
146 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
147 |
if AlphaData is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
148 |
anImage.SetAlphaData(AlphaData) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
149 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
150 |
wx.lib.imageutils.grayOut = grayOut |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
151 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
152 |
class GenBitmapTextButton(wx.lib.buttons.GenBitmapTextButton): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
153 |
def _GetLabelSize(self): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
154 |
""" used internally """ |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
155 |
w, h = self.GetTextExtent(self.GetLabel()) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
156 |
if not self.bmpLabel: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
157 |
return w, h, False # if there isn't a bitmap use the size of the text |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
158 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
159 |
w_bmp = self.bmpLabel.GetWidth()+2 |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
160 |
h_bmp = self.bmpLabel.GetHeight()+2 |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
161 |
height = h + h_bmp |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
162 |
if w_bmp > w: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
163 |
width = w_bmp |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
164 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
165 |
width = w |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
166 |
return width, height, False |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
167 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
168 |
def DrawLabel(self, dc, width, height, dw=0, dy=0): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
169 |
bmp = self.bmpLabel |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
170 |
if bmp != None: # if the bitmap is used |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
171 |
if self.bmpDisabled and not self.IsEnabled(): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
172 |
bmp = self.bmpDisabled |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
173 |
if self.bmpFocus and self.hasFocus: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
174 |
bmp = self.bmpFocus |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
175 |
if self.bmpSelected and not self.up: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
176 |
bmp = self.bmpSelected |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
177 |
bw,bh = bmp.GetWidth(), bmp.GetHeight() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
178 |
if not self.up: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
179 |
dw = dy = self.labelDelta |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
180 |
hasMask = bmp.GetMask() != None |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
181 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
182 |
bw = bh = 0 # no bitmap -> size is zero |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
183 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
184 |
dc.SetFont(self.GetFont()) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
185 |
if self.IsEnabled(): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
186 |
dc.SetTextForeground(self.GetForegroundColour()) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
187 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
188 |
dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
189 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
190 |
label = self.GetLabel() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
191 |
tw, th = dc.GetTextExtent(label) # size of text |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
192 |
if not self.up: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
193 |
dw = dy = self.labelDelta |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
194 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
195 |
pos_x = (width-bw)/2+dw # adjust for bitmap and text to centre |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
196 |
pos_y = (height-bh-th)/2+dy |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
197 |
if bmp !=None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
198 |
dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
199 |
pos_x = (width-tw)/2+dw # adjust for bitmap and text to centre |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
200 |
pos_y += bh + 2 |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
201 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
202 |
dc.DrawText(label, pos_x, pos_y) # draw the text |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
203 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
204 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
205 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
206 |
# CANFESTIVAL CONFNODE HACK |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
207 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
208 |
# from canfestival import canfestival |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
209 |
# class LPC_canfestival_config: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
210 |
# def getCFLAGS(self, *args): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
211 |
# return "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
212 |
# |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
213 |
# def getLDFLAGS(self, *args): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
214 |
# return "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
215 |
# |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
216 |
# canfestival.local_canfestival_config = LPC_canfestival_config() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
217 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
218 |
# LPCModule Class |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
219 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
220 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
221 |
LOCATION_TYPES = {"I": LOCATION_VAR_INPUT, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
222 |
"Q": LOCATION_VAR_OUTPUT, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
223 |
"M": LOCATION_VAR_MEMORY} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
224 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
225 |
LOCATION_DIRS = dict([(dir, size) for size, dir in LOCATION_TYPES.iteritems()]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
226 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
227 |
LOCATION_SIZES = {} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
228 |
for size, types in LOCATIONDATATYPES.iteritems(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
229 |
for type in types: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
230 |
LOCATION_SIZES[type] = size |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
231 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
232 |
def _GetModuleChildren(module): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
233 |
children = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
234 |
for child in module["children"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
235 |
if child["type"] == LOCATION_GROUP: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
236 |
children.extend(child["children"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
237 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
238 |
children.append(child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
239 |
return children |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
240 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
241 |
def _GetVariables(module): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
242 |
variables = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
243 |
for child in module["children"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
244 |
if child["type"] in [LOCATION_GROUP, LOCATION_MODULE]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
245 |
variables.extend(_GetVariables(child)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
246 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
247 |
variables.append(child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
248 |
return variables |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
249 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
250 |
def _GetLastModuleGroup(module): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
251 |
group = module |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
252 |
for child in module["children"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
253 |
if child["type"] == LOCATION_GROUP: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
254 |
group = child |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
255 |
return group["children"] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
256 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
257 |
def _GetModuleBySomething(module, something, toks): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
258 |
for child in _GetModuleChildren(module): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
259 |
if child.get(something) == toks[0]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
260 |
if len(toks) > 1: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
261 |
return _GetModuleBySomething(child, something, toks[1:]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
262 |
return child |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
263 |
return None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
264 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
265 |
def _GetModuleVariable(module, location, direction): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
266 |
for child in _GetModuleChildren(module): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
267 |
if child["location"] == location and child["type"] == LOCATION_TYPES[direction]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
268 |
return child |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
269 |
return None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
270 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
271 |
def _RemoveModuleChild(module, child): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
272 |
if child in module["children"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
273 |
module["children"].remove(child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
274 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
275 |
for group in module["children"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
276 |
if group["type"] == LOCATION_GROUP and child in group["children"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
277 |
group["children"].remove(child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
278 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
279 |
BUS_TEXT = """/* Code generated by LPCBus confnode */ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
280 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
281 |
/* LPCBus confnode includes */ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
282 |
#include "app_glue.h" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
283 |
#ifdef _WINDOWS_H |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
284 |
#include "iec_types.h" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
285 |
#else |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
286 |
#include "iec_std_lib.h" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
287 |
#endif |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
288 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
289 |
%(declare_code)s |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
290 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
291 |
/* LPCBus confnode user variables definition */ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
292 |
%(var_decl)s |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
293 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
294 |
/* LPCBus confnode functions */ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
295 |
int __init_%(location_str)s(int argc,char **argv) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
296 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
297 |
%(init_code)s |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
298 |
return 0; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
299 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
300 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
301 |
void __cleanup_%(location_str)s(void) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
302 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
303 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
304 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
305 |
void __retrieve_%(location_str)s(void) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
306 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
307 |
%(retrieve_code)s |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
308 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
309 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
310 |
void __publish_%(location_str)s(void) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
311 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
312 |
%(publish_code)s |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
313 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
314 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
315 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
316 |
class LPCBus(object): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
317 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
318 |
def __init__(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
319 |
self.VariableLocationTree = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
320 |
self.ResetUsedLocations() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
321 |
self.Icon = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
322 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
323 |
def __getitem__(self, key): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
324 |
if key == "children": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
325 |
return self.VariableLocationTree |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
326 |
raise KeyError, "Only 'children' key is available" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
327 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
328 |
def CTNEnabled(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
329 |
return None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
330 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
331 |
def SetIcon(self, icon): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
332 |
self.Icon = icon |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
333 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
334 |
def _GetChildBySomething(self, something, toks): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
335 |
return _GetModuleBySomething({"children" : self.VariableLocationTree}, something, toks) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
336 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
337 |
def GetBaseTypes(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
338 |
return self.GetCTRoot().GetBaseTypes() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
339 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
340 |
def GetSizeOfType(self, type): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
341 |
return LOCATION_SIZES[self.GetCTRoot().GetBaseType(type)] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
342 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
343 |
def _GetVariableLocationTree(self, current_location, infos): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
344 |
if infos["type"] == LOCATION_MODULE: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
345 |
location = current_location + (infos["IEC_Channel"],) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
346 |
return {"name": infos["name"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
347 |
"type": infos["type"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
348 |
"location": ".".join(map(str, location + ("x",))), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
349 |
"icon": infos["icon"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
350 |
"children": [self._GetVariableLocationTree(location, child) for child in infos["children"]]} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
351 |
elif infos["type"] == LOCATION_GROUP: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
352 |
return {"name": infos["name"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
353 |
"type": infos["type"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
354 |
"location": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
355 |
"icon": infos["icon"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
356 |
"children": [self._GetVariableLocationTree(current_location, child) for child in infos["children"]]} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
357 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
358 |
size = self.GetSizeOfType(infos["IEC_type"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
359 |
location = "%" + LOCATION_DIRS[infos["type"]] + size + ".".join(map(str, current_location + infos["location"])) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
360 |
return {"name": infos["name"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
361 |
"type": infos["type"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
362 |
"size": size, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
363 |
"IEC_type": infos["IEC_type"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
364 |
"var_name": infos["name"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
365 |
"location": location, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
366 |
"description": infos["description"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
367 |
"children": []} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
368 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
369 |
def GetVariableLocationTree(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
370 |
return {"name": self.BaseParams.getName(), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
371 |
"type": LOCATION_CONFNODE, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
372 |
"location": self.GetFullIEC_Channel(), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
373 |
"icon": self.Icon, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
374 |
"children": [self._GetVariableLocationTree(self.GetCurrentLocation(), child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
375 |
for child in self.VariableLocationTree]} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
376 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
377 |
def CTNTestModified(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
378 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
379 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
380 |
def CTNMakeDir(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
381 |
pass |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
382 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
383 |
def CTNRequestSave(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
384 |
return None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
385 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
386 |
def ResetUsedLocations(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
387 |
self.UsedLocations = {} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
388 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
389 |
def _AddUsedLocation(self, parent, location): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
390 |
num = location.pop(0) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
391 |
if not parent.has_key(num): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
392 |
parent[num] = {"used": False, "children": {}} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
393 |
if len(location) > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
394 |
self._AddUsedLocation(parent[num]["children"], location) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
395 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
396 |
parent[num]["used"] = True |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
397 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
398 |
def AddUsedLocation(self, location): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
399 |
if len(location) > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
400 |
self._AddUsedLocation(self.UsedLocations, list(location)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
401 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
402 |
def _CheckLocationConflicts(self, parent, location): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
403 |
num = location.pop(0) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
404 |
if not parent.has_key(num): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
405 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
406 |
if len(location) > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
407 |
if parent[num]["used"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
408 |
return True |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
409 |
return self._CheckLocationConflicts(parent[num]["children"], location) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
410 |
elif len(parent[num]["children"]) > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
411 |
return True |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
412 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
413 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
414 |
def CheckLocationConflicts(self, location): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
415 |
if len(location) > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
416 |
return self._CheckLocationConflicts(self.UsedLocations, list(location)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
417 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
418 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
419 |
def CTNGenerate_C(self, buildpath, locations): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
420 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
421 |
Generate C code |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
422 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
423 |
@param locations: List of complete variables locations \ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
424 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
425 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
426 |
"DIR" : direction "Q","I" or "M" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
427 |
"SIZE" : size "X", "B", "W", "D", "L" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
428 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
429 |
}, ...] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
430 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
431 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
432 |
current_location = self.GetCurrentLocation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
433 |
# define a unique name for the generated C file |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
434 |
location_str = "_".join(map(str, current_location)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
435 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
436 |
code_str = {"location_str": location_str, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
437 |
"var_decl": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
438 |
"declare_code": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
439 |
"init_code": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
440 |
"retrieve_code": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
441 |
"publish_code": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
442 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
443 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
444 |
for module in _GetModuleChildren(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
445 |
if module["init"] != "": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
446 |
code_str["init_code"] += " %s\n" % module["init"] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
447 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
448 |
# Adding variables |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
449 |
vars = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
450 |
self.ResetUsedLocations() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
451 |
for location in locations: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
452 |
loc = location["LOC"][len(current_location):] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
453 |
group = next = self |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
454 |
i = 0 |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
455 |
while next is not None and i < len(loc): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
456 |
next = self._GetChildBySomething("IEC_Channel", loc[:i + 1]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
457 |
if next is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
458 |
i += 1 |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
459 |
group = next |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
460 |
var_loc = loc[i:] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
461 |
for variable in _GetModuleChildren(group): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
462 |
if variable["location"] == var_loc and location["DIR"] == LOCATION_DIRS[variable["type"]]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
463 |
# if location["DIR"] != LOCATION_DIRS[variable["type"]]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
464 |
# raise Exception, "Direction conflict in variable definition" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
465 |
# if location["IEC_TYPE"] != variable["IEC_type"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
466 |
# raise Exception, "Type conflict in variable definition" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
467 |
if location["DIR"] == "Q": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
468 |
if self.CheckLocationConflicts(location["LOC"]): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
469 |
raise Exception, "BYTE and BIT from the same BYTE can't be used together" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
470 |
self.AddUsedLocation(location["LOC"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
471 |
vars.append({"location": location["NAME"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
472 |
"Type": variable["IEC_type"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
473 |
"Retrieve": variable["retrieve"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
474 |
"Publish": variable["publish"], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
475 |
}) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
476 |
break |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
477 |
base_types = self.GetCTRoot().GetBaseTypes() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
478 |
for var in vars: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
479 |
prefix = "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
480 |
if var["Type"] in base_types: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
481 |
prefix = "IEC_" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
482 |
code_str["var_decl"] += "%s%s beremiz%s;\n"%(prefix, var["Type"], var["location"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
483 |
code_str["var_decl"] += "%s%s *%s = &beremiz%s;\n"%(prefix, var["Type"], var["location"], var["location"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
484 |
if var["Retrieve"] != "": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
485 |
code_str["retrieve_code"] += " " + var["Retrieve"] % ("*" + var["location"]) + "\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
486 |
if var["Publish"] != "": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
487 |
code_str["publish_code"] += " " + var["Publish"] % ("*" + var["location"]) + "\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
488 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
489 |
Gen_Module_path = os.path.join(buildpath, "Bus_%s.c"%location_str) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
490 |
module = open(Gen_Module_path,'w') |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
491 |
module.write(BUS_TEXT % code_str) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
492 |
module.close() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
493 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
494 |
matiec_flags = '"-I%s"'%os.path.abspath(self.GetCTRoot().GetIECLibPath()) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
495 |
return [(Gen_Module_path, matiec_flags)],"",True |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
496 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
497 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
498 |
# LPC CanFestival ConfNode Class |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
499 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
500 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
501 |
if havecanfestival: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
502 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
503 |
DEFAULT_SETTINGS = { |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
504 |
"CAN_Baudrate": "125K", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
505 |
"Slave_NodeId": 2, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
506 |
"Master_NodeId": 1, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
507 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
508 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
509 |
class LPCSlaveEditor(SlaveEditor): |
11
6aca5bc9c9a1
Fix bug showing canfestival base node params that can't be changed
Laurent Bessard
parents:
9
diff
changeset
|
510 |
SHOW_BASE_PARAMS = False |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
511 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
512 |
class LPCCanOpenSlave(_SlaveCTN): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
513 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
514 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
515 |
<xsd:element name="CanFestivalSlaveNode"> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
516 |
<xsd:complexType> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
517 |
<xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
518 |
<xsd:attribute name="NodeId" type="xsd:string" use="optional" default="%(Slave_NodeId)d"/> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
519 |
<xsd:attribute name="Sync_Align" type="xsd:integer" use="optional" default="0"/> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
520 |
<xsd:attribute name="Sync_Align_Ratio" use="optional" default="50"> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
521 |
<xsd:simpleType> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
522 |
<xsd:restriction base="xsd:integer"> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
523 |
<xsd:minInclusive value="1"/> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
524 |
<xsd:maxInclusive value="99"/> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
525 |
</xsd:restriction> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
526 |
</xsd:simpleType> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
527 |
</xsd:attribute> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
528 |
</xsd:complexType> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
529 |
</xsd:element> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
530 |
</xsd:schema> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
531 |
""" % DEFAULT_SETTINGS |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
532 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
533 |
EditorType = LPCSlaveEditor |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
534 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
535 |
def __init__(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
536 |
# TODO change netname when name change |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
537 |
NodeManager.__init__(self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
538 |
odfilepath = self.GetSlaveODPath() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
539 |
if(os.path.isfile(odfilepath)): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
540 |
self.OpenFileInCurrent(odfilepath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
541 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
542 |
self.CreateNewNode("SlaveNode", # Name - will be changed at build time |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
543 |
0x00, # NodeID - will be changed at build time |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
544 |
"slave", # Type |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
545 |
"", # description |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
546 |
"None", # profile |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
547 |
"", # prfile filepath |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
548 |
"heartbeat", # NMT |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
549 |
[]) # options |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
550 |
self.OnCTNSave() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
551 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
552 |
def GetCanDevice(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
553 |
return str(self.BaseParams.getIEC_Channel()) |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
554 |
|
14
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
555 |
ConfNodeMethods = [ |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
556 |
{"bitmap" : "NetworkEdit", |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
557 |
"name" : _("Edit slave"), |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
558 |
"tooltip" : _("Edit CanOpen slave with ObjdictEdit"), |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
559 |
"method" : "_OpenView"}, |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
560 |
] + _SlaveCTN.ConfNodeMethods |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
561 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
562 |
class LPCNetworkEditor(NetworkEditor): |
11
6aca5bc9c9a1
Fix bug showing canfestival base node params that can't be changed
Laurent Bessard
parents:
9
diff
changeset
|
563 |
SHOW_BASE_PARAMS = False |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
564 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
565 |
class LPCCanOpenMaster(_NodeListCTN): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
566 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
567 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
568 |
<xsd:element name="CanFestivalNode"> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
569 |
<xsd:complexType> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
570 |
<xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
571 |
<xsd:attribute name="NodeId" type="xsd:string" use="optional" default="%(Master_NodeId)d"/> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
572 |
<xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
573 |
</xsd:complexType> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
574 |
</xsd:element> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
575 |
</xsd:schema> |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
576 |
""" % DEFAULT_SETTINGS |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
577 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
578 |
EditorType = LPCNetworkEditor |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
579 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
580 |
def GetCanDevice(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
581 |
return str(self.BaseParams.getIEC_Channel()) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
582 |
|
14
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
583 |
ConfNodeMethods = [ |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
584 |
{"bitmap" : "NetworkEdit", |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
585 |
"name" : _("Edit network"), |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
586 |
"tooltip" : _("Edit CanOpen Network with NetworkEdit"), |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
587 |
"method" : "_OpenView"}, |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
588 |
] + _NodeListCTN.ConfNodeMethods |
37734da73adc
Adding canfestival specific buttons for opening slave and network editors
Laurent Bessard
parents:
13
diff
changeset
|
589 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
590 |
class LPCCanOpen(CanOpenRootClass): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
591 |
XSD = None |
11
6aca5bc9c9a1
Fix bug showing canfestival base node params that can't be changed
Laurent Bessard
parents:
9
diff
changeset
|
592 |
CTNChildrenTypes = [("CanOpenNode", LPCCanOpenMaster, "CanOpen Master"), |
6aca5bc9c9a1
Fix bug showing canfestival base node params that can't be changed
Laurent Bessard
parents:
9
diff
changeset
|
593 |
("CanOpenSlave", LPCCanOpenSlave, "CanOpen Slave")] |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
594 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
595 |
def GetCanDriver(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
596 |
return "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
597 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
598 |
def LoadChildren(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
599 |
ConfigTreeNode.LoadChildren(self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
600 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
601 |
if self.GetChildByName("Master") is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
602 |
master = self.CTNAddChild("Master", "CanOpenNode", 0) |
4
e8a0af6b89d9
Adding support for LPC pous library using new Beremiz extension paradigm
Laurent Bessard
parents:
2
diff
changeset
|
603 |
#master.BaseParams.setEnabled(False) |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
604 |
master.CTNRequestSave() |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
605 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
606 |
if self.GetChildByName("Slave") is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
607 |
slave = self.CTNAddChild("Slave", "CanOpenSlave", 1) |
4
e8a0af6b89d9
Adding support for LPC pous library using new Beremiz extension paradigm
Laurent Bessard
parents:
2
diff
changeset
|
608 |
#slave.BaseParams.setEnabled(False) |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
609 |
slave.CTNRequestSave() |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
610 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
611 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
612 |
# LPCProjectController Class |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
613 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
614 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
615 |
def mycopytree(src, dst): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
616 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
617 |
Copy content of a directory to an other, omit hidden files |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
618 |
@param src: source directory |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
619 |
@param dst: destination directory |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
620 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
621 |
for i in os.listdir(src): |
4
e8a0af6b89d9
Adding support for LPC pous library using new Beremiz extension paradigm
Laurent Bessard
parents:
2
diff
changeset
|
622 |
if not i.startswith('.'): |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
623 |
srcpath = os.path.join(src,i) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
624 |
dstpath = os.path.join(dst,i) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
625 |
if os.path.isdir(srcpath): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
626 |
if os.path.exists(dstpath): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
627 |
shutil.rmtree(dstpath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
628 |
os.makedirs(dstpath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
629 |
mycopytree(srcpath, dstpath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
630 |
elif os.path.isfile(srcpath): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
631 |
shutil.copy2(srcpath, dstpath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
632 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
633 |
[SIMULATION_MODE, TRANSFER_MODE] = range(2) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
634 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
635 |
class LPCProjectNodeEditor(ProjectNodeEditor): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
636 |
SHOW_PARAMS = False |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
637 |
ENABLE_REQUIRED = False |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
638 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
639 |
class LPCProjectController(ProjectController): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
640 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
641 |
StatusMethods = [ |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
642 |
{"bitmap" : "Debug", |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
643 |
"name" : _("Simulate"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
644 |
"tooltip" : _("Simulate PLC"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
645 |
"method" : "_Simulate"}, |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
646 |
{"bitmap" : "Run", |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
647 |
"name" : _("Run"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
648 |
"shown" : False, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
649 |
"tooltip" : _("Start PLC"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
650 |
"method" : "_Run"}, |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
651 |
{"bitmap" : "Stop", |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
652 |
"name" : _("Stop"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
653 |
"shown" : False, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
654 |
"tooltip" : _("Stop Running PLC"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
655 |
"method" : "_Stop"}, |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
656 |
{"bitmap" : "Build", |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
657 |
"name" : _("Build"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
658 |
"tooltip" : _("Build project into build folder"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
659 |
"method" : "_Build"}, |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
660 |
{"bitmap" : "Transfer", |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
661 |
"name" : _("Transfer"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
662 |
"shown" : False, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
663 |
"tooltip" : _("Transfer PLC"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
664 |
"method" : "_Transfer"}, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
665 |
] |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
666 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
667 |
ConfNodeMethods = [] |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
668 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
669 |
EditorType = LPCProjectNodeEditor |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
670 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
671 |
def __init__(self, frame, logger, buildpath): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
672 |
self.OrigBuildPath = buildpath |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
673 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
674 |
ProjectController.__init__(self, frame, logger) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
675 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
676 |
if havecanfestival: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
677 |
self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus"), ("CanOpen", LPCCanOpen, "CanOpen bus")] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
678 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
679 |
self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus")] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
680 |
self.CTNType = "LPC" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
681 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
682 |
self.OnlineMode = "OFF" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
683 |
self.LPCConnector = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
684 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
685 |
self.CurrentMode = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
686 |
self.previous_mode = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
687 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
688 |
self.SimulationBuildPath = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
689 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
690 |
self.AbortTransferTimer = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
691 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
692 |
def GetProjectInfos(self): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
693 |
infos = PLCControler.GetProjectInfos(self) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
694 |
configurations = infos["values"].pop(-1) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
695 |
resources = None |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
696 |
for config_infos in configurations["values"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
697 |
if resources is None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
698 |
resources = config_infos["values"][0] |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
699 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
700 |
resources["values"].extend(config_infos["values"][0]["values"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
701 |
if resources is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
702 |
infos["values"].append(resources) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
703 |
return infos |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
704 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
705 |
def GetProjectName(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
706 |
return self.Project.getname() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
707 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
708 |
def GetDefaultTargetName(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
709 |
if self.CurrentMode == SIMULATION_MODE: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
710 |
return ProjectController.GetDefaultTargetName(self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
711 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
712 |
return "LPC" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
713 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
714 |
def GetTarget(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
715 |
target = ProjectController.GetTarget(self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
716 |
if self.CurrentMode != SIMULATION_MODE: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
717 |
target.getcontent()["value"].setBuildPath(self.BuildPath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
718 |
return target |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
719 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
720 |
def _getBuildPath(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
721 |
if self.CurrentMode == SIMULATION_MODE: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
722 |
if self.SimulationBuildPath is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
723 |
self.SimulationBuildPath = os.path.join(tempfile.mkdtemp(), os.path.basename(self.ProjectPath), "build") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
724 |
return self.SimulationBuildPath |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
725 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
726 |
return ProjectController._getBuildPath(self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
727 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
728 |
def _Build(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
729 |
save = self.ProjectTestModified() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
730 |
if save: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
731 |
self.SaveProject() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
732 |
self.AppFrame._Refresh(TITLE, FILEMENU) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
733 |
if self.BuildPath is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
734 |
mycopytree(self.OrigBuildPath, self.BuildPath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
735 |
ProjectController._Build(self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
736 |
if save: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
737 |
wx.CallAfter(self.AppFrame.RefreshAll) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
738 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
739 |
def SetProjectName(self, name): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
740 |
return self.Project.setname(name) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
741 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
742 |
def SetOnlineMode(self, mode, path=None): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
743 |
if self.OnlineMode != mode.upper(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
744 |
self.OnlineMode = mode.upper() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
745 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
746 |
if self.OnlineMode != "OFF": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
747 |
uri = "LPC://%s/%s" % (self.OnlineMode,path) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
748 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
749 |
self.LPCConnector = connectors.ConnectorFactory(uri, self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
750 |
except Exception, msg: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
751 |
self.logger.write_error(_("Exception while connecting %s!\n")%uri) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
752 |
self.logger.write_error(traceback.format_exc()) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
753 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
754 |
# Did connection success ? |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
755 |
if self.LPCConnector is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
756 |
# Oups. |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
757 |
self.logger.write_error(_("Connection failed to %s!\n")%uri) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
758 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
759 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
760 |
self.LPCConnector = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
761 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
762 |
self.ApplyOnlineMode() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
763 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
764 |
def ApplyOnlineMode(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
765 |
if self.CurrentMode != SIMULATION_MODE: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
766 |
self.KillDebugThread() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
767 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
768 |
self._connector = self.LPCConnector |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
769 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
770 |
# Init with actual PLC status and print it |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
771 |
self.UpdateMethodsFromPLCStatus() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
772 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
773 |
if self.LPCConnector is not None and self.OnlineMode == "APPLICATION": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
774 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
775 |
self.CompareLocalAndRemotePLC() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
776 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
777 |
if self.previous_plcstate is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
778 |
status = _(self.previous_plcstate) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
779 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
780 |
status = "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
781 |
self.logger.write(_("PLC is %s\n")%status) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
782 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
783 |
#if self.StatusTimer and not self.StatusTimer.IsRunning(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
784 |
# # Start the status Timer |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
785 |
# self.StatusTimer.Start(milliseconds=2000, oneShot=False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
786 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
787 |
if self.previous_plcstate=="Started": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
788 |
if self.DebugAvailable() and self.GetIECProgramsAndVariables(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
789 |
self.logger.write(_("Debug connect matching running PLC\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
790 |
self._connect_debug() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
791 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
792 |
self.logger.write_warning(_("Debug do not match PLC - stop/transfert/start to re-enable\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
793 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
794 |
elif self.StatusTimer and self.StatusTimer.IsRunning(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
795 |
self.StatusTimer.Stop() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
796 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
797 |
if self.CurrentMode == TRANSFER_MODE: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
798 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
799 |
if self.OnlineMode == "BOOTLOADER": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
800 |
self.BeginTransfer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
801 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
802 |
elif self.OnlineMode == "APPLICATION": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
803 |
self.CurrentMode = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
804 |
self.AbortTransferTimer.Stop() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
805 |
self.AbortTransferTimer = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
806 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
807 |
self.logger.write(_("PLC transferred successfully\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
808 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
809 |
# Update a PLCOpenEditor Pou variable name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
810 |
def UpdateProjectVariableName(self, old_name, new_name): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
811 |
self.Project.updateElementName(old_name, new_name) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
812 |
self.BufferProject() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
813 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
814 |
def RemoveProjectVariableByAddress(self, address): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
815 |
self.Project.removeVariableByAddress(address) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
816 |
self.BufferProject() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
817 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
818 |
def RemoveProjectVariableByFilter(self, leading): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
819 |
self.Project.removeVariableByFilter(leading) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
820 |
self.BufferProject() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
821 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
822 |
def LoadProject(self, ProjectPath, BuildPath=None): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
823 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
824 |
Load a project contained in a folder |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
825 |
@param ProjectPath: path of the project folder |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
826 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
827 |
if os.path.basename(ProjectPath) == "": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
828 |
ProjectPath = os.path.dirname(ProjectPath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
829 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
830 |
# Verify that project contains a PLCOpen program |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
831 |
plc_file = os.path.join(ProjectPath, "plc.xml") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
832 |
if os.path.isfile(plc_file): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
833 |
# Load PLCOpen file |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
834 |
result = self.OpenXMLFile(plc_file) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
835 |
if result: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
836 |
return result |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
837 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
838 |
self.CreateNewProject({"companyName": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
839 |
"productName": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
840 |
"productVersion": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
841 |
"projectName": "", |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
842 |
"pageSize": (0, 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
843 |
"scaling": {}}) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
844 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
845 |
# Change XSD into class members |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
846 |
self._AddParamsMembers() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
847 |
self.Children = {} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
848 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
849 |
# Keep track of the root confnode (i.e. project path) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
850 |
self.ProjectPath = ProjectPath |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
851 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
852 |
self.BuildPath = self._getBuildPath() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
853 |
if self.OrigBuildPath is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
854 |
mycopytree(self.OrigBuildPath, self.BuildPath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
855 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
856 |
# If dir have already be made, and file exist |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
857 |
if os.path.isdir(self.CTNPath()) and os.path.isfile(self.ConfNodeXmlFilePath()): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
858 |
#Load the confnode.xml file into parameters members |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
859 |
result = self.LoadXMLParams() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
860 |
if result: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
861 |
return result |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
862 |
#Load and init all the children |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
863 |
self.LoadChildren() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
864 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
865 |
if havecanfestival and self.GetChildByName("CanOpen") is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
866 |
canopen = self.CTNAddChild("CanOpen", "CanOpen", 0) |
4
e8a0af6b89d9
Adding support for LPC pous library using new Beremiz extension paradigm
Laurent Bessard
parents:
2
diff
changeset
|
867 |
#canopen.BaseParams.setEnabled(False) |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
868 |
canopen.LoadChildren() |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
869 |
canopen.CTNRequestSave() |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
870 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
871 |
if self.CTNTestModified(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
872 |
self.SaveProject() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
873 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
874 |
if wx.GetApp() is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
875 |
self.RefreshConfNodesBlockLists() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
876 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
877 |
wx.CallAfter(self.RefreshConfNodesBlockLists) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
878 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
879 |
return None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
880 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
881 |
############# Real PLC object access ############# |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
882 |
def UpdateMethodsFromPLCStatus(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
883 |
# Get PLC state : Running or Stopped |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
884 |
# TODO : use explicit status instead of boolean |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
885 |
if self.OnlineMode == "OFF": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
886 |
status = "Disconnected" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
887 |
elif self.OnlineMode == "BOOTLOADER": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
888 |
status = "Connected" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
889 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
890 |
if self._connector is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
891 |
status = self._connector.GetPLCstatus() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
892 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
893 |
status = "Disconnected" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
894 |
if self.previous_plcstate != status or self.previous_mode != self.CurrentMode: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
895 |
simulating = self.CurrentMode == SIMULATION_MODE |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
896 |
for args in { |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
897 |
"Started" : [("_Simulate", False), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
898 |
("_Run", False), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
899 |
("_Stop", True), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
900 |
("_Build", True), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
901 |
("_Transfer", True)], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
902 |
"Stopped" : [("_Simulate", False), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
903 |
("_Run", True), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
904 |
("_Stop", False), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
905 |
("_Build", True), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
906 |
("_Transfer", True)], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
907 |
"Connected" : [("_Simulate", not simulating), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
908 |
("_Run", True), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
909 |
("_Stop", simulating), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
910 |
("_Build", True), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
911 |
("_Transfer", True)], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
912 |
"Disconnected" :[("_Simulate", not simulating), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
913 |
("_Run", False), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
914 |
("_Stop", simulating), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
915 |
("_Build", True), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
916 |
("_Transfer", False)], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
917 |
}.get(status,[]): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
918 |
self.ShowMethod(*args) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
919 |
self.previous_plcstate = status |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
920 |
self.previous_mode = self.CurrentMode |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
921 |
return True |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
922 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
923 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
924 |
def Generate_plc_declare_locations(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
925 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
926 |
Declare used locations in order to simulatePLC in a black box |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
927 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
928 |
return """#include "iec_types_all.h" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
929 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
930 |
#define __LOCATED_VAR(type, name, ...) \ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
931 |
type beremiz_##name;\ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
932 |
type *name = &beremiz_##name; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
933 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
934 |
#include "LOCATED_VARIABLES.h" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
935 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
936 |
#undef __LOCATED_VAR |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
937 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
938 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
939 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
940 |
def Generate_lpc_retain_array_sim(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
941 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
942 |
Support for retain array in Simulation |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
943 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
944 |
return """/* Support for retain array */ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
945 |
#define USER_RETAIN_ARRAY_SIZE 2000 |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
946 |
#define NUM_OF_COLS 3 |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
947 |
unsigned char readOK = 0; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
948 |
unsigned int foundIndex = USER_RETAIN_ARRAY_SIZE; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
949 |
unsigned int retainArray[USER_RETAIN_ARRAY_SIZE][NUM_OF_COLS]; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
950 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
951 |
unsigned int __GetRetainData(unsigned char READ, unsigned int INDEX, unsigned int COLUMN) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
952 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
953 |
if(READ == 1) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
954 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
955 |
if((0<=INDEX) && (INDEX<USER_RETAIN_ARRAY_SIZE) && (0<=COLUMN) && (COLUMN<NUM_OF_COLS)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
956 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
957 |
readOK = 1; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
958 |
return retainArray[INDEX][COLUMN]; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
959 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
960 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
961 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
962 |
readOK = 0; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
963 |
return 0; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
964 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
965 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
966 |
unsigned char __SetRetainData(unsigned char WRITE, unsigned int INDEX, unsigned int WORD1, unsigned int WORD2, unsigned int WORD3) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
967 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
968 |
if(WRITE == 1) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
969 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
970 |
if((0<=INDEX) && (INDEX<USER_RETAIN_ARRAY_SIZE)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
971 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
972 |
retainArray[INDEX][0] = WORD1; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
973 |
retainArray[INDEX][1] = WORD2; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
974 |
retainArray[INDEX][2] = WORD3; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
975 |
return 1; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
976 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
977 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
978 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
979 |
return 0; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
980 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
981 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
982 |
unsigned char __FindRetainData(unsigned char SEARCH, unsigned int START_IDX, unsigned int END_IDX, unsigned int WORD1, unsigned int WORD2, unsigned int WORD3) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
983 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
984 |
unsigned int i; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
985 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
986 |
if((SEARCH==1) && (0<=START_IDX) && (START_IDX<USER_RETAIN_ARRAY_SIZE) && (START_IDX<=END_IDX) && (END_IDX<USER_RETAIN_ARRAY_SIZE)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
987 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
988 |
for(i=START_IDX;i<=END_IDX;i++) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
989 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
990 |
if((retainArray[i][0] == WORD1) && (retainArray[i][1] == WORD2) && (retainArray[i][2] == WORD3)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
991 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
992 |
foundIndex = i; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
993 |
return 1; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
994 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
995 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
996 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
997 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
998 |
foundIndex = USER_RETAIN_ARRAY_SIZE; /* Data not found => return index that is out of array bounds */ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
999 |
return 0; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1000 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1001 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1002 |
/* Since Beremiz debugger doesn't like pointer-by-reference stuff or global varibles, separate function is a must */ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1003 |
unsigned char __GetReadStatus(unsigned char dummy) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1004 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1005 |
return readOK; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1006 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1007 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1008 |
unsigned int __GetFoundIndex(unsigned char dummy) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1009 |
{ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1010 |
return foundIndex; |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1011 |
} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1012 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1013 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1014 |
def _Simulate(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1015 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1016 |
Method called by user to Simulate PLC |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1017 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1018 |
self.CurrentMode = SIMULATION_MODE |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1019 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1020 |
uri = "LOCAL://" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1021 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1022 |
self._connector = connectors.ConnectorFactory(uri, self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1023 |
except Exception, msg: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1024 |
self.logger.write_error(_("Exception while connecting %s!\n")%uri) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1025 |
self.logger.write_error(traceback.format_exc()) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1026 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1027 |
# Did connection success ? |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1028 |
if self._connector is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1029 |
# Oups. |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1030 |
self.logger.write_error(_("Connection failed to %s!\n")%uri) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1031 |
self.StopSimulation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1032 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1033 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1034 |
buildpath = self._getBuildPath() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1035 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1036 |
# Eventually create build dir |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1037 |
if not os.path.exists(buildpath): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1038 |
os.makedirs(buildpath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1039 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1040 |
# Generate SoftPLC IEC code |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1041 |
IECGenRes = self._Generate_SoftPLC() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1042 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1043 |
# If IEC code gen fail, bail out. |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1044 |
if not IECGenRes: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1045 |
self.logger.write_error(_("IEC-61131-3 code generation failed !\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1046 |
self.StopSimulation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1047 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1048 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1049 |
# Reset variable and program list that are parsed from |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1050 |
# CSV file generated by IEC2C compiler. |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1051 |
self.ResetIECProgramsAndVariables() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1052 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1053 |
gen_result = self.CTNGenerate_C(buildpath, self.PLCGeneratedLocatedVars) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1054 |
CTNCFilesAndCFLAGS, CTNLDFLAGS, DoCalls = gen_result[:3] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1055 |
# if some files have been generated put them in the list with their location |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1056 |
if CTNCFilesAndCFLAGS: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1057 |
self.LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), CTNCFilesAndCFLAGS, DoCalls)] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1058 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1059 |
self.LocationCFilesAndCFLAGS = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1060 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1061 |
# confnode asks for some LDFLAGS |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1062 |
if CTNLDFLAGS: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1063 |
# LDFLAGS can be either string |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1064 |
if type(CTNLDFLAGS)==type(str()): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1065 |
self.LDFLAGS=[CTNLDFLAGS] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1066 |
#or list of strings |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1067 |
elif type(CTNLDFLAGS)==type(list()): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1068 |
self.LDFLAGS=CTNLDFLAGS[:] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1069 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1070 |
self.LDFLAGS=[] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1071 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1072 |
# Template based part of C code generation |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1073 |
# files are stacked at the beginning, as files of confnode tree root |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1074 |
for generator, filename, name in [ |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1075 |
# debugger code |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1076 |
(self.Generate_plc_debugger, "plc_debugger.c", "Debugger"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1077 |
# init/cleanup/retrieve/publish, run and align code |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1078 |
(self.Generate_plc_common_main,"plc_common_main.c","Common runtime"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1079 |
# declare located variables for simulate in a black box |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1080 |
(self.Generate_plc_declare_locations,"plc_declare_locations.c","Declare Locations"), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1081 |
# declare located variables for simulate in a black box |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1082 |
(self.Generate_lpc_retain_array_sim,"lpc_retain_array_sim.c","Retain Array for Simulation")]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1083 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1084 |
# Do generate |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1085 |
code = generator() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1086 |
if code is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1087 |
raise |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1088 |
code_path = os.path.join(buildpath,filename) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1089 |
open(code_path, "w").write(code) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1090 |
# Insert this file as first file to be compiled at root confnode |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1091 |
self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1092 |
except Exception, exc: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1093 |
self.logger.write_error(name+_(" generation failed !\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1094 |
self.logger.write_error(traceback.format_exc()) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1095 |
self.StopSimulation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1096 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1097 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1098 |
# Get simulation builder |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1099 |
builder = self.GetBuilder() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1100 |
if builder is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1101 |
self.logger.write_error(_("Fatal : cannot get builder.\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1102 |
self.StopSimulation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1103 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1104 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1105 |
# Build |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1106 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1107 |
if not builder.build() : |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1108 |
self.logger.write_error(_("C Build failed.\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1109 |
self.StopSimulation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1110 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1111 |
except Exception, exc: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1112 |
self.logger.write_error(_("C Build crashed !\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1113 |
self.logger.write_error(traceback.format_exc()) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1114 |
self.StopSimulation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1115 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1116 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1117 |
data = builder.GetBinaryCode() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1118 |
if data is not None : |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1119 |
if self._connector.NewPLC(builder.GetBinaryCodeMD5(), data, []): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1120 |
self.UnsubscribeAllDebugIECVariable() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1121 |
self.ProgramTransferred() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1122 |
if self.AppFrame is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1123 |
self.AppFrame.CloseObsoleteDebugTabs() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1124 |
self.logger.write(_("Transfer completed successfully.\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1125 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1126 |
self.logger.write_error(_("Transfer failed\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1127 |
self.StopSimulation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1128 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1129 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1130 |
self._Run() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1131 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1132 |
if not self.StatusTimer.IsRunning(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1133 |
# Start the status Timer |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1134 |
self.StatusTimer.Start(milliseconds=500, oneShot=False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1135 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1136 |
def StopSimulation(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1137 |
self.CurrentMode = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1138 |
self.ApplyOnlineMode() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1139 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1140 |
def _Stop(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1141 |
ProjectController._Stop(self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1142 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1143 |
if self.CurrentMode == SIMULATION_MODE: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1144 |
self.StopSimulation() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1145 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1146 |
def CompareLocalAndRemotePLC(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1147 |
if self.LPCConnector is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1148 |
return |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1149 |
# We are now connected. Update button status |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1150 |
MD5 = self.GetLastBuildMD5() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1151 |
# Check remote target PLC correspondance to that md5 |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1152 |
if MD5 is not None and self.LPCConnector.MatchMD5(MD5): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1153 |
# warns controller that program match |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1154 |
self.ProgramTransferred() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1155 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1156 |
def ResetBuildMD5(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1157 |
builder=self.GetBuilder() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1158 |
if builder is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1159 |
builder.ResetBinaryCodeMD5(self.OnlineMode) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1160 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1161 |
def GetLastBuildMD5(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1162 |
builder=self.GetBuilder() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1163 |
if builder is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1164 |
return builder.GetBinaryCodeMD5(self.OnlineMode) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1165 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1166 |
return None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1167 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1168 |
def _Transfer(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1169 |
if self.CurrentMode is None and self.OnlineMode != "OFF": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1170 |
self.CurrentMode = TRANSFER_MODE |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1171 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1172 |
if ProjectController._Build(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1173 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1174 |
ID_ABORTTRANSFERTIMER = wx.NewId() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1175 |
self.AbortTransferTimer = wx.Timer(self.AppFrame, ID_ABORTTRANSFERTIMER) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1176 |
self.AppFrame.Bind(wx.EVT_TIMER, self.AbortTransfer, self.AbortTransferTimer) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1177 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1178 |
if self.OnlineMode == "BOOTLOADER": |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1179 |
self.BeginTransfer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1180 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1181 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1182 |
self.logger.write(_("Resetting PLC\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1183 |
#self.StatusTimer.Stop() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1184 |
self.LPCConnector.ResetPLC() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1185 |
self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1186 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1187 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1188 |
self.CurrentMode = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1189 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1190 |
def BeginTransfer(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1191 |
self.logger.write(_("Start PLC transfer\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1192 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1193 |
self.AbortTransferTimer.Stop() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1194 |
ProjectController._Transfer(self) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1195 |
self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1196 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1197 |
def AbortTransfer(self, event): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1198 |
self.logger.write_warning(_("Timeout waiting PLC to recover\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1199 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1200 |
self.CurrentMode = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1201 |
self.AbortTransferTimer.Stop() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1202 |
self.AbortTransferTimer = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1203 |
event.Skip() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1204 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1205 |
def _Run(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1206 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1207 |
Start PLC |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1208 |
""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1209 |
if self.GetIECProgramsAndVariables(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1210 |
self._connector.StartPLC() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1211 |
self.logger.write(_("Starting PLC\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1212 |
self._connect_debug() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1213 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1214 |
self.logger.write_error(_("Couldn't start PLC !\n")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1215 |
self.UpdateMethodsFromPLCStatus() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1216 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1217 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1218 |
# LPCBeremiz Class |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1219 |
#------------------------------------------------------------------------------- |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1220 |
lpcberemiz_cmd=None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1221 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1222 |
class LPCBeremiz(Beremiz): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1223 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1224 |
def _init_coll_FileMenu_Items(self, parent): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1225 |
AppendMenu(parent, help='', id=wx.ID_SAVE, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1226 |
kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S')) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1227 |
AppendMenu(parent, help='', id=wx.ID_CLOSE, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1228 |
kind=wx.ITEM_NORMAL, text=_(u'Close Tab\tCTRL+W')) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1229 |
parent.AppendSeparator() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1230 |
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1231 |
kind=wx.ITEM_NORMAL, text=_(u'Page Setup')) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1232 |
AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1233 |
kind=wx.ITEM_NORMAL, text=_(u'Preview')) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1234 |
AppendMenu(parent, help='', id=wx.ID_PRINT, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1235 |
kind=wx.ITEM_NORMAL, text=_(u'Print')) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1236 |
parent.AppendSeparator() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1237 |
AppendMenu(parent, help='', id=wx.ID_EXIT, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1238 |
kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q')) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1239 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1240 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1241 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1242 |
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1243 |
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1244 |
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1245 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1246 |
|
16
3eaac9927941
Fix bug in icon names for file menu toolbar items
Laurent Bessard
parents:
15
diff
changeset
|
1247 |
self.AddToMenuToolBar([(wx.ID_SAVE, "save", _(u'Save'), None), |
3eaac9927941
Fix bug in icon names for file menu toolbar items
Laurent Bessard
parents:
15
diff
changeset
|
1248 |
(wx.ID_PRINT, "print", _(u'Print'), None)]) |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1249 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1250 |
def _init_coll_AddMenu_Items(self, parent): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1251 |
IDEFrame._init_coll_AddMenu_Items(self, parent, False) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1252 |
new_id = wx.NewId() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1253 |
AppendMenu(parent, help='', id=new_id, |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1254 |
kind=wx.ITEM_NORMAL, text=_(u'&Resource')) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1255 |
self.Bind(wx.EVT_MENU, self.AddResourceMenu, id=new_id) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1256 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1257 |
def _init_ctrls(self, prnt): |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1258 |
Beremiz._init_ctrls(self, prnt) |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1259 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1260 |
self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1261 |
name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1262 |
size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1263 |
self.PLCConfig.SetBackgroundColour(wx.WHITE) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1264 |
self.PLCConfig.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1265 |
self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow) |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1266 |
self.MainTabs["PLCConfig"] = (self.PLCConfig, _("Topology")) |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1267 |
self.LeftNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1268 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1269 |
self.PLCConfigMainSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1270 |
self.PLCParamsSizer = wx.BoxSizer(wx.VERTICAL) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1271 |
self.ConfNodeTreeSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=0, vgap=2) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1272 |
self.ConfNodeTreeSizer.AddGrowableCol(0) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1273 |
self.ConfNodeTreeSizer.AddGrowableCol(1) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1274 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1275 |
self.PLCConfigMainSizer.AddSizer(self.PLCParamsSizer, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1276 |
self.PLCConfigMainSizer.AddSizer(self.ConfNodeTreeSizer, 0, border=10, flag=wx.BOTTOM|wx.LEFT|wx.RIGHT) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1277 |
self.PLCConfigMainSizer.AddGrowableCol(0) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1278 |
self.PLCConfigMainSizer.AddGrowableRow(1) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1279 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1280 |
self.PLCConfig.SetSizer(self.PLCConfigMainSizer) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1281 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1282 |
self.AUIManager.Update() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1283 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1284 |
def __init__(self, parent, projectOpen=None, buildpath=None, ctr=None, debug=True): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1285 |
self.ConfNodeInfos = {} |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1286 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1287 |
Beremiz.__init__(self, parent, projectOpen, buildpath, ctr, debug) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1288 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1289 |
def OnCloseFrame(self, event): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1290 |
global frame |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1291 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1292 |
if self.CheckSaveBeforeClosing(_("Close Application")): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1293 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1294 |
frame.Hide() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1295 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1296 |
self.CTR.ResetAppFrame(lpcberemiz_cmd.Log) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1297 |
if self.CTR.OnlineMode == 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1298 |
self.CTR._connector = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1299 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1300 |
self.CTR.KillDebugThread() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1301 |
self.KillLocalRuntime() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1302 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1303 |
self.SaveLastState() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1304 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1305 |
lpcberemiz_cmd.Log.write("Closed\n") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1306 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1307 |
event.Veto() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1308 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1309 |
def OnMoveWindow(self, event): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1310 |
self.GetBestSize() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1311 |
self.RefreshScrollBars() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1312 |
event.Skip() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1313 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1314 |
def OnPanelLeftDown(self, event): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1315 |
focused = self.FindFocus() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1316 |
if isinstance(focused, TextCtrlAutoComplete): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1317 |
focused.DismissListBox() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1318 |
event.Skip() |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1319 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1320 |
def RefreshFileMenu(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1321 |
MenuToolBar = self.Panes["MenuToolBar"] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1322 |
if self.CTR is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1323 |
selected = self.TabsOpened.GetSelection() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1324 |
if selected >= 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1325 |
graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1326 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1327 |
graphic_viewer = False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1328 |
if self.TabsOpened.GetPageCount() > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1329 |
self.FileMenu.Enable(wx.ID_CLOSE, True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1330 |
if graphic_viewer: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1331 |
self.FileMenu.Enable(wx.ID_PREVIEW, True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1332 |
self.FileMenu.Enable(wx.ID_PRINT, True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1333 |
MenuToolBar.EnableTool(wx.ID_PRINT, True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1334 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1335 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1336 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1337 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1338 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1339 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1340 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1341 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1342 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1343 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1344 |
project_modified = self.CTR.ProjectTestModified() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1345 |
self.FileMenu.Enable(wx.ID_SAVE, project_modified) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1346 |
MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1347 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1348 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1349 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1350 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1351 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1352 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1353 |
self.FileMenu.Enable(wx.ID_SAVE, False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1354 |
MenuToolBar.EnableTool(wx.ID_SAVE, False) |
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1355 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1356 |
def RefreshScrollBars(self): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1357 |
xstart, ystart = self.PLCConfig.GetViewStart() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1358 |
window_size = self.PLCConfig.GetClientSize() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1359 |
sizer = self.PLCConfig.GetSizer() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1360 |
if sizer: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1361 |
maxx, maxy = sizer.GetMinSize() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1362 |
posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1363 |
posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1364 |
self.PLCConfig.Scroll(posx, posy) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1365 |
self.PLCConfig.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1366 |
maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1367 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1368 |
def RefreshPLCParams(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1369 |
self.Freeze() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1370 |
self.ClearSizer(self.PLCParamsSizer) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1371 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1372 |
if self.CTR is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1373 |
plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1374 |
if self.CTR.CTNTestModified(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1375 |
bkgdclr = CHANGED_TITLE_COLOUR |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1376 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1377 |
bkgdclr = TITLE_COLOUR |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1378 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1379 |
if self.CTR not in self.ConfNodeInfos: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1380 |
self.ConfNodeInfos[self.CTR] = {"right_visible" : False} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1381 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1382 |
plcwindow.SetBackgroundColour(TITLE_COLOUR) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1383 |
plcwindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1384 |
self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1385 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1386 |
plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1387 |
plcwindow.SetSizer(plcwindowsizer) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1388 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1389 |
st = wx.StaticText(plcwindow, -1) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1390 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1391 |
st.SetLabel(self.CTR.GetProjectName()) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1392 |
plcwindowsizer.AddWindow(st, 0, border=5, flag=wx.ALL|wx.ALIGN_CENTER) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1393 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1394 |
plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1395 |
plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1396 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1397 |
plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1398 |
plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1399 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1400 |
msizer = self.GenerateMethodButtonSizer(self.CTR, plcwindow, not self.ConfNodeInfos[self.CTR]["right_visible"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1401 |
plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1402 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1403 |
self.PLCConfigMainSizer.Layout() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1404 |
self.RefreshScrollBars() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1405 |
self.Thaw() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1406 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1407 |
def GenerateMethodButtonSizer(self, confnode, parent, horizontal = True): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1408 |
normal_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1409 |
mouseover_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, underline=True, faceName = faces["helv"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1410 |
if horizontal: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1411 |
msizer = wx.FlexGridSizer(cols=len(confnode.ConfNodeMethods)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1412 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1413 |
msizer = wx.FlexGridSizer(cols=1) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1414 |
for confnode_method in confnode.ConfNodeMethods: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1415 |
if "method" in confnode_method and confnode_method.get("shown",True): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1416 |
id = wx.NewId() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1417 |
label = confnode_method["name"] |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1418 |
button = GenBitmapTextButton(id=id, parent=parent, |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1419 |
bitmap=wx.Bitmap(Bpath("images", "%s.png"%confnode_method.get("bitmap", "Unknown"))), label=label, |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1420 |
name=label, pos=wx.DefaultPosition, style=wx.NO_BORDER) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1421 |
button.SetFont(normal_bt_font) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1422 |
button.SetToolTipString(confnode_method["tooltip"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1423 |
button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode, confnode_method["method"]), id=id) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1424 |
# a fancy underline on mouseover |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1425 |
def setFontStyle(b, s): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1426 |
def fn(event): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1427 |
b.SetFont(s) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1428 |
b.Refresh() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1429 |
event.Skip() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1430 |
return fn |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1431 |
button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1432 |
button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1433 |
#hack to force size to mini |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1434 |
if not confnode_method.get("enabled",True): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1435 |
button.Disable() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1436 |
msizer.AddWindow(button, 0, border=0, flag=wx.ALIGN_CENTER) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1437 |
return msizer |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1438 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1439 |
def GenerateEnableButton(self, parent, sizer, confnode): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1440 |
enabled = confnode.CTNEnabled() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1441 |
if enabled is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1442 |
enablebutton_id = wx.NewId() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1443 |
enablebutton = wx.lib.buttons.GenBitmapToggleButton(id=enablebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Disabled.png')), |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1444 |
name='EnableButton', parent=parent, size=wx.Size(16, 16), pos=wx.Point(0, 0), style=0)#wx.NO_BORDER) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1445 |
enablebutton.SetToolTipString(_("Enable/Disable this confnode")) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1446 |
make_genbitmaptogglebutton_flat(enablebutton) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1447 |
enablebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Enabled.png'))) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1448 |
enablebutton.SetToggle(enabled) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1449 |
def toggleenablebutton(event): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1450 |
res = self.SetConfNodeParamsAttribute(confnode, "BaseParams.Enabled", enablebutton.GetToggle()) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1451 |
enablebutton.SetToggle(res) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1452 |
event.Skip() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1453 |
enablebutton.Bind(wx.EVT_BUTTON, toggleenablebutton, id=enablebutton_id) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1454 |
sizer.AddWindow(enablebutton, 0, border=0, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1455 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1456 |
sizer.AddSpacer(wx.Size(16, 16)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1457 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1458 |
def RefreshConfNodeTree(self): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1459 |
self.Freeze() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1460 |
self.ClearSizer(self.ConfNodeTreeSizer) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1461 |
if self.CTR is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1462 |
for child in self.CTR.IECSortedChildren(): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1463 |
self.GenerateTreeBranch(child) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1464 |
if not self.ConfNodeInfos[child]["expanded"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1465 |
self.CollapseConfNode(child) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1466 |
self.PLCConfigMainSizer.Layout() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1467 |
self.RefreshScrollBars() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1468 |
self.Thaw() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1469 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1470 |
def GenerateTreeBranch(self, confnode): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1471 |
leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1472 |
if confnode.CTNTestModified(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1473 |
bkgdclr=CHANGED_WINDOW_COLOUR |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1474 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1475 |
bkgdclr=WINDOW_COLOUR |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1476 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1477 |
leftwindow.SetBackgroundColour(bkgdclr) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1478 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1479 |
if confnode not in self.ConfNodeInfos: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1480 |
self.ConfNodeInfos[confnode] = {"expanded" : False, "left_visible" : False, "right_visible" : False} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1481 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1482 |
self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChildren() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1483 |
confnode_infos = confnode.GetVariableLocationTree() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1484 |
confnode_locations = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1485 |
if len(self.ConfNodeInfos[confnode]["children"]) == 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1486 |
confnode_locations = confnode_infos["children"] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1487 |
if not self.ConfNodeInfos[confnode].has_key("locations_infos"): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1488 |
self.ConfNodeInfos[confnode]["locations_infos"] = {"root": {"expanded" : False}} |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1489 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1490 |
self.ConfNodeInfos[confnode]["locations_infos"]["root"]["left"] = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1491 |
self.ConfNodeInfos[confnode]["locations_infos"]["root"]["right"] = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1492 |
self.ConfNodeInfos[confnode]["locations_infos"]["root"]["children"] = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1493 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1494 |
self.ConfNodeTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1495 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1496 |
leftwindowvsizer = wx.BoxSizer(wx.VERTICAL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1497 |
leftwindow.SetSizer(leftwindowvsizer) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1498 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1499 |
leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1500 |
leftwindowvsizer.AddSizer(leftwindowsizer, 0, border=0, flag=0) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1501 |
|
4
e8a0af6b89d9
Adding support for LPC pous library using new Beremiz extension paradigm
Laurent Bessard
parents:
2
diff
changeset
|
1502 |
#self.GenerateEnableButton(leftwindow, leftwindowsizer, confnode) |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1503 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1504 |
st = wx.StaticText(leftwindow, -1) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1505 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1506 |
st.SetLabel(confnode.GetFullIEC_Channel()) |
4
e8a0af6b89d9
Adding support for LPC pous library using new Beremiz extension paradigm
Laurent Bessard
parents:
2
diff
changeset
|
1507 |
leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.LEFT|wx.RIGHT) |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1508 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1509 |
expandbutton_id = wx.NewId() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1510 |
expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1511 |
name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1512 |
size=wx.Size(13, 13), style=wx.NO_BORDER) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1513 |
expandbutton.labelDelta = 0 |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1514 |
expandbutton.SetBezelWidth(0) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1515 |
expandbutton.SetUseFocusIndicator(False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1516 |
expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png'))) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1517 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1518 |
if len(self.ConfNodeInfos[confnode]["children"]) > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1519 |
expandbutton.SetToggle(self.ConfNodeInfos[confnode]["expanded"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1520 |
def togglebutton(event): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1521 |
if expandbutton.GetToggle(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1522 |
self.ExpandConfNode(confnode) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1523 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1524 |
self.CollapseConfNode(confnode) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1525 |
self.ConfNodeInfos[confnode]["expanded"] = expandbutton.GetToggle() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1526 |
self.PLCConfigMainSizer.Layout() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1527 |
self.RefreshScrollBars() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1528 |
event.Skip() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1529 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1530 |
elif len(confnode_locations) > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1531 |
locations_infos = self.ConfNodeInfos[confnode]["locations_infos"] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1532 |
expandbutton.SetToggle(locations_infos["root"]["expanded"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1533 |
def togglebutton(event): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1534 |
if expandbutton.GetToggle(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1535 |
self.ExpandLocation(locations_infos, "root") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1536 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1537 |
self.CollapseLocation(locations_infos, "root") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1538 |
self.ConfNodeInfos[confnode]["expanded"] = expandbutton.GetToggle() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1539 |
locations_infos["root"]["expanded"] = expandbutton.GetToggle() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1540 |
self.PLCConfigMainSizer.Layout() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1541 |
self.RefreshScrollBars() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1542 |
event.Skip() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1543 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1544 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1545 |
expandbutton.Enable(False) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1546 |
leftwindowsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1547 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1548 |
sb = wx.StaticBitmap(leftwindow, -1) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1549 |
icon = confnode_infos.get("icon", None) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1550 |
if icon is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1551 |
icon_bitmap = self.LocationImageList.GetBitmap(self.LocationImageDict[confnode_infos["type"]]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1552 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1553 |
icon_bitmap = wx.Bitmap(icon) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1554 |
sb.SetBitmap(icon_bitmap) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1555 |
leftwindowsizer.AddWindow(sb, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1556 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1557 |
st_id = wx.NewId() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1558 |
st = wx.StaticText(leftwindow, st_id, size=wx.DefaultSize, style=wx.NO_BORDER) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1559 |
st.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1560 |
st.SetLabel(confnode.MandatoryParams[1].getName()) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1561 |
leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1562 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1563 |
rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1564 |
rightwindow.SetBackgroundColour(bkgdclr) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1565 |
rightwindowsizer = self.GenerateMethodButtonSizer(confnode, rightwindow, not self.ConfNodeInfos[confnode]["right_visible"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1566 |
rightwindow.SetSizer(rightwindowsizer) |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1567 |
self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1568 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1569 |
self.ConfNodeInfos[confnode]["left"] = leftwindow |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1570 |
self.ConfNodeInfos[confnode]["right"] = rightwindow |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1571 |
for child in self.ConfNodeInfos[confnode]["children"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1572 |
self.GenerateTreeBranch(child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1573 |
if not self.ConfNodeInfos[child]["expanded"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1574 |
self.CollapseConfNode(child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1575 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1576 |
if len(confnode_locations) > 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1577 |
locations_infos = self.ConfNodeInfos[confnode]["locations_infos"] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1578 |
treectrl = wx.TreeCtrl(self.PLCConfig, -1, size=wx.DefaultSize, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1579 |
style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.NO_BORDER|wx.TR_HIDE_ROOT|wx.TR_NO_LINES|wx.TR_LINES_AT_ROOT) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1580 |
treectrl.SetImageList(self.LocationImageList) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1581 |
treectrl.Bind(wx.EVT_TREE_BEGIN_DRAG, self.GenerateLocationBeginDragFunction(locations_infos)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1582 |
treectrl.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.GenerateLocationExpandCollapseFunction(locations_infos, True)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1583 |
treectrl.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.GenerateLocationExpandCollapseFunction(locations_infos, False)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1584 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1585 |
treectrl.AddRoot("") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1586 |
self.ConfNodeTreeSizer.AddWindow(treectrl, 0, border=0, flag=0) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1587 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1588 |
rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1589 |
rightwindow.SetBackgroundColour(wx.WHITE) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1590 |
self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1591 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1592 |
locations_infos["root"]["left"] = treectrl |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1593 |
locations_infos["root"]["right"] = rightwindow |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1594 |
for location in confnode_locations: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1595 |
locations_infos["root"]["children"].append("root.%s" % location["name"]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1596 |
self.GenerateLocationTreeBranch(treectrl, treectrl.GetRootItem(), locations_infos, "root", location) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1597 |
if locations_infos["root"]["expanded"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1598 |
self.ExpandLocation(locations_infos, "root") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1599 |
|
2
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1600 |
def ExpandConfNode(self, confnode, force = False): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1601 |
for child in self.ConfNodeInfos[confnode]["children"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1602 |
self.ConfNodeInfos[child]["left"].Show() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1603 |
self.ConfNodeInfos[child]["right"].Show() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1604 |
if force or self.ConfNodeInfos[child]["expanded"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1605 |
self.ExpandConfNode(child, force) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1606 |
if force: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1607 |
self.ConfNodeInfos[child]["expanded"] = True |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1608 |
locations_infos = self.ConfNodeInfos[confnode].get("locations_infos", None) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1609 |
if locations_infos is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1610 |
if force or locations_infos["root"]["expanded"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1611 |
self.ExpandLocation(locations_infos, "root", force) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1612 |
if force: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1613 |
locations_infos["root"]["expanded"] = True |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1614 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1615 |
def CollapseConfNode(self, confnode, force = False): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1616 |
for child in self.ConfNodeInfos[confnode]["children"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1617 |
self.ConfNodeInfos[child]["left"].Hide() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1618 |
self.ConfNodeInfos[child]["right"].Hide() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1619 |
self.CollapseConfNode(child, force) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1620 |
if force: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1621 |
self.ConfNodeInfos[child]["expanded"] = False |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1622 |
locations_infos = self.ConfNodeInfos[confnode].get("locations_infos", None) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1623 |
if locations_infos is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1624 |
self.CollapseLocation(locations_infos, "root", force) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1625 |
if force: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1626 |
locations_infos["root"]["expanded"] = False |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1627 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1628 |
def ExpandLocation(self, locations_infos, group, force = False, refresh_size=True): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1629 |
locations_infos[group]["expanded"] = True |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1630 |
if group == "root": |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1631 |
if locations_infos[group]["left"] is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1632 |
locations_infos[group]["left"].Show() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1633 |
if locations_infos[group]["right"] is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1634 |
locations_infos[group]["right"].Show() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1635 |
elif locations_infos["root"]["left"] is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1636 |
locations_infos["root"]["left"].Expand(locations_infos[group]["item"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1637 |
if force: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1638 |
for child in locations_infos[group]["children"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1639 |
self.ExpandLocation(locations_infos, child, force, False) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1640 |
if locations_infos["root"]["left"] is not None and refresh_size: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1641 |
self.RefreshTreeCtrlSize(locations_infos["root"]["left"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1642 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1643 |
def CollapseLocation(self, locations_infos, group, force = False, refresh_size=True): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1644 |
locations_infos[group]["expanded"] = False |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1645 |
if group == "root": |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1646 |
if locations_infos[group]["left"] is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1647 |
locations_infos[group]["left"].Hide() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1648 |
if locations_infos[group]["right"] is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1649 |
locations_infos[group]["right"].Hide() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1650 |
elif locations_infos["root"]["left"] is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1651 |
locations_infos["root"]["left"].Collapse(locations_infos[group]["item"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1652 |
if force: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1653 |
for child in locations_infos[group]["children"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1654 |
self.CollapseLocation(locations_infos, child, force, False) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1655 |
if locations_infos["root"]["left"] is not None and refresh_size: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1656 |
self.RefreshTreeCtrlSize(locations_infos["root"]["left"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1657 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1658 |
def GenerateLocationTreeBranch(self, treectrl, root, locations_infos, parent, location): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1659 |
location_name = "%s.%s" % (parent, location["name"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1660 |
if not locations_infos.has_key(location_name): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1661 |
locations_infos[location_name] = {"expanded" : False} |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1662 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1663 |
if location["type"] in [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1664 |
label = "%(name)s (%(location)s)" % location |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1665 |
elif location["location"] != "": |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1666 |
label = "%(location)s: %(name)s" % location |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1667 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1668 |
label = location["name"] |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1669 |
item = treectrl.AppendItem(root, label) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1670 |
treectrl.SetPyData(item, location_name) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1671 |
treectrl.SetItemImage(item, self.LocationImageDict[location["type"]]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1672 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1673 |
locations_infos[location_name]["item"] = item |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1674 |
locations_infos[location_name]["children"] = [] |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1675 |
infos = location.copy() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1676 |
infos.pop("children") |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1677 |
locations_infos[location_name]["infos"] = infos |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1678 |
for child in location["children"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1679 |
child_name = "%s.%s" % (location_name, child["name"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1680 |
locations_infos[location_name]["children"].append(child_name) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1681 |
self.GenerateLocationTreeBranch(treectrl, item, locations_infos, location_name, child) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1682 |
if locations_infos[location_name]["expanded"]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1683 |
self.ExpandLocation(locations_infos, location_name) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1684 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1685 |
def GenerateLocationBeginDragFunction(self, locations_infos): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1686 |
def OnLocationBeginDragFunction(event): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1687 |
item = event.GetItem() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1688 |
location_name = locations_infos["root"]["left"].GetPyData(item) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1689 |
if location_name is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1690 |
infos = locations_infos[location_name]["infos"] |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1691 |
if infos["type"] in [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1692 |
data = wx.TextDataObject(str((infos["location"], "location", infos["IEC_type"], infos["var_name"], infos["description"]))) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1693 |
dragSource = wx.DropSource(self) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1694 |
dragSource.SetData(data) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1695 |
dragSource.DoDragDrop() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1696 |
return OnLocationBeginDragFunction |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1697 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1698 |
def RefreshTreeCtrlSize(self, treectrl): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1699 |
rect = self.GetTreeCtrlItemRect(treectrl, treectrl.GetRootItem()) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1700 |
treectrl.SetMinSize(wx.Size(max(rect.width, rect.x + rect.width) + 20, max(rect.height, rect.y + rect.height))) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1701 |
self.PLCConfigMainSizer.Layout() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1702 |
self.PLCConfig.Refresh() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1703 |
wx.CallAfter(self.RefreshScrollBars) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1704 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1705 |
def GetTreeCtrlItemRect(self, treectrl, item): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1706 |
item_rect = treectrl.GetBoundingRect(item, True) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1707 |
if item_rect is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1708 |
minx, miny = item_rect.x, item_rect.y |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1709 |
maxx, maxy = item_rect.x + item_rect.width, item_rect.y + item_rect.height |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1710 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1711 |
minx = miny = maxx = maxy = 0 |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1712 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1713 |
if treectrl.ItemHasChildren(item) and (item == treectrl.GetRootItem() or treectrl.IsExpanded(item)): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1714 |
if wx.VERSION >= (2, 6, 0): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1715 |
child, item_cookie = treectrl.GetFirstChild(item) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1716 |
else: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1717 |
child, item_cookie = treectrl.GetFirstChild(item, 0) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1718 |
while child.IsOk(): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1719 |
child_rect = self.GetTreeCtrlItemRect(treectrl, child) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1720 |
minx = min(minx, child_rect.x) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1721 |
miny = min(miny, child_rect.y) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1722 |
maxx = max(maxx, child_rect.x + child_rect.width) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1723 |
maxy = max(maxy, child_rect.y + child_rect.height) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1724 |
child, item_cookie = treectrl.GetNextChild(item, item_cookie) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1725 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1726 |
return wx.Rect(minx, miny, maxx - minx, maxy - miny) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1727 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1728 |
def GenerateLocationExpandCollapseFunction(self, locations_infos, expand): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1729 |
def OnLocationExpandedFunction(event): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1730 |
item = event.GetItem() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1731 |
location_name = locations_infos["root"]["left"].GetPyData(item) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1732 |
if location_name is not None: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1733 |
locations_infos[location_name]["expanded"] = expand |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1734 |
self.RefreshTreeCtrlSize(locations_infos["root"]["left"]) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1735 |
event.Skip() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1736 |
return OnLocationExpandedFunction |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1737 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1738 |
def GetButtonCallBackFunction(self, confnode, method): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1739 |
""" Generate the callbackfunc for a given confnode method""" |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1740 |
def OnButtonClick(event): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1741 |
# Disable button to prevent re-entrant call |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1742 |
event.GetEventObject().Disable() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1743 |
# Call |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1744 |
getattr(confnode,method)() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1745 |
# Re-enable button |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1746 |
event.GetEventObject().Enable() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1747 |
# Trigger refresh on Idle |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1748 |
wx.CallAfter(self.RefreshAll) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1749 |
event.Skip() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1750 |
return OnButtonClick |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1751 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1752 |
def ClearSizer(self, sizer): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1753 |
staticboxes = [] |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1754 |
for item in sizer.GetChildren(): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1755 |
if item.IsSizer(): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1756 |
item_sizer = item.GetSizer() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1757 |
self.ClearSizer(item_sizer) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1758 |
if isinstance(item_sizer, wx.StaticBoxSizer): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1759 |
staticboxes.append(item_sizer.GetStaticBox()) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1760 |
sizer.Clear(True) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1761 |
for staticbox in staticboxes: |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1762 |
staticbox.Destroy() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1763 |
|
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1764 |
def RefreshAll(self): |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1765 |
Beremiz.RefreshAll(self) |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1766 |
self.RefreshPLCParams() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1767 |
self.RefreshConfNodeTree() |
0c697b8fc443
Fixing bugs introduced with the new Beremiz extension paradigm
Laurent Bessard
parents:
1
diff
changeset
|
1768 |
|
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1769 |
class StdoutPseudoFile: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1770 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1771 |
def __init__(self, port): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1772 |
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1773 |
self.socket.connect(('localhost', port)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1774 |
self.Buffer = "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1775 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1776 |
def __del__(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1777 |
self.socket.close() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1778 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1779 |
def readline(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1780 |
idx = self.Buffer.find("\n") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1781 |
if idx == -1: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1782 |
self.Buffer += self.socket.recv(2048) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1783 |
idx = self.Buffer.find("\n") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1784 |
if idx != -1: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1785 |
line = self.Buffer[:idx+1] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1786 |
self.Buffer = self.Buffer[idx+1:] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1787 |
if BMZ_DBG: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1788 |
print "command >"+line |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1789 |
return line |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1790 |
return "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1791 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1792 |
""" Base class for file like objects to facilitate StdOut for the Shell.""" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1793 |
def write(self, s, style = None): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1794 |
if s != '': |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1795 |
self.socket.send(s.encode('utf8')) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1796 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1797 |
def writeyield(self, s): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1798 |
self.write(s) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1799 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1800 |
def write_warning(self, s): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1801 |
self.write(s) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1802 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1803 |
def write_error(self, s): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1804 |
self.write(s) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1805 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1806 |
def flush(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1807 |
pass |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1808 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1809 |
def isatty(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1810 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1811 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1812 |
if __name__ == '__main__': |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1813 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1814 |
from threading import Thread, Timer, Semaphore |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1815 |
import cmd |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1816 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1817 |
wx_eval_lock = Semaphore(0) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1818 |
eval_res = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1819 |
def wx_evaluator(callable, *args, **kwargs): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1820 |
global eval_res |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1821 |
eval_res = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1822 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1823 |
eval_res=callable(*args,**kwargs) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1824 |
finally: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1825 |
wx_eval_lock.release() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1826 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1827 |
def evaluator(callable, *args, **kwargs): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1828 |
global eval_res |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1829 |
wx.CallAfter(wx_evaluator,callable,*args,**kwargs) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1830 |
wx_eval_lock.acquire() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1831 |
return eval_res |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1832 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1833 |
# Command log for debug, for viewing from wxInspector |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1834 |
if BMZ_DBG: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1835 |
__builtins__.cmdlog = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1836 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1837 |
class LPCBeremiz_Cmd(cmd.Cmd): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1838 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1839 |
prompt = "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1840 |
RefreshTimer = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1841 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1842 |
def __init__(self, CTR, Log): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1843 |
cmd.Cmd.__init__(self, stdin=Log, stdout=Log) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1844 |
self.use_rawinput = False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1845 |
self.Log = Log |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1846 |
self.CTR = CTR |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1847 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1848 |
def RestartTimer(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1849 |
if self.RefreshTimer is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1850 |
self.RefreshTimer.cancel() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1851 |
self.RefreshTimer = Timer(0.1, wx.CallAfter, args = [self.Refresh]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1852 |
self.RefreshTimer.start() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1853 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1854 |
def Exit(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1855 |
global frame, app |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1856 |
self.Close() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1857 |
app.ExitMainLoop() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1858 |
return True |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1859 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1860 |
def do_EOF(self, line): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1861 |
return self.Exit() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1862 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1863 |
def Show(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1864 |
global frame |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1865 |
if frame is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1866 |
self.CTR.SetAppFrame(frame, frame.Log) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1867 |
frame.Show() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1868 |
frame.Raise() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1869 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1870 |
def Refresh(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1871 |
global frame |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1872 |
if frame is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1873 |
frame._Refresh(TITLE, POUINSTANCEVARIABLESPANEL, FILEMENU, EDITMENU) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1874 |
frame.RefreshEditor() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1875 |
frame.RefreshAll() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1876 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1877 |
def Close(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1878 |
global frame |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1879 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1880 |
self.CTR.ResetAppFrame(self.Log) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1881 |
if frame is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1882 |
frame.Hide() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1883 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1884 |
def Compile(self): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1885 |
self.CTR._Build() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1886 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1887 |
def SetProjectProperties(self, projectname, productname, productversion, companyname): |
6
8863b78144ee
Fix bug when defining project properties from LPCComposer
Laurent Bessard
parents:
4
diff
changeset
|
1888 |
new_properties = { |
8863b78144ee
Fix bug when defining project properties from LPCComposer
Laurent Bessard
parents:
4
diff
changeset
|
1889 |
"projectName": projectname, |
8863b78144ee
Fix bug when defining project properties from LPCComposer
Laurent Bessard
parents:
4
diff
changeset
|
1890 |
"productName": productname, |
8863b78144ee
Fix bug when defining project properties from LPCComposer
Laurent Bessard
parents:
4
diff
changeset
|
1891 |
"productVersion": productversion, |
8863b78144ee
Fix bug when defining project properties from LPCComposer
Laurent Bessard
parents:
4
diff
changeset
|
1892 |
"companyName": companyname} |
8863b78144ee
Fix bug when defining project properties from LPCComposer
Laurent Bessard
parents:
4
diff
changeset
|
1893 |
self.CTR.SetProjectProperties(properties=new_properties, buffer=False) |
8863b78144ee
Fix bug when defining project properties from LPCComposer
Laurent Bessard
parents:
4
diff
changeset
|
1894 |
self.RestartTimer() |
0
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1895 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1896 |
def SetOnlineMode(self, mode, path=None): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1897 |
self.CTR.SetOnlineMode(mode, path) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1898 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1899 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1900 |
def AddBus(self, iec_channel, name, icon=None): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1901 |
for child in self.CTR.IterChildren(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1902 |
if child.BaseParams.getName() == name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1903 |
return "Error: A bus named %s already exists\n" % name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1904 |
elif child.BaseParams.getIEC_Channel() == iec_channel: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1905 |
return "Error: A bus with IEC_channel %d already exists\n" % iec_channel |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1906 |
bus = self.CTR.CTNAddChild(name, "LPCBus", iec_channel) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1907 |
if bus is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1908 |
return "Error: Unable to create bus\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1909 |
bus.SetIcon(icon) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1910 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1911 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1912 |
def RenameBus(self, iec_channel, name): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1913 |
bus = self.CTR.GetChildByIECLocation((iec_channel,)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1914 |
if bus is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1915 |
return "Error: No bus found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1916 |
for child in self.CTR.IterChildren(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1917 |
if child != bus and child.BaseParams.getName() == name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1918 |
return "Error: A bus named %s already exists\n" % name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1919 |
bus.BaseParams.setName(name) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1920 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1921 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1922 |
def ChangeBusIECChannel(self, old_iec_channel, new_iec_channel): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1923 |
bus = self.CTR.GetChildByIECLocation((old_iec_channel,)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1924 |
if bus is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1925 |
return "Error: No bus found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1926 |
for child in self.CTR.IterChildren(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1927 |
if child != bus and child.BaseParams.getIEC_Channel() == new_iec_channel: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1928 |
return "Error: A bus with IEC_channel %d already exists\n" % new_iec_channel |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1929 |
if wx.GetApp() is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1930 |
self.CTR.UpdateProjectVariableLocation(str(old_iec_channel), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1931 |
str(new_iec_channel)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1932 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1933 |
self.CTR.UpdateProjectVariableLocation( |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1934 |
str(old_iec_channel), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1935 |
str(new_iec_channel)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1936 |
bus.BaseParams.setIEC_Channel(new_iec_channel) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1937 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1938 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1939 |
def RemoveBus(self, iec_channel): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1940 |
bus = self.CTR.GetChildByIECLocation((iec_channel,)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1941 |
if bus is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1942 |
return "Error: No bus found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1943 |
self.CTR.RemoveProjectVariableByFilter(str(iec_channel)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1944 |
self.CTR.Children["LPCBus"].remove(bus) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1945 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1946 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1947 |
def AddModule(self, parent, iec_channel, name, icode, icon=None): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1948 |
module = self.CTR.GetChildByIECLocation(parent) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1949 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1950 |
return "Error: No parent found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1951 |
for child in _GetModuleChildren(module): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1952 |
if child["name"] == name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1953 |
return "Error: A module named %s already exists\n" % name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1954 |
elif child["IEC_Channel"] == iec_channel: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1955 |
return "Error: A module with IEC_channel %d already exists\n" % iec_channel |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1956 |
_GetLastModuleGroup(module).append({"name": name, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1957 |
"type": LOCATION_MODULE, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1958 |
"IEC_Channel": iec_channel, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1959 |
"icon": icon, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1960 |
"init": icode, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1961 |
"children": []}) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1962 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1963 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1964 |
def RenameModule(self, iec_location, name): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1965 |
module = self.CTR.GetChildByIECLocation(iec_location) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1966 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1967 |
return "Error: No module found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1968 |
parent = self.CTR.GetChildByIECLocation(iec_location[:-1]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1969 |
if parent is self.CTR: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1970 |
return "Error: No module found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1971 |
if module["name"] != name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1972 |
for child in _GetModuleChildren(parent): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1973 |
if child["name"] == name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1974 |
return "Error: A module named %s already exists\n" % name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1975 |
module["name"] = name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1976 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1977 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1978 |
def ChangeModuleIECChannel(self, old_iec_location, new_iec_channel): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1979 |
module = self.CTR.GetChildByIECLocation(old_iec_location) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1980 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1981 |
return "Error: No module found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1982 |
parent = self.CTR.GetChildByIECLocation(old_iec_location[:-1]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1983 |
if parent is self.CTR: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1984 |
return "Error: No module found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1985 |
if module["IEC_Channel"] != new_iec_channel: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1986 |
for child in _GetModuleChildren(parent): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1987 |
if child["IEC_Channel"] == new_iec_channel: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1988 |
return "Error: A module with IEC_channel %d already exists\n" % new_iec_channel |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1989 |
self.CTR.UpdateProjectVariableLocation(".".join(map(str, old_iec_location)), ".".join(map(str, old_iec_location[:1] + (new_iec_channel,)))) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1990 |
module["IEC_Channel"] = new_iec_channel |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1991 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1992 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1993 |
def ChangeModuleInitCode(self, iec_location, icode): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1994 |
module = self.CTR.GetChildByIECLocation(iec_location) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1995 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1996 |
return "Error: No module found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1997 |
module["init"] = icode |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1998 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
1999 |
def RemoveModule(self, parent, iec_channel): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2000 |
module = self.CTR.GetChildByIECLocation(parent) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2001 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2002 |
return "Error: No parent found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2003 |
child = _GetModuleBySomething(module, "IEC_Channel", (iec_channel,)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2004 |
if child is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2005 |
return "Error: No module found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2006 |
self.CTR.RemoveProjectVariableByFilter(".".join(map(str, parent + (iec_channel,)))) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2007 |
_RemoveModuleChild(module, child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2008 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2009 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2010 |
def StartGroup(self, parent, name, icon=None): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2011 |
module = self.CTR.GetChildByIECLocation(parent) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2012 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2013 |
return "Error: No parent found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2014 |
for child in module["children"]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2015 |
if child["type"] == LOCATION_GROUP and child["name"] == name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2016 |
return "Error: A group named %s already exists\n" % name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2017 |
module["children"].append({"name": name, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2018 |
"type": LOCATION_GROUP, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2019 |
"icon": icon, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2020 |
"children": []}) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2021 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2022 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2023 |
def AddVariable(self, parent, location, name, direction, type, rcode, pcode, description=""): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2024 |
module = self.CTR.GetChildByIECLocation(parent) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2025 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2026 |
return "Error: No parent found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2027 |
for child in _GetModuleChildren(module): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2028 |
if child["name"] == name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2029 |
return "Error: A variable named %s already exists\n" % name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2030 |
if child["location"] == location and child["type"] == LOCATION_TYPES[direction]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2031 |
return "Error: A variable with location %s already exists\n" % ".".join(map(str, location)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2032 |
_GetLastModuleGroup(module).append({"name": name, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2033 |
"location": location, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2034 |
"type": LOCATION_TYPES[direction], |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2035 |
"IEC_type": type, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2036 |
"description": description, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2037 |
"retrieve": rcode, |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2038 |
"publish": pcode}) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2039 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2040 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2041 |
def ChangeVariableParams(self, parent, location, new_name, new_direction, new_type, new_rcode, new_pcode, new_description=None): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2042 |
module = self.CTR.GetChildByIECLocation(parent) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2043 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2044 |
return "Error: No parent found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2045 |
variable = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2046 |
for child in _GetModuleChildren(module): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2047 |
if child["location"] == location and child["type"] == LOCATION_TYPES[new_direction]: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2048 |
variable = child |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2049 |
elif child["name"] == new_name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2050 |
return "Error: A variable named %s already exists\n" % new_name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2051 |
if variable is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2052 |
return "Error: No variable found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2053 |
if variable["name"] != new_name: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2054 |
self.CTR.UpdateProjectVariableName(variable["name"], new_name) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2055 |
variable["name"] = new_name |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2056 |
variable["type"] = LOCATION_TYPES[new_direction] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2057 |
variable["IEC_type"] = new_type |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2058 |
variable["retrieve"] = new_rcode |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2059 |
variable["publish"] = new_pcode |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2060 |
if new_description is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2061 |
variable["description"] = new_description |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2062 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2063 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2064 |
def RemoveVariable(self, parent, location, direction): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2065 |
module = self.CTR.GetChildByIECLocation(parent) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2066 |
if module is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2067 |
return "Error: No parent found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2068 |
child = _GetModuleVariable(module, location, direction) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2069 |
if child is None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2070 |
return "Error: No variable found\n" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2071 |
size = LOCATION_SIZES[self.CTR.GetBaseType(child["IEC_type"])] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2072 |
address = "%" + LOCATION_DIRS[child["type"]] + size + ".".join(map(str, parent + location)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2073 |
self.CTR.RemoveProjectVariableByAddress(address) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2074 |
_RemoveModuleChild(module, child) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2075 |
self.RestartTimer() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2076 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2077 |
def location(loc): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2078 |
return tuple(map(int, loc.split("."))) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2079 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2080 |
def GetCmdFunction(function, arg_types, opt=0): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2081 |
arg_number = len(arg_types) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2082 |
def CmdFunction(self, line): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2083 |
args_toks = line.split('"') |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2084 |
if len(args_toks) % 2 == 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2085 |
self.Log.write("Error: Invalid command\n") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2086 |
sys.stdout.flush() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2087 |
return |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2088 |
args = [] |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2089 |
for num, arg in enumerate(args_toks): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2090 |
if num % 2 == 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2091 |
stripped = arg.strip() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2092 |
if stripped: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2093 |
args.extend(stripped.split(" ")) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2094 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2095 |
args.append(arg) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2096 |
number = None |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2097 |
extra = "" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2098 |
if opt == 0 and len(args) != arg_number: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2099 |
number = arg_number |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2100 |
elif len(args) > arg_number: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2101 |
number = arg_number |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2102 |
extra = " at most" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2103 |
elif len(args) < arg_number - opt: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2104 |
number = arg_number - opt |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2105 |
extra = " at least" |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2106 |
if number is not None: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2107 |
if number == 0: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2108 |
self.Log.write("Error: No argument%s expected\n" % extra) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2109 |
elif number == 1: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2110 |
self.Log.write("Error: 1 argument%s expected\n" % extra) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2111 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2112 |
self.Log.write("Error: %d arguments%s expected\n" % (number, extra)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2113 |
sys.stdout.flush() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2114 |
return |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2115 |
for num, arg in enumerate(args): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2116 |
try: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2117 |
args[num] = arg_types[num](arg) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2118 |
except: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2119 |
self.Log.write("Error: Invalid value for argument %d\n" % (num + 1)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2120 |
sys.stdout.flush() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2121 |
return |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2122 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2123 |
func = getattr(self, function) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2124 |
res = evaluator(func,*args) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2125 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2126 |
if BMZ_DBG: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2127 |
cmdlog.append((function,line,res)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2128 |
if len(cmdlog) > 100: #prevent debug log to grow too much |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2129 |
cmdlog.pop(0) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2130 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2131 |
if isinstance(res, (StringType, UnicodeType)): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2132 |
self.Log.write(res) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2133 |
return False |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2134 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2135 |
return res |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2136 |
return CmdFunction |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2137 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2138 |
def CmdThreadProc(CTR, Log): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2139 |
global lpcberemiz_cmd |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2140 |
for function, (arg_types, opt) in {"Exit": ([], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2141 |
"Show": ([], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2142 |
"Refresh": ([], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2143 |
"Close": ([], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2144 |
"Compile": ([], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2145 |
"SetProjectProperties": ([str, str, str, str], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2146 |
"SetOnlineMode": ([str, str], 1), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2147 |
"AddBus": ([int, str, str], 1), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2148 |
"RenameBus": ([int, str], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2149 |
"ChangeBusIECChannel": ([int, int], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2150 |
"RemoveBus": ([int], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2151 |
"AddModule": ([location, int, str, str, str], 1), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2152 |
"RenameModule": ([location, str], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2153 |
"ChangeModuleIECChannel": ([location, int], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2154 |
"ChangeModuleInitCode": ([location, str], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2155 |
"RemoveModule": ([location, int], 0), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2156 |
"StartGroup": ([location, str, str], 1), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2157 |
"AddVariable": ([location, location, str, str, str, str, str, str], 1), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2158 |
"ChangeVariableParams": ([location, location, str, str, str, str, str, str], 1), |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2159 |
"RemoveVariable": ([location, location], 0)}.iteritems(): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2160 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2161 |
setattr(LPCBeremiz_Cmd, "do_%s" % function, GetCmdFunction(function, arg_types, opt)) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2162 |
lpcberemiz_cmd = LPCBeremiz_Cmd(CTR, Log) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2163 |
lpcberemiz_cmd.cmdloop() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2164 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2165 |
Log = StdoutPseudoFile(port) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2166 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2167 |
CTR = LPCProjectController(None, Log, buildpath) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2168 |
if projectOpen is not None and os.path.isdir(projectOpen): |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2169 |
result = CTR.LoadProject(projectOpen) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2170 |
if result: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2171 |
Log.write("Error: Invalid project directory", result) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2172 |
else: |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2173 |
Log.write("Error: No such file or directory") |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2174 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2175 |
cmd_thread=Thread(target=CmdThreadProc, args=[CTR, Log]) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2176 |
cmd_thread.start() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2177 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2178 |
# Install a exception handle for bug reports |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2179 |
AddExceptHook(os.getcwd(),__version__) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2180 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2181 |
frame = LPCBeremiz(None, ctr=CTR, debug=True) |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2182 |
|
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2183 |
app.MainLoop() |
51f5a3138405
Initial commit, LPC files taken out of beremiz revision 915be999f3f0
Edouard Tisserant
parents:
diff
changeset
|
2184 |