objdictgen/node.py
author leonid
Wed, 14 Feb 2007 22:19:53 +0100
changeset 109 46010c1b6c6e
parent 68 234dad27b398
child 176 5d57fe1e3a5b
permissions -rwxr-xr-x
file resource.h was initially added on branch BRANCH_WIN32PORT.
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 *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
Dictionary of translation between access symbol and their signification
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
AccessType = {"ro" : "Read Only", "wo" : "Write Only", "rw" : "Read/Write"}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
BoolType = {True : "True", False : "False"} 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
OptionType = {True : "Yes", False : "No"}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
CustomisableTypes = [(0x02, 0), (0x03, 0), (0x04, 0), (0x05, 0), (0x06, 0), (0x07, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
    (0x08, 0), (0x09, 1), (0x0A, 1), (0x0B, 1), (0x10, 0), (0x11, 0), (0x12, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
    (0x13, 0), (0x14, 0), (0x15, 0), (0x16, 0), (0x18, 0), (0x19, 0), (0x1A, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
    (0x1B, 0)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
DefaultParams = {"comment" : "", "save" : False}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
#                      Dictionary Mapping and Organisation
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    44
#-------------------------------------------------------------------------------
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
Properties of entry structure in the Object Dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
OD_Subindex = 1             # Entry has at least one subindex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
OD_MultipleSubindexes = 2   # Entry has more than one subindex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
OD_IdenticalSubindexes = 4  # Subindexes of entry have the same description
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
OD_IdenticalIndexes = 8     # Entry has the same description on multiple indexes
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
Structures of entry in the Object Dictionary, sum of the properties described above
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
for all sorts of entries use in CAN Open specification
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
nosub = 0 # Entry without subindex (only for type declaration)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
var = 1
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
array = 3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
rec = 7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
# Entries identical on multiple indexes
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
plurivar = 9
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
pluriarray = 11 # Example : PDO Parameters
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    65
plurirec = 15   # Example : PDO Mapping
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    66
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
MappingDictionary is the structure used for writing a good organised Object
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    69
Dictionary. It follows the specifications of the CANOpen standard.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
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
    71
organisation of this object, it will involve in a malfunction of the application.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
MappingDictionary = {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
    0x0001 : {"name" : "BOOLEAN", "struct" : nosub, "size" : 1, "default" : False, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
    0x0002 : {"name" : "INTEGER8", "struct" : nosub, "size" : 8, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
    0x0003 : {"name" : "INTEGER16", "struct" : nosub, "size" : 16, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
    0x0004 : {"name" : "INTEGER32", "struct" : nosub, "size" : 32, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
    0x0005 : {"name" : "UNSIGNED8", "struct" : nosub, "size" : 8, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
    0x0006 : {"name" : "UNSIGNED16", "struct" : nosub, "size" : 16, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
    0x0007 : {"name" : "UNSIGNED32", "struct" : nosub, "size" : 32, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
    0x0008 : {"name" : "REAL32", "struct" : nosub, "size" : 32, "default" : 0.0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
    0x0009 : {"name" : "VISIBLE_STRING", "struct" : nosub, "size" : 8, "default" : "", "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
    0x000A : {"name" : "OCTET_STRING", "struct" : nosub, "size" : 8, "default" : "", "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
    0x000B : {"name" : "UNICODE_STRING", "struct" : nosub, "size" : 16, "default" : "", "values" : []},
67
51642fb5a0af TIME_OF_DAY and TIME_DIFFERENCE disabled
lbessard
parents: 65
diff changeset
    86
#    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
    87
#    0x000D : {"name" : "TIME_DIFFERENCE", "struct" : nosub, "size" : 48, "default" : 0, "values" : []},
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 0
diff changeset
    88
#    0x000F : {"name" : "DOMAIN", "struct" : nosub, "size" : 0, "default" : "", "values" : []},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
    0x0010 : {"name" : "INTEGER24", "struct" : nosub, "size" : 24, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
    0x0011 : {"name" : "REAL64", "struct" : nosub, "size" : 64, "default" : 0.0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
    0x0012 : {"name" : "INTEGER40", "struct" : nosub, "size" : 40, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
    0x0013 : {"name" : "INTEGER48", "struct" : nosub, "size" : 48, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
    0x0014 : {"name" : "INTEGER56", "struct" : nosub, "size" : 56, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
    0x0015 : {"name" : "INTEGER64", "struct" : nosub, "size" : 64, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
    0x0016 : {"name" : "UNSIGNED24", "struct" : nosub, "size" : 24, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
    0x0018 : {"name" : "UNSIGNED40", "struct" : nosub, "size" : 40, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
    0x0019 : {"name" : "UNSIGNED48", "struct" : nosub, "size" : 48, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
    0x001A : {"name" : "UNSIGNED56", "struct" : nosub, "size" : 56, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
    0x001B : {"name" : "UNSIGNED64", "struct" : nosub, "size" : 64, "default" : 0, "values" : []},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
    0x1000 : {"name" : "Device Type", "struct" : var, "need" : True, "values" : 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
                [{"name" : "Device Type", "type" : 0x04, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
    0x1001 : {"name" : "Error Register", "struct" : var,  "need" : True, "values" : 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
                [{"name" : "Error Register", "type" : 0x02, "access": 'ro', "pdo" : True}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
    0x1002 : {"name" : "Manufacturer Status Register", "struct" : var, "need" : False,  "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
                [{"name" : "Manufacturer Status Register", "type" : 0x04, "access" : 'ro', "pdo" : True}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
    0x1003 : {"name" : "Pre-defined Error Field", "struct" : rec, "need" : False,  "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
                [{"name" : "Number of Errors", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
                 {"name" : "Standard Error Field", "type" : 0x04, "access" : 'ro', "pdo" : False, "nbmax" : 0xFE}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
    0x1005 : {"name" : "SYNC COB ID", "struct" : var, "need" : True, "callback" : True, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
                [{"name" : "SYNC COB ID", "type" : 0x04, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
    0x1006 : {"name" : "Communication / Cycle Period", "struct" : var, "need" : False, "callback" : True, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
                [{"name" : "Communication Cycle Period", "type" : 0x04, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
    0x1007 : {"name" : "Synchronous Window Length", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
                [{"name" : "Synchronous Window Length", "type" : 0x04, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
    0x1008 : {"name" : "Manufacturer Device Name", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
                [{"name" : "Manufacturer Device Name", "type" : 0x09, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
    0x1009 : {"name" : "Manufacturer Hardware Version", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
                [{"name" : "Manufacturer Hardware Version", "type" : 0x09, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
    0x100A : {"name" : "Manufacturer Software Version", "struct" : var, "need" : False, "values" :
62
93d4db3677e6 index 0x1004 is a visible_string
frdupin
parents: 59
diff changeset
   120
                [{"name" : "Manufacturer Software Version", "type" : 0x09, "access" : 'ro', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
    0x100C : {"name" : "Guard Time", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
                [{"name" : "Guard Time", "type" : 0x03, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
    0x100D : {"name" : "Life Time Factor", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
                [{"name" : "Life Time Factor", "type" : 0x02, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
    0x1010 : {"name" : "Store parameters", "struct" : array, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
                 {"name" : "Save All Parameters", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
                 {"name" : "Save Communication Parameters", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
                 {"name" : "Save Application Parameters", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
                 {"name" : "Save Manufacturer Parameters", "type" : 0x04, "access" : 'rw', "pdo" : False, "nbmax" : 0x7C}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
    0x1011 : {"name" : "Restore Default Parameters", "struct" : array, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
                 {"name" : "Restore All Default Parameters", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
                 {"name" : "Restore Communication Default Parameters", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
                 {"name" : "Restore Application Default Parameters", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
                 {"name" : "Restore Manufacturer Default Parameters", "type" : 0x04, "access" : 'rw', "pdo" : False, "nbmax" : 0x7C}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
    0x1012 : {"name" : "TIME COB ID", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
                [{"name" : "TIME COB ID", "type" : 0x04, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
    0x1013 : {"name" : "High Resolution Timestamp", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
                [{"name" : "High Resolution Time Stamp", "type" : 0x04, "access" : 'rw', "pdo" : True}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
    0x1014 : {"name" : "Emergency COB ID", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
                [{"name" : "Emergency COB ID", "type" : 0x04, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
    0x1015 : {"name" : "Inhibit Time Emergency", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
                [{"name" : "Inhibit Time Emergency", "type" : 0x03, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
    0x1016 : {"name" : "Consumer Heartbeat Time", "struct" : rec, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   147
                 {"name" : "Consumer Heartbeat Time", "type" : 0x04, "access" : 'rw', "pdo" : False, "nbmax" : 0x7F}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
    0x1017 : {"name" : "Producer Heartbeat Time", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
                [{"name" : "Producer Heartbeat Time", "type" : 0x03, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
    0x1018 : {"name" : "Identity", "struct" : array, "need" : True, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
                 {"name" : "Vendor ID", "type" : 0x04, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
                 {"name" : "Product Code", "type" : 0x04, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
                 {"name" : "Revision Number", "type" : 0x04, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
                 {"name" : "Serial Number", "type" : 0x04, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
    0x1020 : {"name" : "Verify Configuration", "struct" : array, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
                 {"name" : "Configuration Date", "type" : 0x04, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
                 {"name" : "Configuration Time", "type" : 0x04, "access" : 'ro', "pdo" : False}]},
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 0
diff changeset
   160
#    0x1021 : {"name" : "Store EDS", "struct" : var, "need" : False, "values" :
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 0
diff changeset
   161
#                [{"name" : "Store EDS", "type" : 0x0F, "access" : 'rw', "pdo" : False}]},
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 0
diff changeset
   162
#    0x1022 : {"name" : "Storage Format", "struct" : var, "need" : False, "values" :
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 0
diff changeset
   163
#                [{"name" : "Storage Format", "type" : 0x04, "access" : 'rw', "pdo" : False}]},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
    0x1023 : {"name" : "OS Command", "struct" : array, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
                 {"name" : "Command", "type" : 0x0A, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
                 {"name" : "Status", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
                 {"name" : "Reply", "type" : 0x0A, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
    0x1024 : {"name" : "OS Command Mode", "struct" : var, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
                [{"name" : "OS Command Mode", "type" : 0x02, "access" : 'wo', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
    0x1025 : {"name" : "OS Debugger Interface", "struct" : array, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   173
                 {"name" : "Command", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   174
                 {"name" : "Status", "type" : 0x04, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
                 {"name" : "Reply", "type" : 0x04, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
    0x1026 : {"name" : "OS Prompt", "struct" : array, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
                 {"name" : "StdIn", "type" : 0x02, "access" : 'wo', "pdo" : True},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   179
                 {"name" : "StdOut", "type" : 0x02, "access" : 'ro', "pdo" : True},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   180
                 {"name" : "StdErr", "type" : 0x02, "access" : 'ro', "pdo" : True}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   181
    0x1027 : {"name" : "Module List", "struct" : rec, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   182
                [{"name" : "Number of Connected Modules", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   183
                 {"name" : "Module %d[(sub)]", "type" : 0x03, "access" : 'ro', "pdo" : False, "nbmax" : 0xFE}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   184
    0x1028 : {"name" : "Emergency Consumer", "struct" : rec, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
                [{"name" : "Number of Consumed Emergency Objects", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   186
                 {"name" : "Emergency Consumer", "type" : 0x04, "access" : 'rw', "pdo" : False, "nbmax" : 0x7E}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
    0x1029 : {"name" : "Error Behavior", "struct" : array, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
                [{"name" : "Number of Error Classes", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
                 {"name" : "Communication Error", "type" : 0x02, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
                 {"name" : "Device Profile", "type" : 0x02, "access" : 'rw', "pdo" : False, "nbmax" : 0xFE}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
    0x1200 : {"name" : "Server SDO Parameter", "struct" : array, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
                 {"name" : "COB ID Client to Server (Receive SDO)", "type" : 0x04, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
                 {"name" : "COB ID Server to Client (Transmit SDO)", "type" : 0x04, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   195
    0x1201 : {"name" : "Additional Server SDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x7F, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   197
                 {"name" : "COB ID Client to Server (Receive SDO)", "type" : 0x04, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   198
                 {"name" : "COB ID Server to Client (Transmit SDO)", "type" : 0x04, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   199
                 {"name" : "Node ID of the SDO Client", "type" : 0x04, "access" : 'ro', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
    0x1280 : {"name" : "Client SDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x100, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   202
                 {"name" : "COB ID Client to Server (Transmit SDO)", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   203
                 {"name" : "COB ID Server to Client (Receive SDO)", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   204
                 {"name" : "Node ID of the SDO Server", "type" : 0x04, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   205
    0x1400 : {"name" : "Receive PDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x200, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
                [{"name" : "Highest SubIndex Supported", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
                 {"name" : "COB ID used by PDO", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
                 {"name" : "Transmission Type", "type" : 0x02, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
                 {"name" : "Inhibit Time", "type" : 0x03, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
                 {"name" : "Compatibility Entry", "type" : 0x03, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
                 {"name" : "Event Timer", "type" : 0x03, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
    0x1600 : {"name" : "Receive PDO %d Mapping[(idx)]", "struct" : plurirec, "incr" : 1, "nbmax" : 0x200, "need" : False, "values" :
65
94c820522994 PDO mapping parameters : number of mapped app must be in RW access
frdupin
parents: 64
diff changeset
   213
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'rw', "pdo" : False},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
                 {"name" : "PDO %d Mapping for an application object %d[(idx,sub)]", "type" : 0x04, "access" : 'rw', "pdo" : False, "nbmax" : 0x40}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
    0x1800 : {"name" : "Transmit PDO %d Parameter[(idx)]", "struct" : pluriarray, "incr" : 1, "nbmax" : 0x200, "need" : False, "values" :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   216
                [{"name" : "Highest SubIndex Supported", "type" : 0x02, "access" : 'ro', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   217
                 {"name" : "COB ID used by PDO", "type" : 0x04, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   218
                 {"name" : "Transmission Type", "type" : 0x02, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
                 {"name" : "Inhibit Time", "type" : 0x03, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   220
                 {"name" : "Compatibility Entry", "type" : 0x03, "access" : 'rw', "pdo" : False},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
                 {"name" : "Event Timer", "type" : 0x03, "access" : 'rw', "pdo" : False}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   222
    0x1A00 : {"name" : "Transmit PDO %d Mapping[(idx)]", "struct" : plurirec, "incr" : 1, "nbmax" : 0x200, "need" : False, "values" :
65
94c820522994 PDO mapping parameters : number of mapped app must be in RW access
frdupin
parents: 64
diff changeset
   223
                [{"name" : "Number of Entries", "type" : 0x02, "access" : 'rw', "pdo" : False},
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   224
                 {"name" : "PDO %d Mapping for a process data variable %d[(idx,sub)]", "type" : 0x04, "access" : 'rw', "pdo" : False, "nbmax" : 0x40}]},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
}
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
#                          Definition of Node Object
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   229
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   230
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   231
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   232
Class recording the Object Dictionary entries. It checks at each modification
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   233
that the structure of the Object Dictionary stay coherent
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   234
"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   235
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   236
class Node:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   237
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   238
    def __init__(self, name = "", type = "slave", id = 0, profilename = "DS-301", profile = {}, specificmenu = []):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   239
        self.Name = name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   240
        self.Type = type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   241
        self.ID = id
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   242
        self.ProfileName = profilename
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   243
        self.Profile = profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   244
        self.SpecificMenu = specificmenu
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   245
        self.Dictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   246
        self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   247
        self.DS302 = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   248
        self.UserMapping = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   249
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   250
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   251
    Return the node name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   252
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   253
    def GetNodeName(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   254
        return self.Name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   255
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   256
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   257
    Define the node name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   258
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   259
    def SetNodeName(self, name):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   260
        self.Name = name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   261
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   262
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   263
    Return the node type ("master" or "slave")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   264
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   265
    def GetNodeType(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   266
        return self.Type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   267
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   268
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   269
    Define the node type ("master" or "slave")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   270
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   271
    def SetNodeType(self, type):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   272
        self.Type = type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   273
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   274
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   275
    Return the node ID
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   276
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   277
    def GetNodeID(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   278
        return self.ID
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   279
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   280
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   281
    Define the node ID
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   282
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   283
    def SetNodeID(self, id):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   284
        self.ID = id
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   285
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   286
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   287
    Return the Specific Profile Name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   288
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   289
    def GetProfileName(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   290
        return self.ProfileName
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   291
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   292
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   293
    Define the Specific Profile Name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   294
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   295
    def SetProfileName(self, profilename):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   296
        self.ProfileName = profilename
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   297
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   298
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   299
    Return the Specific Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   300
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   301
    def GetProfile(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   302
        return self.Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   303
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   304
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   305
    Define the Specific Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   306
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   307
    def SetProfile(self, profile):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   308
        self.Profile = profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   309
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   310
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   311
    Define the DS-302 Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   312
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   313
    def SetDS302Profile(self, profile):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   314
        self.DS302 = profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   315
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   316
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   317
    Define the DS-302 Profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   318
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   319
    def GetDS302Profile(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   320
        return self.DS302
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   321
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   322
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   323
    Return the Specific Menu Entries
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   324
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   325
    def GetSpecificMenu(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   326
        return self.SpecificMenu
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   327
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   328
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   329
    Define the Specific Menu Entries
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   330
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   331
    def SetSpecificMenu(self, specificmenu):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   332
        self.SpecificMenu = specificmenu
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   333
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   334
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   335
    Extend the Specific Menu Entries
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   336
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   337
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   338
    def ExtendSpecificMenu(self, specificmenu):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   339
        self.SpecificMenu.extend(AddMenuEntries)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   340
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   341
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   342
    Function which return the different Mappings available for this node
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   343
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   344
    def GetMappings(self, userdefinedtoo = True):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   345
        if userdefinedtoo:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   346
            return [self.Profile, self.DS302, self.UserMapping]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   347
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   348
            return [self.Profile, self.DS302]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   349
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   350
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   351
    Add a new entry in the Object Dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   352
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   353
    def AddEntry(self, index, subIndex = None, value = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   354
        if index not in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   355
            if not subIndex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   356
                self.Dictionary[index] = value
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   357
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   358
            elif subIndex == 1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   359
                self.Dictionary[index] = [value]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   360
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   361
        elif subIndex > 1 and type(self.Dictionary[index]) == ListType and subIndex == len(self.Dictionary[index]) + 1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   362
            self.Dictionary[index].append(value)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   363
            return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   364
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   365
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   366
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   367
    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
   368
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   369
    def SetEntry(self, index, subIndex = None, value = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   370
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   371
            if not subIndex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   372
                if value != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   373
                    self.Dictionary[index] = value
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   374
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   375
            elif type(self.Dictionary[index]) == ListType and 0 < subIndex <= len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   376
                if value != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   377
                    self.Dictionary[index][subIndex - 1] = value
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   378
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   379
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   380
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   381
    def SetParamsEntry(self, index, subIndex = None, comment = None, save = None, callback = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   382
        if not getattr(self, "ParamsDictionary", False):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   383
            self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   384
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   385
            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
   386
                self.ParamsDictionary[index] = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   387
            if subIndex == None or type(self.Dictionary[index]) != ListType and subIndex == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   388
                if comment != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   389
                    self.ParamsDictionary[index]["comment"] = comment
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   390
                if save != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   391
                    self.ParamsDictionary[index]["save"] = save
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   392
                if callback != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   393
                    self.ParamsDictionary[index]["callback"] = callback
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   394
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   395
            elif type(self.Dictionary[index]) == ListType and 0 <= subIndex <= len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   396
                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
   397
                    self.ParamsDictionary[index][subIndex] = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   398
                if comment != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   399
                    self.ParamsDictionary[index][subIndex]["comment"] = comment
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   400
                if save != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   401
                    self.ParamsDictionary[index][subIndex]["save"] = save
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   402
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   403
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   404
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   405
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   406
    Removes an existing entry in the Object Dictionary. If a subIndex is specified
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   407
    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
   408
    is specified it removes the whole index and subIndexes from the Object Dictionary.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   409
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   410
    def RemoveEntry(self, index, subIndex = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   411
        if not getattr(self, "ParamsDictionary", False):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   412
            self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   413
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   414
            if not subIndex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   415
                self.Dictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   416
                if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   417
                    self.ParamsDictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   418
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   419
            elif type(self.Dictionary[index]) == ListType and subIndex == len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   420
                self.Dictionary[index].pop(subIndex - 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   421
                if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   422
                    if subIndex in self.ParamsDictionary[index]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   423
                        self.ParamsDictionary[index].pop(subIndex)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   424
                    if len(self.ParamsDictionary[index]) == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   425
                        self.ParamsDictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   426
                if len(self.Dictionary[index]) == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   427
                    self.Dictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   428
                    if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   429
                        self.ParamsDictionary.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   430
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   431
        return False
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
    Check if an entry exists in the Object Dictionary and returns the answer.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   435
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   436
    def IsEntry(self, index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   437
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   438
            return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   439
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   440
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   441
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   442
    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
   443
    returns the number of subIndex in the entry except the first.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   444
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   445
    def GetEntry(self, index, subIndex = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   446
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   447
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   448
                if type(self.Dictionary[index]) == ListType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   449
                    values = [len(self.Dictionary[index])]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   450
                    values.extend(self.Dictionary[index])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   451
                    return values
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   452
                else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   453
                    return self.Dictionary[index]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   454
            elif subIndex == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   455
                if type(self.Dictionary[index]) == ListType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   456
                    return len(self.Dictionary[index])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   457
                else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   458
                    return self.Dictionary[index]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   459
            elif type(self.Dictionary[index]) == ListType and 0 < subIndex <= len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   460
                return self.Dictionary[index][subIndex - 1]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   461
        return None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   462
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   463
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   464
    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
   465
    returns the number of subIndex in the entry except the first.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   466
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   467
    def GetParamsEntry(self, index, subIndex = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   468
        if not getattr(self, "ParamsDictionary", False):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   469
            self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   470
        if index in self.Dictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   471
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   472
                if type(self.Dictionary[index]) == ListType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   473
                    if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   474
                        result = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   475
                        for i in xrange(len(self.Dictionary[index]) + 1):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   476
                            line = DefaultParams.copy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   477
                            if i in self.ParamsDictionary[index]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   478
                                line.update(self.ParamsDictionary[index][i])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   479
                            result.append(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   480
                        return result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   481
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   482
                        return [DefaultParams.copy() for i in xrange(len(self.Dictionary[index]) + 1)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   483
                else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   484
                    result = DefaultParams.copy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   485
                    if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   486
                        result.update(self.ParamsDictionary[index])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   487
                    return result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   488
            elif subIndex == 0 and type(self.Dictionary[index]) != ListType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   489
                result = DefaultParams.copy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   490
                if index in self.ParamsDictionary:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   491
                    result.update(self.ParamsDictionary[index])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   492
                return result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   493
            elif type(self.Dictionary[index]) == ListType and 0 <= subIndex <= len(self.Dictionary[index]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   494
                result = DefaultParams.copy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   495
                if index in self.ParamsDictionary and subIndex in self.ParamsDictionary[index]:
64
c72dd78e547f Bug reported by Dean corrected
lbessard
parents: 63
diff changeset
   496
                    result.update(self.ParamsDictionary[index][subIndex])
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   497
                return result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   498
        return None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   499
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   500
    def HasEntryCallbacks(self, index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   501
        if not getattr(self, "ParamsDictionary", False):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   502
            self.ParamsDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   503
        if index in self.Dictionary and index in self.ParamsDictionary and "callback" in self.ParamsDictionary[index]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   504
            return self.ParamsDictionary[index]["callback"]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   505
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   506
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   507
    """
68
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   508
    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
   509
    """
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   510
    def IsMappingEntry(self, index):
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   511
        if index in self.UserMapping:
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   512
            return True
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   513
        return False
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   514
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 67
diff changeset
   515
    """
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   516
    Add a new entry in the User Mapping Dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   517
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   518
    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
   519
        if index not in self.UserMapping:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   520
            if values == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   521
                values = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   522
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   523
                self.UserMapping[index] = {"name" : name, "struct" : struct, "need" : False, "values" : values}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   524
                if size != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   525
                    self.UserMapping[index]["size"] = size
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   526
                if nbmax != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   527
                    self.UserMapping[index]["nbmax"] = nbmax
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   528
                if default != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   529
                    self.UserMapping[index]["default"] = default
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   530
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   531
        elif subIndex != None and subIndex == len(self.UserMapping[index]["values"]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   532
            if values == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   533
                values = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   534
            self.UserMapping[index]["values"].append(values)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   535
            return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   536
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   537
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   538
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   539
    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
   540
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   541
    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
   542
        if index in self.UserMapping:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   543
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   544
                if name != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   545
                    self.UserMapping[index]["name"] = name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   546
                    if self.UserMapping[index]["struct"] & OD_IdenticalSubindexes:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   547
                        self.UserMapping[index]["values"][1]["name"] = name + " %d[(sub)]"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   548
                    elif not self.UserMapping[index]["struct"] & OD_MultipleSubindexes:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   549
                        self.UserMapping[index]["values"][0]["name"] = name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   550
                if struct != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   551
                    self.UserMapping[index]["struct"] = struct
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   552
                if size != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   553
                    self.UserMapping[index]["size"] = size
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   554
                if nbmax != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   555
                    self.UserMapping[index]["nbmax"] = nbmax
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   556
                if default != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   557
                    self.UserMapping[index]["default"] = default
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   558
                if values != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   559
                    self.UserMapping[index]["values"] = values
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 0 <= subIndex < len(self.UserMapping[index]["values"]) and values != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   562
                self.UserMapping[index]["values"][subIndex].update(values)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   563
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   564
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   565
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   566
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   567
    Removes an existing entry in the User Mapping Dictionary. If a subIndex is specified
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   568
    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
   569
    is specified it removes the whole index and subIndexes from the User Mapping Dictionary.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   570
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   571
    def RemoveMappingEntry(self, index, subIndex = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   572
        if index in self.UserMapping:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   573
            if subIndex == None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   574
                self.UserMapping.pop(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   575
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   576
            elif subIndex == len(self.UserMapping[index]["values"]) - 1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   577
                self.UserMapping[index]["values"].pop(subIndex)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   578
                return True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   579
        return False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   580
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   581
    def RemoveMapVariable(self, index, subIndex):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   582
        model = index << 16
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   583
        mask = 0xFFFF << 16
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   584
        if subIndex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   585
            model += subIndex << 8
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   586
            mask = 0xFF << 8
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   587
        for i in self.Dictionary.iterkeys():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   588
            if 0x1600 <= i <= 0x17FF or 0x1A00 <= i <= 0x1BFF:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   589
                for j,value in enumerate(self.Dictionary[i]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   590
                    if (value & mask) == model:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   591
                        self.Dictionary[i][j] = 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   592
    
63
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   593
    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
   594
        model = index << 16
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   595
        mask = 0xFFFF << 16
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   596
        if subIndex:
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   597
            model += subIndex << 8
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   598
            mask = 0xFF << 8
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   599
        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
   600
            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
   601
                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
   602
                    if (value & mask) == model:
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 62
diff changeset
   603
                        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
   604
    
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   605
    def RemoveLine(self, index, max, incr = 1):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   606
        i = index
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   607
        while i < max and self.IsEntry(i + incr):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   608
            self.Dictionary[i] = self.Dictionary[i + incr]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   609
            i += incr
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   610
        self.Dictionary.pop(i)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   611
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   612
    def RemoveUserType(self, index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   613
        type = self.GetEntry(index, 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   614
        for i in self.UserMapping:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   615
            for value in self.UserMapping[i]["values"]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   616
                if value["type"] == index:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   617
                    value["type"] = type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   618
        self.RemoveMappingEntry(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   619
        self.RemoveEntry(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   620
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   621
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   622
    Return a copy of the node
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   623
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   624
    def Copy(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   625
        return cPickle.loads(cPickle.dumps(self))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   626
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   627
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   628
    Return a sorted list of indexes in Object Dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   629
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   630
    def GetIndexes(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   631
        listindex = self.Dictionary.keys()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   632
        listindex.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   633
        return listindex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   634
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   635
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   636
    Print the Dictionary values
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   637
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   638
    def Print(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   639
        listindex = self.Dictionary.keys()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   640
        listindex.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   641
        for index in listindex:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   642
            print "%04X : %s"%(index, self.Dictionary[index])