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