author | Edouard Tisserant |
Tue, 29 Jan 2013 16:21:01 +1100 | |
changeset 911 | ffa24427396a |
parent 847 | b157705a9024 |
child 948 | 89fead207c35 |
permissions | -rw-r--r-- |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
1 |
import os, sys |
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
802
diff
changeset
|
2 |
|
20 | 3 |
base_folder = os.path.split(sys.path[0])[0] |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
47
diff
changeset
|
4 |
CanFestivalPath = os.path.join(base_folder, "CanFestival-3") |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
47
diff
changeset
|
5 |
sys.path.append(os.path.join(CanFestivalPath, "objdictgen")) |
20 | 6 |
|
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
802
diff
changeset
|
7 |
import wx |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
802
diff
changeset
|
8 |
|
11 | 9 |
from nodelist import NodeList |
10 |
from nodemanager import NodeManager |
|
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
11 |
import config_utils, gen_cfile, eds_utils |
12 | 12 |
from networkedit import networkedit |
77
7de69369373e
Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents:
65
diff
changeset
|
13 |
from objdictedit import objdictedit |
512
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
427
diff
changeset
|
14 |
import canfestival_config as local_canfestival_config |
725 | 15 |
from ConfigTreeNode import ConfigTreeNode |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
16 |
from commondialogs import CreateNodeDialog |
11 | 17 |
|
777 | 18 |
from SlaveEditor import SlaveEditor, MasterViewer |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
19 |
from NetworkEditor import NetworkEditor |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
20 |
|
77
7de69369373e
Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents:
65
diff
changeset
|
21 |
from gnosis.xml.pickle import * |
7de69369373e
Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents:
65
diff
changeset
|
22 |
from gnosis.xml.pickle.util import setParanoia |
7de69369373e
Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents:
65
diff
changeset
|
23 |
setParanoia(0) |
7de69369373e
Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents:
65
diff
changeset
|
24 |
|
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
802
diff
changeset
|
25 |
from util.TranslationCatalogs import AddCatalog |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
802
diff
changeset
|
26 |
AddCatalog(os.path.join(CanFestivalPath, "objdictgen", "locale")) |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
802
diff
changeset
|
27 |
|
411
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
28 |
if wx.Platform == '__WXMSW__': |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
29 |
DEFAULT_SETTINGS = { |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
30 |
"CAN_Driver": "can_tcp_win32", |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
31 |
"CAN_Device": "127.0.0.1", |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
32 |
"CAN_Baudrate": "125K", |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
33 |
"Slave_NodeId": 2, |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
34 |
"Master_NodeId": 1, |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
35 |
} |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
36 |
else: |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
37 |
DEFAULT_SETTINGS = { |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
38 |
"CAN_Driver": "../CanFestival-3/drivers/can_socket/libcanfestival_can_socket.so", |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
39 |
"CAN_Device": "vcan0", |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
40 |
"CAN_Baudrate": "125K", |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
41 |
"Slave_NodeId": 2, |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
42 |
"Master_NodeId": 1, |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
43 |
} |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
44 |
|
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
45 |
#-------------------------------------------------- |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
46 |
# SLAVE |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
47 |
#-------------------------------------------------- |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
48 |
|
718 | 49 |
class _SlaveCTN(NodeManager): |
12 | 50 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
51 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
166 | 52 |
<xsd:element name="CanFestivalSlaveNode"> |
12 | 53 |
<xsd:complexType> |
411
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
54 |
<xsd:attribute name="CAN_Device" type="xsd:string" use="optional" default="%(CAN_Device)s"/> |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
55 |
<xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/> |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
56 |
<xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="%(Slave_NodeId)d"/> |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
57 |
<xsd:attribute name="Sync_Align" type="xsd:integer" use="optional" default="0"/> |
203 | 58 |
<xsd:attribute name="Sync_Align_Ratio" use="optional" default="50"> |
59 |
<xsd:simpleType> |
|
60 |
<xsd:restriction base="xsd:integer"> |
|
61 |
<xsd:minInclusive value="1"/> |
|
62 |
<xsd:maxInclusive value="99"/> |
|
63 |
</xsd:restriction> |
|
64 |
</xsd:simpleType> |
|
65 |
</xsd:attribute> |
|
12 | 66 |
</xsd:complexType> |
67 |
</xsd:element> |
|
68 |
</xsd:schema> |
|
411
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
69 |
""" % DEFAULT_SETTINGS |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
70 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
71 |
EditorType = SlaveEditor |
738 | 72 |
IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png") |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
73 |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
15
diff
changeset
|
74 |
def __init__(self): |
23 | 75 |
# TODO change netname when name change |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
76 |
NodeManager.__init__(self) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
77 |
odfilepath = self.GetSlaveODPath() |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
78 |
if(os.path.isfile(odfilepath)): |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
79 |
self.OpenFileInCurrent(odfilepath) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
80 |
else: |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
81 |
self.FilePath = "" |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
82 |
dialog = CreateNodeDialog(None, wx.OK) |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
83 |
dialog.Type.Enable(False) |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
84 |
dialog.GenSYNC.Enable(False) |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
85 |
if dialog.ShowModal() == wx.ID_OK: |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
86 |
name, id, nodetype, description = dialog.GetValues() |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
87 |
profile, filepath = dialog.GetProfile() |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
88 |
NMT = dialog.GetNMTManagement() |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
89 |
options = dialog.GetOptions() |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
90 |
self.CreateNewNode(name, # Name - will be changed at build time |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
91 |
id, # NodeID - will be changed at build time |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
92 |
"slave", # Type |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
93 |
description,# description |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
94 |
profile, # profile |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
95 |
filepath, # prfile filepath |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
96 |
NMT, # NMT |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
97 |
options) # options |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
98 |
else: |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
99 |
self.CreateNewNode("SlaveNode", # Name - will be changed at build time |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
100 |
0x00, # NodeID - will be changed at build time |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
101 |
"slave", # Type |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
102 |
"", # description |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
103 |
"None", # profile |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
104 |
"", # prfile filepath |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
105 |
"heartbeat", # NMT |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
106 |
[]) # options |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
107 |
dialog.Destroy() |
718 | 108 |
self.OnCTNSave() |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
109 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
110 |
def GetCurrentNodeName(self): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
111 |
return self.CTNName() |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
112 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
113 |
def GetSlaveODPath(self): |
718 | 114 |
return os.path.join(self.CTNPath(), 'slave.od') |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
115 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
116 |
def GetCanDevice(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
117 |
return self.CanFestivalSlaveNode.getCan_Device() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
118 |
|
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
119 |
def _OpenView(self, name=None, onlyopened=False): |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
120 |
ConfigTreeNode._OpenView(self, name, onlyopened) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
121 |
if self._View is not None: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
122 |
self._View.SetBusId(self.GetCurrentLocation()) |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
123 |
return self._View |
777 | 124 |
|
125 |
def _ExportSlave(self): |
|
847
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
126 |
dialog = wx.FileDialog(self.GetCTRoot().AppFrame, |
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
127 |
_("Choose a file"), |
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
128 |
os.path.expanduser("~"), |
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
129 |
"%s.eds" % self.CTNName(), |
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
130 |
_("EDS files (*.eds)|*.eds|All files|*.*"), |
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
131 |
wx.SAVE|wx.OVERWRITE_PROMPT) |
777 | 132 |
if dialog.ShowModal() == wx.ID_OK: |
133 |
result = eds_utils.GenerateEDSFile(dialog.GetPath(), self.GetCurrentNodeCopy()) |
|
134 |
if result: |
|
135 |
self.GetCTRoot().logger.write_error(_("Error: Export slave failed\n")) |
|
136 |
dialog.Destroy() |
|
137 |
||
717 | 138 |
ConfNodeMethods = [ |
777 | 139 |
{"bitmap" : "ExportSlave", |
140 |
"name" : _("Export slave"), |
|
141 |
"tooltip" : _("Export CanOpen slave to EDS file"), |
|
142 |
"method" : "_ExportSlave"}, |
|
65 | 143 |
] |
777 | 144 |
|
718 | 145 |
def CTNTestModified(self): |
166 | 146 |
return self.ChangesToSave or self.OneFileHasChanged() |
12 | 147 |
|
718 | 148 |
def OnCTNSave(self): |
166 | 149 |
return self.SaveCurrentInFile(self.GetSlaveODPath()) |
12 | 150 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
151 |
def SetParamsAttribute(self, path, value): |
717 | 152 |
result = ConfigTreeNode.SetParamsAttribute(self, path, value) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
153 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
154 |
# Filter IEC_Channel and Name, that have specific behavior |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
155 |
if path == "BaseParams.IEC_Channel" and self._View is not None: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
156 |
self._View.SetBusId(self.GetCurrentLocation()) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
157 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
158 |
return result |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
159 |
|
718 | 160 |
def CTNGenerate_C(self, buildpath, locations): |
12 | 161 |
""" |
15
7a473efc4530
More precise design for plugins.... to be continued...
etisserant
parents:
13
diff
changeset
|
162 |
Generate C code |
717 | 163 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
15
7a473efc4530
More precise design for plugins.... to be continued...
etisserant
parents:
13
diff
changeset
|
164 |
@param locations: List of complete variables locations \ |
22 | 165 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
166 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
|
167 |
"DIR" : direction "Q","I" or "M" |
|
168 |
"SIZE" : size "X", "B", "W", "D", "L" |
|
169 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
|
170 |
}, ...] |
|
171 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
|
12 | 172 |
""" |
24 | 173 |
current_location = self.GetCurrentLocation() |
22 | 174 |
# define a unique name for the generated C file |
166 | 175 |
prefix = "_".join(map(str, current_location)) |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
47
diff
changeset
|
176 |
Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix ) |
166 | 177 |
# Create a new copy of the model |
178 |
slave = self.GetCurrentNodeCopy() |
|
179 |
slave.SetNodeName("OD_%s"%prefix) |
|
180 |
# allow access to local OD from Slave PLC |
|
181 |
pointers = config_utils.LocalODPointers(locations, current_location, slave) |
|
182 |
res = gen_cfile.GenerateFile(Gen_OD_path, slave, pointers) |
|
15
7a473efc4530
More precise design for plugins.... to be continued...
etisserant
parents:
13
diff
changeset
|
183 |
if res : |
7a473efc4530
More precise design for plugins.... to be continued...
etisserant
parents:
13
diff
changeset
|
184 |
raise Exception, res |
172
8eefeccbd021
Adding support for modification in CanFestival eds_utils
lbessard
parents:
169
diff
changeset
|
185 |
res = eds_utils.GenerateEDSFile(os.path.join(buildpath, "Slave_%s.eds"%prefix), slave) |
8eefeccbd021
Adding support for modification in CanFestival eds_utils
lbessard
parents:
169
diff
changeset
|
186 |
if res : |
8eefeccbd021
Adding support for modification in CanFestival eds_utils
lbessard
parents:
169
diff
changeset
|
187 |
raise Exception, res |
512
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
427
diff
changeset
|
188 |
return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
189 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
190 |
def LoadPrevious(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
191 |
self.LoadCurrentPrevious() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
192 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
193 |
def LoadNext(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
194 |
self.LoadCurrentNext() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
195 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
196 |
def GetBufferState(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
197 |
return self.GetCurrentBufferState() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
198 |
|
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
199 |
#-------------------------------------------------- |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
200 |
# MASTER |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
201 |
#-------------------------------------------------- |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
202 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
203 |
class MiniNodeManager(NodeManager): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
204 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
205 |
def __init__(self, parent, filepath, fullname): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
206 |
NodeManager.__init__(self) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
207 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
208 |
self.OpenFileInCurrent(filepath) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
209 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
210 |
self.Parent = parent |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
211 |
self.Fullname = fullname |
777 | 212 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
777
diff
changeset
|
213 |
def GetIconName(self): |
777 | 214 |
return None |
215 |
||
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
216 |
def OnCloseEditor(self, view): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
217 |
self.Parent.OnCloseEditor(view) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
218 |
|
718 | 219 |
def CTNFullName(self): |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
220 |
return self.Fullname |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
221 |
|
777 | 222 |
def CTNTestModified(self): |
223 |
return False |
|
224 |
||
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
225 |
def GetBufferState(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
226 |
return self.GetCurrentBufferState() |
777 | 227 |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
228 |
ConfNodeMethods = [] |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
229 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
230 |
class _NodeManager(NodeManager): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
231 |
|
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
232 |
def __init__(self, parent, *args, **kwargs): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
233 |
NodeManager.__init__(self, *args, **kwargs) |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
234 |
self.Parent = parent |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
235 |
|
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
236 |
def __del__(self): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
237 |
self.Parent = None |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
238 |
|
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
239 |
def GetCurrentNodeName(self): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
240 |
return self.Parent.CTNName() |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
241 |
|
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
242 |
def GetCurrentNodeID(self): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
243 |
return self.Parent.CanFestivalNode.getNodeId() |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
244 |
|
718 | 245 |
class _NodeListCTN(NodeList): |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
246 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
247 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
248 |
<xsd:element name="CanFestivalNode"> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
249 |
<xsd:complexType> |
411
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
250 |
<xsd:attribute name="CAN_Device" type="xsd:string" use="optional" default="%(CAN_Device)s"/> |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
251 |
<xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/> |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
252 |
<xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="%(Master_NodeId)d"/> |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
253 |
<xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
254 |
</xsd:complexType> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
255 |
</xsd:element> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
256 |
</xsd:schema> |
411
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
257 |
""" % DEFAULT_SETTINGS |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
258 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
259 |
EditorType = NetworkEditor |
738 | 260 |
IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png") |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
261 |
|
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
262 |
def __init__(self): |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
263 |
manager = _NodeManager(self) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
264 |
NodeList.__init__(self, manager) |
718 | 265 |
self.LoadProject(self.CTNPath()) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
266 |
self.SetNetworkName(self.BaseParams.getName()) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
267 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
268 |
def GetCanDevice(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
269 |
return self.CanFestivalNode.getCan_Device() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
270 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
271 |
def SetParamsAttribute(self, path, value): |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
272 |
if path == "CanFestivalNode.NodeId": |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
273 |
nodeid = self.CanFestivalNode.getNodeId() |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
274 |
if value != nodeid: |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
275 |
slaves = self.GetSlaveIDs() |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
276 |
dir = (value - nodeid) / abs(value - nodeid) |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
277 |
while value in slaves and value >= 0: |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
278 |
value += dir |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
279 |
if value < 0: |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
280 |
value = nodeid |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
281 |
|
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
282 |
value, refresh = ConfigTreeNode.SetParamsAttribute(self, path, value) |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
283 |
refresh_network = False |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
284 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
285 |
# Filter IEC_Channel and Name, that have specific behavior |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
286 |
if path == "BaseParams.IEC_Channel" and self._View is not None: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
287 |
self._View.SetBusId(self.GetCurrentLocation()) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
288 |
elif path == "BaseParams.Name": |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
289 |
self.SetNetworkName(value) |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
290 |
refresh_network = True |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
291 |
elif path == "CanFestivalNode.NodeId": |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
292 |
refresh_network = True |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
293 |
|
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
294 |
if refresh_network and self._View is not None: |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
295 |
wx.CallAfter(self._View.RefreshBufferState) |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
296 |
return value, refresh |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
297 |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
298 |
_GeneratedMasterView = None |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
299 |
def _ShowGeneratedMaster(self): |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
300 |
self._OpenView("Generated master") |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
301 |
|
782 | 302 |
def _OpenView(self, name=None, onlyopened=False): |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
303 |
if name == "Generated master": |
782 | 304 |
app_frame = self.GetCTRoot().AppFrame |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
305 |
if self._GeneratedMasterView is None: |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
306 |
buildpath = self._getBuildPath() |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
307 |
# Eventually create build dir |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
308 |
if not os.path.exists(buildpath): |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
309 |
self.GetCTRoot().logger.write_error(_("Error: No PLC built\n")) |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
310 |
return |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
311 |
|
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
312 |
masterpath = os.path.join(buildpath, "MasterGenerated.od") |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
313 |
if not os.path.exists(masterpath): |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
314 |
self.GetCTRoot().logger.write_error(_("Error: No Master generated\n")) |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
315 |
return |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
316 |
|
847
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
317 |
manager = MiniNodeManager(self, masterpath, self.CTNFullName()) |
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
318 |
self._GeneratedMasterView = MasterViewer(app_frame.TabsOpened, manager, app_frame, name) |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
319 |
|
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
320 |
if self._GeneratedMasterView is not None: |
847
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
321 |
app_frame.EditProjectElement(self._GeneratedMasterView, self._GeneratedMasterView.GetInstancePath()) |
782 | 322 |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
323 |
return self._GeneratedMasterView |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
324 |
else: |
782 | 325 |
ConfigTreeNode._OpenView(self, name, onlyopened) |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
326 |
if self._View is not None: |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
327 |
self._View.SetBusId(self.GetCurrentLocation()) |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
328 |
return self._View |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
329 |
|
717 | 330 |
ConfNodeMethods = [ |
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
331 |
{"bitmap" : "ShowMaster", |
372
35cc4c6a2936
Added ShowMaster button icon for Canfestival plugin
edouard
parents:
361
diff
changeset
|
332 |
"name" : _("Show Master"), |
361 | 333 |
"tooltip" : _("Show Master generated by config_utils"), |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
334 |
"method" : "_ShowGeneratedMaster"} |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
335 |
] |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
336 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
337 |
def OnCloseEditor(self, view): |
717 | 338 |
ConfigTreeNode.OnCloseEditor(self, view) |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
339 |
if self._GeneratedMasterView == view: |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
340 |
self._GeneratedMasterView = None |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
341 |
|
718 | 342 |
def OnCTNClose(self): |
343 |
ConfigTreeNode.OnCTNClose(self) |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
344 |
self._CloseView(self._GeneratedMasterView) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
345 |
return True |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
346 |
|
718 | 347 |
def CTNTestModified(self): |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
348 |
return self.ChangesToSave or self.HasChanged() |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
349 |
|
718 | 350 |
def OnCTNSave(self): |
351 |
self.SetRoot(self.CTNPath()) |
|
250 | 352 |
return self.SaveProject() is None |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
353 |
|
718 | 354 |
def CTNGenerate_C(self, buildpath, locations): |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
355 |
""" |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
356 |
Generate C code |
717 | 357 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
358 |
@param locations: List of complete variables locations \ |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
359 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
360 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
361 |
"DIR" : direction "Q","I" or "M" |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
362 |
"SIZE" : size "X", "B", "W", "D", "L" |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
363 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
364 |
}, ...] |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
365 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
366 |
""" |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
367 |
self._CloseView(self._GeneratedMasterView) |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
368 |
current_location = self.GetCurrentLocation() |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
369 |
# define a unique name for the generated C file |
166 | 370 |
prefix = "_".join(map(str, current_location)) |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
371 |
Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix ) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
372 |
# Create a new copy of the model with DCF loaded with PDO mappings for desired location |
341 | 373 |
try: |
374 |
master, pointers = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(),"OD_%s"%prefix) |
|
375 |
except config_utils.PDOmappingException, e: |
|
376 |
raise Exception, e.message |
|
166 | 377 |
# Do generate C file. |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
378 |
res = gen_cfile.GenerateFile(Gen_OD_path, master, pointers) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
379 |
if res : |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
380 |
raise Exception, res |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
381 |
|
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
382 |
file = open(os.path.join(buildpath, "MasterGenerated.od"), "w") |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
383 |
dump(master, file) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
384 |
file.close() |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
385 |
|
512
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
427
diff
changeset
|
386 |
return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False |
12 | 387 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
388 |
def LoadPrevious(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
389 |
self.Manager.LoadCurrentPrevious() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
390 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
391 |
def LoadNext(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
392 |
self.Manager.LoadCurrentNext() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
393 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
394 |
def GetBufferState(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
395 |
return self.Manager.GetCurrentBufferState() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
396 |
|
13
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
397 |
class RootClass: |
12 | 398 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
399 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
400 |
<xsd:element name="CanFestivalInstance"> |
|
401 |
<xsd:complexType> |
|
411
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
402 |
<xsd:attribute name="CAN_Driver" type="xsd:string" use="optional" default="%(CAN_Driver)s"/> |
157 | 403 |
<xsd:attribute name="Debug_mode" type="xsd:boolean" use="optional" default="false"/> |
12 | 404 |
</xsd:complexType> |
405 |
</xsd:element> |
|
406 |
</xsd:schema> |
|
411
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
407 |
""" % DEFAULT_SETTINGS |
8261c8f1e365
Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents:
372
diff
changeset
|
408 |
|
718 | 409 |
CTNChildrenTypes = [("CanOpenNode",_NodeListCTN, "CanOpen Master"), |
410 |
("CanOpenSlave",_SlaveCTN, "CanOpen Slave")] |
|
95
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
411 |
def GetParamsAttributes(self, path = None): |
717 | 412 |
infos = ConfigTreeNode.GetParamsAttributes(self, path = None) |
95
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
413 |
for element in infos: |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
414 |
if element["name"] == "CanFestivalInstance": |
95
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
415 |
for child in element["children"]: |
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
416 |
if child["name"] == "CAN_Driver": |
512
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
427
diff
changeset
|
417 |
DLL_LIST= getattr(local_canfestival_config,"DLL_LIST",None) |
95
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
418 |
if DLL_LIST is not None: |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
419 |
child["type"] = DLL_LIST |
95
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
420 |
return infos |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
421 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
422 |
def GetCanDriver(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
423 |
can_driver = self.CanFestivalInstance.getCAN_Driver() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
424 |
if sys.platform == 'win32': |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
425 |
if self.CanFestivalInstance.getDebug_mode() and os.path.isfile(os.path.join("%s"%(can_driver + '_DEBUG.dll'))): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
426 |
can_driver += '_DEBUG.dll' |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
427 |
else: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
428 |
can_driver += '.dll' |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
429 |
return can_driver |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
430 |
|
718 | 431 |
def CTNGenerate_C(self, buildpath, locations): |
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
432 |
|
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
433 |
format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())), |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
434 |
"candriver" : self.GetCanDriver(), |
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
435 |
"nodes_includes" : "", |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
436 |
"board_decls" : "", |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
437 |
"nodes_init" : "", |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
438 |
"nodes_open" : "", |
336
ae3488c79283
Fixed bug : Segmentation fault or locks when stop PLC if no CAN network.
greg
parents:
307
diff
changeset
|
439 |
"nodes_stop" : "", |
57 | 440 |
"nodes_close" : "", |
441 |
"nodes_send_sync" : "", |
|
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
442 |
"nodes_proceed_sync" : "", |
174 | 443 |
"slavebootups" : "", |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
444 |
"slavebootup_register" : "", |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
445 |
"post_sync" : "", |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
446 |
"post_sync_register" : "", |
778 | 447 |
"pre_op" : "", |
448 |
"pre_op_register" : "", |
|
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
449 |
} |
718 | 450 |
for child in self.IECSortedChildren(): |
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
451 |
childlocstr = "_".join(map(str,child.GetCurrentLocation())) |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
452 |
nodename = "OD_%s" % childlocstr |
166 | 453 |
|
454 |
# Try to get Slave Node |
|
455 |
child_data = getattr(child, "CanFestivalSlaveNode", None) |
|
456 |
if child_data is None: |
|
457 |
# Not a slave -> master |
|
458 |
child_data = getattr(child, "CanFestivalNode") |
|
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
459 |
# Apply sync setting |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
460 |
format_dict["nodes_init"] += 'NODE_MASTER_INIT(%s, %s)\n '%( |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
461 |
nodename, |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
462 |
child_data.getNodeId()) |
166 | 463 |
if child_data.getSync_TPDOs(): |
464 |
format_dict["nodes_send_sync"] += 'NODE_SEND_SYNC(%s)\n '%(nodename) |
|
465 |
format_dict["nodes_proceed_sync"] += 'NODE_PROCEED_SYNC(%s)\n '%(nodename) |
|
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
466 |
|
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
467 |
# initialize and declare node boot status variables for post_SlaveBootup lookup |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
468 |
SlaveIDs = child.GetSlaveIDs() |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
469 |
if len(SlaveIDs) == 0: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
470 |
# define post_SlaveBootup lookup functions |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
471 |
format_dict["slavebootups"] += ( |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
472 |
"static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){}\n"%(nodename)) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
473 |
else: |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
474 |
format_dict["slavebootups"] += ( |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
475 |
"static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){\n"%(nodename)+ |
776
c81397b665b6
Fixed generated CF code to match latest changes
Edouard Tisserant
parents:
774
diff
changeset
|
476 |
" check_and_start_node(d, nodeId);\n"+ |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
477 |
"}\n") |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
478 |
# register previously declared func as post_SlaveBootup callback for that node |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
479 |
format_dict["slavebootup_register"] += ( |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
480 |
"%s_Data.post_SlaveBootup = %s_post_SlaveBootup;\n"%(nodename,nodename)) |
779 | 481 |
format_dict["pre_op"] += ( |
482 |
"static void %s_preOperational(CO_Data* d){\n "%(nodename)+ |
|
483 |
"".join([" masterSendNMTstateChange(d, %d, NMT_Reset_Comunication);\n"%NdId for NdId in SlaveIDs])+ |
|
484 |
"}\n") |
|
485 |
format_dict["pre_op_register"] += ( |
|
486 |
"%s_Data.preOperational = %s_preOperational;\n"%(nodename,nodename)) |
|
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
487 |
else: |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
488 |
# Slave node |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
489 |
align = child_data.getSync_Align() |
203 | 490 |
align_ratio=child_data.getSync_Align_Ratio() |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
491 |
if align > 0: |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
492 |
format_dict["post_sync"] += ( |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
493 |
"static int %s_CalCount = 0;\n"%(nodename)+ |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
494 |
"static void %s_post_sync(CO_Data* d){\n"%(nodename)+ |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
495 |
" if(%s_CalCount < %d){\n"%(nodename, align)+ |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
496 |
" %s_CalCount++;\n"%(nodename)+ |
203 | 497 |
" align_tick(-1);\n"+ |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
498 |
" }else{\n"+ |
203 | 499 |
" align_tick(%d);\n"%(align_ratio)+ |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
500 |
" }\n"+ |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
501 |
"}\n") |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
502 |
format_dict["post_sync_register"] += ( |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
503 |
"%s_Data.post_sync = %s_post_sync;\n"%(nodename,nodename)) |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
504 |
format_dict["nodes_init"] += 'NODE_SLAVE_INIT(%s, %s)\n '%( |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
505 |
nodename, |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
506 |
child_data.getNodeId()) |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
507 |
|
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
508 |
# Include generated OD headers |
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
509 |
format_dict["nodes_includes"] += '#include "%s.h"\n'%(nodename) |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
510 |
# Declare CAN channels according user filled config |
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
511 |
format_dict["board_decls"] += 'BOARD_DECL(%s, "%s", "%s")\n'%( |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
512 |
nodename, |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
513 |
child.GetCanDevice(), |
166 | 514 |
child_data.getCAN_Baudrate()) |
57 | 515 |
format_dict["nodes_open"] += 'NODE_OPEN(%s)\n '%(nodename) |
516 |
format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n '%(nodename) |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
517 |
format_dict["nodes_stop"] += 'NODE_STOP(%s)\n '%(nodename) |
157 | 518 |
|
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
519 |
filename = os.path.join(os.path.split(__file__)[0],"cf_runtime.c") |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
520 |
cf_main = open(filename).read() % format_dict |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
521 |
cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict) |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
522 |
f = open(cf_main_path,'w') |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
523 |
f.write(cf_main) |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
524 |
f.close() |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
525 |
|
512
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
427
diff
changeset
|
526 |
return [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))],local_canfestival_config.getLDFLAGS(CanFestivalPath), True |
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
427
diff
changeset
|
527 |
|
36aeab46f27d
Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents:
427
diff
changeset
|
528 |