author | Edouard Tisserant |
Thu, 08 Mar 2018 15:03:04 +0100 | |
changeset 798 | 6bafede3de2b |
parent 781 | 77fe158d6ccd |
permissions | -rw-r--r-- |
205 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of CanFestival, a library implementing CanOpen Stack. |
|
5 |
# |
|
6 |
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD |
|
7 |
# |
|
8 |
#See COPYING file for copyrights details. |
|
9 |
# |
|
10 |
#This library is free software; you can redistribute it and/or |
|
11 |
#modify it under the terms of the GNU Lesser General Public |
|
12 |
#License as published by the Free Software Foundation; either |
|
13 |
#version 2.1 of the License, or (at your option) any later version. |
|
14 |
# |
|
15 |
#This library is distributed in the hope that it will be useful, |
|
16 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 |
#Lesser General Public License for more details. |
|
19 |
# |
|
20 |
#You should have received a copy of the GNU Lesser General Public |
|
21 |
#License along with this library; if not, write to the Free Software |
|
22 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
||
24 |
from node import * |
|
25 |
import eds_utils |
|
268 | 26 |
import os, shutil, types |
205 | 27 |
|
28 |
#------------------------------------------------------------------------------- |
|
29 |
# Definition of NodeList Object |
|
30 |
#------------------------------------------------------------------------------- |
|
31 |
||
32 |
""" |
|
33 |
Class recording a node list for a CANOpen network. |
|
34 |
""" |
|
35 |
||
36 |
class NodeList: |
|
37 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
38 |
def __init__(self, manager, netname = ""): |
205 | 39 |
self.Root = "" |
40 |
self.Manager = manager |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
41 |
self.NetworkName = netname |
205 | 42 |
self.SlaveNodes = {} |
43 |
self.EDSNodes = {} |
|
44 |
self.CurrentSelected = None |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
45 |
self.Changed = False |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
46 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
47 |
def HasChanged(self): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
48 |
return self.Changed or not self.Manager.CurrentIsSaved() |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
49 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
50 |
def ForceChanged(self, changed): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
51 |
self.Changed = changed |
205 | 52 |
|
53 |
def GetNetworkName(self): |
|
54 |
return self.NetworkName |
|
55 |
||
56 |
def SetNetworkName(self, name): |
|
57 |
self.NetworkName = name |
|
58 |
||
59 |
def GetManager(self): |
|
60 |
return self.Manager |
|
61 |
||
781 | 62 |
def GetEDSFolder(self, root_path=None): |
63 |
if root_path is None: |
|
64 |
root_path = self.Root |
|
65 |
return os.path.join(root_path, "eds") |
|
66 |
||
205 | 67 |
def GetRoot(self): |
68 |
return self.Root |
|
272
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
69 |
|
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
70 |
def SetRoot(self, newrootpath): |
781 | 71 |
if os.path.isdir(newrootpath): |
72 |
self.Root = newrootpath |
|
73 |
self.Manager.SetCurrentFilePath(os.path.join(self.Root, "master.od")) |
|
74 |
return True |
|
75 |
return False |
|
205 | 76 |
|
748
18ed0f3b030a
Fixing networkedit to deal with non-null master nodeid
Laurent Bessard
parents:
744
diff
changeset
|
77 |
def GetMasterNodeID(self): |
18ed0f3b030a
Fixing networkedit to deal with non-null master nodeid
Laurent Bessard
parents:
744
diff
changeset
|
78 |
return self.Manager.GetCurrentNodeID() |
18ed0f3b030a
Fixing networkedit to deal with non-null master nodeid
Laurent Bessard
parents:
744
diff
changeset
|
79 |
|
205 | 80 |
def GetSlaveNumber(self): |
81 |
return len(self.SlaveNodes) |
|
82 |
||
740
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
83 |
def GetSlaveName(self, idx): |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
84 |
return self.SlaveNodes[idx]["Name"] |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
85 |
|
205 | 86 |
def GetSlaveNames(self): |
87 |
nodes = self.SlaveNodes.keys() |
|
88 |
nodes.sort() |
|
89 |
return ["0x%2.2X %s"%(idx, self.SlaveNodes[idx]["Name"]) for idx in nodes] |
|
90 |
||
91 |
def GetSlaveIDs(self): |
|
92 |
nodes = self.SlaveNodes.keys() |
|
93 |
nodes.sort() |
|
94 |
return nodes |
|
95 |
||
96 |
def SetCurrentSelected(self, selected): |
|
97 |
self.CurrentSelected = selected |
|
98 |
||
99 |
def GetCurrentSelected(self): |
|
100 |
return self.CurrentSelected |
|
101 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
102 |
def LoadProject(self, root, netname = None): |
205 | 103 |
self.SlaveNodes = {} |
104 |
self.EDSNodes = {} |
|
105 |
||
106 |
self.Root = root |
|
107 |
if not os.path.exists(self.Root): |
|
580 | 108 |
return _("\"%s\" folder doesn't exist")%self.Root |
205 | 109 |
|
781 | 110 |
eds_folder = self.GetEDSFolder() |
111 |
if not os.path.exists(eds_folder): |
|
112 |
os.mkdir(eds_folder) |
|
265
36cc4c87cdaa
Create "eds" folder if it doesn't exist in any case
lbessard
parents:
258
diff
changeset
|
113 |
#return "\"%s\" folder doesn't contain a \"eds\" folder"%self.Root |
205 | 114 |
|
781 | 115 |
files = os.listdir(eds_folder) |
205 | 116 |
for file in files: |
781 | 117 |
filepath = os.path.join(eds_folder, file) |
243 | 118 |
if os.path.isfile(filepath) and os.path.splitext(filepath)[-1] == ".eds": |
119 |
result = self.LoadEDS(file) |
|
120 |
if result != None: |
|
121 |
return result |
|
270 | 122 |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
123 |
result = self.LoadMasterNode(netname) |
205 | 124 |
if result != None: |
125 |
return result |
|
126 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
127 |
result = self.LoadSlaveNodes(netname) |
205 | 128 |
if result != None: |
129 |
return result |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
130 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
131 |
self.NetworkName = netname |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
132 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
133 |
def SaveProject(self, netname = None): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
134 |
result = self.SaveMasterNode(netname) |
205 | 135 |
if result != None: |
136 |
return result |
|
137 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
138 |
result = self.SaveNodeList(netname) |
205 | 139 |
if result != None: |
140 |
return result |
|
141 |
||
505
88956169c8b5
Adding support for replace imported EDS in nodelist
lbessard
parents:
337
diff
changeset
|
142 |
def ImportEDSFile(self, edspath, force = False): |
205 | 143 |
dir, file = os.path.split(edspath) |
781 | 144 |
eds_folder = self.GetEDSFolder() |
145 |
eds = os.path.join(eds_folder, file) |
|
505
88956169c8b5
Adding support for replace imported EDS in nodelist
lbessard
parents:
337
diff
changeset
|
146 |
if not force and os.path.isfile(eds): |
740
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
147 |
return _("EDS file already imported"), True |
205 | 148 |
else: |
781 | 149 |
shutil.copy(edspath, eds_folder) |
740
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
150 |
return self.LoadEDS(file), False |
205 | 151 |
|
152 |
def LoadEDS(self, eds): |
|
781 | 153 |
edspath = os.path.join(self.GetEDSFolder(), eds) |
258 | 154 |
node = eds_utils.GenerateNode(edspath) |
205 | 155 |
if isinstance(node, Node): |
156 |
self.EDSNodes[eds] = node |
|
157 |
return None |
|
158 |
else: |
|
159 |
return node |
|
160 |
||
161 |
def AddSlaveNode(self, nodeName, nodeID, eds): |
|
162 |
if eds in self.EDSNodes.keys(): |
|
163 |
slave = {"Name" : nodeName, "EDS" : eds, "Node" : self.EDSNodes[eds]} |
|
164 |
self.SlaveNodes[nodeID] = slave |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
165 |
self.Changed = True |
205 | 166 |
return None |
167 |
else: |
|
580 | 168 |
return _("\"%s\" EDS file is not available")%eds |
205 | 169 |
|
170 |
def RemoveSlaveNode(self, index): |
|
171 |
if index in self.SlaveNodes.keys(): |
|
172 |
self.SlaveNodes.pop(index) |
|
744
bc1bbbb5ef71
Fix bug with 'not saved' state for network when removing a slave
Laurent Bessard
parents:
740
diff
changeset
|
173 |
self.Changed = True |
205 | 174 |
return None |
175 |
else: |
|
580 | 176 |
return _("Node with \"0x%2.2X\" ID doesn't exist") |
205 | 177 |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
178 |
def LoadMasterNode(self, netname = None): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
179 |
if netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
180 |
masterpath = os.path.join(self.Root, "%s_master.od"%netname) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
181 |
else: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
182 |
masterpath = os.path.join(self.Root, "master.od") |
205 | 183 |
if os.path.isfile(masterpath): |
268 | 184 |
result = self.Manager.OpenFileInCurrent(masterpath) |
185 |
else: |
|
186 |
result = self.Manager.CreateNewNode("MasterNode", 0x00, "master", "", "None", "", "heartbeat", ["DS302"]) |
|
187 |
if not isinstance(result, types.IntType): |
|
188 |
return result |
|
189 |
return None |
|
205 | 190 |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
191 |
def SaveMasterNode(self, netname = None): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
192 |
if netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
193 |
masterpath = os.path.join(self.Root, "%s_master.od"%netname) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
194 |
else: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
195 |
masterpath = os.path.join(self.Root, "master.od") |
205 | 196 |
if self.Manager.SaveCurrentInFile(masterpath): |
197 |
return None |
|
198 |
else: |
|
580 | 199 |
return _("Fail to save Master Node") |
205 | 200 |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
201 |
def LoadSlaveNodes(self, netname = None): |
205 | 202 |
cpjpath = os.path.join(self.Root, "nodelist.cpj") |
203 |
if os.path.isfile(cpjpath): |
|
204 |
try: |
|
205 |
networks = eds_utils.ParseCPJFile(cpjpath) |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
206 |
network = None |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
207 |
if netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
208 |
for net in networks: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
209 |
if net["Name"] == netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
210 |
network = net |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
211 |
self.NetworkName = netname |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
212 |
elif len(networks) > 0: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
213 |
network = networks[0] |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
214 |
self.NetworkName = network["Name"] |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
215 |
if network: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
216 |
for nodeid, node in network["Nodes"].items(): |
205 | 217 |
if node["Present"] == 1: |
218 |
result = self.AddSlaveNode(node["Name"], nodeid, node["DCFName"]) |
|
219 |
if result != None: |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
220 |
return result |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
221 |
self.Changed = False |
205 | 222 |
except SyntaxError, message: |
580 | 223 |
return _("Unable to load CPJ file\n%s")%message |
205 | 224 |
return None |
225 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
226 |
def SaveNodeList(self, netname = None): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
227 |
try: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
228 |
cpjpath = os.path.join(self.Root, "nodelist.cpj") |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
229 |
content = eds_utils.GenerateCPJContent(self) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
230 |
if netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
231 |
file = open(cpjpath, "a") |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
232 |
else: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
233 |
file = open(cpjpath, "w") |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
234 |
file.write(content) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
235 |
file.close() |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
236 |
self.Changed = False |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
237 |
return None |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
238 |
except: |
580 | 239 |
return _("Fail to save node list") |
205 | 240 |
|
241 |
def GetSlaveNodeEntry(self, nodeid, index, subindex = None): |
|
242 |
if nodeid in self.SlaveNodes.keys(): |
|
243 |
self.SlaveNodes[nodeid]["Node"].SetNodeID(nodeid) |
|
244 |
return self.SlaveNodes[nodeid]["Node"].GetEntry(index, subindex) |
|
245 |
else: |
|
580 | 246 |
return _("Node 0x%2.2X doesn't exist")%nodeid |
205 | 247 |
|
248 |
def GetMasterNodeEntry(self, index, subindex = None): |
|
249 |
return self.Manager.GetCurrentEntry(index, subindex) |
|
250 |
||
251 |
def SetMasterNodeEntry(self, index, subindex = None, value = None): |
|
252 |
self.Manager.SetCurrentEntry(index, subindex, value) |
|
253 |
||
254 |
def GetOrderNumber(self, nodeid): |
|
255 |
nodeindexes = self.SlaveNodes.keys() |
|
256 |
nodeindexes.sort() |
|
257 |
return nodeindexes.index(nodeid) + 1 |
|
258 |
||
259 |
def GetNodeByOrder(self, order): |
|
260 |
if order > 0: |
|
261 |
nodeindexes = self.SlaveNodes.keys() |
|
262 |
nodeindexes.sort() |
|
263 |
if order <= len(nodeindexes): |
|
264 |
return self.SlaveNodes[nodeindexes[order - 1]]["Node"] |
|
265 |
return None |
|
266 |
||
267 |
def IsCurrentEntry(self, index): |
|
268 |
if self.CurrentSelected != None: |
|
269 |
if self.CurrentSelected == 0: |
|
270 |
return self.Manager.IsCurrentEntry(index) |
|
271 |
else: |
|
272 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
|
273 |
if node: |
|
273 | 274 |
node.SetNodeID(self.CurrentSelected) |
205 | 275 |
return node.IsEntry(index) |
276 |
return False |
|
277 |
||
278 |
def GetEntryInfos(self, index): |
|
279 |
if self.CurrentSelected != None: |
|
280 |
if self.CurrentSelected == 0: |
|
281 |
return self.Manager.GetEntryInfos(index) |
|
282 |
else: |
|
283 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
|
284 |
if node: |
|
273 | 285 |
node.SetNodeID(self.CurrentSelected) |
205 | 286 |
return node.GetEntryInfos(index) |
287 |
return None |
|
288 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
289 |
def GetSubentryInfos(self, index, subindex): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
290 |
if self.CurrentSelected != None: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
291 |
if self.CurrentSelected == 0: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
292 |
return self.Manager.GetSubentryInfos(index, subindex) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
293 |
else: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
294 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
295 |
if node: |
273 | 296 |
node.SetNodeID(self.CurrentSelected) |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
297 |
return node.GetSubentryInfos(index, subindex) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
298 |
return None |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
299 |
|
205 | 300 |
def GetCurrentValidIndexes(self, min, max): |
301 |
if self.CurrentSelected != None: |
|
302 |
if self.CurrentSelected == 0: |
|
303 |
return self.Manager.GetCurrentValidIndexes(min, max) |
|
304 |
else: |
|
305 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
|
306 |
if node: |
|
273 | 307 |
node.SetNodeID(self.CurrentSelected) |
205 | 308 |
validindexes = [] |
309 |
for index in node.GetIndexes(): |
|
310 |
if min <= index <= max: |
|
311 |
validindexes.append((node.GetEntryName(index), index)) |
|
312 |
return validindexes |
|
313 |
else: |
|
580 | 314 |
print _("Can't find node") |
205 | 315 |
return [] |
316 |
||
317 |
def GetCurrentEntryValues(self, index): |
|
318 |
if self.CurrentSelected != None: |
|
319 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
|
320 |
if node: |
|
273 | 321 |
node.SetNodeID(self.CurrentSelected) |
205 | 322 |
return self.Manager.GetNodeEntryValues(node, index) |
323 |
else: |
|
580 | 324 |
print _("Can't find node") |
205 | 325 |
return [], [] |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
326 |
|
327 | 327 |
def AddToMasterDCF(self, node_id, index, subindex, size, value): |
328 |
# Adding DCF entry into Master node |
|
329 |
if not self.Manager.IsCurrentEntry(0x1F22): |
|
337 | 330 |
self.Manager.ManageEntriesOfCurrent([0x1F22], []) |
327 | 331 |
self.Manager.AddSubentriesToCurrent(0x1F22, 127) |
332 |
||
333 |
self.Manager.AddToDCF(node_id, index, subindex, size, value) |
|
334 |
||
205 | 335 |
if __name__ == "__main__": |
336 |
from nodemanager import * |
|
337 |
import os, sys, shutil |
|
338 |
||
339 |
manager = NodeManager(sys.path[0]) |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
340 |
|
205 | 341 |
nodelist = NodeList(manager) |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
342 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
343 |
result = nodelist.LoadProject("/home/laurent/test_nodelist") |
205 | 344 |
if result != None: |
345 |
print result |
|
346 |
else: |
|
347 |
print "MasterNode :" |
|
348 |
manager.CurrentNode.Print() |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
349 |
|
205 | 350 |
for nodeid, node in nodelist.SlaveNodes.items(): |
351 |
print "SlaveNode name=%s id=0x%2.2X :"%(node["Name"], nodeid) |
|
352 |
node["Node"].Print() |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
353 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
354 |