author | lbessard |
Wed, 25 Jun 2008 17:32:53 +0200 | |
changeset 172 | 8eefeccbd021 |
parent 165 | f9c6c9e36725 |
child 181 | f01bcc3c9157 |
permissions | -rw-r--r-- |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
1 |
import os, shutil, sys |
20 | 2 |
base_folder = os.path.split(sys.path[0])[0] |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
3 |
sys.path.append(os.path.join(base_folder, "wxsvg", "SVGUIEditor")) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
4 |
sys.path.append(os.path.join(base_folder, "plcopeneditor", "graphics")) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
5 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
6 |
import wx |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
7 |
|
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
8 |
from SVGUIGenerator import * |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
9 |
from SVGUIControler import * |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
10 |
from SVGUIEditor import * |
37 | 11 |
from FBD_Objects import * |
11 | 12 |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
13 |
from wxPopen import ProcessLogger |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
14 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
15 |
[ID_SVGUIEDITORFBDPANEL, |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
16 |
] = [wx.NewId() for _init_ctrls in range(1)] |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
17 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
18 |
SVGUIFB_Types = {ITEM_CONTAINER : "Container", |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
19 |
ITEM_BUTTON : "Button", |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
20 |
ITEM_TEXT : "TextCtrl", |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
21 |
ITEM_SCROLLBAR : "ScrollBar", |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
22 |
ITEM_ROTATING : "RotatingCtrl", |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
23 |
ITEM_NOTEBOOK : "NoteBook", |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
24 |
ITEM_TRANSFORM : "Transform"} |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
25 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
26 |
class _SVGUIEditor(SVGUIEditor): |
37 | 27 |
""" |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
28 |
This Class add IEC specific features to the SVGUIEditor : |
37 | 29 |
- FDB preview |
30 |
- FBD begin drag |
|
31 |
""" |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
32 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
33 |
def _init_coll_EditorGridSizer_Items(self, parent): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
34 |
SVGUIEditor._init_coll_EditorGridSizer_Items(self, parent) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
35 |
parent.AddWindow(self.FBDPanel, 0, border=0, flag=wx.GROW) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
36 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
37 |
def _init_ctrls(self, prnt): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
38 |
SVGUIEditor._init_ctrls(self, prnt, False) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
39 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
40 |
self.FBDPanel = wx.Panel(id=ID_SVGUIEDITORFBDPANEL, |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
41 |
name='FBDPanel', parent=self.EditorPanel, pos=wx.Point(0, 0), |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
42 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
43 |
self.FBDPanel.SetBackgroundColour(wx.WHITE) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
44 |
self.FBDPanel.Bind(wx.EVT_LEFT_DOWN, self.OnFBDPanelClick) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
45 |
self.FBDPanel.Bind(wx.EVT_PAINT, self.OnPaintFBDPanel) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
46 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
47 |
setattr(self.FBDPanel, "GetScaling", lambda: None) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
48 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
49 |
self._init_sizers() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
50 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
51 |
def __init__(self, parent, controler = None, fileOpen = None): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
52 |
SVGUIEditor.__init__(self, parent, controler, fileOpen) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
53 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
54 |
self.FBDBlock = None |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
55 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
56 |
def RefreshView(self, select_id = None): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
57 |
SVGUIEditor.RefreshView(self, select_id) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
58 |
self.FBDPanel.Refresh() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
59 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
60 |
def OnPaintFBDPanel(self,event): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
61 |
dc = wx.ClientDC(self.FBDPanel) |
37 | 62 |
dc.Clear() |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
63 |
selected = self.GetSelected() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
64 |
if selected is not None: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
65 |
selected_type = self.Controler.GetElementType(selected) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
66 |
if selected_type is not None: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
67 |
self.FBDBlock = FBD_Block(parent=self.FBDPanel,type=SVGUIFB_Types[selected_type],name=self.Controler.GetElementName(selected)) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
68 |
width, height = self.FBDBlock.GetMinSize() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
69 |
self.FBDBlock.SetSize(width,height) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
70 |
clientsize = self.FBDPanel.GetClientSize() |
37 | 71 |
x = (clientsize.width - width) / 2 |
72 |
y = (clientsize.height - height) / 2 |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
73 |
self.FBDBlock.SetPosition(x, y) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
74 |
self.FBDBlock.Draw(dc) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
75 |
else: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
76 |
self.FBDBlock = None |
37 | 77 |
event.Skip() |
78 |
||
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
79 |
def OnFBDPanelClick(self, event): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
80 |
if self.FBDBlock: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
81 |
data = wx.TextDataObject(str((self.FBDBlock.GetType(), "functionBlock", self.FBDBlock.GetName()))) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
82 |
DropSrc = wx.DropSource(self.FBDPanel) |
37 | 83 |
DropSrc.SetData(data) |
84 |
DropSrc.DoDragDrop() |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
85 |
event.Skip() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
86 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
87 |
def OnInterfaceTreeItemSelected(self, event): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
88 |
self.FBDPanel.Refresh() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
89 |
SVGUIEditor.OnInterfaceTreeItemSelected(self, event) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
90 |
|
37 | 91 |
def OnGenerate(self,event): |
92 |
self.SaveProject() |
|
93 |
self.Controler.PlugGenerate_C(sys.path[0],(0,0,4,5),None) |
|
94 |
event.Skip() |
|
95 |
||
96 |
TYPECONVERSION = {"BOOL" : "X", "SINT" : "B", "INT" : "W", "DINT" : "D", "LINT" : "L", |
|
97 |
"USINT" : "B", "UINT" : "W", "UDINT" : "D", "ULINT" : "L", "REAL" : "D", "LREAL" : "L", |
|
98 |
"STRING" : "B", "BYTE" : "B", "WORD" : "W", "DWORD" : "D", "LWORD" : "L", "WSTRING" : "W"} |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
99 |
|
44
1f5407c0263f
Various changes to make SVGUI plugin generated code eventually compile
etisserant
parents:
43
diff
changeset
|
100 |
CTYPECONVERSION = {"BOOL" : "IEC_BOOL", "UINT" : "IEC_UINT", "STRING" : "IEC_STRING", "REAL" : "IEC_REAL"} |
37 | 101 |
CPRINTTYPECONVERSION = {"BOOL" : "d", "UINT" : "d", "STRING" : "s", "REAL" : "f"} |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
102 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
103 |
class RootClass(SVGUIControler): |
37 | 104 |
|
38
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
105 |
def __init__(self): |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
106 |
SVGUIControler.__init__(self) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
107 |
filepath = os.path.join(self.PlugPath(), "gui.xml") |
37 | 108 |
|
12 | 109 |
if os.path.isfile(filepath): |
37 | 110 |
svgfile = os.path.join(self.PlugPath(), "gui.svg") |
111 |
if os.path.isfile(svgfile): |
|
112 |
self.SvgFilepath = svgfile |
|
12 | 113 |
self.OpenXMLFile(filepath) |
13
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
114 |
else: |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
115 |
self.CreateNewInterface() |
12 | 116 |
self.SetFilePath(filepath) |
117 |
||
158 | 118 |
def IsGUIPlugin(self): |
119 |
return True |
|
120 |
||
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
121 |
def GetElementIdFromName(self, name): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
122 |
element = self.GetElementByName(name) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
123 |
if element is not None: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
124 |
return element.getid() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
125 |
return None |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
126 |
|
38
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
127 |
_View = None |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
128 |
def _OpenView(self, logger): |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
129 |
if not self._View: |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
130 |
def _onclose(): |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
131 |
self._View = None |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
132 |
def _onsave(): |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
133 |
self.GetPlugRoot().SaveProject() |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
134 |
self._View = _SVGUIEditor(self.GetPlugRoot().AppFrame, self) |
38
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
135 |
self._View._onclose = _onclose |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
136 |
self._View._onsave = _onsave |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
137 |
self._View.Show() |
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
138 |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
139 |
def _ImportSVG(self, logger): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
140 |
if not self._View: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
141 |
dialog = wx.FileDialog(self.GetPlugRoot().AppFrame, "Choose a SVG file", os.getcwd(), "", "SVG files (*.svg)|*.svg|All files|*.*", wx.OPEN) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
142 |
if dialog.ShowModal() == wx.ID_OK: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
143 |
svgpath = dialog.GetPath() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
144 |
if os.path.isfile(svgpath): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
145 |
shutil.copy(svgpath, os.path.join(self.PlugPath(), "gui.svg")) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
146 |
else: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
147 |
logger.write_error("No such SVG file: %s\n"%svgpath) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
148 |
dialog.Destroy() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
149 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
150 |
def _ImportXML(self, logger): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
151 |
if not self._View: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
152 |
dialog = wx.FileDialog(self.GetPlugRoot().AppFrame, "Choose a XML file", os.getcwd(), "", "XML files (*.xml)|*.xml|All files|*.*", wx.OPEN) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
153 |
if dialog.ShowModal() == wx.ID_OK: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
154 |
xmlpath = dialog.GetPath() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
155 |
if os.path.isfile(xmlpath): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
156 |
shutil.copy(xmlpath, os.path.join(self.PlugPath(), "gui.xml")) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
157 |
else: |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
158 |
logger.write_error("No such XML file: %s\n"%xmlpath) |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
159 |
dialog.Destroy() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
160 |
|
65 | 161 |
PluginMethods = [ |
82
d7b4dd1f543f
Beremiz layout improved for wx2.8 by inserting all control in TreeCtrl
lbessard
parents:
73
diff
changeset
|
162 |
{"bitmap" : os.path.join("images","HMIEditor"), |
65 | 163 |
"name" : "HMI Editor", |
164 |
"tooltip" : "HMI Editor", |
|
105
434aed8dc58d
Added ability to override plugin methods with arbitrary python code (methods.py) when loading plugins
etisserant
parents:
82
diff
changeset
|
165 |
"method" : "_OpenView"}, |
82
d7b4dd1f543f
Beremiz layout improved for wx2.8 by inserting all control in TreeCtrl
lbessard
parents:
73
diff
changeset
|
166 |
{"bitmap" : os.path.join("images","ImportSVG"), |
65 | 167 |
"name" : "Import SVG", |
168 |
"tooltip" : "Import SVG", |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
169 |
"method" : "_ImportSVG"}, |
82
d7b4dd1f543f
Beremiz layout improved for wx2.8 by inserting all control in TreeCtrl
lbessard
parents:
73
diff
changeset
|
170 |
{"bitmap" : os.path.join("images","ImportDEF"), |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
171 |
"name" : "Import XML", |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
172 |
"tooltip" : "Import XML", |
139 | 173 |
"method" : "_ImportXML"}, |
65 | 174 |
] |
38
8cb20bc13a91
SVGUI's DefEditor now runs and generate C code. Swapped __I with __Q
etisserant
parents:
37
diff
changeset
|
175 |
|
37 | 176 |
def OnPlugSave(self): |
12 | 177 |
self.SaveXMLFile() |
178 |
return True |
|
37 | 179 |
|
180 |
def PlugGenerate_C(self, buildpath, locations, logger): |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
181 |
progname = "SVGUI_%s"%"_".join(map(str, self.GetCurrentLocation())) |
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
182 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
183 |
generator = _SVGUICGenerator(self.GetElementsByType(), self.GetSVGFilePath(), self.GetFilePath(), self.GetCurrentLocation()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
184 |
generator.GenerateProgram((0, 0), buildpath, progname) |
47
fd45c291fed0
PLC and plugins compilation with gcc now starts (and fail).
etisserant
parents:
44
diff
changeset
|
185 |
Gen_C_file = os.path.join(buildpath, progname+".cpp" ) |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
186 |
|
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
187 |
if wx.Platform == '__WXMSW__': |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
188 |
cxx_flags = "-I..\\..\\wxPython-src-2.8.7.1\\bld\\lib\\wx\\include\\msw-unicode-release-2.8 -I..\\..\\wxPython-src-2.8.7.1\\include -I..\\..\\wxPython-src-2.8.7.1\\contrib\\include -I..\\..\\matiec\\lib -DWXUSINGDLL -D__WXMSW__ -mthreads" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
189 |
libs = "\"..\\lib\\libwxsvg.a\" \"..\\lib\\libwxsvg_agg.a\" \"..\\lib\\libagg.a\" \"..\\lib\\libaggplatformwin32.a\" \"..\\lib\\libaggfontwin32tt.a\" -L..\\..\\wxPython-src-2.8.7.1\\bld\\lib -mno-cygwin -mwindows -mthreads -mno-cygwin -mwindows -Wl,--subsystem,windows -mwindows -lwx_mswu_richtext-2.8 -lwx_mswu_aui-2.8 -lwx_mswu_xrc-2.8 -lwx_mswu_qa-2.8 -lwx_mswu_html-2.8 -lwx_mswu_adv-2.8 -lwx_mswu_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
190 |
else: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
191 |
status, result, err_result = ProcessLogger(logger, "wx-config --cxxflags", no_stdout=True).spin() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
192 |
if status: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
193 |
logger.write_error("Unable to get wx cxxflags\n") |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
194 |
cxx_flags = result.strip() + " -I../matiec/lib" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
195 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
196 |
status, result, err_result = ProcessLogger(logger, "wx-config --libs", no_stdout=True).spin() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
197 |
if status: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
198 |
logger.write_error("Unable to get wx libs\n") |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
199 |
libs = result.strip() + " -lwxsvg" |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
200 |
|
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
201 |
return [(Gen_C_file, cxx_flags)],libs,True |
13
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
202 |
|
12 | 203 |
def BlockTypesFactory(self): |
73 | 204 |
def generate_svgui_block(generator, block, body, link, order=False): |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
205 |
name = block.getinstanceName() |
42 | 206 |
block_id = self.GetElementIdFromName(name) |
12 | 207 |
if block_id == None: |
208 |
raise ValueError, "No corresponding block found" |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
209 |
type = block.gettypeName() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
210 |
block_infos = GetBlockType(type) |
43 | 211 |
current_location = ".".join(map(str, self.GetCurrentLocation())) |
73 | 212 |
if not generator.ComputedBlocks.get(name, False) and not order: |
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
213 |
generator.ComputedBlocks[block] = True |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
214 |
for num, variable in enumerate(block.inputVariables.getvariable()): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
215 |
connections = variable.connectionPointIn.getconnections() |
12 | 216 |
if connections and len(connections) == 1: |
47
fd45c291fed0
PLC and plugins compilation with gcc now starts (and fail).
etisserant
parents:
44
diff
changeset
|
217 |
parameter = "%sQ%s%s.%d.%d"%("%", TYPECONVERSION[block_infos["inputs"][num][1]], current_location, block_id, num+1) |
12 | 218 |
value = generator.ComputeFBDExpression(body, connections[0]) |
219 |
generator.Program += (" %s := %s;\n"%(parameter, generator.ExtractModifier(variable, value))) |
|
220 |
if link: |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
221 |
connectionPoint = link.getposition()[-1] |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
222 |
for num, variable in enumerate(block.outputVariables.getvariable()): |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
223 |
blockPointx, blockPointy = variable.connectionPointOut.getrelPositionXY() |
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
224 |
if block.getx() + blockPointx == connectionPoint.getx() and block.gety() + blockPointy == connectionPoint.gety(): |
47
fd45c291fed0
PLC and plugins compilation with gcc now starts (and fail).
etisserant
parents:
44
diff
changeset
|
225 |
return "%sI%s%s.%d.%d"%("%", TYPECONVERSION[block_infos["outputs"][num][1]], current_location, block_id, num+1) |
12 | 226 |
raise ValueError, "No output variable found" |
227 |
else: |
|
228 |
return None |
|
11 | 229 |
|
138 | 230 |
def initialise_block(type, name, block = None): |
43 | 231 |
block_id = self.GetElementIdFromName(name) |
232 |
if block_id == None: |
|
233 |
raise ValueError, "No corresponding block found" |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
234 |
block_infos = GetBlockType(type) |
43 | 235 |
current_location = ".".join(map(str, self.GetCurrentLocation())) |
236 |
variables = [] |
|
138 | 237 |
if block is not None: |
238 |
input_variables = block.inputVariables.getvariable() |
|
239 |
output_variables = block.outputVariables.getvariable() |
|
240 |
else: |
|
241 |
input_variables = None |
|
242 |
output_variables = None |
|
43 | 243 |
for num, (input_name, input_type, input_modifier) in enumerate(block_infos["inputs"]): |
138 | 244 |
if input_variables is not None and num < len(input_variables): |
245 |
connections = input_variables[num].connectionPointIn.getconnections() |
|
246 |
if input_variables is None or connections and len(connections) == 1: |
|
247 |
variables.append((input_type, None, "%sQ%s%s.%d.%d"%("%", TYPECONVERSION[input_type], current_location, block_id, num+1), None)) |
|
43 | 248 |
for num, (output_name, output_type, output_modifier) in enumerate(block_infos["outputs"]): |
47
fd45c291fed0
PLC and plugins compilation with gcc now starts (and fail).
etisserant
parents:
44
diff
changeset
|
249 |
variables.append((output_type, None, "%sI%s%s.%d.%d"%("%", TYPECONVERSION[input_type], current_location, block_id, num+1), None)) |
43 | 250 |
return variables |
251 |
||
12 | 252 |
return [{"name" : "SVGUI function blocks", "list" : |
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
253 |
[{"name" : "Container", "type" : "functionBlock", "extensible" : False, |
138 | 254 |
"inputs" : [("Show","BOOL","none"),("Enable","BOOL","none")], |
255 |
"outputs" : [], |
|
42 | 256 |
"comment" : "SVGUI Container", |
43 | 257 |
"generate" : generate_svgui_block, "initialise" : initialise_block}, |
37 | 258 |
{"name" : "Button", "type" : "functionBlock", "extensible" : False, |
138 | 259 |
"inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("Toggle","BOOL","none")], |
260 |
"outputs" : [("State","BOOL","none")], |
|
42 | 261 |
"comment" : "SVGUI Button", |
43 | 262 |
"generate" : generate_svgui_block, "initialise" : initialise_block}, |
37 | 263 |
{"name" : "TextCtrl", "type" : "functionBlock", "extensible" : False, |
138 | 264 |
"inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetText","STRING","none")], |
265 |
"outputs" : [("Text","STRING","none")], |
|
42 | 266 |
"comment" : "SVGUI Text Control", |
43 | 267 |
"generate" : generate_svgui_block, "initialise" : initialise_block}, |
37 | 268 |
{"name" : "ScrollBar", "type" : "functionBlock", "extensible" : False, |
138 | 269 |
"inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetThumb","UINT","none"),("SetRange","UINT","none"),("SetPosition","UINT","none")], |
270 |
"outputs" : [("Position","UINT","none")], |
|
42 | 271 |
"comment" : "SVGUI ScrollBar", |
43 | 272 |
"generate" : generate_svgui_block, "initialise" : initialise_block}, |
37 | 273 |
{"name" : "NoteBook", "type" : "functionBlock", "extensible" : False, |
138 | 274 |
"inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetSelected","BOOL","none")], |
275 |
"outputs" : [("Selected","UINT","none")], |
|
42 | 276 |
"comment" : "SVGUI Notebook", |
43 | 277 |
"generate" : generate_svgui_block, "initialise" : initialise_block}, |
37 | 278 |
{"name" : "RotatingCtrl", "type" : "functionBlock", "extensible" : False, |
138 | 279 |
"inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetAngle","REAL","none")], |
280 |
"outputs" : [("Angle","REAL","none")], |
|
42 | 281 |
"comment" : "SVGUI Rotating Control", |
43 | 282 |
"generate" : generate_svgui_block, "initialise" : initialise_block}, |
37 | 283 |
{"name" : "Transform", "type" : "functionBlock", "extensible" : False, |
138 | 284 |
"inputs" : [("Show","BOOL","none"),("Enable","BOOL","none"),("SetX","REAL","none"),("SetY","REAL","none"),("SetXScale","REAL","none"),("SetYScale","REAL","none"),("SetAngle","REAL","none")], |
285 |
"outputs" : [("X","REAL","none"),("Y","REAL","none")], |
|
42 | 286 |
"comment" : "SVGUI Transform", |
43 | 287 |
"generate" : generate_svgui_block, "initialise" : initialise_block}, |
37 | 288 |
]} |
289 |
] |
|
137
187a4e2412e5
Modifying svgui plugin for following new SVGUIEditor version
lbessard
parents:
105
diff
changeset
|
290 |
|
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
291 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
292 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
293 |
class _SVGUICGenerator(SVGUICGenerator): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
294 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
295 |
def __init__(self, elements, svgfile, xmlfile, current_location): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
296 |
SVGUICGenerator.__init__(self, elements, svgfile, xmlfile) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
297 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
298 |
self.CurrentLocation = current_location |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
299 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
300 |
def GenerateProgramHeadersPublicVars(self): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
301 |
text = """ void OnPlcOutEvent(wxEvent& event); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
302 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
303 |
void Retrieve(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
304 |
void Publish(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
305 |
void Initialize(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
306 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
307 |
# text += " void Print();\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
308 |
return text |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
309 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
310 |
def GenerateIECVars(self): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
311 |
text = "" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
312 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
313 |
text += "STATE_TYPE out_state_%d;\n"%element.getid() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
314 |
text += "STATE_TYPE in_state_%d;\n"%element.getid() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
315 |
text +="\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
316 |
current_location = "_".join(map(str, self.CurrentLocation)) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
317 |
#Declaration des variables |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
318 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
319 |
block_infos = GetBlockType(SVGUIFB_Types[GetElementType(element)]) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
320 |
block_id = element.getid() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
321 |
for i, input in enumerate(block_infos["inputs"]): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
322 |
element_c_type = CTYPECONVERSION[input[1]] |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
323 |
variable = "__Q%s%s_%d_%d"%(TYPECONVERSION[input[1]], current_location, block_id, i + 1) |
165 | 324 |
text += "%s beremiz%s;\n"%(element_c_type, variable) |
325 |
text += "%s* %s = &beremiz%s;\n"%(element_c_type, variable, variable) |
|
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
326 |
text += "%s _copy%s;\n"%(element_c_type, variable) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
327 |
for i, output in enumerate(block_infos["outputs"]): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
328 |
element_c_type = CTYPECONVERSION[output[1]] |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
329 |
variable = "__I%s%s_%d_%d"%(TYPECONVERSION[output[1]], current_location, block_id, i + 1) |
165 | 330 |
text += "%s beremiz%s;\n"%(element_c_type, variable) |
331 |
text += "%s* %s = &beremiz%s;\n"%(element_c_type, variable, variable) |
|
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
332 |
text += "%s _copy%s;\n"%(element_c_type, variable) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
333 |
text +="\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
334 |
return text |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
335 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
336 |
def GenerateGlobalVarsAndFuncs(self, size): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
337 |
text = """#include \"iec_types.h\" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
338 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
339 |
#ifdef __WXMSW__ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
340 |
#define COMPARE_AND_SWAP_VAL(Destination, comparand, exchange) InterlockedCompareExchange(Destination, exchange, comparand) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
341 |
#define THREAD_RETURN_TYPE DWORD WINAPI |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
342 |
#define STATE_TYPE long int |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
343 |
#else |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
344 |
#define COMPARE_AND_SWAP_VAL(Destination, comparand, exchange) __sync_val_compare_and_swap(Destination, comparand, exchange) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
345 |
#define THREAD_RETURN_TYPE void* |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
346 |
#define STATE_TYPE volatile int |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
347 |
#endif |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
348 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
349 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
350 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
351 |
text += self.GenerateIECVars() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
352 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
353 |
text += """IMPLEMENT_APP_NO_MAIN(SVGViewApp); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
354 |
IMPLEMENT_WX_THEME_SUPPORT; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
355 |
SVGViewApp *myapp = NULL; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
356 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
357 |
#ifdef __WXMSW__ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
358 |
HANDLE wxMainLoop; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
359 |
DWORD wxMainLoopId; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
360 |
#else |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
361 |
pthread_t wxMainLoop; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
362 |
#endif |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
363 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
364 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
365 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
366 |
# text += "pthread_t wxMainLoop,automate;\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
367 |
text += """int myargc = 0; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
368 |
char** myargv = NULL; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
369 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
370 |
#define UNCHANGED 1 |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
371 |
#define PLC_BUSY 2 |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
372 |
#define CHANGED 3 |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
373 |
#define GUI_BUSY 4 |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
374 |
#ifdef __WXMSW__ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
375 |
#else |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
376 |
#endif |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
377 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
378 |
bool refresh = false; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
379 |
bool refreshing = false; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
380 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
381 |
THREAD_RETURN_TYPE InitWxEntry(void* args) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
382 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
383 |
wxEntry(myargc,myargv); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
384 |
return 0; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
385 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
386 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
387 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
388 |
# text += """void* SimulAutomate(void* args) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
389 |
#{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
390 |
# while(1){ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
391 |
# myapp->frame->m_svgCtrl->IN_"+self.BusNumber+"(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
392 |
# //printf(\"AUTOMATE\\n\"); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
393 |
# myapp->frame->m_svgCtrl->OUT_"+self.BusNumber+"(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
394 |
# sleep(1); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
395 |
# } |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
396 |
# return args; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
397 |
#} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
398 |
# |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
399 |
#""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
400 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
401 |
text += """bool SVGViewApp::OnInit() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
402 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
403 |
#ifndef __WXMSW__ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
404 |
setlocale(LC_NUMERIC, "C"); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
405 |
#endif |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
406 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
407 |
#text += " frame = new MainFrame(NULL, wxT(\"Program\"),wxDefaultPosition, wxSize(%d, %d));\n"%size |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
408 |
text += """ frame = new MainFrame(NULL, wxT("Program"),wxDefaultPosition, wxDefaultSize); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
409 |
frame->Show(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
410 |
myapp = this; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
411 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
412 |
# text += " pthread_create(&automate, NULL, SimulAutomate, NULL);\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
413 |
text += """ return true; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
414 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
415 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
416 |
extern "C" { |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
417 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
418 |
int __init_%(location)s(int argc, char** argv) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
419 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
420 |
myargc = argc; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
421 |
myargv = argv; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
422 |
#ifdef __WXMSW__ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
423 |
wxMainLoop = CreateThread(NULL, 0, InitWxEntry, 0, 0, &wxMainLoopId); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
424 |
#else |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
425 |
pthread_create(&wxMainLoop, NULL, InitWxEntry, NULL); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
426 |
#endif |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
427 |
return 0; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
428 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
429 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
430 |
void __cleanup_%(location)s() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
431 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
432 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
433 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
434 |
void __retrieve_%(location)s() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
435 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
436 |
if(myapp){ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
437 |
myapp->frame->m_svgCtrl->Retrieve(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
438 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
439 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
440 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
441 |
void __publish_%(location)s() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
442 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
443 |
if(myapp){ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
444 |
myapp->frame->m_svgCtrl->Publish(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
445 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
446 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
447 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
448 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
449 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
450 |
IEC_STRING wxStringToIEC_STRING(wxString s) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
451 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
452 |
IEC_STRING res = {0,""}; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
453 |
int i; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
454 |
for(i = 0; i<s.Length() && i<STR_MAX_LEN; i++) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
455 |
res.body[i] = s.GetChar(i); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
456 |
res.len = i; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
457 |
return res; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
458 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
459 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
460 |
"""%{"location" : "_".join(map(str, self.CurrentLocation))} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
461 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
462 |
return text |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
463 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
464 |
def GenerateProgramEventTable(self): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
465 |
text = """BEGIN_DECLARE_EVENT_TYPES() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
466 |
DECLARE_LOCAL_EVENT_TYPE( EVT_PLC, wxNewEventType() ) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
467 |
END_DECLARE_EVENT_TYPES() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
468 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
469 |
DEFINE_LOCAL_EVENT_TYPE( EVT_PLC ) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
470 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
471 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
472 |
#Event Table Declaration |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
473 |
text += "BEGIN_EVENT_TABLE(Program, SVGUIWindow)\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
474 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
475 |
element_type = GetElementType(element) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
476 |
element_name = element.getname() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
477 |
if element_type == ITEM_BUTTON: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
478 |
text += " EVT_BUTTON (SVGUIID(\"%s\"), Program::On%sClick)\n"%(element_name, element_name) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
479 |
elif element_type in [ITEM_SCROLLBAR, ITEM_ROTATING, ITEM_TRANSFORM]: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
480 |
text += " EVT_COMMAND_SCROLL_THUMBTRACK (SVGUIID(\"%s\"), Program::On%sChanging)\n"%(element_name, element_name) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
481 |
elif element_type == ITEM_NOTEBOOK: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
482 |
text += " EVT_NOTEBOOK_PAGE_CHANGED (SVGUIID(\"%s\"), Program::On%sTabChanged)\n"%(element_name, element_name) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
483 |
text += " EVT_CUSTOM(EVT_PLC, wxID_ANY, Program::OnPlcOutEvent)\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
484 |
text += "END_EVENT_TABLE()\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
485 |
return text |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
486 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
487 |
def GenerateProgramInitFrame(self): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
488 |
text = """MainFrame::MainFrame(wxWindow *parent, const wxString& title, const wxPoint& pos,const wxSize& size, long style): wxFrame(parent, wxID_ANY, title, pos, size, style) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
489 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
490 |
m_svgCtrl = new Program(this); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
491 |
if (m_svgCtrl->LoadFiles(wxT("%s"), wxT("%s"))) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
492 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
493 |
Show(true); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
494 |
m_svgCtrl->SetFocus(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
495 |
m_svgCtrl->SetFitToFrame(true); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
496 |
m_svgCtrl->RefreshScale(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
497 |
m_svgCtrl->InitScrollBars(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
498 |
m_svgCtrl->Initialize(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
499 |
m_svgCtrl->Update(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
500 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
501 |
else |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
502 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
503 |
printf("Error while opening files\\n"); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
504 |
exit(0); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
505 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
506 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
507 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
508 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
509 |
"""%(self.SVGFilePath, self.XMLFilePath) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
510 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
511 |
return text |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
512 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
513 |
def GenerateProgramInitProgram(self): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
514 |
text = "Program::Program(wxWindow* parent):SVGUIWindow(parent)\n{\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
515 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
516 |
text += " out_state_%d = UNCHANGED;\n"%element.getid() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
517 |
text += " in_state_%d = UNCHANGED;\n"%element.getid() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
518 |
text += "}\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
519 |
return text |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
520 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
521 |
def GenerateProgramEventFunctions(self): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
522 |
text = "" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
523 |
current_location = "_".join(map(str, self.CurrentLocation)) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
524 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
525 |
element_type = GetElementType(element) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
526 |
element_lock = """ if (COMPARE_AND_SWAP_VAL(&in_state_%d, CHANGED, GUI_BUSY) == CHANGED || |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
527 |
COMPARE_AND_SWAP_VAL(&in_state_%d, UNCHANGED, GUI_BUSY) == UNCHANGED) { |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
528 |
"""%(element.getid(), element.getid()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
529 |
element_unlock = """ COMPARE_AND_SWAP_VAL(&in_state_%d, GUI_BUSY, CHANGED); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
530 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
531 |
else |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
532 |
ProcessEvent(event); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
533 |
"""%element.getid() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
534 |
element_name = element.getname() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
535 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
536 |
if element_type == ITEM_BUTTON: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
537 |
text += """void Program::On%sClick(wxCommandEvent& event) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
538 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
539 |
SVGUIButton* button = (SVGUIButton*)GetElementByName(wxT("%s"));\n"""%(element_name, element_name) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
540 |
text += element_lock |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
541 |
text += " _copy__IX%s_%d_1 = button->GetToggle();\n"%(current_location, element.getid()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
542 |
text += element_unlock |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
543 |
text += " event.Skip();\n}\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
544 |
elif element_type == ITEM_ROTATING: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
545 |
text += """void Program::On%sChanging(wxScrollEvent& event) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
546 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
547 |
SVGUIRotatingCtrl* rotating = (SVGUIRotatingCtrl*)GetElementByName(wxT("%s")); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
548 |
"""%(element_name, element_name) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
549 |
text += element_lock |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
550 |
text += " _copy__ID%s_%d_1 = rotating->GetAngle();\n"%(current_location, element.getid()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
551 |
text += element_unlock |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
552 |
text += " event.Skip();\n}\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
553 |
elif element_type == ITEM_NOTEBOOK: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
554 |
text += """void Program::On%sTabChanged(wxNotebookEvent& event) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
555 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
556 |
SVGUINoteBook* notebook = (SVGUINoteBook*)GetElementByName(wxT("%s")); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
557 |
"""%(element_name, element_name) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
558 |
text += element_lock |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
559 |
text += " _copy__IB%s_%d_1 = notebook->GetCurrentPage();\n"%(current_location, element.getid()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
560 |
text += element_unlock |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
561 |
text += " event.Skip();\n}\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
562 |
elif element_type == ITEM_TRANSFORM: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
563 |
text += """void Program::On%sChanging(wxScrollEvent& event) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
564 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
565 |
SVGUITransform* transform = (SVGUITransform*)GetElementByName(wxT("%s")); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
566 |
"""%(element_name, element_name) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
567 |
text += element_lock |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
568 |
text += " _copy__ID%s_%d_1 = transform->GetX();\n"%(current_location, element.getid()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
569 |
text += " _copy__ID%s_%d_2 = transform->GetY();\n"%(current_location, element.getid()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
570 |
text += element_unlock |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
571 |
text += " event.Skip();\n}\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
572 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
573 |
text += "/* OnPlcOutEvent update GUI with provided IEC __Q* PLC output variables */\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
574 |
text += """void Program::OnPlcOutEvent(wxEvent& event) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
575 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
576 |
SVGUIElement* element; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
577 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
578 |
refreshing = true; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
579 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
580 |
wxMutexGuiEnter(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
581 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
582 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
583 |
element_type = GetElementType(element) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
584 |
texts = {"location" : current_location, "id" : element.getid()} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
585 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
586 |
text += """ if (COMPARE_AND_SWAP_VAL(&out_state_%(id)d, CHANGED, GUI_BUSY) == CHANGED) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
587 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
588 |
element = (SVGUIElement*)GetElementById(wxT("%(id)d")); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
589 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
590 |
if (_copy__QX%(location)s_%(id)d_1 != element->IsVisible()) { |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
591 |
if (_copy__QX%(location)s_%(id)d_1) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
592 |
element->Show(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
593 |
else |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
594 |
element->Hide(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
595 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
596 |
if (_copy__QX%(location)s_%(id)d_2 != element->IsEnabled()) { |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
597 |
if (_copy__QX%(location)s_%(id)d_2) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
598 |
element->Enable(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
599 |
else |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
600 |
element->Disable(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
601 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
602 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
603 |
if element_type == ITEM_BUTTON: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
604 |
text += """ if (_copy__QX%(location)s_%(id)d_3 != ((SVGUIButton*)element)->GetToggle()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
605 |
((SVGUIButton*)element)->SetToggle(_copy__QX%(location)s_%(id)d_3); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
606 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
607 |
elif element_type == ITEM_TEXT: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
608 |
text += """ if (((SVGUITextCtrl*)element)->GetValue().compare(_copy__QX%(location)s_%(id)d_3)) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
609 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
610 |
wxString str = wxString::FromAscii(_copy__QB%(location)s_%(id)d_3); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
611 |
((SVGUITextCtrl*)element)->SetText(str); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
612 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
613 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
614 |
elif element_type == ITEM_SCROLLBAR: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
615 |
text += """ if (_copy__QW%(location)s_%(id)d_3 != ((SVGUIScrollBar*)element)->GetThumbPosition() || |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
616 |
_copy__QW%(location)s_%(id)d_4 != ((SVGUIScrollBar*)element)->GetThumbSize() || |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
617 |
_copy__QW%(location)s_%(id)d_5 != ((SVGUIScrollBar*)element)->GetRange()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
618 |
((SVGUIScrollBar*)element)->Init_ScrollBar(_copy__QW%(location)s_%(id)d_3, _copy__QW%(location)s_%(id)d_4, _copy__QW%(location)s_%(id)d_5); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
619 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
620 |
elif element_type == ITEM_ROTATING: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
621 |
text += """ if (_copy__QD%(location)s_%(id)d_3 != ((SVGUIRotatingCtrl*)element)->GetAngle()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
622 |
((SVGUIRotatingCtrl*)element)->SetAngle(_copy__QD%(location)s_%(id)d_3); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
623 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
624 |
elif element_type == ITEM_NOTEBOOK: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
625 |
text += """ if (_copy__QB%(location)s_%(id)d_3 != ((SVGUINoteBook*)element)->GetCurrentPage()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
626 |
((SVGUINoteBook*)element)->SetCurrentPage(_copy__QB%(location)s_%(id)d_3); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
627 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
628 |
elif element_type == ITEM_TRANSFORM: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
629 |
text += """ if (_copy__QD%(location)s_%(id)d_3 != ((SVGUITransform*)element)->GetX() || |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
630 |
copy__QD%(location)s_%(id)d_4 != ((SVGUITransform*)element)->GetY()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
631 |
transform->Move(_copy__QD%(location)s_%(id)d_3, _copy__QD%(location)s_%(id)d_4); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
632 |
if (_copy__QD%(location)s_%(id)d_5 != ((SVGUITransform*)element)->GetXScale() || |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
633 |
copy__QD%(location)s_%(id)d_6 != ((SVGUITransform*)element)->GetYScale()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
634 |
transform->Scale(_copy__QD%(location)s_%(id)d_5, _copy__QD%(location)s_%(id)d_6); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
635 |
if (_copy__QD%(location)s_%(id)d_7 != ((SVGUITransform*)element)->GetAngle()) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
636 |
transform->Rotate(_copy__QD%(location)s_%(id)d_7); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
637 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
638 |
text += " COMPARE_AND_SWAP_VAL(&out_state_%(id)d, GUI_BUSY, UNCHANGED);\n }\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
639 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
640 |
text += """ wxMutexGuiLeave(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
641 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
642 |
refreshing = false; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
643 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
644 |
event.Skip(); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
645 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
646 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
647 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
648 |
return text |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
649 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
650 |
def GenerateProgramPrivateFunctions(self): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
651 |
current_location = "_".join(map(str, self.CurrentLocation)) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
652 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
653 |
text = "void Program::Retrieve()\n{\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
654 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
655 |
element_type = GetElementType(element) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
656 |
texts = {"location" : current_location, "id" : element.getid()} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
657 |
block_infos = GetBlockType(SVGUIFB_Types[GetElementType(element)]) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
658 |
if len(block_infos["outputs"]) > 0: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
659 |
text += """ if (COMPARE_AND_SWAP_VAL(&in_state_%(id)d, CHANGED, PLC_BUSY) == CHANGED) { |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
660 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
661 |
for i, output in enumerate(block_infos["outputs"]): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
662 |
texts["type"] = TYPECONVERSION[output[1]] |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
663 |
texts["pin"] = i + 1 |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
664 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
665 |
variable = "__I%(type)s%(location)s_%(id)d_%(pin)d"%texts |
165 | 666 |
text +=" beremiz%s = _copy%s;\n"%(variable, variable) |
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
667 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
668 |
text += """ COMPARE_AND_SWAP_VAL(&in_state_%(id)d, PLC_BUSY, UNCHANGED); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
669 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
670 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
671 |
text += "}\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
672 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
673 |
text += "void Program::Publish()\n{\n STATE_TYPE new_state;\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
674 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
675 |
element_type = GetElementType(element) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
676 |
texts = {"location" : current_location, "id" : element.getid()} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
677 |
block_infos = GetBlockType(SVGUIFB_Types[GetElementType(element)]) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
678 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
679 |
text += """ if ((new_state = COMPARE_AND_SWAP_VAL(&out_state_%(id)d, UNCHANGED, PLC_BUSY)) == UNCHANGED || |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
680 |
(new_state = COMPARE_AND_SWAP_VAL(&out_state_%(id)d, CHANGED, PLC_BUSY)) == CHANGED) { |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
681 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
682 |
for i, input in enumerate(block_infos["inputs"]): |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
683 |
texts["type"] = TYPECONVERSION[input[1]] |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
684 |
texts["pin"] = i + 1 |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
685 |
variable = "__Q%(type)s%(location)s_%(id)d_%(pin)d"%texts |
165 | 686 |
text += " if (_copy%s != beremiz%s) {\n"%(variable, variable) |
687 |
text += " _copy%s = beremiz%s;\n"%(variable, variable) |
|
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
688 |
text += " new_state = CHANGED;\n }\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
689 |
text += """ COMPARE_AND_SWAP_VAL(&out_state_%(id)d, PLC_BUSY, new_state); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
690 |
refresh |= new_state == CHANGED; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
691 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
692 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
693 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
694 |
text += """ /* Replace this with determinist signal if called from RT */ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
695 |
if (refresh && !refreshing) { |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
696 |
wxCommandEvent event( EVT_PLC ); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
697 |
ProcessEvent(event); |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
698 |
refresh = false; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
699 |
} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
700 |
}; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
701 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
702 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
703 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
704 |
text += """void Program::Initialize() |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
705 |
{ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
706 |
SVGUIElement* element; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
707 |
""" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
708 |
for element in self.Elements: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
709 |
element_type = GetElementType(element) |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
710 |
texts = {"location" : current_location, "id" : element.getid()} |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
711 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
712 |
text += """ |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
713 |
element = (SVGUIElement*)GetElementById(wxT("%(id)d")); |
165 | 714 |
beremiz__QX%(location)s_%(id)d_1 = 1; |
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
715 |
_copy__QX%(location)s_%(id)d_1 = 1; |
165 | 716 |
beremiz__QX%(location)s_%(id)d_2 = 1; |
147
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
717 |
_copy__QX%(location)s_%(id)d_2 = 1; |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
718 |
"""%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
719 |
if element_type == ITEM_BUTTON: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
720 |
text += " _copy__IX%(location)s_%(id)d_1 = ((SVGUIButton*)element)->GetToggle();\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
721 |
elif element_type == ITEM_TEXT: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
722 |
text += " _copy__IB%(location)s_%(id)d_1 = ((SVGUITextCtrl*)element)->GetValue();\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
723 |
elif element_type == ITEM_SCROLLBAR: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
724 |
text += " _copy__IW%(location)s_%(id)d_1 = ((SVGUIScrollBar*)element)->GetThumbPosition();\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
725 |
elif element_type == ITEM_ROTATING: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
726 |
text += " _copy__ID%(location)s_%(id)d_1 = ((SVGUIRotatingCtrl*)element)->GetAngle();\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
727 |
elif element_type == ITEM_NOTEBOOK: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
728 |
text += " _copy__IB%(location)s_%(id)d_1 = ((SVGUINoteBook*)element)->GetCurrentPage();\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
729 |
elif element_type == ITEM_TRANSFORM: |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
730 |
text += " _copy__ID%(location)s_%(id)d_1 = ((SVGUITransform*)element)->GetX();\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
731 |
text += " _copy__ID%(location)s_%(id)d_2 = ((SVGUITransform*)element)->GetY();\n"%texts |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
732 |
text += "}\n\n" |
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
733 |
|
ccc5e683583d
Improve svgui plugin for following SVGUIEditor modifications
lbessard
parents:
142
diff
changeset
|
734 |
return text |