objdictgen/nodemanager.py
changeset 258 8f7725451453
parent 254 f2b0acb54e65
child 268 8a21eb5bdedc
equal deleted inserted replaced
257:4f3364846782 258:8f7725451453
   148 class NodeManager:
   148 class NodeManager:
   149 
   149 
   150     """
   150     """
   151     Constructor
   151     Constructor
   152     """
   152     """
   153     def __init__(self, cwd):
   153     def __init__(self):
   154         self.LastNewIndex = 0
   154         self.LastNewIndex = 0
   155         self.FilePaths = {}
   155         self.FilePaths = {}
   156         self.FileNames = {}
   156         self.FileNames = {}
   157         self.NodeIndex = None
   157         self.NodeIndex = None
   158         self.CurrentNode = None
   158         self.CurrentNode = None
   159         self.ScriptDirectory = cwd
       
   160         self.UndoBuffers = {}
   159         self.UndoBuffers = {}
   161 
   160 
   162 #-------------------------------------------------------------------------------
   161 #-------------------------------------------------------------------------------
   163 #                         Type and Map Variable Lists
   162 #                         Type and Map Variable Lists
   164 #-------------------------------------------------------------------------------
   163 #-------------------------------------------------------------------------------
   205                 AddIndexList.extend([0x100C, 0x100D])
   204                 AddIndexList.extend([0x100C, 0x100D])
   206             elif NMT == "Heartbeat":
   205             elif NMT == "Heartbeat":
   207                 AddIndexList.append(0x1017)
   206                 AddIndexList.append(0x1017)
   208             for option in options:
   207             for option in options:
   209                 if option == "DS302":
   208                 if option == "DS302":
   210                     DS302Path = os.path.join(self.ScriptDirectory, "config/DS-302.prf")
   209                     DS302Path = os.path.join(os.path.split(__file__)[0], "config/DS-302.prf")
   211                     # Charging DS-302 profile if choosen by user
   210                     # Charging DS-302 profile if choosen by user
   212                     if os.path.isfile(DS302Path):
   211                     if os.path.isfile(DS302Path):
   213                         try:
   212                         try:
   214                             execfile(DS302Path)
   213                             execfile(DS302Path)
   215                             self.CurrentNode.SetDS302Profile(Mapping)
   214                             self.CurrentNode.SetDS302Profile(Mapping)
   301     """
   300     """
   302     Import an eds file and store it in a new buffer if no node edited
   301     Import an eds file and store it in a new buffer if no node edited
   303     """
   302     """
   304     def ImportCurrentFromEDSFile(self, filepath):
   303     def ImportCurrentFromEDSFile(self, filepath):
   305         # Generate node from definition in a xml file
   304         # Generate node from definition in a xml file
   306         result = eds_utils.GenerateNode(filepath, self.ScriptDirectory)
   305         result = eds_utils.GenerateNode(filepath)
   307         if isinstance(result, Node):
   306         if isinstance(result, Node):
   308             self.CurrentNode = result
   307             self.CurrentNode = result
   309             index = self.AddNodeBuffer(self.CurrentNode.Copy(), False)
   308             index = self.AddNodeBuffer(self.CurrentNode.Copy(), False)
   310             self.SetCurrentFilePath("")
   309             self.SetCurrentFilePath("")
   311             return index
   310             return index