author | mwildbolz |
Mon, 01 Oct 2012 17:04:34 +0200 | |
changeset 751 | d005211221c7 |
parent 744 | bc1bbbb5ef71 |
child 748 | 18ed0f3b030a |
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 = "" |
258 | 40 |
self.EDSFolder = "" |
205 | 41 |
self.Manager = manager |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
42 |
self.NetworkName = netname |
205 | 43 |
self.SlaveNodes = {} |
44 |
self.EDSNodes = {} |
|
45 |
self.CurrentSelected = None |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
46 |
self.Changed = False |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
47 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
48 |
def HasChanged(self): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
49 |
return self.Changed or not self.Manager.CurrentIsSaved() |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
50 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
51 |
def ForceChanged(self, changed): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
52 |
self.Changed = changed |
205 | 53 |
|
54 |
def GetNetworkName(self): |
|
55 |
return self.NetworkName |
|
56 |
||
57 |
def SetNetworkName(self, name): |
|
58 |
self.NetworkName = name |
|
59 |
||
60 |
def GetManager(self): |
|
61 |
return self.Manager |
|
62 |
||
63 |
def GetRoot(self): |
|
64 |
return self.Root |
|
272
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
65 |
|
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
66 |
def SetRoot(self, newrootpath): |
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
67 |
""" |
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
68 |
Define a new path for the CanOpen network project |
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
69 |
!!! Does not check if new path is valid !!! |
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
70 |
""" |
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
71 |
self.Root = newrootpath |
bbdbf0c17d3c
Added SetRoot in networkedit to change project root on the fly
etisserant
parents:
270
diff
changeset
|
72 |
self.Manager.SetCurrentFilePath(os.path.join(self.Root, "master.od")) |
205 | 73 |
|
74 |
def GetSlaveNumber(self): |
|
75 |
return len(self.SlaveNodes) |
|
76 |
||
740
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
77 |
def GetSlaveName(self, idx): |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
78 |
return self.SlaveNodes[idx]["Name"] |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
79 |
|
205 | 80 |
def GetSlaveNames(self): |
81 |
nodes = self.SlaveNodes.keys() |
|
82 |
nodes.sort() |
|
83 |
return ["0x%2.2X %s"%(idx, self.SlaveNodes[idx]["Name"]) for idx in nodes] |
|
84 |
||
85 |
def GetSlaveIDs(self): |
|
86 |
nodes = self.SlaveNodes.keys() |
|
87 |
nodes.sort() |
|
88 |
return nodes |
|
89 |
||
90 |
def SetCurrentSelected(self, selected): |
|
91 |
self.CurrentSelected = selected |
|
92 |
||
93 |
def GetCurrentSelected(self): |
|
94 |
return self.CurrentSelected |
|
95 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
96 |
def LoadProject(self, root, netname = None): |
205 | 97 |
self.SlaveNodes = {} |
98 |
self.EDSNodes = {} |
|
99 |
||
100 |
self.Root = root |
|
101 |
if not os.path.exists(self.Root): |
|
580 | 102 |
return _("\"%s\" folder doesn't exist")%self.Root |
205 | 103 |
|
104 |
self.EDSFolder = os.path.join(self.Root, "eds") |
|
105 |
if not os.path.exists(self.EDSFolder): |
|
265
36cc4c87cdaa
Create "eds" folder if it doesn't exist in any case
lbessard
parents:
258
diff
changeset
|
106 |
os.mkdir(self.EDSFolder) |
36cc4c87cdaa
Create "eds" folder if it doesn't exist in any case
lbessard
parents:
258
diff
changeset
|
107 |
#return "\"%s\" folder doesn't contain a \"eds\" folder"%self.Root |
205 | 108 |
|
109 |
files = os.listdir(self.EDSFolder) |
|
110 |
for file in files: |
|
243 | 111 |
filepath = os.path.join(self.EDSFolder, file) |
112 |
if os.path.isfile(filepath) and os.path.splitext(filepath)[-1] == ".eds": |
|
113 |
result = self.LoadEDS(file) |
|
114 |
if result != None: |
|
115 |
return result |
|
270 | 116 |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
117 |
result = self.LoadMasterNode(netname) |
205 | 118 |
if result != None: |
119 |
return result |
|
120 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
121 |
result = self.LoadSlaveNodes(netname) |
205 | 122 |
if result != None: |
123 |
return result |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
124 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
125 |
self.NetworkName = netname |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
126 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
127 |
def SaveProject(self, netname = None): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
128 |
result = self.SaveMasterNode(netname) |
205 | 129 |
if result != None: |
130 |
return result |
|
131 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
132 |
result = self.SaveNodeList(netname) |
205 | 133 |
if result != None: |
134 |
return result |
|
135 |
||
505
88956169c8b5
Adding support for replace imported EDS in nodelist
lbessard
parents:
337
diff
changeset
|
136 |
def ImportEDSFile(self, edspath, force = False): |
205 | 137 |
dir, file = os.path.split(edspath) |
138 |
eds = os.path.join(self.EDSFolder, file) |
|
505
88956169c8b5
Adding support for replace imported EDS in nodelist
lbessard
parents:
337
diff
changeset
|
139 |
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
|
140 |
return _("EDS file already imported"), True |
205 | 141 |
else: |
142 |
shutil.copy(edspath, self.EDSFolder) |
|
740
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
580
diff
changeset
|
143 |
return self.LoadEDS(file), False |
205 | 144 |
|
145 |
def LoadEDS(self, eds): |
|
146 |
edspath = os.path.join(self.EDSFolder, eds) |
|
258 | 147 |
node = eds_utils.GenerateNode(edspath) |
205 | 148 |
if isinstance(node, Node): |
149 |
self.EDSNodes[eds] = node |
|
150 |
return None |
|
151 |
else: |
|
152 |
return node |
|
153 |
||
154 |
def AddSlaveNode(self, nodeName, nodeID, eds): |
|
155 |
if eds in self.EDSNodes.keys(): |
|
156 |
slave = {"Name" : nodeName, "EDS" : eds, "Node" : self.EDSNodes[eds]} |
|
157 |
self.SlaveNodes[nodeID] = slave |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
158 |
self.Changed = True |
205 | 159 |
return None |
160 |
else: |
|
580 | 161 |
return _("\"%s\" EDS file is not available")%eds |
205 | 162 |
|
163 |
def RemoveSlaveNode(self, index): |
|
164 |
if index in self.SlaveNodes.keys(): |
|
165 |
self.SlaveNodes.pop(index) |
|
744
bc1bbbb5ef71
Fix bug with 'not saved' state for network when removing a slave
Laurent Bessard
parents:
740
diff
changeset
|
166 |
self.Changed = True |
205 | 167 |
return None |
168 |
else: |
|
580 | 169 |
return _("Node with \"0x%2.2X\" ID doesn't exist") |
205 | 170 |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
171 |
def LoadMasterNode(self, netname = None): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
172 |
if netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
173 |
masterpath = os.path.join(self.Root, "%s_master.od"%netname) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
174 |
else: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
175 |
masterpath = os.path.join(self.Root, "master.od") |
205 | 176 |
if os.path.isfile(masterpath): |
268 | 177 |
result = self.Manager.OpenFileInCurrent(masterpath) |
178 |
else: |
|
179 |
result = self.Manager.CreateNewNode("MasterNode", 0x00, "master", "", "None", "", "heartbeat", ["DS302"]) |
|
180 |
if not isinstance(result, types.IntType): |
|
181 |
return result |
|
182 |
return None |
|
205 | 183 |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
184 |
def SaveMasterNode(self, netname = None): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
185 |
if netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
186 |
masterpath = os.path.join(self.Root, "%s_master.od"%netname) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
187 |
else: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
188 |
masterpath = os.path.join(self.Root, "master.od") |
205 | 189 |
if self.Manager.SaveCurrentInFile(masterpath): |
190 |
return None |
|
191 |
else: |
|
580 | 192 |
return _("Fail to save Master Node") |
205 | 193 |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
194 |
def LoadSlaveNodes(self, netname = None): |
205 | 195 |
cpjpath = os.path.join(self.Root, "nodelist.cpj") |
196 |
if os.path.isfile(cpjpath): |
|
197 |
try: |
|
198 |
networks = eds_utils.ParseCPJFile(cpjpath) |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
199 |
network = None |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
200 |
if netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
201 |
for net in networks: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
202 |
if net["Name"] == netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
203 |
network = net |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
204 |
self.NetworkName = netname |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
205 |
elif len(networks) > 0: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
206 |
network = networks[0] |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
207 |
self.NetworkName = network["Name"] |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
208 |
if network: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
209 |
for nodeid, node in network["Nodes"].items(): |
205 | 210 |
if node["Present"] == 1: |
211 |
result = self.AddSlaveNode(node["Name"], nodeid, node["DCFName"]) |
|
212 |
if result != None: |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
213 |
return result |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
214 |
self.Changed = False |
205 | 215 |
except SyntaxError, message: |
580 | 216 |
return _("Unable to load CPJ file\n%s")%message |
205 | 217 |
return None |
218 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
219 |
def SaveNodeList(self, netname = None): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
220 |
try: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
221 |
cpjpath = os.path.join(self.Root, "nodelist.cpj") |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
222 |
content = eds_utils.GenerateCPJContent(self) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
223 |
if netname: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
224 |
file = open(cpjpath, "a") |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
225 |
else: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
226 |
file = open(cpjpath, "w") |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
227 |
file.write(content) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
228 |
file.close() |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
229 |
self.Changed = False |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
230 |
return None |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
231 |
except: |
580 | 232 |
return _("Fail to save node list") |
205 | 233 |
|
234 |
def GetSlaveNodeEntry(self, nodeid, index, subindex = None): |
|
235 |
if nodeid in self.SlaveNodes.keys(): |
|
236 |
self.SlaveNodes[nodeid]["Node"].SetNodeID(nodeid) |
|
237 |
return self.SlaveNodes[nodeid]["Node"].GetEntry(index, subindex) |
|
238 |
else: |
|
580 | 239 |
return _("Node 0x%2.2X doesn't exist")%nodeid |
205 | 240 |
|
241 |
def GetMasterNodeEntry(self, index, subindex = None): |
|
242 |
return self.Manager.GetCurrentEntry(index, subindex) |
|
243 |
||
244 |
def SetMasterNodeEntry(self, index, subindex = None, value = None): |
|
245 |
self.Manager.SetCurrentEntry(index, subindex, value) |
|
246 |
||
247 |
def GetOrderNumber(self, nodeid): |
|
248 |
nodeindexes = self.SlaveNodes.keys() |
|
249 |
nodeindexes.sort() |
|
250 |
return nodeindexes.index(nodeid) + 1 |
|
251 |
||
252 |
def GetNodeByOrder(self, order): |
|
253 |
if order > 0: |
|
254 |
nodeindexes = self.SlaveNodes.keys() |
|
255 |
nodeindexes.sort() |
|
256 |
if order <= len(nodeindexes): |
|
257 |
return self.SlaveNodes[nodeindexes[order - 1]]["Node"] |
|
258 |
return None |
|
259 |
||
260 |
def IsCurrentEntry(self, index): |
|
261 |
if self.CurrentSelected != None: |
|
262 |
if self.CurrentSelected == 0: |
|
263 |
return self.Manager.IsCurrentEntry(index) |
|
264 |
else: |
|
265 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
|
266 |
if node: |
|
273 | 267 |
node.SetNodeID(self.CurrentSelected) |
205 | 268 |
return node.IsEntry(index) |
269 |
return False |
|
270 |
||
271 |
def GetEntryInfos(self, index): |
|
272 |
if self.CurrentSelected != None: |
|
273 |
if self.CurrentSelected == 0: |
|
274 |
return self.Manager.GetEntryInfos(index) |
|
275 |
else: |
|
276 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
|
277 |
if node: |
|
273 | 278 |
node.SetNodeID(self.CurrentSelected) |
205 | 279 |
return node.GetEntryInfos(index) |
280 |
return None |
|
281 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
282 |
def GetSubentryInfos(self, index, subindex): |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
283 |
if self.CurrentSelected != None: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
284 |
if self.CurrentSelected == 0: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
285 |
return self.Manager.GetSubentryInfos(index, subindex) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
286 |
else: |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
287 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
288 |
if node: |
273 | 289 |
node.SetNodeID(self.CurrentSelected) |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
290 |
return node.GetSubentryInfos(index, subindex) |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
291 |
return None |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
292 |
|
205 | 293 |
def GetCurrentValidIndexes(self, min, max): |
294 |
if self.CurrentSelected != None: |
|
295 |
if self.CurrentSelected == 0: |
|
296 |
return self.Manager.GetCurrentValidIndexes(min, max) |
|
297 |
else: |
|
298 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
|
299 |
if node: |
|
273 | 300 |
node.SetNodeID(self.CurrentSelected) |
205 | 301 |
validindexes = [] |
302 |
for index in node.GetIndexes(): |
|
303 |
if min <= index <= max: |
|
304 |
validindexes.append((node.GetEntryName(index), index)) |
|
305 |
return validindexes |
|
306 |
else: |
|
580 | 307 |
print _("Can't find node") |
205 | 308 |
return [] |
309 |
||
310 |
def GetCurrentEntryValues(self, index): |
|
311 |
if self.CurrentSelected != None: |
|
312 |
node = self.SlaveNodes[self.CurrentSelected]["Node"] |
|
313 |
if node: |
|
273 | 314 |
node.SetNodeID(self.CurrentSelected) |
205 | 315 |
return self.Manager.GetNodeEntryValues(node, index) |
316 |
else: |
|
580 | 317 |
print _("Can't find node") |
205 | 318 |
return [], [] |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
319 |
|
327 | 320 |
def AddToMasterDCF(self, node_id, index, subindex, size, value): |
321 |
# Adding DCF entry into Master node |
|
322 |
if not self.Manager.IsCurrentEntry(0x1F22): |
|
337 | 323 |
self.Manager.ManageEntriesOfCurrent([0x1F22], []) |
327 | 324 |
self.Manager.AddSubentriesToCurrent(0x1F22, 127) |
325 |
||
326 |
self.Manager.AddToDCF(node_id, index, subindex, size, value) |
|
327 |
||
205 | 328 |
if __name__ == "__main__": |
329 |
from nodemanager import * |
|
330 |
import os, sys, shutil |
|
331 |
||
332 |
manager = NodeManager(sys.path[0]) |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
333 |
|
205 | 334 |
nodelist = NodeList(manager) |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
335 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
336 |
result = nodelist.LoadProject("/home/laurent/test_nodelist") |
205 | 337 |
if result != None: |
338 |
print result |
|
339 |
else: |
|
340 |
print "MasterNode :" |
|
341 |
manager.CurrentNode.Print() |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
342 |
|
205 | 343 |
for nodeid, node in nodelist.SlaveNodes.items(): |
344 |
print "SlaveNode name=%s id=0x%2.2X :"%(node["Name"], nodeid) |
|
345 |
node["Node"].Print() |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
346 |
|
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
347 |