author | ct@78566C00-6F59-1014-AAEE-A77C3B9AAB40 |
Mon, 08 Aug 2011 11:57:43 +0000 | |
changeset 681 | 3c42b5df66b1 |
parent 584 | e23359f62023 |
child 762 | 4b60a0d313b0 |
permissions | -rwxr-xr-x |
0 | 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 gnosis.xml.pickle import * |
|
25 |
from gnosis.xml.pickle.util import setParanoia |
|
26 |
setParanoia(0) |
|
27 |
||
28 |
from node import * |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
29 |
import eds_utils, gen_cfile |
0 | 30 |
|
31 |
from types import * |
|
32 |
import os, re |
|
33 |
||
34 |
UndoBufferLength = 20 |
|
35 |
||
36 |
type_model = re.compile('([\_A-Z]*)([0-9]*)') |
|
37 |
range_model = re.compile('([\_A-Z]*)([0-9]*)\[([\-0-9]*)-([\-0-9]*)\]') |
|
205 | 38 |
|
39 |
# ID for the file viewed |
|
40 |
CurrentID = 0 |
|
41 |
||
42 |
# Returns a new id |
|
43 |
def GetNewId(): |
|
44 |
global CurrentID |
|
45 |
CurrentID += 1 |
|
46 |
return CurrentID |
|
0 | 47 |
|
48 |
""" |
|
49 |
Class implementing a buffer of changes made on the current editing Object Dictionary |
|
50 |
""" |
|
51 |
||
52 |
class UndoBuffer: |
|
53 |
||
54 |
""" |
|
55 |
Constructor initialising buffer |
|
56 |
""" |
|
57 |
def __init__(self, currentstate, issaved = False): |
|
58 |
self.Buffer = [] |
|
59 |
self.CurrentIndex = -1 |
|
60 |
self.MinIndex = -1 |
|
61 |
self.MaxIndex = -1 |
|
62 |
# if current state is defined |
|
63 |
if currentstate: |
|
64 |
self.CurrentIndex = 0 |
|
65 |
self.MinIndex = 0 |
|
66 |
self.MaxIndex = 0 |
|
67 |
# Initialising buffer with currentstate at the first place |
|
68 |
for i in xrange(UndoBufferLength): |
|
69 |
if i == 0: |
|
70 |
self.Buffer.append(currentstate) |
|
71 |
else: |
|
72 |
self.Buffer.append(None) |
|
73 |
# Initialising index of state saved |
|
74 |
if issaved: |
|
75 |
self.LastSave = 0 |
|
76 |
else: |
|
77 |
self.LastSave = -1 |
|
78 |
||
79 |
""" |
|
80 |
Add a new state in buffer |
|
81 |
""" |
|
82 |
def Buffering(self, currentstate): |
|
83 |
self.CurrentIndex = (self.CurrentIndex + 1) % UndoBufferLength |
|
84 |
self.Buffer[self.CurrentIndex] = currentstate |
|
85 |
# Actualising buffer limits |
|
86 |
self.MaxIndex = self.CurrentIndex |
|
87 |
if self.MinIndex == self.CurrentIndex: |
|
88 |
# If the removed state was the state saved, there is no state saved in the buffer |
|
89 |
if self.LastSave == self.MinIndex: |
|
90 |
self.LastSave = -1 |
|
91 |
self.MinIndex = (self.MinIndex + 1) % UndoBufferLength |
|
92 |
self.MinIndex = max(self.MinIndex, 0) |
|
93 |
||
94 |
""" |
|
95 |
Return current state of buffer |
|
96 |
""" |
|
97 |
def Current(self): |
|
98 |
return self.Buffer[self.CurrentIndex] |
|
99 |
||
100 |
""" |
|
101 |
Change current state to previous in buffer and return new current state |
|
102 |
""" |
|
103 |
def Previous(self): |
|
104 |
if self.CurrentIndex != self.MinIndex: |
|
105 |
self.CurrentIndex = (self.CurrentIndex - 1) % UndoBufferLength |
|
106 |
return self.Buffer[self.CurrentIndex] |
|
107 |
return None |
|
108 |
||
109 |
""" |
|
110 |
Change current state to next in buffer and return new current state |
|
111 |
""" |
|
112 |
def Next(self): |
|
113 |
if self.CurrentIndex != self.MaxIndex: |
|
114 |
self.CurrentIndex = (self.CurrentIndex + 1) % UndoBufferLength |
|
115 |
return self.Buffer[self.CurrentIndex] |
|
116 |
return None |
|
117 |
||
118 |
""" |
|
119 |
Return True if current state is the first in buffer |
|
120 |
""" |
|
121 |
def IsFirst(self): |
|
122 |
return self.CurrentIndex == self.MinIndex |
|
123 |
||
124 |
""" |
|
125 |
Return True if current state is the last in buffer |
|
126 |
""" |
|
127 |
def IsLast(self): |
|
128 |
return self.CurrentIndex == self.MaxIndex |
|
129 |
||
130 |
""" |
|
131 |
Note that current state is saved |
|
132 |
""" |
|
133 |
def CurrentSaved(self): |
|
134 |
self.LastSave = self.CurrentIndex |
|
135 |
||
136 |
""" |
|
137 |
Return True if current state is saved |
|
138 |
""" |
|
139 |
def IsCurrentSaved(self): |
|
140 |
return self.LastSave == self.CurrentIndex |
|
141 |
||
142 |
||
143 |
||
144 |
""" |
|
145 |
Class which control the operations made on the node and answer to view requests |
|
146 |
""" |
|
147 |
||
148 |
class NodeManager: |
|
149 |
||
150 |
""" |
|
151 |
Constructor |
|
152 |
""" |
|
258 | 153 |
def __init__(self): |
0 | 154 |
self.LastNewIndex = 0 |
205 | 155 |
self.FilePaths = {} |
156 |
self.FileNames = {} |
|
157 |
self.NodeIndex = None |
|
0 | 158 |
self.CurrentNode = None |
205 | 159 |
self.UndoBuffers = {} |
0 | 160 |
|
161 |
#------------------------------------------------------------------------------- |
|
162 |
# Type and Map Variable Lists |
|
163 |
#------------------------------------------------------------------------------- |
|
164 |
||
165 |
""" |
|
166 |
Return the list of types defined for the current node |
|
167 |
""" |
|
168 |
def GetCurrentTypeList(self): |
|
205 | 169 |
if self.CurrentNode: |
170 |
return self.CurrentNode.GetTypeList() |
|
171 |
else: |
|
172 |
return "" |
|
0 | 173 |
|
174 |
""" |
|
175 |
Return the list of variables that can be mapped for the current node |
|
176 |
""" |
|
177 |
def GetCurrentMapList(self): |
|
205 | 178 |
if self.CurrentNode: |
179 |
return self.CurrentNode.GetMapList() |
|
180 |
else: |
|
181 |
return "" |
|
0 | 182 |
|
183 |
#------------------------------------------------------------------------------- |
|
184 |
# Create Load and Save Functions |
|
185 |
#------------------------------------------------------------------------------- |
|
186 |
||
187 |
""" |
|
188 |
Create a new node and add a new buffer for storing it |
|
189 |
""" |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
190 |
def CreateNewNode(self, name, id, type, description, profile, filepath, NMT, options): |
0 | 191 |
# Create a new node |
192 |
node = Node() |
|
193 |
# Try to load profile given |
|
194 |
result = self.LoadProfile(profile, filepath, node) |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
195 |
if not result: |
0 | 196 |
# if success, initialising node |
197 |
self.CurrentNode = node |
|
198 |
self.CurrentNode.SetNodeName(name) |
|
199 |
self.CurrentNode.SetNodeID(id) |
|
200 |
self.CurrentNode.SetNodeType(type) |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
201 |
self.CurrentNode.SetNodeDescription(description) |
0 | 202 |
AddIndexList = self.GetMandatoryIndexes() |
492 | 203 |
AddSubIndexList = [] |
0 | 204 |
if NMT == "NodeGuarding": |
205 |
AddIndexList.extend([0x100C, 0x100D]) |
|
206 |
elif NMT == "Heartbeat": |
|
207 |
AddIndexList.append(0x1017) |
|
208 |
for option in options: |
|
209 |
if option == "DS302": |
|
258 | 210 |
DS302Path = os.path.join(os.path.split(__file__)[0], "config/DS-302.prf") |
0 | 211 |
# Charging DS-302 profile if choosen by user |
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
212 |
if os.path.isfile(DS302Path): |
0 | 213 |
try: |
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
214 |
execfile(DS302Path) |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
215 |
self.CurrentNode.SetDS302Profile(Mapping) |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
216 |
self.CurrentNode.ExtendSpecificMenu(AddMenuEntries) |
0 | 217 |
except: |
580 | 218 |
return _("Problem with DS-302! Syntax Error.") |
0 | 219 |
else: |
580 | 220 |
return _("Couldn't find DS-302 in 'config' folder!") |
0 | 221 |
elif option == "GenSYNC": |
222 |
AddIndexList.extend([0x1005, 0x1006]) |
|
223 |
elif option == "Emergency": |
|
224 |
AddIndexList.append(0x1014) |
|
225 |
elif option == "SaveConfig": |
|
226 |
AddIndexList.extend([0x1010, 0x1011, 0x1020]) |
|
227 |
elif option == "StoreEDS": |
|
228 |
AddIndexList.extend([0x1021, 0x1022]) |
|
487
7292e686f1ab
Automatic SDO server added when creating new slave node.
etisserant
parents:
485
diff
changeset
|
229 |
if type == "slave": |
7292e686f1ab
Automatic SDO server added when creating new slave node.
etisserant
parents:
485
diff
changeset
|
230 |
# add default SDO server |
492 | 231 |
AddIndexList.append(0x1200) |
232 |
# add default 4 receive and 4 transmit PDO |
|
233 |
for comm, mapping in [(0x1400, 0x1600),(0x1800, 0x1A00)]: |
|
234 |
firstparamindex = self.GetLineFromIndex(comm) |
|
235 |
firstmappingindex = self.GetLineFromIndex(mapping) |
|
236 |
AddIndexList.extend(range(firstparamindex, firstparamindex + 4)) |
|
237 |
for idx in range(firstmappingindex, firstmappingindex + 4): |
|
238 |
AddIndexList.append(idx) |
|
239 |
AddSubIndexList.append((idx, 8)) |
|
0 | 240 |
# Add a new buffer |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
241 |
index = self.AddNodeBuffer(self.CurrentNode.Copy(), False) |
0 | 242 |
self.SetCurrentFilePath("") |
243 |
# Add Mandatory indexes |
|
244 |
self.ManageEntriesOfCurrent(AddIndexList, []) |
|
492 | 245 |
for idx, num in AddSubIndexList: |
246 |
self.AddSubentriesToCurrent(idx, num) |
|
205 | 247 |
return index |
0 | 248 |
else: |
249 |
return result |
|
250 |
||
251 |
""" |
|
252 |
Load a profile in node |
|
253 |
""" |
|
254 |
def LoadProfile(self, profile, filepath, node): |
|
255 |
if profile != "None": |
|
256 |
# Try to charge the profile given |
|
257 |
try: |
|
258 |
execfile(filepath) |
|
259 |
node.SetProfileName(profile) |
|
260 |
node.SetProfile(Mapping) |
|
261 |
node.SetSpecificMenu(AddMenuEntries) |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
262 |
return None |
0 | 263 |
except: |
580 | 264 |
return _("Syntax Error\nBad OD Profile file!") |
0 | 265 |
else: |
266 |
# Default profile |
|
267 |
node.SetProfileName("None") |
|
268 |
node.SetProfile({}) |
|
269 |
node.SetSpecificMenu([]) |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
270 |
return None |
0 | 271 |
|
272 |
""" |
|
273 |
Open a file and store it in a new buffer |
|
274 |
""" |
|
275 |
def OpenFileInCurrent(self, filepath): |
|
268 | 276 |
try: |
277 |
# Open and load file |
|
278 |
file = open(filepath, "r") |
|
279 |
node = load(file) |
|
280 |
file.close() |
|
281 |
self.CurrentNode = node |
|
299 | 282 |
self.CurrentNode.SetNodeID(0) |
268 | 283 |
# Add a new buffer and defining current state |
284 |
index = self.AddNodeBuffer(self.CurrentNode.Copy(), True) |
|
285 |
self.SetCurrentFilePath(filepath) |
|
286 |
return index |
|
287 |
except: |
|
580 | 288 |
return _("Unable to load file \"%s\"!")%filepath |
0 | 289 |
|
290 |
""" |
|
291 |
Save current node in a file |
|
292 |
""" |
|
293 |
def SaveCurrentInFile(self, filepath = None): |
|
294 |
# if no filepath given, verify if current node has a filepath defined |
|
295 |
if not filepath: |
|
296 |
filepath = self.GetCurrentFilePath() |
|
297 |
if filepath == "": |
|
298 |
return False |
|
299 |
# Save node in file |
|
300 |
file = open(filepath, "w") |
|
301 |
dump(self.CurrentNode, file) |
|
302 |
file.close() |
|
303 |
self.SetCurrentFilePath(filepath) |
|
304 |
# Update saved state in buffer |
|
305 |
self.UndoBuffers[self.NodeIndex].CurrentSaved() |
|
306 |
return True |
|
307 |
||
308 |
""" |
|
309 |
Close current state |
|
310 |
""" |
|
311 |
def CloseCurrent(self, ignore = False): |
|
312 |
# Verify if it's not forced that the current node is saved before closing it |
|
490
305d75028630
Adding support for modification in CanFestival eds_utils
lbessard
parents:
487
diff
changeset
|
313 |
if self.NodeIndex in self.UndoBuffers and (self.UndoBuffers[self.NodeIndex].IsCurrentSaved() or ignore): |
0 | 314 |
self.RemoveNodeBuffer(self.NodeIndex) |
299 | 315 |
if len(self.UndoBuffers) > 0: |
316 |
previousindexes = [idx for idx in self.UndoBuffers.keys() if idx < self.NodeIndex] |
|
317 |
nextindexes = [idx for idx in self.UndoBuffers.keys() if idx > self.NodeIndex] |
|
318 |
if len(previousindexes) > 0: |
|
319 |
previousindexes.sort() |
|
320 |
self.NodeIndex = previousindexes[-1] |
|
321 |
elif len(nextindexes) > 0: |
|
322 |
nextindexes.sort() |
|
323 |
self.NodeIndex = nextindexes[0] |
|
324 |
else: |
|
325 |
self.NodeIndex = None |
|
326 |
else: |
|
327 |
self.NodeIndex = None |
|
0 | 328 |
return True |
329 |
return False |
|
330 |
||
331 |
""" |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
332 |
Import an eds file and store it in a new buffer if no node edited |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
333 |
""" |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
334 |
def ImportCurrentFromEDSFile(self, filepath): |
0 | 335 |
# Generate node from definition in a xml file |
258 | 336 |
result = eds_utils.GenerateNode(filepath) |
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
337 |
if isinstance(result, Node): |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
338 |
self.CurrentNode = result |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
339 |
index = self.AddNodeBuffer(self.CurrentNode.Copy(), False) |
223 | 340 |
self.SetCurrentFilePath("") |
205 | 341 |
return index |
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
342 |
else: |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
343 |
return result |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
344 |
|
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
345 |
""" |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
346 |
Export to an eds file and store it in a new buffer if no node edited |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
347 |
""" |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
348 |
def ExportCurrentToEDSFile(self, filepath): |
490
305d75028630
Adding support for modification in CanFestival eds_utils
lbessard
parents:
487
diff
changeset
|
349 |
return eds_utils.GenerateEDSFile(filepath, self.CurrentNode) |
0 | 350 |
|
351 |
""" |
|
352 |
Build the C definition of Object Dictionary for current node |
|
353 |
""" |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
354 |
def ExportCurrentToCFile(self, filepath): |
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
244
diff
changeset
|
355 |
if self.CurrentNode: |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
244
diff
changeset
|
356 |
return gen_cfile.GenerateFile(filepath, self.CurrentNode) |
0 | 357 |
|
358 |
#------------------------------------------------------------------------------- |
|
359 |
# Add Entries to Current Functions |
|
360 |
#------------------------------------------------------------------------------- |
|
361 |
||
362 |
""" |
|
363 |
Add the specified number of subentry for the given entry. Verify that total |
|
364 |
number of subentry (except 0) doesn't exceed nbmax defined |
|
365 |
""" |
|
244 | 366 |
def AddSubentriesToCurrent(self, index, number, node = None): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
245
diff
changeset
|
367 |
disable_buffer = node != None |
244 | 368 |
if node == None: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
245
diff
changeset
|
369 |
node = self.CurrentNode |
0 | 370 |
# Informations about entry |
244 | 371 |
length = node.GetEntry(index, 0) |
372 |
infos = node.GetEntryInfos(index) |
|
373 |
subentry_infos = node.GetSubentryInfos(index, 1) |
|
0 | 374 |
# Get default value for subindex |
375 |
if "default" in subentry_infos: |
|
376 |
default = subentry_infos["default"] |
|
377 |
else: |
|
378 |
default = self.GetTypeDefaultValue(subentry_infos["type"]) |
|
379 |
# First case entry is record |
|
244 | 380 |
if infos["struct"] & OD_IdenticalSubindexes: |
0 | 381 |
for i in xrange(1, min(number,subentry_infos["nbmax"]-length) + 1): |
244 | 382 |
node.AddEntry(index, length + i, default) |
383 |
if not disable_buffer: |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
244
diff
changeset
|
384 |
self.BufferCurrentNode() |
244 | 385 |
return None |
0 | 386 |
# Second case entry is array, only possible for manufacturer specific |
387 |
elif infos["struct"] & OD_MultipleSubindexes and 0x2000 <= index <= 0x5FFF: |
|
388 |
values = {"name" : "Undefined", "type" : 5, "access" : "rw", "pdo" : True} |
|
389 |
for i in xrange(1, min(number,0xFE-length) + 1): |
|
244 | 390 |
node.AddMappingEntry(index, length + i, values = values.copy()) |
391 |
node.AddEntry(index, length + i, 0) |
|
392 |
if not disable_buffer: |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
244
diff
changeset
|
393 |
self.BufferCurrentNode() |
244 | 394 |
return None |
395 |
||
0 | 396 |
|
397 |
""" |
|
398 |
Remove the specified number of subentry for the given entry. Verify that total |
|
399 |
number of subentry (except 0) isn't less than 1 |
|
400 |
""" |
|
401 |
def RemoveSubentriesFromCurrent(self, index, number): |
|
402 |
# Informations about entry |
|
403 |
infos = self.GetEntryInfos(index) |
|
404 |
length = self.CurrentNode.GetEntry(index, 0) |
|
299 | 405 |
if "nbmin" in infos: |
406 |
nbmin = infos["nbmin"] |
|
407 |
else: |
|
408 |
nbmin = 1 |
|
0 | 409 |
# Entry is a record, or is an array of manufacturer specific |
410 |
if infos["struct"] & OD_IdenticalSubindexes or 0x2000 <= index <= 0x5FFF and infos["struct"] & OD_IdenticalSubindexes: |
|
299 | 411 |
for i in xrange(min(number, length - nbmin)): |
0 | 412 |
self.RemoveCurrentVariable(index, length - i) |
413 |
self.BufferCurrentNode() |
|
414 |
||
415 |
""" |
|
416 |
Add a SDO Server to current node |
|
417 |
""" |
|
418 |
def AddSDOServerToCurrent(self): |
|
419 |
# An SDO Server is already defined at index 0x1200 |
|
420 |
if self.CurrentNode.IsEntry(0x1200): |
|
421 |
indexlist = [self.GetLineFromIndex(0x1201)] |
|
422 |
if None not in indexlist: |
|
423 |
self.ManageEntriesOfCurrent(indexlist, []) |
|
424 |
# Add an SDO Server at index 0x1200 |
|
425 |
else: |
|
426 |
self.ManageEntriesOfCurrent([0x1200], []) |
|
427 |
||
428 |
""" |
|
429 |
Add a SDO Server to current node |
|
430 |
""" |
|
431 |
def AddSDOClientToCurrent(self): |
|
432 |
indexlist = [self.GetLineFromIndex(0x1280)] |
|
433 |
if None not in indexlist: |
|
434 |
self.ManageEntriesOfCurrent(indexlist, []) |
|
435 |
||
436 |
""" |
|
437 |
Add a Transmit PDO to current node |
|
438 |
""" |
|
439 |
def AddPDOTransmitToCurrent(self): |
|
440 |
indexlist = [self.GetLineFromIndex(0x1800),self.GetLineFromIndex(0x1A00)] |
|
441 |
if None not in indexlist: |
|
442 |
self.ManageEntriesOfCurrent(indexlist, []) |
|
443 |
||
444 |
""" |
|
445 |
Add a Receive PDO to current node |
|
446 |
""" |
|
447 |
def AddPDOReceiveToCurrent(self): |
|
448 |
indexlist = [self.GetLineFromIndex(0x1400),self.GetLineFromIndex(0x1600)] |
|
449 |
if None not in indexlist: |
|
450 |
self.ManageEntriesOfCurrent(indexlist, []) |
|
451 |
||
452 |
""" |
|
453 |
Add a list of entries defined in profile for menu item selected to current node |
|
454 |
""" |
|
455 |
def AddSpecificEntryToCurrent(self, menuitem): |
|
456 |
indexlist = [] |
|
457 |
for menu, indexes in self.CurrentNode.GetSpecificMenu(): |
|
458 |
if menuitem == menu: |
|
459 |
for index in indexes: |
|
460 |
indexlist.append(self.GetLineFromIndex(index)) |
|
461 |
if None not in indexlist: |
|
462 |
self.ManageEntriesOfCurrent(indexlist, []) |
|
463 |
||
464 |
""" |
|
465 |
Search the first index available for a pluri entry from base_index |
|
466 |
""" |
|
467 |
def GetLineFromIndex(self, base_index): |
|
468 |
found = False |
|
469 |
index = base_index |
|
470 |
infos = self.GetEntryInfos(base_index) |
|
471 |
while index < base_index + infos["incr"]*infos["nbmax"] and not found: |
|
472 |
if not self.CurrentNode.IsEntry(index): |
|
473 |
found = True |
|
474 |
else: |
|
475 |
index += infos["incr"] |
|
476 |
if found: |
|
477 |
return index |
|
478 |
return None |
|
479 |
||
480 |
""" |
|
481 |
Add entries specified in addinglist and remove entries specified in removinglist |
|
482 |
""" |
|
244 | 483 |
def ManageEntriesOfCurrent(self, addinglist, removinglist, node = None): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
245
diff
changeset
|
484 |
disable_buffer = node != None |
244 | 485 |
if node == None: |
486 |
node = self.CurrentNode |
|
0 | 487 |
# Add all the entries in addinglist |
488 |
for index in addinglist: |
|
489 |
infos = self.GetEntryInfos(index) |
|
490 |
if infos["struct"] & OD_MultipleSubindexes: |
|
491 |
# First case entry is a record |
|
492 |
if infos["struct"] & OD_IdenticalSubindexes: |
|
493 |
subentry_infos = self.GetSubentryInfos(index, 1) |
|
494 |
if "default" in subentry_infos: |
|
495 |
default = subentry_infos["default"] |
|
496 |
else: |
|
497 |
default = self.GetTypeDefaultValue(subentry_infos["type"]) |
|
299 | 498 |
node.AddEntry(index, value = []) |
499 |
if "nbmin" in subentry_infos: |
|
500 |
for i in xrange(subentry_infos["nbmin"]): |
|
501 |
node.AddEntry(index, i + 1, default) |
|
502 |
else: |
|
503 |
node.AddEntry(index, 1, default) |
|
0 | 504 |
# Second case entry is a record |
505 |
else: |
|
506 |
i = 1 |
|
507 |
subentry_infos = self.GetSubentryInfos(index, i) |
|
508 |
while subentry_infos: |
|
509 |
if "default" in subentry_infos: |
|
510 |
default = subentry_infos["default"] |
|
511 |
else: |
|
512 |
default = self.GetTypeDefaultValue(subentry_infos["type"]) |
|
244 | 513 |
node.AddEntry(index, i, default) |
0 | 514 |
i += 1 |
515 |
subentry_infos = self.GetSubentryInfos(index, i) |
|
516 |
# Third case entry is a record |
|
517 |
else: |
|
518 |
subentry_infos = self.GetSubentryInfos(index, 0) |
|
519 |
if "default" in subentry_infos: |
|
520 |
default = subentry_infos["default"] |
|
521 |
else: |
|
522 |
default = self.GetTypeDefaultValue(subentry_infos["type"]) |
|
244 | 523 |
node.AddEntry(index, 0, default) |
0 | 524 |
# Remove all the entries in removinglist |
525 |
for index in removinglist: |
|
526 |
self.RemoveCurrentVariable(index) |
|
244 | 527 |
if not disable_buffer: |
528 |
self.BufferCurrentNode() |
|
529 |
return None |
|
0 | 530 |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
531 |
|
0 | 532 |
""" |
299 | 533 |
Reset an subentry from current node to its default value |
534 |
""" |
|
535 |
def SetCurrentEntryToDefault(self, index, subindex, node = None): |
|
536 |
disable_buffer = node != None |
|
537 |
if node == None: |
|
538 |
node = self.CurrentNode |
|
539 |
if node.IsEntry(index, subindex): |
|
540 |
subentry_infos = self.GetSubentryInfos(index, subindex) |
|
541 |
if "default" in subentry_infos: |
|
542 |
default = subentry_infos["default"] |
|
543 |
else: |
|
544 |
default = self.GetTypeDefaultValue(subentry_infos["type"]) |
|
545 |
node.SetEntry(index, subindex, default) |
|
546 |
if not disable_buffer: |
|
547 |
self.BufferCurrentNode() |
|
548 |
||
549 |
""" |
|
0 | 550 |
Remove an entry from current node. Analize the index to perform the correct |
551 |
method |
|
552 |
""" |
|
553 |
def RemoveCurrentVariable(self, index, subIndex = None): |
|
554 |
Mappings = self.CurrentNode.GetMappings() |
|
555 |
if index < 0x1000 and subIndex == None: |
|
556 |
type = self.CurrentNode.GetEntry(index, 1) |
|
557 |
for i in Mappings[-1]: |
|
558 |
for value in Mappings[-1][i]["values"]: |
|
559 |
if value["type"] == index: |
|
560 |
value["type"] = type |
|
561 |
self.CurrentNode.RemoveMappingEntry(index) |
|
562 |
self.CurrentNode.RemoveEntry(index) |
|
563 |
elif index == 0x1200 and subIndex == None: |
|
564 |
self.CurrentNode.RemoveEntry(0x1200) |
|
565 |
elif 0x1201 <= index <= 0x127F and subIndex == None: |
|
566 |
self.CurrentNode.RemoveLine(index, 0x127F) |
|
567 |
elif 0x1280 <= index <= 0x12FF and subIndex == None: |
|
568 |
self.CurrentNode.RemoveLine(index, 0x12FF) |
|
569 |
elif 0x1400 <= index <= 0x15FF or 0x1600 <= index <= 0x17FF and subIndex == None: |
|
570 |
if 0x1600 <= index <= 0x17FF and subIndex == None: |
|
571 |
index -= 0x200 |
|
572 |
self.CurrentNode.RemoveLine(index, 0x15FF) |
|
573 |
self.CurrentNode.RemoveLine(index + 0x200, 0x17FF) |
|
574 |
elif 0x1800 <= index <= 0x19FF or 0x1A00 <= index <= 0x1BFF and subIndex == None: |
|
575 |
if 0x1A00 <= index <= 0x1BFF: |
|
576 |
index -= 0x200 |
|
577 |
self.CurrentNode.RemoveLine(index, 0x19FF) |
|
578 |
self.CurrentNode.RemoveLine(index + 0x200, 0x1BFF) |
|
579 |
else: |
|
580 |
found = False |
|
581 |
for menu,list in self.CurrentNode.GetSpecificMenu(): |
|
582 |
for i in list: |
|
583 |
iinfos = self.GetEntryInfos(i) |
|
584 |
indexes = [i + incr * iinfos["incr"] for incr in xrange(iinfos["nbmax"])] |
|
585 |
if index in indexes: |
|
586 |
found = True |
|
587 |
diff = index - i |
|
588 |
for j in list: |
|
589 |
jinfos = self.GetEntryInfos(j) |
|
590 |
self.CurrentNode.RemoveLine(j + diff, j + jinfos["incr"]*jinfos["nbmax"], jinfos["incr"]) |
|
591 |
self.CurrentNode.RemoveMapVariable(index, subIndex) |
|
592 |
if not found: |
|
593 |
infos = self.GetEntryInfos(index) |
|
594 |
if not infos["need"]: |
|
595 |
self.CurrentNode.RemoveEntry(index, subIndex) |
|
596 |
if index in Mappings[-1]: |
|
597 |
self.CurrentNode.RemoveMappingEntry(index, subIndex) |
|
598 |
||
244 | 599 |
def AddMapVariableToCurrent(self, index, name, struct, number, node = None): |
0 | 600 |
if 0x2000 <= index <= 0x5FFF: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
245
diff
changeset
|
601 |
disable_buffer = node != None |
244 | 602 |
if node == None: |
603 |
node = self.CurrentNode |
|
604 |
if not node.IsEntry(index): |
|
605 |
node.AddMappingEntry(index, name = name, struct = struct) |
|
0 | 606 |
if struct == var: |
205 | 607 |
values = {"name" : name, "type" : 0x05, "access" : "rw", "pdo" : True} |
244 | 608 |
node.AddMappingEntry(index, 0, values = values) |
609 |
node.AddEntry(index, 0, 0) |
|
0 | 610 |
else: |
205 | 611 |
values = {"name" : "Number of Entries", "type" : 0x05, "access" : "ro", "pdo" : False} |
244 | 612 |
node.AddMappingEntry(index, 0, values = values) |
0 | 613 |
if struct == rec: |
205 | 614 |
values = {"name" : name + " %d[(sub)]", "type" : 0x05, "access" : "rw", "pdo" : True, "nbmax" : 0xFE} |
244 | 615 |
node.AddMappingEntry(index, 1, values = values) |
0 | 616 |
for i in xrange(number): |
244 | 617 |
node.AddEntry(index, i + 1, 0) |
0 | 618 |
else: |
619 |
for i in xrange(number): |
|
205 | 620 |
values = {"name" : "Undefined", "type" : 0x05, "access" : "rw", "pdo" : True} |
244 | 621 |
node.AddMappingEntry(index, i + 1, values = values) |
622 |
node.AddEntry(index, i + 1, 0) |
|
623 |
if not disable_buffer: |
|
624 |
self.BufferCurrentNode() |
|
0 | 625 |
return None |
626 |
else: |
|
580 | 627 |
return _("Index 0x%04X already defined!")%index |
628 |
else: |
|
629 |
return _("Index 0x%04X isn't a valid index for Map Variable!")%index |
|
0 | 630 |
|
631 |
def AddUserTypeToCurrent(self, type, min, max, length): |
|
632 |
index = 0xA0 |
|
633 |
while index < 0x100 and self.CurrentNode.IsEntry(index): |
|
634 |
index += 1 |
|
635 |
if index < 0x100: |
|
636 |
customisabletypes = self.GetCustomisableTypes() |
|
637 |
name, valuetype = customisabletypes[type] |
|
638 |
size = self.GetEntryInfos(type)["size"] |
|
639 |
default = self.GetTypeDefaultValue(type) |
|
640 |
if valuetype == 0: |
|
641 |
self.CurrentNode.AddMappingEntry(index, name = "%s[%d-%d]"%(name, min, max), struct = 3, size = size, default = default) |
|
205 | 642 |
self.CurrentNode.AddMappingEntry(index, 0, values = {"name" : "Number of Entries", "type" : 0x05, "access" : "ro", "pdo" : False}) |
643 |
self.CurrentNode.AddMappingEntry(index, 1, values = {"name" : "Type", "type" : 0x05, "access" : "ro", "pdo" : False}) |
|
0 | 644 |
self.CurrentNode.AddMappingEntry(index, 2, values = {"name" : "Minimum Value", "type" : type, "access" : "ro", "pdo" : False}) |
645 |
self.CurrentNode.AddMappingEntry(index, 3, values = {"name" : "Maximum Value", "type" : type, "access" : "ro", "pdo" : False}) |
|
646 |
self.CurrentNode.AddEntry(index, 1, type) |
|
647 |
self.CurrentNode.AddEntry(index, 2, min) |
|
648 |
self.CurrentNode.AddEntry(index, 3, max) |
|
649 |
elif valuetype == 1: |
|
650 |
self.CurrentNode.AddMappingEntry(index, name = "%s%d"%(name, length), struct = 3, size = length * size, default = default) |
|
205 | 651 |
self.CurrentNode.AddMappingEntry(index, 0, values = {"name" : "Number of Entries", "type" : 0x05, "access" : "ro", "pdo" : False}) |
652 |
self.CurrentNode.AddMappingEntry(index, 1, values = {"name" : "Type", "type" : 0x05, "access" : "ro", "pdo" : False}) |
|
653 |
self.CurrentNode.AddMappingEntry(index, 2, values = {"name" : "Length", "type" : 0x05, "access" : "ro", "pdo" : False}) |
|
0 | 654 |
self.CurrentNode.AddEntry(index, 1, type) |
655 |
self.CurrentNode.AddEntry(index, 2, length) |
|
656 |
self.BufferCurrentNode() |
|
657 |
return None |
|
658 |
else: |
|
580 | 659 |
return _("Too many User Types have already been defined!") |
0 | 660 |
|
661 |
#------------------------------------------------------------------------------- |
|
662 |
# Modify Entry and Mapping Functions |
|
663 |
#------------------------------------------------------------------------------- |
|
664 |
||
665 |
def SetCurrentEntryCallbacks(self, index, value): |
|
666 |
if self.CurrentNode and self.CurrentNode.IsEntry(index): |
|
667 |
entry_infos = self.GetEntryInfos(index) |
|
668 |
if "callback" not in entry_infos: |
|
669 |
self.CurrentNode.SetParamsEntry(index, None, callback = value) |
|
670 |
self.BufferCurrentNode() |
|
671 |
||
244 | 672 |
def SetCurrentEntry(self, index, subIndex, value, name, editor, node = None): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
245
diff
changeset
|
673 |
disable_buffer = node != None |
244 | 674 |
if node == None: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
245
diff
changeset
|
675 |
node = self.CurrentNode |
244 | 676 |
if node and node.IsEntry(index): |
0 | 677 |
if name == "value": |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
239
diff
changeset
|
678 |
if editor == "map": |
244 | 679 |
value = node.GetMapValue(value) |
545
ff692766e5e9
Remove deletion PDO when mapping undefined in export to EDS
lbessard
parents:
512
diff
changeset
|
680 |
if value is not None: |
244 | 681 |
node.SetEntry(index, subIndex, value) |
0 | 682 |
elif editor == "bool": |
683 |
value = value == "True" |
|
244 | 684 |
node.SetEntry(index, subIndex, value) |
68
234dad27b398
Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents:
63
diff
changeset
|
685 |
elif editor == "time": |
244 | 686 |
node.SetEntry(index, subIndex, value) |
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
687 |
elif editor == "number": |
188 | 688 |
try: |
244 | 689 |
node.SetEntry(index, subIndex, int(value)) |
188 | 690 |
except: |
691 |
pass |
|
453 | 692 |
elif editor == "float": |
693 |
try: |
|
694 |
node.SetEntry(index, subIndex, float(value)) |
|
695 |
except: |
|
696 |
pass |
|
176 | 697 |
elif editor == "domain": |
698 |
try: |
|
699 |
if len(value) % 2 != 0: |
|
700 |
value = "0" + value |
|
701 |
value = value.decode('hex_codec') |
|
244 | 702 |
node.SetEntry(index, subIndex, value) |
176 | 703 |
except: |
704 |
pass |
|
327 | 705 |
elif editor == "dcf": |
706 |
node.SetEntry(index, subIndex, value) |
|
0 | 707 |
else: |
708 |
subentry_infos = self.GetSubentryInfos(index, subIndex) |
|
30 | 709 |
type = subentry_infos["type"] |
0 | 710 |
dic = {} |
711 |
for typeindex, typevalue in CustomisableTypes: |
|
712 |
dic[typeindex] = typevalue |
|
30 | 713 |
if type not in dic: |
244 | 714 |
type = node.GetEntry(type)[1] |
30 | 715 |
if dic[type] == 0: |
0 | 716 |
try: |
299 | 717 |
if value.startswith("$NODEID"): |
718 |
value = "\"%s\""%value |
|
719 |
elif value.startswith("0x"): |
|
233
6f2936f7fb3f
Permitting user to type decimal or hexadecimal for integer values
lbessard
parents:
223
diff
changeset
|
720 |
value = int(value, 16) |
6f2936f7fb3f
Permitting user to type decimal or hexadecimal for integer values
lbessard
parents:
223
diff
changeset
|
721 |
else: |
6f2936f7fb3f
Permitting user to type decimal or hexadecimal for integer values
lbessard
parents:
223
diff
changeset
|
722 |
value = int(value) |
244 | 723 |
node.SetEntry(index, subIndex, value) |
0 | 724 |
except: |
725 |
pass |
|
726 |
else: |
|
244 | 727 |
node.SetEntry(index, subIndex, value) |
0 | 728 |
elif name in ["comment", "save"]: |
729 |
if editor == "option": |
|
730 |
value = value == "Yes" |
|
731 |
if name == "save": |
|
244 | 732 |
node.SetParamsEntry(index, subIndex, save = value) |
0 | 733 |
elif name == "comment": |
244 | 734 |
node.SetParamsEntry(index, subIndex, comment = value) |
0 | 735 |
else: |
736 |
if editor == "type": |
|
205 | 737 |
value = self.GetTypeIndex(value) |
63
2be18e405e40
Bug on map variable type changing and on comments with special characters corrected
lbessard
parents:
59
diff
changeset
|
738 |
size = self.GetEntryInfos(value)["size"] |
244 | 739 |
node.UpdateMapVariable(index, subIndex, size) |
68
234dad27b398
Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents:
63
diff
changeset
|
740 |
elif editor in ["access","raccess"]: |
0 | 741 |
dic = {} |
742 |
for abbrev,access in AccessType.iteritems(): |
|
743 |
dic[access] = abbrev |
|
744 |
value = dic[value] |
|
244 | 745 |
if editor == "raccess" and not node.IsMappingEntry(index): |
68
234dad27b398
Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents:
63
diff
changeset
|
746 |
entry_infos = self.GetEntryInfos(index) |
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
747 |
subIndex0_infos = self.GetSubentryInfos(index, 0, False).copy() |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
748 |
subIndex1_infos = self.GetSubentryInfos(index, 1, False).copy() |
244 | 749 |
node.AddMappingEntry(index, name = entry_infos["name"], struct = 7) |
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
750 |
node.AddMappingEntry(index, 0, values = subIndex0_infos) |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
751 |
node.AddMappingEntry(index, 1, values = subIndex1_infos) |
244 | 752 |
node.SetMappingEntry(index, subIndex, values = {name : value}) |
753 |
if not disable_buffer: |
|
754 |
self.BufferCurrentNode() |
|
755 |
return None |
|
0 | 756 |
|
757 |
def SetCurrentEntryName(self, index, name): |
|
758 |
self.CurrentNode.SetMappingEntry(index, name=name) |
|
759 |
self.BufferCurrentNode() |
|
760 |
||
761 |
def SetCurrentUserType(self, index, type, min, max, length): |
|
762 |
customisabletypes = self.GetCustomisableTypes() |
|
763 |
values, valuetype = self.GetCustomisedTypeValues(index) |
|
764 |
name, new_valuetype = customisabletypes[type] |
|
765 |
size = self.GetEntryInfos(type)["size"] |
|
766 |
default = self.GetTypeDefaultValue(type) |
|
767 |
if new_valuetype == 0: |
|
768 |
self.CurrentNode.SetMappingEntry(index, name = "%s[%d-%d]"%(name, min, max), struct = 3, size = size, default = default) |
|
769 |
if valuetype == 1: |
|
770 |
self.CurrentNode.SetMappingEntry(index, 2, values = {"name" : "Minimum Value", "type" : type, "access" : "ro", "pdo" : False}) |
|
771 |
self.CurrentNode.AddMappingEntry(index, 3, values = {"name" : "Maximum Value", "type" : type, "access" : "ro", "pdo" : False}) |
|
772 |
self.CurrentNode.SetEntry(index, 1, type) |
|
773 |
self.CurrentNode.SetEntry(index, 2, min) |
|
774 |
if valuetype == 1: |
|
775 |
self.CurrentNode.AddEntry(index, 3, max) |
|
776 |
else: |
|
777 |
self.CurrentNode.SetEntry(index, 3, max) |
|
778 |
elif new_valuetype == 1: |
|
779 |
self.CurrentNode.SetMappingEntry(index, name = "%s%d"%(name, length), struct = 3, size = size, default = default) |
|
780 |
if valuetype == 0: |
|
781 |
self.CurrentNode.SetMappingEntry(index, 2, values = {"name" : "Length", "type" : 0x02, "access" : "ro", "pdo" : False}) |
|
782 |
self.CurrentNode.RemoveMappingEntry(index, 3) |
|
783 |
self.CurrentNode.SetEntry(index, 1, type) |
|
784 |
self.CurrentNode.SetEntry(index, 2, length) |
|
785 |
if valuetype == 0: |
|
786 |
self.CurrentNode.RemoveEntry(index, 3) |
|
787 |
self.BufferCurrentNode() |
|
788 |
||
789 |
#------------------------------------------------------------------------------- |
|
790 |
# Current Buffering Management Functions |
|
791 |
#------------------------------------------------------------------------------- |
|
792 |
||
793 |
def BufferCurrentNode(self): |
|
794 |
self.UndoBuffers[self.NodeIndex].Buffering(self.CurrentNode.Copy()) |
|
795 |
||
796 |
def CurrentIsSaved(self): |
|
797 |
return self.UndoBuffers[self.NodeIndex].IsCurrentSaved() |
|
798 |
||
799 |
def OneFileHasChanged(self): |
|
800 |
result = False |
|
205 | 801 |
for buffer in self.UndoBuffers.values(): |
0 | 802 |
result |= not buffer.IsCurrentSaved() |
803 |
return result |
|
804 |
||
805 |
def GetBufferNumber(self): |
|
806 |
return len(self.UndoBuffers) |
|
807 |
||
485
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
808 |
def GetBufferIndexes(self): |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
809 |
return self.UndoBuffers.keys() |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
810 |
|
0 | 811 |
def LoadCurrentPrevious(self): |
812 |
self.CurrentNode = self.UndoBuffers[self.NodeIndex].Previous().Copy() |
|
813 |
||
814 |
def LoadCurrentNext(self): |
|
815 |
self.CurrentNode = self.UndoBuffers[self.NodeIndex].Next().Copy() |
|
816 |
||
817 |
def AddNodeBuffer(self, currentstate = None, issaved = False): |
|
205 | 818 |
self.NodeIndex = GetNewId() |
819 |
self.UndoBuffers[self.NodeIndex] = UndoBuffer(currentstate, issaved) |
|
820 |
self.FilePaths[self.NodeIndex] = "" |
|
821 |
self.FileNames[self.NodeIndex] = "" |
|
822 |
return self.NodeIndex |
|
0 | 823 |
|
824 |
def ChangeCurrentNode(self, index): |
|
205 | 825 |
if index in self.UndoBuffers.keys(): |
0 | 826 |
self.NodeIndex = index |
827 |
self.CurrentNode = self.UndoBuffers[self.NodeIndex].Current().Copy() |
|
828 |
||
829 |
def RemoveNodeBuffer(self, index): |
|
830 |
self.UndoBuffers.pop(index) |
|
831 |
self.FilePaths.pop(index) |
|
832 |
self.FileNames.pop(index) |
|
833 |
||
834 |
def GetCurrentNodeIndex(self): |
|
835 |
return self.NodeIndex |
|
836 |
||
837 |
def GetCurrentFilename(self): |
|
838 |
return self.GetFilename(self.NodeIndex) |
|
839 |
||
840 |
def GetAllFilenames(self): |
|
205 | 841 |
indexes = self.UndoBuffers.keys() |
842 |
indexes.sort() |
|
843 |
return [self.GetFilename(idx) for idx in indexes] |
|
0 | 844 |
|
845 |
def GetFilename(self, index): |
|
846 |
if self.UndoBuffers[index].IsCurrentSaved(): |
|
847 |
return self.FileNames[index] |
|
848 |
else: |
|
849 |
return "~%s~"%self.FileNames[index] |
|
850 |
||
851 |
def SetCurrentFilePath(self, filepath): |
|
852 |
self.FilePaths[self.NodeIndex] = filepath |
|
853 |
if filepath == "": |
|
854 |
self.LastNewIndex += 1 |
|
580 | 855 |
self.FileNames[self.NodeIndex] = _("Unnamed%d")%self.LastNewIndex |
0 | 856 |
else: |
857 |
self.FileNames[self.NodeIndex] = os.path.splitext(os.path.basename(filepath))[0] |
|
858 |
||
859 |
def GetCurrentFilePath(self): |
|
860 |
if len(self.FilePaths) > 0: |
|
861 |
return self.FilePaths[self.NodeIndex] |
|
862 |
else: |
|
863 |
return "" |
|
864 |
||
865 |
def GetCurrentBufferState(self): |
|
866 |
first = self.UndoBuffers[self.NodeIndex].IsFirst() |
|
867 |
last = self.UndoBuffers[self.NodeIndex].IsLast() |
|
868 |
return not first, not last |
|
869 |
||
870 |
#------------------------------------------------------------------------------- |
|
871 |
# Profiles Management Functions |
|
872 |
#------------------------------------------------------------------------------- |
|
873 |
||
874 |
def GetCurrentCommunicationLists(self): |
|
875 |
list = [] |
|
876 |
for index in MappingDictionary.iterkeys(): |
|
877 |
if 0x1000 <= index < 0x1200: |
|
878 |
list.append(index) |
|
879 |
return self.GetProfileLists(MappingDictionary, list) |
|
880 |
||
881 |
def GetCurrentDS302Lists(self): |
|
882 |
return self.GetSpecificProfileLists(self.CurrentNode.GetDS302Profile()) |
|
883 |
||
884 |
def GetCurrentProfileLists(self): |
|
885 |
return self.GetSpecificProfileLists(self.CurrentNode.GetProfile()) |
|
886 |
||
887 |
def GetSpecificProfileLists(self, mappingdictionary): |
|
888 |
validlist = [] |
|
889 |
exclusionlist = [] |
|
890 |
for name, list in self.CurrentNode.GetSpecificMenu(): |
|
891 |
exclusionlist.extend(list) |
|
892 |
for index in mappingdictionary.iterkeys(): |
|
893 |
if index not in exclusionlist: |
|
894 |
validlist.append(index) |
|
895 |
return self.GetProfileLists(mappingdictionary, validlist) |
|
896 |
||
897 |
def GetProfileLists(self, mappingdictionary, list): |
|
898 |
dictionary = {} |
|
899 |
current = [] |
|
900 |
for index in list: |
|
901 |
dictionary[index] = (mappingdictionary[index]["name"], mappingdictionary[index]["need"]) |
|
902 |
if self.CurrentNode.IsEntry(index): |
|
903 |
current.append(index) |
|
904 |
return dictionary, current |
|
905 |
||
39 | 906 |
def GetCurrentNextMapIndex(self): |
907 |
if self.CurrentNode: |
|
908 |
index = 0x2000 |
|
909 |
while self.CurrentNode.IsEntry(index) and index < 0x5FFF: |
|
910 |
index += 1 |
|
911 |
if index < 0x6000: |
|
912 |
return index |
|
913 |
else: |
|
914 |
return None |
|
915 |
||
0 | 916 |
def CurrentDS302Defined(self): |
917 |
if self.CurrentNode: |
|
918 |
return len(self.CurrentNode.GetDS302Profile()) > 0 |
|
919 |
return False |
|
920 |
||
921 |
#------------------------------------------------------------------------------- |
|
922 |
# Node State and Values Functions |
|
923 |
#------------------------------------------------------------------------------- |
|
205 | 924 |
|
925 |
def GetCurrentNodeName(self): |
|
926 |
if self.CurrentNode: |
|
927 |
return self.CurrentNode.GetNodeName() |
|
928 |
else: |
|
929 |
return "" |
|
930 |
||
244 | 931 |
def GetCurrentNodeCopy(self): |
932 |
if self.CurrentNode: |
|
933 |
return self.CurrentNode.Copy() |
|
934 |
else: |
|
935 |
return None |
|
936 |
||
937 |
def GetCurrentNodeID(self, node = None): |
|
205 | 938 |
if self.CurrentNode: |
939 |
return self.CurrentNode.GetNodeID() |
|
940 |
else: |
|
941 |
return None |
|
0 | 942 |
|
943 |
def GetCurrentNodeInfos(self): |
|
944 |
name = self.CurrentNode.GetNodeName() |
|
945 |
id = self.CurrentNode.GetNodeID() |
|
946 |
type = self.CurrentNode.GetNodeType() |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
947 |
description = self.CurrentNode.GetNodeDescription() |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
948 |
return name, id, type, description |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
949 |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
950 |
def SetCurrentNodeInfos(self, name, id, type, description): |
0 | 951 |
self.CurrentNode.SetNodeName(name) |
952 |
self.CurrentNode.SetNodeID(id) |
|
953 |
self.CurrentNode.SetNodeType(type) |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
954 |
self.CurrentNode.SetNodeDescription(description) |
0 | 955 |
self.BufferCurrentNode() |
956 |
||
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
957 |
def GetCurrentNodeDefaultStringSize(self): |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
958 |
if self.CurrentNode: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
959 |
return self.CurrentNode.GetDefaultStringSize() |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
960 |
else: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
961 |
return Node.DefaultStringSize |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
962 |
|
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
963 |
def SetCurrentNodeDefaultStringSize(self, size): |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
964 |
if self.CurrentNode: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
965 |
self.CurrentNode.SetDefaultStringSize(size) |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
966 |
else: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
967 |
Node.DefaultStringSize = size |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
338
diff
changeset
|
968 |
|
0 | 969 |
def GetCurrentProfileName(self): |
970 |
if self.CurrentNode: |
|
971 |
return self.CurrentNode.GetProfileName() |
|
972 |
return "" |
|
973 |
||
974 |
def IsCurrentEntry(self, index): |
|
975 |
if self.CurrentNode: |
|
976 |
return self.CurrentNode.IsEntry(index) |
|
977 |
return False |
|
978 |
||
299 | 979 |
def GetCurrentEntry(self, index, subIndex = None, compute = True): |
980 |
if self.CurrentNode: |
|
981 |
return self.CurrentNode.GetEntry(index, subIndex, compute) |
|
0 | 982 |
return None |
983 |
||
984 |
def GetCurrentParamsEntry(self, index, subIndex = None): |
|
985 |
if self.CurrentNode: |
|
986 |
return self.CurrentNode.GetParamsEntry(index, subIndex) |
|
987 |
return None |
|
988 |
||
989 |
def GetCurrentValidIndexes(self, min, max): |
|
990 |
validindexes = [] |
|
991 |
for index in self.CurrentNode.GetIndexes(): |
|
992 |
if min <= index <= max: |
|
993 |
validindexes.append((self.GetEntryName(index), index)) |
|
994 |
return validindexes |
|
995 |
||
996 |
def GetCurrentValidChoices(self, min, max): |
|
997 |
validchoices = [] |
|
998 |
exclusionlist = [] |
|
999 |
for menu, indexes in self.CurrentNode.GetSpecificMenu(): |
|
1000 |
exclusionlist.extend(indexes) |
|
1001 |
good = True |
|
1002 |
for index in indexes: |
|
1003 |
good &= min <= index <= max |
|
1004 |
if good: |
|
1005 |
validchoices.append((menu, None)) |
|
1006 |
list = [index for index in MappingDictionary.keys() if index >= 0x1000] |
|
1007 |
profiles = self.CurrentNode.GetMappings(False) |
|
1008 |
for profile in profiles: |
|
1009 |
list.extend(profile.keys()) |
|
1010 |
list.sort() |
|
1011 |
for index in list: |
|
1012 |
if min <= index <= max and not self.CurrentNode.IsEntry(index) and index not in exclusionlist: |
|
1013 |
validchoices.append((self.GetEntryName(index), index)) |
|
1014 |
return validchoices |
|
1015 |
||
1016 |
def HasCurrentEntryCallbacks(self, index): |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
244
diff
changeset
|
1017 |
if self.CurrentNode: |
0 | 1018 |
return self.CurrentNode.HasEntryCallbacks(index) |
1019 |
return False |
|
1020 |
||
1021 |
def GetCurrentEntryValues(self, index): |
|
205 | 1022 |
if self.CurrentNode: |
1023 |
return self.GetNodeEntryValues(self.CurrentNode, index) |
|
1024 |
||
1025 |
def GetNodeEntryValues(self, node, index): |
|
1026 |
if node and node.IsEntry(index): |
|
1027 |
entry_infos = node.GetEntryInfos(index) |
|
0 | 1028 |
data = [] |
1029 |
editors = [] |
|
299 | 1030 |
values = node.GetEntry(index, compute = False) |
205 | 1031 |
params = node.GetParamsEntry(index) |
512 | 1032 |
if isinstance(values, ListType): |
0 | 1033 |
for i, value in enumerate(values): |
1034 |
data.append({"value" : value}) |
|
176 | 1035 |
data[-1].update(params[i]) |
0 | 1036 |
else: |
1037 |
data.append({"value" : values}) |
|
1038 |
data[-1].update(params) |
|
1039 |
for i, dic in enumerate(data): |
|
205 | 1040 |
infos = node.GetSubentryInfos(index, i) |
0 | 1041 |
dic["subindex"] = "0x%02X"%i |
1042 |
dic["name"] = infos["name"] |
|
205 | 1043 |
dic["type"] = node.GetTypeName(infos["type"]) |
582
e297491483ea
Adding support for displaying 'unknown' while datatype is not supported by CanFestival
laurent
parents:
580
diff
changeset
|
1044 |
if dic["type"] is None: |
e297491483ea
Adding support for displaying 'unknown' while datatype is not supported by CanFestival
laurent
parents:
580
diff
changeset
|
1045 |
dic["type"] = "Unknown" |
0 | 1046 |
dic["access"] = AccessType[infos["access"]] |
1047 |
dic["save"] = OptionType[dic["save"]] |
|
582
e297491483ea
Adding support for displaying 'unknown' while datatype is not supported by CanFestival
laurent
parents:
580
diff
changeset
|
1048 |
editor = {"subindex" : None, "name" : None, |
e297491483ea
Adding support for displaying 'unknown' while datatype is not supported by CanFestival
laurent
parents:
580
diff
changeset
|
1049 |
"type" : None, "value" : None, |
e297491483ea
Adding support for displaying 'unknown' while datatype is not supported by CanFestival
laurent
parents:
580
diff
changeset
|
1050 |
"access" : None, "save" : "option", |
e297491483ea
Adding support for displaying 'unknown' while datatype is not supported by CanFestival
laurent
parents:
580
diff
changeset
|
1051 |
"callback" : "option", "comment" : "string"} |
512 | 1052 |
if isinstance(values, ListType) and i == 0: |
68
234dad27b398
Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents:
63
diff
changeset
|
1053 |
if 0x1600 <= index <= 0x17FF or 0x1A00 <= index <= 0x1C00: |
234dad27b398
Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents:
63
diff
changeset
|
1054 |
editor["access"] = "raccess" |
0 | 1055 |
else: |
1056 |
if infos["user_defined"]: |
|
1057 |
if entry_infos["struct"] & OD_IdenticalSubindexes: |
|
582
e297491483ea
Adding support for displaying 'unknown' while datatype is not supported by CanFestival
laurent
parents:
580
diff
changeset
|
1058 |
if i == 0: |
0 | 1059 |
editor["type"] = "type" |
1060 |
editor["access"] = "access" |
|
1061 |
else: |
|
1062 |
if entry_infos["struct"] & OD_MultipleSubindexes: |
|
1063 |
editor["name"] = "string" |
|
1064 |
editor["type"] = "type" |
|
1065 |
editor["access"] = "access" |
|
1066 |
if index < 0x260: |
|
1067 |
if i == 1: |
|
205 | 1068 |
dic["value"] = node.GetTypeName(dic["value"]) |
0 | 1069 |
elif 0x1600 <= index <= 0x17FF or 0x1A00 <= index <= 0x1C00: |
1070 |
editor["value"] = "map" |
|
205 | 1071 |
dic["value"] = node.GetMapName(dic["value"]) |
0 | 1072 |
else: |
333 | 1073 |
if dic["type"].startswith("VISIBLE_STRING") or dic["type"].startswith("OCTET_STRING"): |
0 | 1074 |
editor["value"] = "string" |
176 | 1075 |
elif dic["type"] in ["TIME_OF_DAY","TIME_DIFFERENCE"]: |
68
234dad27b398
Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents:
63
diff
changeset
|
1076 |
editor["value"] = "time" |
176 | 1077 |
elif dic["type"] == "DOMAIN": |
327 | 1078 |
if index == 0x1F22: |
1079 |
editor["value"] = "dcf" |
|
1080 |
else: |
|
1081 |
editor["value"] = "domain" |
|
176 | 1082 |
dic["value"] = dic["value"].encode('hex_codec') |
0 | 1083 |
elif dic["type"] == "BOOLEAN": |
1084 |
editor["value"] = "bool" |
|
1085 |
dic["value"] = BoolType[dic["value"]] |
|
1086 |
result = type_model.match(dic["type"]) |
|
1087 |
if result: |
|
1088 |
values = result.groups() |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
1089 |
if values[0] == "UNSIGNED": |
299 | 1090 |
try: |
1091 |
format = "0x%0" + str(int(values[1])/4) + "X" |
|
1092 |
dic["value"] = format%dic["value"] |
|
1093 |
except: |
|
1094 |
pass |
|
0 | 1095 |
editor["value"] = "string" |
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
1096 |
if values[0] == "INTEGER": |
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
1097 |
editor["value"] = "number" |
0 | 1098 |
elif values[0] == "REAL": |
1099 |
editor["value"] = "float" |
|
333 | 1100 |
elif values[0] in ["VISIBLE_STRING", "OCTET_STRING"]: |
0 | 1101 |
editor["length"] = values[0] |
1102 |
result = range_model.match(dic["type"]) |
|
1103 |
if result: |
|
1104 |
values = result.groups() |
|
182
988f2b302aa6
Adding support for importing and exporting EDS files
lbessard
parents:
176
diff
changeset
|
1105 |
if values[0] in ["UNSIGNED", "INTEGER", "REAL"]: |
0 | 1106 |
editor["min"] = values[2] |
1107 |
editor["max"] = values[3] |
|
1108 |
editors.append(editor) |
|
1109 |
return data, editors |
|
1110 |
else: |
|
1111 |
return None |
|
205 | 1112 |
|
327 | 1113 |
def AddToDCF(self, node_id, index, subindex, size, value): |
1114 |
if self.CurrentNode.IsEntry(0x1F22, node_id): |
|
1115 |
dcf_value = self.CurrentNode.GetEntry(0x1F22, node_id) |
|
338 | 1116 |
if dcf_value != "": |
1117 |
nbparams = BE_to_LE(dcf_value[:4]) |
|
1118 |
else: |
|
1119 |
nbparams = 0 |
|
327 | 1120 |
new_value = LE_to_BE(nbparams + 1, 4) + dcf_value[4:] |
1121 |
new_value += LE_to_BE(index, 2) + LE_to_BE(subindex, 1) + LE_to_BE(size, 4) + LE_to_BE(value, size) |
|
1122 |
self.CurrentNode.SetEntry(0x1F22, node_id, new_value) |
|
1123 |
||
0 | 1124 |
#------------------------------------------------------------------------------- |
1125 |
# Node Informations Functions |
|
1126 |
#------------------------------------------------------------------------------- |
|
1127 |
||
1128 |
def GetCustomisedTypeValues(self, index): |
|
205 | 1129 |
if self.CurrentNode: |
1130 |
values = self.CurrentNode.GetEntry(index) |
|
1131 |
customisabletypes = self.GetCustomisableTypes() |
|
1132 |
return values, customisabletypes[values[1]][1] |
|
1133 |
else: |
|
1134 |
return None, None |
|
1135 |
||
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1136 |
def GetEntryName(self, index, compute=True): |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1137 |
if self.CurrentNode: |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1138 |
return self.CurrentNode.GetEntryName(index, compute) |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1139 |
else: |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1140 |
return FindEntryName(index, MappingDictionary, compute) |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1141 |
|
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1142 |
def GetEntryInfos(self, index, compute=True): |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1143 |
if self.CurrentNode: |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1144 |
return self.CurrentNode.GetEntryInfos(index, compute) |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1145 |
else: |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1146 |
return FindEntryInfos(index, MappingDictionary, compute) |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1147 |
|
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1148 |
def GetSubentryInfos(self, index, subindex, compute=True): |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1149 |
if self.CurrentNode: |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1150 |
return self.CurrentNode.GetSubentryInfos(index, subindex, compute) |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1151 |
else: |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1152 |
result = FindSubentryInfos(index, subindex, MappingDictionary, compute) |
68
234dad27b398
Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents:
63
diff
changeset
|
1153 |
if result: |
234dad27b398
Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents:
63
diff
changeset
|
1154 |
result["user_defined"] = False |
205 | 1155 |
return result |
1156 |
||
1157 |
def GetTypeIndex(self, typename): |
|
1158 |
if self.CurrentNode: |
|
1159 |
return self.CurrentNode.GetTypeIndex(typename) |
|
1160 |
else: |
|
1161 |
return FindTypeIndex(typename, MappingDictionary) |
|
1162 |
||
1163 |
def GetTypeName(self, typeindex): |
|
1164 |
if self.CurrentNode: |
|
1165 |
return self.CurrentNode.GetTypeName(typeindex) |
|
1166 |
else: |
|
1167 |
return FindTypeName(typeindex, MappingDictionary) |
|
1168 |
||
1169 |
def GetTypeDefaultValue(self, typeindex): |
|
1170 |
if self.CurrentNode: |
|
1171 |
return self.CurrentNode.GetTypeDefaultValue(typeindex) |
|
1172 |
else: |
|
1173 |
return FindTypeDefaultValue(typeindex, MappingDictionary) |
|
1174 |
||
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1175 |
def GetMapVariableList(self, compute=True): |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1176 |
if self.CurrentNode: |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
582
diff
changeset
|
1177 |
return self.CurrentNode.GetMapVariableList(compute) |
205 | 1178 |
else: |
1179 |
return [] |
|
1180 |
||
244 | 1181 |
def GetMandatoryIndexes(self): |
205 | 1182 |
if self.CurrentNode: |
220 | 1183 |
return self.CurrentNode.GetMandatoryIndexes() |
205 | 1184 |
else: |
1185 |
return FindMandatoryIndexes(MappingDictionary) |
|
0 | 1186 |
|
1187 |
def GetCustomisableTypes(self): |
|
1188 |
dic = {} |
|
1189 |
for index, valuetype in CustomisableTypes: |
|
1190 |
name = self.GetTypeName(index) |
|
1191 |
dic[index] = [name, valuetype] |
|
1192 |
return dic |
|
1193 |
||
1194 |
def GetCurrentSpecificMenu(self): |
|
1195 |
if self.CurrentNode: |
|
1196 |
return self.CurrentNode.GetSpecificMenu() |
|
1197 |
return [] |
|
1198 |