objdictgen/node.py
author etisserant
Mon, 21 Apr 2008 16:34:51 +0200
changeset 442 010c26b9ba89
parent 418 64a8c24b61a5
child 453 c74a73474cce
permissions -rwxr-xr-x
Doxy-style comments and various cleanup in unix.c
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
#!/usr/bin/env python
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
#This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
#See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
#This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
#modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
#License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
#version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
#This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
#but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
#Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
#You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
#License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
import cPickle
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
from types import *
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
    26
import re
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
Dictionary of translation between access symbol and their signification
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
AccessType = {"ro" : "Read Only", "wo" : "Write Only", "rw" : "Read/Write"}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
BoolType = {True : "True", False : "False"} 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
OptionType = {True : "Yes", False : "No"}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
CustomisableTypes = [(0x02, 0), (0x03, 0), (0x04, 0), (0x05, 0), (0x06, 0), (0x07, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
    (0x08, 0), (0x09, 1), (0x0A, 1), (0x0B, 1), (0x10, 0), (0x11, 0), (0x12, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
    (0x13, 0), (0x14, 0), (0x15, 0), (0x16, 0), (0x18, 0), (0x19, 0), (0x1A, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
    (0x1B, 0)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
DefaultParams = {"comment" : "", "save" : False}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    44
#                      Dictionary Mapping and Organisation
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    45
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
Properties of entry structure in the Object Dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
OD_Subindex = 1             # Entry has at least one subindex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
OD_MultipleSubindexes = 2   # Entry has more than one subindex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
OD_IdenticalSubindexes = 4  # Subindexes of entry have the same description
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
OD_IdenticalIndexes = 8     # Entry has the same description on multiple indexes
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
Structures of entry in the Object Dictionary, sum of the properties described above
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
for all sorts of entries use in CAN Open specification
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
nosub = 0 # Entry without subindex (only for type declaration)
260
1eafe582b6a1 Better code readability
etisserant
parents: 258
diff changeset
    60
var = OD_Subindex
1eafe582b6a1 Better code readability
etisserant
parents: 258
diff changeset
    61
array = OD_Subindex | OD_MultipleSubindexes
1eafe582b6a1 Better code readability
etisserant
parents: 258
diff changeset
    62
rec = OD_Subindex | OD_MultipleSubindexes | OD_IdenticalSubindexes
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
# Entries identical on multiple indexes
260
1eafe582b6a1 Better code readability
etisserant
parents: 258
diff changeset
    64
plurivar = OD_Subindex | OD_IdenticalIndexes
1eafe582b6a1 Better code readability
etisserant
parents: 258
diff changeset
    65
pluriarray = OD_Subindex | OD_MultipleSubindexes | OD_IdenticalIndexes # Example : PDO Parameters
1eafe582b6a1 Better code readability
etisserant
parents: 258
diff changeset
    66
plurirec = OD_Subindex | OD_MultipleSubindexes | OD_IdenticalSubindexes |OD_IdenticalIndexes   # Example : PDO Mapping
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    69
MappingDictionary is the structure used for writing a good organised Object
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
Dictionary. It follows the specifications of the CANOpen standard.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
Change the informations within it if there is a mistake. But don't modify the
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
organisation of this object, it will involve in a malfunction of the application.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
MappingDictionary = {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
    0x0001 : {"name" : "BOOLEAN", "struct" : nosub, "size" : 1, "default" : False, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
    0x0002 : {"name" : "INTEGER8", "struct" : nosub, "size" : 8, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
    0x0003 : {"name" : "INTEGER16", "struct" : nosub, "size" : 16, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
    0x0004 : {"name" : "INTEGER32", "struct" : nosub, "size" : 32, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
    0x0005 : {"name" : "UNSIGNED8", "struct" : nosub, "size" : 8, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
    0x0006 : {"name" : "UNSIGNED16", "struct" : nosub, "size" : 16, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
    0x0007 : {"name" : "UNSIGNED32", "struct" : nosub, "size" : 32, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
    0x0008 : {"name" : "REAL32", "struct" : nosub, "size" : 32, "default" : 0.0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
    0x0009 : {"name" : "VISIBLE_STRING", "struct" : nosub, "size" : 8, "default" : "", "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
    0x000A : {"name" : "OCTET_STRING", "struct" : nosub, "size" : 8, "default" : "", "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
    0x000B : {"name" : "UNICODE_STRING", "struct" : nosub, "size" : 16, "default" : "", "values" : []},
67
51642fb5a0af TIME_OF_DAY and TIME_DIFFERENCE disabled
lbessard
parents: 65
diff changeset
    87
#    0x000C : {"name" : "TIME_OF_DAY", "struct" : nosub, "size" : 48, "default" : 0, "values" : []},
51642fb5a0af TIME_OF_DAY and TIME_DIFFERENCE disabled
lbessard
parents: 65
diff changeset
    88
#    0x000D : {"name" : "TIME_DIFFERENCE", "struct" : nosub, "size" : 48, "default" : 0, "values" : []},
176
5d57fe1e3a5b Support for DCF (DS-302)
greg
parents: 68
diff changeset
    89
    0x000F : {"name" : "DOMAIN", "struct" : nosub, "size" : 0, "default" : "", "values" : []},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
    0x0010 : {"name" : "INTEGER24", "struct" : nosub, "size" : 24, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
    0x0011 : {"name" : "REAL64", "struct" : nosub, "size" : 64, "default" : 0.0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
    0x0012 : {"name" : "INTEGER40", "struct" : nosub, "size" : 40, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
    0x0013 : {"name" : "INTEGER48", "struct" : nosub, "size" : 48, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
    0x0014 : {"name" : "INTEGER56", "struct" : nosub, "size" : 56, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
    0x0015 : {"name" : "INTEGER64", "struct" : nosub, "size" : 64, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
    0x0016 : {"name" : "UNSIGNED24", "struct" : nosub, "size" : 24, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
    0x0018 : {"name" : "UNSIGNED40", "struct" : nosub, "size" : 40, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
    0x0019 : {"name" : "UNSIGNED48", "struct" : nosub, "size" : 48, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
    0x001A : {"name" : "UNSIGNED56", "struct" : nosub, "size" : 56, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
    0x001B : {"name" : "UNSIGNED64", "struct" : nosub, "size" : 64, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
    0x1000 : {"name" : "Device Type", "struct" : var, "need" : True, "values" : 
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   102
                [{"name" : "Device Type", "type" : 0x07, "access" : 'ro', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
    0x1001 : {"name" : "Error Register", "struct" : var,  "need" : True, "values" : 
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   104
                [{"name" : "Error Register", "type" : 0x05, "access": 'ro', "pdo" : True}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
    0x1002 : {"name" : "Manufacturer Status Register", "struct" : var, "need" : False,  "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   106
                [{"name" : "Manufacturer Status Register", "type" : 0x07, "access" : 'ro', "pdo" : True}]},
284
24bf3d692993 Implemented EMCY objects.
luis
parents: 281
diff changeset
   107
    0x1003 : {"name" : "Pre-defined Error Field", "struct" : rec, "need" : False, "callback" : True,  "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   108
                [{"name" : "Number of Errors", "type" : 0x05, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   109
                 {"name" : "Standard Error Field", "type" : 0x07, "access" : 'ro', "pdo" : False, "nbmax" : 0xFE}]},
258
8f7725451453 Some bugs fixed:
lbessard
parents: 245
diff changeset
   110
    0x1005 : {"name" : "SYNC COB ID", "struct" : var, "need" : False, "callback" : True, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   111
                [{"name" : "SYNC COB ID", "type" : 0x07, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
    0x1006 : {"name" : "Communication / Cycle Period", "struct" : var, "need" : False, "callback" : True, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   113
                [{"name" : "Communication Cycle Period", "type" : 0x07, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
    0x1007 : {"name" : "Synchronous Window Length", "struct" : var, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   115
                [{"name" : "Synchronous Window Length", "type" : 0x07, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
    0x1008 : {"name" : "Manufacturer Device Name", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
                [{"name" : "Manufacturer Device Name", "type" : 0x09, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
    0x1009 : {"name" : "Manufacturer Hardware Version", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
                [{"name" : "Manufacturer Hardware Version", "type" : 0x09, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
    0x100A : {"name" : "Manufacturer Software Version", "struct" : var, "need" : False, "values" :
62
93d4db3677e6 index 0x1004 is a visible_string
frdupin
parents: 59
diff changeset
   121
                [{"name" : "Manufacturer Software Version", "type" : 0x09, "access" : 'ro', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
    0x100C : {"name" : "Guard Time", "struct" : var, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   123
                [{"name" : "Guard Time", "type" : 0x06, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
    0x100D : {"name" : "Life Time Factor", "struct" : var, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   125
                [{"name" : "Life Time Factor", "type" : 0x05, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
    0x1010 : {"name" : "Store parameters", "struct" : array, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   127
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   128
                 {"name" : "Save All Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   129
                 {"name" : "Save Communication Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   130
                 {"name" : "Save Application Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   131
                 {"name" : "Save Manufacturer Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmax" : 0x7C}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
    0x1011 : {"name" : "Restore Default Parameters", "struct" : array, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   133
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   134
                 {"name" : "Restore All Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   135
                 {"name" : "Restore Communication Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   136
                 {"name" : "Restore Application Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   137
                 {"name" : "Restore Manufacturer Default Parameters", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmax" : 0x7C}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
    0x1012 : {"name" : "TIME COB ID", "struct" : var, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   139
                [{"name" : "TIME COB ID", "type" : 0x07, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
    0x1013 : {"name" : "High Resolution Timestamp", "struct" : var, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   141
                [{"name" : "High Resolution Time Stamp", "type" : 0x07, "access" : 'rw', "pdo" : True}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
    0x1014 : {"name" : "Emergency COB ID", "struct" : var, "need" : False, "values" :
313
fed411af774a Adding standard default value to index 0x1014
lbessard
parents: 304
diff changeset
   143
                [{"name" : "Emergency COB ID", "type" : 0x07, "access" : 'rw', "pdo" : False, "default" : "\"$NODEID+0x80\""}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
    0x1015 : {"name" : "Inhibit Time Emergency", "struct" : var, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   145
                [{"name" : "Inhibit Time Emergency", "type" : 0x06, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
    0x1016 : {"name" : "Consumer Heartbeat Time", "struct" : rec, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   147
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   148
                 {"name" : "Consumer Heartbeat Time", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmin" : 1, "nbmax" : 0x7F}]},
177
d485a3fc5739 Add default callback for index entry 0x1017
greg
parents: 176
diff changeset
   149
    0x1017 : {"name" : "Producer Heartbeat Time", "struct" : var, "need" : False, "callback" : True, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   150
                [{"name" : "Producer Heartbeat Time", "type" : 0x06, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
    0x1018 : {"name" : "Identity", "struct" : array, "need" : True, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   152
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   153
                 {"name" : "Vendor ID", "type" : 0x07, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   154
                 {"name" : "Product Code", "type" : 0x07, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   155
                 {"name" : "Revision Number", "type" : 0x07, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   156
                 {"name" : "Serial Number", "type" : 0x07, "access" : 'ro', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
    0x1020 : {"name" : "Verify Configuration", "struct" : array, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   158
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   159
                 {"name" : "Configuration Date", "type" : 0x07, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   160
                 {"name" : "Configuration Time", "type" : 0x07, "access" : 'ro', "pdo" : False}]},
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 0
diff changeset
   161
#    0x1021 : {"name" : "Store EDS", "struct" : var, "need" : False, "values" :
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 0
diff changeset
   162
#                [{"name" : "Store EDS", "type" : 0x0F, "access" : 'rw', "pdo" : False}]},
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 0
diff changeset
   163
#    0x1022 : {"name" : "Storage Format", "struct" : var, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   164
#                [{"name" : "Storage Format", "type" : 0x06, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
    0x1023 : {"name" : "OS Command", "struct" : array, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   166
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
                 {"name" : "Command", "type" : 0x0A, "access" : 'rw', "pdo" : False},
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   168
                 {"name" : "Status", "type" : 0x05, "access" : 'ro', "pdo" : False},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
                 {"name" : "Reply", "type" : 0x0A, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
    0x1024 : {"name" : "OS Command Mode", "struct" : var, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   171
                [{"name" : "OS Command Mode", "type" : 0x05, "access" : 'wo', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
    0x1025 : {"name" : "OS Debugger Interface", "struct" : array, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   173
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   174
                 {"name" : "Command", "type" : 0x0A, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   175
                 {"name" : "Status", "type" : 0x07, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   176
                 {"name" : "Reply", "type" : 0x0A, "access" : 'ro', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
    0x1026 : {"name" : "OS Prompt", "struct" : array, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   178
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   179
                 {"name" : "StdIn", "type" : 0x05, "access" : 'wo', "pdo" : True},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   180
                 {"name" : "StdOut", "type" : 0x05, "access" : 'ro', "pdo" : True},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   181
                 {"name" : "StdErr", "type" : 0x05, "access" : 'ro', "pdo" : True}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   182
    0x1027 : {"name" : "Module List", "struct" : rec, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   183
                [{"name" : "Number of Connected Modules", "type" : 0x05, "access" : 'ro', "pdo" : False},
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   184
                 {"name" : "Module %d[(sub)]", "type" : 0x06, "access" : 'ro', "pdo" : False, "nbmin" : 1, "nbmax" : 0xFE}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
    0x1028 : {"name" : "Emergency Consumer", "struct" : rec, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   186
                [{"name" : "Number of Consumed Emergency Objects", "type" : 0x05, "access" : 'ro', "pdo" : False},
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   187
                 {"name" : "Emergency Consumer", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmin" : 1, "nbmax" : 0x7E}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
    0x1029 : {"name" : "Error Behavior", "struct" : array, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   189
                [{"name" : "Number of Error Classes", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   190
                 {"name" : "Communication Error", "type" : 0x05, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   191
                 {"name" : "Device Profile", "type" : 0x05, "access" : 'rw', "pdo" : False, "nbmax" : 0xFE}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
    0x1200 : {"name" : "Server SDO Parameter", "struct" : array, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   193
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   194
                 {"name" : "COB ID Client to Server (Receive SDO)", "type" : 0x07, "access" : 'ro', "pdo" : False, "default" : "\"$NODEID+0x600\""},
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   195
                 {"name" : "COB ID Server to Client (Transmit SDO)", "type" : 0x07, "access" : 'ro', "pdo" : False, "default" : "\"$NODEID+0x580\""}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
    0x1201 : {"name" : "Additional Server SDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x7F, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   197
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   198
                 {"name" : "COB ID Client to Server (Receive SDO)", "type" : 0x07, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   199
                 {"name" : "COB ID Server to Client (Transmit SDO)", "type" : 0x07, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   200
                 {"name" : "Node ID of the SDO Client", "type" : 0x05, "access" : 'ro', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
    0x1280 : {"name" : "Client SDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x100, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   202
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'ro', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   203
                 {"name" : "COB ID Client to Server (Transmit SDO)", "type" : 0x07, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   204
                 {"name" : "COB ID Server to Client (Receive SDO)", "type" : 0x07, "access" : 'rw', "pdo" : False},
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   205
                 {"name" : "Node ID of the SDO Server", "type" : 0x05, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
    0x1400 : {"name" : "Receive PDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x200, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   207
                [{"name" : "Highest SubIndex Supported", "type" : 0x05, "access" : 'ro', "pdo" : False},
317
f1c472b42327 Bug on default COB ID value for PDO transmit and receive 5 and higher fixed
lbessard
parents: 313
diff changeset
   208
                 {"name" : "COB ID used by PDO", "type" : 0x07, "access" : 'rw', "pdo" : False, "default" : "{True:\"$NODEID+0x%X00\"%(base+2),False:0x80000000}[base<4]"},
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   209
                 {"name" : "Transmission Type", "type" : 0x05, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   210
                 {"name" : "Inhibit Time", "type" : 0x06, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   211
                 {"name" : "Compatibility Entry", "type" : 0x05, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   212
                 {"name" : "Event Timer", "type" : 0x06, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
    0x1600 : {"name" : "Receive PDO %d Mapping[(idx)]", "struct" : plurirec, "incr" : 1, "nbmax" : 0x200, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   214
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'rw', "pdo" : False},
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   215
                 {"name" : "PDO %d Mapping for an application object %d[(idx,sub)]", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmin" : 0, "nbmax" : 0x40}]},
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 227
diff changeset
   216
    0x1800 : {"name" : "Transmit PDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x200, "need" : False, "callback" : True, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   217
                [{"name" : "Highest SubIndex Supported", "type" : 0x05, "access" : 'ro', "pdo" : False},
317
f1c472b42327 Bug on default COB ID value for PDO transmit and receive 5 and higher fixed
lbessard
parents: 313
diff changeset
   218
                 {"name" : "COB ID used by PDO", "type" : 0x07, "access" : 'rw', "pdo" : False, "default" : "{True:\"$NODEID+0x%X80\"%(base+1),False:0x80000000}[base<4]"},
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   219
                 {"name" : "Transmission Type", "type" : 0x05, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   220
                 {"name" : "Inhibit Time", "type" : 0x06, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   221
                 {"name" : "Compatibility Entry", "type" : 0x05, "access" : 'rw', "pdo" : False},
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   222
                 {"name" : "Event Timer", "type" : 0x06, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
    0x1A00 : {"name" : "Transmit PDO %d Mapping[(idx)]", "struct" : plurirec, "incr" : 1, "nbmax" : 0x200, "need" : False, "values" :
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   224
                [{"name" : "Number of Entries", "type" : 0x05, "access" : 'rw', "pdo" : False},
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   225
                 {"name" : "PDO %d Mapping for a process data variable %d[(idx,sub)]", "type" : 0x07, "access" : 'rw', "pdo" : False, "nbmin" : 0, "nbmax" : 0x40}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   226
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   227
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   228
#-------------------------------------------------------------------------------
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   229
#                         Search in a Mapping Dictionary
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   230
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   231
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   232
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   233
Return the index of the typename given by searching in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   234
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   235
def FindTypeIndex(typename, mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   236
    testdic = {}
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   237
    for index, values in mappingdictionary.iteritems():
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   238
        if index < 0x1000:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   239
            testdic[values["name"]] = index
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   240
    if typename in testdic:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   241
        return testdic[typename]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   242
    return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   243
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   244
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   245
Return the name of the type by searching in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   246
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   247
def FindTypeName(typeindex, mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   248
    if typeindex < 0x1000 and typeindex in mappingdictionary:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   249
        return mappingdictionary[typeindex]["name"]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   250
    return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   251
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   252
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   253
Return the default value of the type by searching in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   254
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   255
def FindTypeDefaultValue(typeindex, mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   256
    if typeindex < 0x1000 and typeindex in mappingdictionary:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   257
        return mappingdictionary[typeindex]["default"]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   258
    return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   259
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   260
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   261
Return the list of types defined in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   262
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   263
def FindTypeList(mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   264
    list = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   265
    for index in mappingdictionary.keys():
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   266
        if index < 0x1000:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   267
            list.append(mappingdictionary[index]["name"])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   268
    return list
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   269
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   270
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   271
Return the name of an entry by searching in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   272
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   273
def FindEntryName(index, mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   274
    base_index = FindIndex(index, mappingdictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   275
    if base_index:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   276
        infos = mappingdictionary[base_index]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   277
        if infos["struct"] & OD_IdenticalIndexes:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   278
            return StringFormat(infos["name"], (index - base_index) / infos["incr"] + 1, 0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   279
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   280
            return infos["name"]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   281
    return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   282
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   283
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   284
Return the informations of one entry by searching in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   285
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   286
def FindEntryInfos(index, mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   287
    base_index = FindIndex(index, mappingdictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   288
    if base_index:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   289
        copy = mappingdictionary[base_index].copy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   290
        if copy["struct"] & OD_IdenticalIndexes:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   291
            copy["name"] = StringFormat(copy["name"], (index - base_index) / copy["incr"] + 1, 0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   292
        copy.pop("values")
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   293
        return copy
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   294
    return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   295
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   296
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   297
Return the informations of one subentry of an entry by searching in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   298
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   299
def FindSubentryInfos(index, subIndex, mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   300
    base_index = FindIndex(index, mappingdictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   301
    if base_index:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   302
        struct = mappingdictionary[base_index]["struct"]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   303
        if struct & OD_Subindex:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   304
            if struct & OD_IdenticalSubindexes:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   305
                if struct & OD_IdenticalIndexes:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   306
                    incr = mappingdictionary[base_index]["incr"]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   307
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   308
                    incr = 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   309
                if subIndex == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   310
                    return mappingdictionary[base_index]["values"][0].copy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   311
                elif 0 < subIndex <= mappingdictionary[base_index]["values"][1]["nbmax"]:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   312
                    copy = mappingdictionary[base_index]["values"][1].copy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   313
                    copy["name"] = StringFormat(copy["name"], (index - base_index) / incr + 1, subIndex)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   314
                    return copy
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   315
            elif struct & OD_MultipleSubindexes and 0 <= subIndex < len(mappingdictionary[base_index]["values"]):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   316
                return mappingdictionary[base_index]["values"][subIndex].copy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   317
            elif subIndex == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   318
                return mappingdictionary[base_index]["values"][0].copy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   319
    return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   320
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   321
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   322
Return the list of variables that can be mapped defined in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   323
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   324
def FindMapVariableList(mappingdictionary, Node):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   325
    list = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   326
    for index in mappingdictionary.iterkeys():
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   327
        if Node.IsEntry(index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   328
            for subIndex, values in enumerate(mappingdictionary[index]["values"]):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   329
                if mappingdictionary[index]["values"][subIndex]["pdo"]:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   330
                    infos = Node.GetEntryInfos(mappingdictionary[index]["values"][subIndex]["type"])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   331
                    if mappingdictionary[index]["struct"] & OD_IdenticalSubindexes:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   332
                        values = Node.GetEntry(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   333
                        for i in xrange(len(values) - 1):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   334
                            list.append((index, i + 1, infos["size"], StringFormat(mappingdictionary[index]["values"][subIndex]["name"],1,i+1)))
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   335
                    else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   336
                        list.append((index, subIndex, infos["size"], mappingdictionary[index]["values"][subIndex]["name"]))
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   337
    return list
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   338
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   339
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   340
Return the list of mandatory indexes defined in mappingdictionary 
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   341
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   342
def FindMandatoryIndexes(mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   343
    list = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   344
    for index in mappingdictionary.iterkeys():
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   345
        if index >= 0x1000 and mappingdictionary[index]["need"]:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   346
            list.append(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   347
    return list
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   348
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   349
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   350
Return the index of the informations in the Object Dictionary in case of identical
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   351
indexes
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   352
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   353
def FindIndex(index, mappingdictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   354
    if index in mappingdictionary:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   355
        return index
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   356
    else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   357
        listpluri = [idx for idx in mappingdictionary.keys() if mappingdictionary[idx]["struct"] & OD_IdenticalIndexes]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   358
        listpluri.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   359
        for idx in listpluri:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   360
            nb_max = mappingdictionary[idx]["nbmax"]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   361
            incr = mappingdictionary[idx]["incr"]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   362
            if idx < index < idx + incr * nb_max and (index - idx)%incr == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   363
                return idx
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   364
    return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   365
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   366
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   367
#                           Formating Name of an Entry
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   368
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   369
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   370
name_model = re.compile('(.*)\[(.*)\]')
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   371
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   372
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   373
Format the text given with the index and subindex defined
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   374
"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   375
def StringFormat(text, idx, sub):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   376
    result = name_model.match(text)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   377
    if result:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   378
        format = result.groups()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   379
        return format[0]%eval(format[1])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   380
    else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   381
        return text
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   382
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   383
#-------------------------------------------------------------------------------
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   384
#                          Definition of Node Object
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   385
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   386
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   387
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   388
Class recording the Object Dictionary entries. It checks at each modification
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   389
that the structure of the Object Dictionary stay coherent
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   390
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   391
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   392
class Node:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   393
    
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   394
    DefaultStringSize = 10
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   395
    
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   396
    def __init__(self, name = "", type = "slave", id = 0, description = "", profilename = "DS-301", profile = {}, specificmenu = []):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   397
        self.Name = name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   398
        self.Type = type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   399
        self.ID = id
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   400
        self.Description = description
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   401
        self.ProfileName = profilename
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   402
        self.Profile = profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   403
        self.SpecificMenu = specificmenu
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   404
        self.Dictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   405
        self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   406
        self.DS302 = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   407
        self.UserMapping = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   408
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   409
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   410
    Return the node name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   411
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   412
    def GetNodeName(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   413
        return self.Name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   414
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   415
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   416
    Define the node name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   417
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   418
    def SetNodeName(self, name):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   419
        self.Name = name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   420
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   421
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   422
    Return the node type ("master" or "slave")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   423
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   424
    def GetNodeType(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   425
        return self.Type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   426
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   427
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   428
    Define the node type ("master" or "slave")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   429
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   430
    def SetNodeType(self, type):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   431
        self.Type = type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   432
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   433
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   434
    Return the node ID
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   435
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   436
    def GetNodeID(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   437
        return self.ID
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   438
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   439
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   440
    Define the node ID
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   441
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   442
    def SetNodeID(self, id):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   443
        self.ID = id
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   444
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   445
    """
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   446
    Return the node description
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   447
    """
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   448
    def GetNodeDescription(self):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   449
        if getattr(self, "Description", False):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   450
            return self.Description
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   451
        else:
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   452
            return ""
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   453
    
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   454
    """
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   455
    Define the node description
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   456
    """
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   457
    def SetNodeDescription(self, description):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   458
        self.Description = description
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   459
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 177
diff changeset
   460
    """
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   461
    Return the Specific Profile Name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   462
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   463
    def GetProfileName(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   464
        return self.ProfileName
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   465
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   466
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   467
    Define the Specific Profile Name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   468
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   469
    def SetProfileName(self, profilename):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   470
        self.ProfileName = profilename
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   471
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   472
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   473
    Return the Specific Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   474
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   475
    def GetProfile(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   476
        return self.Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   477
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   478
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   479
    Define the Specific Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   480
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   481
    def SetProfile(self, profile):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   482
        self.Profile = profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   483
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   484
    """
418
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   485
    Return the default string size
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   486
    """
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   487
    def GetDefaultStringSize(self):
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   488
        return self.DefaultStringSize
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   489
    
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   490
    """
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   491
    Define the default string size
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   492
    """
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   493
    def SetDefaultStringSize(self, size):
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   494
        self.DefaultStringSize = size
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   495
    
64a8c24b61a5 Problem with String size in C file generated fixed
lbessard
parents: 327
diff changeset
   496
    """
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   497
    Define the DS-302 Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   498
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   499
    def SetDS302Profile(self, profile):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   500
        self.DS302 = profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   501
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   502
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   503
    Define the DS-302 Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   504
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   505
    def GetDS302Profile(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   506
        return self.DS302
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   507
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   508
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   509
    Return the Specific Menu Entries
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   510
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   511
    def GetSpecificMenu(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   512
        return self.SpecificMenu
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   513
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   514
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   515
    Define the Specific Menu Entries
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   516
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   517
    def SetSpecificMenu(self, specificmenu):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   518
        self.SpecificMenu = specificmenu
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   519
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   520
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   521
    Extend the Specific Menu Entries
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   522
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   523
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   524
    def ExtendSpecificMenu(self, specificmenu):
176
5d57fe1e3a5b Support for DCF (DS-302)
greg
parents: 68
diff changeset
   525
        self.SpecificMenu.extend(specificmenu)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   526
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   527
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   528
    Function which return the different Mappings available for this node
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   529
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   530
    def GetMappings(self, userdefinedtoo = True):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   531
        if userdefinedtoo:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   532
            return [self.Profile, self.DS302, self.UserMapping]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   533
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   534
            return [self.Profile, self.DS302]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   535
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   536
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   537
    Add a new entry in the Object Dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   538
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   539
    def AddEntry(self, index, subIndex = None, value = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   540
        if index not in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   541
            if not subIndex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   542
                self.Dictionary[index] = value
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   543
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   544
            elif subIndex == 1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   545
                self.Dictionary[index] = [value]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   546
                return True
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   547
        elif subIndex > 0 and type(self.Dictionary[index]) == ListType and subIndex == len(self.Dictionary[index]) + 1:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   548
            self.Dictionary[index].append(value)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   549
            return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   550
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   551
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   552
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   553
    Warning ! Modifies an existing entry in the Object Dictionary. Can't add a new one.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   554
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   555
    def SetEntry(self, index, subIndex = None, value = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   556
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   557
            if not subIndex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   558
                if value != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   559
                    self.Dictionary[index] = value
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   560
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   561
            elif type(self.Dictionary[index]) == ListType and 0 < subIndex <= len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   562
                if value != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   563
                    self.Dictionary[index][subIndex - 1] = value
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   564
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   565
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   566
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   567
    def SetParamsEntry(self, index, subIndex = None, comment = None, save = None, callback = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   568
        if not getattr(self, "ParamsDictionary", False):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   569
            self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   570
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   571
            if (comment != None or save != None or callback != None) and index not in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   572
                self.ParamsDictionary[index] = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   573
            if subIndex == None or type(self.Dictionary[index]) != ListType and subIndex == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   574
                if comment != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   575
                    self.ParamsDictionary[index]["comment"] = comment
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   576
                if save != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   577
                    self.ParamsDictionary[index]["save"] = save
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   578
                if callback != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   579
                    self.ParamsDictionary[index]["callback"] = callback
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   580
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   581
            elif type(self.Dictionary[index]) == ListType and 0 <= subIndex <= len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   582
                if (comment != None or save != None or callback != None) and subIndex not in self.ParamsDictionary[index]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   583
                    self.ParamsDictionary[index][subIndex] = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   584
                if comment != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   585
                    self.ParamsDictionary[index][subIndex]["comment"] = comment
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   586
                if save != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   587
                    self.ParamsDictionary[index][subIndex]["save"] = save
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   588
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   589
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   590
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   591
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   592
    Removes an existing entry in the Object Dictionary. If a subIndex is specified
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   593
    it will remove this subIndex only if it's the last of the index. If no subIndex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   594
    is specified it removes the whole index and subIndexes from the Object Dictionary.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   595
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   596
    def RemoveEntry(self, index, subIndex = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   597
        if not getattr(self, "ParamsDictionary", False):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   598
            self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   599
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   600
            if not subIndex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   601
                self.Dictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   602
                if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   603
                    self.ParamsDictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   604
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   605
            elif type(self.Dictionary[index]) == ListType and subIndex == len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   606
                self.Dictionary[index].pop(subIndex - 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   607
                if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   608
                    if subIndex in self.ParamsDictionary[index]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   609
                        self.ParamsDictionary[index].pop(subIndex)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   610
                    if len(self.ParamsDictionary[index]) == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   611
                        self.ParamsDictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   612
                if len(self.Dictionary[index]) == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   613
                    self.Dictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   614
                    if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   615
                        self.ParamsDictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   616
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   617
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   618
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   619
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   620
    Check if an entry exists in the Object Dictionary and returns the answer.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   621
    """
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   622
    def IsEntry(self, index, subIndex = None):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   623
        if index in self.Dictionary:
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   624
            if not subIndex:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   625
                return True
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   626
            return subIndex <= len(self.Dictionary[index])
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   627
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   628
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   629
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   630
    Returns the value of the entry asked. If the entry has the value "count", it
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   631
    returns the number of subIndex in the entry except the first.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   632
    """
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   633
    def GetEntry(self, index, subIndex = None, compute = True):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   634
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   635
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   636
                if type(self.Dictionary[index]) == ListType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   637
                    values = [len(self.Dictionary[index])]
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   638
                    for value in self.Dictionary[index]:
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   639
                        values.append(self.CompileValue(value, index, compute))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   640
                    return values
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   641
                else:
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   642
                    return self.CompileValue(self.Dictionary[index], index, compute)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   643
            elif subIndex == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   644
                if type(self.Dictionary[index]) == ListType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   645
                    return len(self.Dictionary[index])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   646
                else:
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   647
                    return self.CompileValue(self.Dictionary[index], index, compute)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   648
            elif type(self.Dictionary[index]) == ListType and 0 < subIndex <= len(self.Dictionary[index]):
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   649
                return self.CompileValue(self.Dictionary[index][subIndex - 1], index, compute)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   650
        return None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   651
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   652
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   653
    Returns the value of the entry asked. If the entry has the value "count", it
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   654
    returns the number of subIndex in the entry except the first.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   655
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   656
    def GetParamsEntry(self, index, subIndex = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   657
        if not getattr(self, "ParamsDictionary", False):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   658
            self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   659
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   660
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   661
                if type(self.Dictionary[index]) == ListType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   662
                    if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   663
                        result = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   664
                        for i in xrange(len(self.Dictionary[index]) + 1):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   665
                            line = DefaultParams.copy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   666
                            if i in self.ParamsDictionary[index]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   667
                                line.update(self.ParamsDictionary[index][i])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   668
                            result.append(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   669
                        return result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   670
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   671
                        return [DefaultParams.copy() for i in xrange(len(self.Dictionary[index]) + 1)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   672
                else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   673
                    result = DefaultParams.copy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   674
                    if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   675
                        result.update(self.ParamsDictionary[index])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   676
                    return result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   677
            elif subIndex == 0 and type(self.Dictionary[index]) != ListType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   678
                result = DefaultParams.copy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   679
                if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   680
                    result.update(self.ParamsDictionary[index])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   681
                return result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   682
            elif type(self.Dictionary[index]) == ListType and 0 <= subIndex <= len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   683
                result = DefaultParams.copy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   684
                if index in self.ParamsDictionary and subIndex in self.ParamsDictionary[index]:
64
c72dd78e547f Bug reported by Dean corrected
lbessard
parents: 63
diff changeset
   685
                    result.update(self.ParamsDictionary[index][subIndex])
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   686
                return result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   687
        return None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   688
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   689
    def HasEntryCallbacks(self, index):
245
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 239
diff changeset
   690
        entry_infos = self.GetEntryInfos(index)
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 239
diff changeset
   691
        if entry_infos and "callback" in entry_infos:
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 239
diff changeset
   692
            return entry_infos["callback"]
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 239
diff changeset
   693
        else:
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 239
diff changeset
   694
            if not getattr(self, "ParamsDictionary", False):
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 239
diff changeset
   695
                self.ParamsDictionary = {}
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 239
diff changeset
   696
            if index in self.Dictionary and index in self.ParamsDictionary and "callback" in self.ParamsDictionary[index]:
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 239
diff changeset
   697
                return self.ParamsDictionary[index]["callback"]
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   698
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   699
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   700
    """
68
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   701
    Check if an entry exists in the User Mapping Dictionary and returns the answer.
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   702
    """
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   703
    def IsMappingEntry(self, index):
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   704
        if index in self.UserMapping:
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   705
            return True
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   706
        return False
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   707
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   708
    """
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   709
    Add a new entry in the User Mapping Dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   710
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   711
    def AddMappingEntry(self, index, subIndex = None, name = "Undefined", struct = 0, size = None, nbmax = None, default = None, values = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   712
        if index not in self.UserMapping:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   713
            if values == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   714
                values = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   715
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   716
                self.UserMapping[index] = {"name" : name, "struct" : struct, "need" : False, "values" : values}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   717
                if size != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   718
                    self.UserMapping[index]["size"] = size
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   719
                if nbmax != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   720
                    self.UserMapping[index]["nbmax"] = nbmax
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   721
                if default != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   722
                    self.UserMapping[index]["default"] = default
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   723
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   724
        elif subIndex != None and subIndex == len(self.UserMapping[index]["values"]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   725
            if values == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   726
                values = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   727
            self.UserMapping[index]["values"].append(values)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   728
            return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   729
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   730
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   731
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   732
    Warning ! Modifies an existing entry in the User Mapping Dictionary. Can't add a new one.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   733
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   734
    def SetMappingEntry(self, index, subIndex = None, name = None, struct = None, size = None, nbmax = None, default = None, values = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   735
        if index in self.UserMapping:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   736
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   737
                if name != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   738
                    self.UserMapping[index]["name"] = name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   739
                    if self.UserMapping[index]["struct"] & OD_IdenticalSubindexes:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   740
                        self.UserMapping[index]["values"][1]["name"] = name + " %d[(sub)]"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   741
                    elif not self.UserMapping[index]["struct"] & OD_MultipleSubindexes:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   742
                        self.UserMapping[index]["values"][0]["name"] = name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   743
                if struct != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   744
                    self.UserMapping[index]["struct"] = struct
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   745
                if size != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   746
                    self.UserMapping[index]["size"] = size
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   747
                if nbmax != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   748
                    self.UserMapping[index]["nbmax"] = nbmax
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   749
                if default != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   750
                    self.UserMapping[index]["default"] = default
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   751
                if values != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   752
                    self.UserMapping[index]["values"] = values
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   753
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   754
            elif 0 <= subIndex < len(self.UserMapping[index]["values"]) and values != None:
281
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
   755
                if "type" in values:
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
   756
                    if self.IsStringType(values["type"]) and not self.IsStringType(self.UserMapping[index]["values"][subIndex]["type"]):
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
   757
                        self.SetEntry(index, subIndex, "")
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
   758
                    elif not self.IsStringType(values["type"]) and self.IsStringType(self.UserMapping[index]["values"][subIndex]["type"]):
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
   759
                        self.SetEntry(index, subIndex, 0)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   760
                self.UserMapping[index]["values"][subIndex].update(values)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   761
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   762
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   763
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   764
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   765
    Removes an existing entry in the User Mapping Dictionary. If a subIndex is specified
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   766
    it will remove this subIndex only if it's the last of the index. If no subIndex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   767
    is specified it removes the whole index and subIndexes from the User Mapping Dictionary.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   768
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   769
    def RemoveMappingEntry(self, index, subIndex = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   770
        if index in self.UserMapping:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   771
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   772
                self.UserMapping.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   773
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   774
            elif subIndex == len(self.UserMapping[index]["values"]) - 1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   775
                self.UserMapping[index]["values"].pop(subIndex)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   776
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   777
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   778
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   779
    def RemoveMapVariable(self, index, subIndex = None):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   780
        model = index << 16
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   781
        mask = 0xFFFF << 16
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   782
        if subIndex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   783
            model += subIndex << 8
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   784
            mask += 0xFF << 8
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   785
        for i in self.Dictionary.iterkeys():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   786
            if 0x1600 <= i <= 0x17FF or 0x1A00 <= i <= 0x1BFF:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   787
                for j,value in enumerate(self.Dictionary[i]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   788
                    if (value & mask) == model:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   789
                        self.Dictionary[i][j] = 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   790
    
63
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   791
    def UpdateMapVariable(self, index, subIndex, size):
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   792
        model = index << 16
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   793
        mask = 0xFFFF << 16
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   794
        if subIndex:
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   795
            model += subIndex << 8
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   796
            mask = 0xFF << 8
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   797
        for i in self.Dictionary.iterkeys():
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   798
            if 0x1600 <= i <= 0x17FF or 0x1A00 <= i <= 0x1BFF:
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   799
                for j,value in enumerate(self.Dictionary[i]):
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   800
                    if (value & mask) == model:
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   801
                        self.Dictionary[i][j] = model + size
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   802
    
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   803
    def RemoveLine(self, index, max, incr = 1):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   804
        i = index
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   805
        while i < max and self.IsEntry(i + incr):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   806
            self.Dictionary[i] = self.Dictionary[i + incr]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   807
            i += incr
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   808
        self.Dictionary.pop(i)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   809
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   810
    def RemoveUserType(self, index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   811
        type = self.GetEntry(index, 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   812
        for i in self.UserMapping:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   813
            for value in self.UserMapping[i]["values"]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   814
                if value["type"] == index:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   815
                    value["type"] = type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   816
        self.RemoveMappingEntry(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   817
        self.RemoveEntry(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   818
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   819
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   820
    Return a copy of the node
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   821
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   822
    def Copy(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   823
        return cPickle.loads(cPickle.dumps(self))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   824
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   825
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   826
    Return a sorted list of indexes in Object Dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   827
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   828
    def GetIndexes(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   829
        listindex = self.Dictionary.keys()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   830
        listindex.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   831
        return listindex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   832
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   833
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   834
    Print the Dictionary values
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   835
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   836
    def Print(self):
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   837
        print self.PrintString()
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   838
    
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   839
    def PrintString(self):
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   840
        result = ""
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   841
        listindex = self.Dictionary.keys()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   842
        listindex.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   843
        for index in listindex:
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   844
            name = self.GetEntryName(index)
239
f45fd4cd3832 add auto-mapping tool (config_utils)
greg
parents: 236
diff changeset
   845
            values = self.Dictionary[index]
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   846
            if isinstance(values, ListType):
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   847
                result += "%04X (%s):\n"%(index, name)
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   848
                for subidx, value in enumerate(values):
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   849
                    subentry_infos = self.GetSubentryInfos(index, subidx + 1)
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   850
                    if index == 0x1F22 and value:
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   851
                        nb_params = BE_to_LE(value[:4])
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   852
                        data = value[4:]
274
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   853
                        value = "%d arg defined"%nb_params
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   854
                        i = 0
274
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   855
                        count = 1
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   856
                        while i < len(data):
274
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   857
                            value += "\n%04X %02X, arg %d: "%(index, subidx+1, count)
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   858
                            value += "%04X"%BE_to_LE(data[i:i+2])
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   859
                            value += " %02X"%BE_to_LE(data[i+2:i+3])
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   860
                            size = BE_to_LE(data[i+3:i+7])
274
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   861
                            value += " %08X"%size
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   862
                            value += (" %0"+"%d"%(size * 2)+"X")%BE_to_LE(data[i+7:i+7+size])
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   863
                            i += 7 + size
274
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   864
                            count += 1
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   865
                    elif isinstance(value, IntType):
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   866
                        value = "%X"%value
274
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   867
                    result += "%04X %02X (%s): %s\n"%(index, subidx+1, subentry_infos["name"], value)
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   868
            else:
274
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   869
                if isinstance(values, IntType):
39beb1c7542a Modifying node Print function for displaying more informations
lbessard
parents: 273
diff changeset
   870
                    values = "%X"%values
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   871
                result += "%04X (%s): %s\n"%(index, name, values)
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   872
        return result
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
   873
            
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   874
    def CompileValue(self, value, index, compute = True):
304
32d93e0c6e64 Fixed crash with visible_string due to latest changes.
etisserant
parents: 299
diff changeset
   875
        if type(value) == StringType and value.find("$NODEID") != -1:
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   876
            base = self.GetBaseIndex(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   877
            try:
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   878
                raw = eval(value)
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   879
                if compute:
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   880
                    return eval(raw.replace("$NODEID","self.ID"))
506f9700b9fb Allowing user to type formulas
lbessard
parents: 284
diff changeset
   881
                return raw
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   882
            except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   883
                return 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   884
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   885
            return value
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   886
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   887
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   888
#                         Node Informations Functions
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   889
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   890
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   891
    def GetBaseIndex(self, index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   892
        for mapping in self.GetMappings():
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   893
            result = FindIndex(index, mapping)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   894
            if result != None:
227
f76c64f66097 Bugs on cfile generation fixed
lbessard
parents: 205
diff changeset
   895
                return (index - result) / mapping[result].get("incr", 1)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   896
        result = FindIndex(index, MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   897
        if result != None:
227
f76c64f66097 Bugs on cfile generation fixed
lbessard
parents: 205
diff changeset
   898
            return (index - result) / MappingDictionary[result].get("incr", 1)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   899
        return 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   900
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   901
    def GetCustomisedTypeValues(self, index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   902
        values = self.GetEntry(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   903
        customisabletypes = self.GetCustomisableTypes()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   904
        return values, customisabletypes[values[1]][1]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   905
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   906
    def GetEntryName(self, index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   907
        result = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   908
        mappings = self.GetMappings()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   909
        i = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   910
        while not result and i < len(mappings):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   911
            result = FindEntryName(index, mappings[i])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   912
            i += 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   913
        if result == None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   914
            result = FindEntryName(index, MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   915
        return result
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   916
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   917
    def GetEntryInfos(self, index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   918
        result = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   919
        mappings = self.GetMappings()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   920
        i = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   921
        while not result and i < len(mappings):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   922
            result = FindEntryInfos(index, mappings[i])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   923
            i += 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   924
        if result == None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   925
            result = FindEntryInfos(index, MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   926
        return result
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   927
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   928
    def GetSubentryInfos(self, index, subIndex):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   929
        result = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   930
        mappings = self.GetMappings()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   931
        i = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   932
        while not result and i < len(mappings):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   933
            result = FindSubentryInfos(index, subIndex, mappings[i])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   934
            if result:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   935
                result["user_defined"] = i == len(mappings) - 1 and index >= 0x1000
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   936
            i += 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   937
        if result == None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   938
            result = FindSubentryInfos(index, subIndex, MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   939
            if result:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   940
                result["user_defined"] = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   941
        return result
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   942
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   943
    def GetTypeIndex(self, typename):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   944
        result = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   945
        mappings = self.GetMappings()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   946
        i = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   947
        while not result and i < len(mappings):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   948
            result = FindTypeIndex(typename, mappings[i])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   949
            i += 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   950
        if result == None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   951
            result = FindTypeIndex(typename, MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   952
        return result
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   953
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   954
    def GetTypeName(self, typeindex):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   955
        result = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   956
        mappings = self.GetMappings()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   957
        i = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   958
        while not result and i < len(mappings):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   959
            result = FindTypeName(typeindex, mappings[i])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   960
            i += 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   961
        if result == None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   962
            result = FindTypeName(typeindex, MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   963
        return result
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   964
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   965
    def GetTypeDefaultValue(self, typeindex):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   966
        result = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   967
        mappings = self.GetMappings()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   968
        i = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   969
        while not result and i < len(mappings):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   970
            result = FindTypeDefaultValue(typeindex, mappings[i])
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   971
            i += 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   972
        if result == None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   973
            result = FindTypeDefaultValue(typeindex, MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   974
        return result
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   975
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   976
    def GetMapVariableList(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   977
        list = FindMapVariableList(MappingDictionary, self)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   978
        for mapping in self.GetMappings():
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   979
            list.extend(FindMapVariableList(mapping, self))
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   980
        list.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   981
        return list
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   982
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   983
    def GetMandatoryIndexes(self, node = None):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   984
        list = FindMandatoryIndexes(MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   985
        for mapping in self.GetMappings():
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   986
            list.extend(FindMandatoryIndexes(mapping))
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   987
        return list
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   988
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   989
    def GetCustomisableTypes(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   990
        dic = {}
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   991
        for index, valuetype in CustomisableTypes:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   992
            name = self.GetTypeName(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   993
            dic[index] = [name, valuetype]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   994
        return dic
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   995
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   996
#-------------------------------------------------------------------------------
281
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
   997
#                            Type helper functions
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
   998
#-------------------------------------------------------------------------------
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
   999
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1000
    def IsStringType(self, index):
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1001
        if index in (0x9, 0xA, 0xB):
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1002
            return True
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1003
        elif 0xA0 <= index < 0x100:
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1004
            result = self.GetEntry(index, 1)
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1005
            if result is not None and result in (0x9, 0xA, 0xB):
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1006
                return True
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1007
        return False
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1008
685d9a26e4f9 Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents: 274
diff changeset
  1009
#-------------------------------------------------------------------------------
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1010
#                            Type and Map Variable Lists
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1011
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1012
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1013
    def GetTypeList(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1014
        list = FindTypeList(MappingDictionary)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1015
        for mapping in self.GetMappings():
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1016
            list.extend(FindTypeList(mapping))
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1017
        list.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1018
        return ",".join(list)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1019
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1020
    """
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1021
    Generate the list of variables that can be mapped for the current node
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1022
    """
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1023
    def GenerateMapList(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1024
        self.MapList = "None"
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1025
        self.NameTranslation = {"None" : "00000000"}
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1026
        self.MapTranslation = {"00000000" : "None"}
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1027
        list = self.GetMapVariableList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1028
        for index, subIndex, size, name in list:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1029
            self.MapList += ",%s"%name
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1030
            map = "%04X%02X%02X"%(index,subIndex,size)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1031
            self.NameTranslation[name] = map
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1032
            self.MapTranslation[map] = name
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1033
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1034
    def GetMapValue(self, mapname):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1035
        if mapname == "None":
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1036
            return 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1037
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1038
            list = self.GetMapVariableList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1039
            for index, subIndex, size, name in list:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1040
                if mapname == name:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1041
                    return (index << 16) + (subIndex << 8) + size
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1042
            return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1043
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1044
    def GetMapName(self, value):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1045
        if value != 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1046
            index = value >> 16
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1047
            subindex = (value >> 8) % (1 << 8)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1048
            result = self.GetSubentryInfos(index, subindex)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1049
            if result:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1050
                return result["name"]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1051
        return "None"
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1052
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1053
    """
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1054
    Return the list of variables that can be mapped for the current node
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1055
    """
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1056
    def GetMapList(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1057
        list = ["None"] + [name for index, subIndex, size, name in self.GetMapVariableList()]
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
  1058
        return ",".join(list)
273
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1059
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1060
def BE_to_LE(value):
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1061
    """
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1062
    Convert Big Endian to Little Endian 
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1063
    @param value: value expressed in Big Endian
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1064
    @param size: number of bytes generated
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1065
    @return: a string containing the value converted
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1066
    """
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1067
    
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1068
    data = [char for char in value]
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1069
    data.reverse()
58b39f97e352 Some bugs fixed
lbessard
parents: 260
diff changeset
  1070
    return int("".join(["%2.2X"%ord(char) for char in data]), 16)
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1071
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1072
def LE_to_BE(value, size):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1073
    """
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1074
    Convert Little Endian to Big Endian
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1075
    @param value: value expressed in integer
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1076
    @param size: number of bytes generated
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1077
    @return: a string containing the value converted
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1078
    """
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1079
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1080
    data = ("%" + str(size * 2) + "." + str(size * 2) + "X") % value
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1081
    list_car = [data[i:i+2] for i in xrange(0, len(data), 2)]
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1082
    list_car.reverse()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1083
    return "".join([chr(int(car, 16)) for car in list_car])
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 317
diff changeset
  1084