canfestival/canfestival.py
changeset 777 daa6941fe21a
parent 776 c81397b665b6
child 778 4f9e6d9a3d98
child 781 cdc6393705ce
equal deleted inserted replaced
776:c81397b665b6 777:daa6941fe21a
    11 import canfestival_config as local_canfestival_config
    11 import canfestival_config as local_canfestival_config
    12 from ConfigTreeNode import ConfigTreeNode
    12 from ConfigTreeNode import ConfigTreeNode
    13 from commondialogs import CreateNodeDialog
    13 from commondialogs import CreateNodeDialog
    14 import wx
    14 import wx
    15 
    15 
    16 from SlaveEditor import SlaveEditor
    16 from SlaveEditor import SlaveEditor, MasterViewer
    17 from NetworkEditor import NetworkEditor
    17 from NetworkEditor import NetworkEditor
    18 
    18 
    19 from gnosis.xml.pickle import *
    19 from gnosis.xml.pickle import *
    20 from gnosis.xml.pickle.util import setParanoia
    20 from gnosis.xml.pickle.util import setParanoia
    21 setParanoia(0)
    21 setParanoia(0)
   111     def _OpenView(self):
   111     def _OpenView(self):
   112         ConfigTreeNode._OpenView(self)
   112         ConfigTreeNode._OpenView(self)
   113         if self._View is not None:
   113         if self._View is not None:
   114             self._View.SetBusId(self.GetCurrentLocation())
   114             self._View.SetBusId(self.GetCurrentLocation())
   115         return self._View
   115         return self._View
   116 
   116     
       
   117     def _ExportSlave(self):
       
   118         dialog = wx.FileDialog(self.GetCTRoot().AppFrame, _("Choose a file"), os.getcwd(), "",  _("EDS files (*.eds)|*.eds|All files|*.*"), wx.SAVE|wx.OVERWRITE_PROMPT)
       
   119         if dialog.ShowModal() == wx.ID_OK:
       
   120             result = eds_utils.GenerateEDSFile(dialog.GetPath(), self.GetCurrentNodeCopy())
       
   121             if result:
       
   122                 self.GetCTRoot().logger.write_error(_("Error: Export slave failed\n"))
       
   123         dialog.Destroy()  
       
   124         
   117     ConfNodeMethods = [
   125     ConfNodeMethods = [
   118         {"bitmap" : "NetworkEdit",
   126         {"bitmap" : "ExportSlave",
   119          "name" : "Edit slave", 
   127          "name" : _("Export slave"), 
   120          "tooltip" : "Edit CanOpen slave with ObjdictEdit",
   128          "tooltip" : _("Export CanOpen slave to EDS file"),
   121          "method" : "_OpenView"},
   129          "method" : "_ExportSlave"},
   122     ]
   130     ]
   123 
   131     
   124     def CTNTestModified(self):
   132     def CTNTestModified(self):
   125         return self.ChangesToSave or self.OneFileHasChanged()
   133         return self.ChangesToSave or self.OneFileHasChanged()
   126         
   134         
   127     def OnCTNSave(self):
   135     def OnCTNSave(self):
   128         return self.SaveCurrentInFile(self.GetSlaveODPath())
   136         return self.SaveCurrentInFile(self.GetSlaveODPath())
   186         
   194         
   187         self.OpenFileInCurrent(filepath)
   195         self.OpenFileInCurrent(filepath)
   188             
   196             
   189         self.Parent = parent
   197         self.Parent = parent
   190         self.Fullname = fullname
   198         self.Fullname = fullname
   191         
   199     
       
   200     def GetIconPath(self):
       
   201         return None
       
   202     
   192     def OnCloseEditor(self, view):
   203     def OnCloseEditor(self, view):
   193         self.Parent.OnCloseEditor(view)
   204         self.Parent.OnCloseEditor(view)
   194     
   205     
   195     def CTNFullName(self):
   206     def CTNFullName(self):
   196         return self.Fullname
   207         return self.Fullname
   197     
   208     
       
   209     def CTNTestModified(self):
       
   210         return False
       
   211     
   198     def GetBufferState(self):
   212     def GetBufferState(self):
   199         return self.GetCurrentBufferState()
   213         return self.GetCurrentBufferState()
   200 
   214     
   201     ConfNodeMethods = []
   215     ConfNodeMethods = []
   202 
   216 
   203 class _NodeListCTN(NodeList):
   217 class _NodeListCTN(NodeList):
   204     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
   218     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
   205     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   219     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   256                     return
   270                     return
   257                 
   271                 
   258                 app_frame = self.GetCTRoot().AppFrame
   272                 app_frame = self.GetCTRoot().AppFrame
   259                 
   273                 
   260                 manager = MiniNodeManager(self, masterpath, self.CTNFullName() + ".generated_master")
   274                 manager = MiniNodeManager(self, masterpath, self.CTNFullName() + ".generated_master")
   261                 self._GeneratedMasterView = SlaveEditor(app_frame.TabsOpened, manager, app_frame, False)
   275                 self._GeneratedMasterView = MasterViewer(app_frame.TabsOpened, manager, app_frame)
   262                 
   276                 
   263                 app_frame.EditProjectElement(self._GeneratedMasterView, name)
   277                 app_frame.EditProjectElement(self._GeneratedMasterView, name)
   264             
   278             
   265             return self._GeneratedMasterView
   279             return self._GeneratedMasterView
   266         else:
   280         else:
   268             if self._View is not None:
   282             if self._View is not None:
   269                 self._View.SetBusId(self.GetCurrentLocation())
   283                 self._View.SetBusId(self.GetCurrentLocation())
   270             return self._View
   284             return self._View
   271     
   285     
   272     ConfNodeMethods = [
   286     ConfNodeMethods = [
   273         {"bitmap" : "NetworkEdit",
       
   274          "name" : _("Edit network"), 
       
   275          "tooltip" : _("Edit CanOpen Network with NetworkEdit"),
       
   276          "method" : "_OpenView"},
       
   277         {"bitmap" : "ShowMaster",
   287         {"bitmap" : "ShowMaster",
   278          "name" : _("Show Master"), 
   288          "name" : _("Show Master"), 
   279          "tooltip" : _("Show Master generated by config_utils"),
   289          "tooltip" : _("Show Master generated by config_utils"),
   280          "method" : "_ShowGeneratedMaster"}
   290          "method" : "_ShowGeneratedMaster"}
   281     ]
   291     ]