etherlab/EthercatMaster.py
changeset 2152 e6946c298a42
parent 2149 7f473761c932
child 2157 a2385e535cf5
equal deleted inserted replaced
2151:015dab6a915f 2152:e6946c298a42
     9 from PLCControler import UndoBuffer, LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
     9 from PLCControler import UndoBuffer, LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
    10 from ConfigTreeNode import ConfigTreeNode
    10 from ConfigTreeNode import ConfigTreeNode
    11 from dialogs import BrowseValuesLibraryDialog
    11 from dialogs import BrowseValuesLibraryDialog
    12 from IDEFrame import TITLE, FILEMENU, PROJECTTREE
    12 from IDEFrame import TITLE, FILEMENU, PROJECTTREE
    13 
    13 
    14 from EthercatSlave import _EthercatSlaveCTN, ExtractHexDecValue, GenerateHexDecValue, TYPECONVERSION, VARCLASSCONVERSION
    14 from EthercatSlave import _EthercatSlaveCTN, ExtractHexDecValue, GenerateHexDecValue, TYPECONVERSION, VARCLASSCONVERSION, _CommonSlave
    15 from EthercatCFileGenerator import _EthercatCFileGenerator
    15 from EthercatCFileGenerator import _EthercatCFileGenerator
    16 from ConfigEditor import MasterEditor
    16 from ConfigEditor import MasterEditor
    17 from POULibrary import POULibrary
    17 from POULibrary import POULibrary
    18 
    18 
    19 try:
    19 try:
    71         Gen_etherlabfile_path = os.path.join(buildpath, "etherlab_ext.c")
    71         Gen_etherlabfile_path = os.path.join(buildpath, "etherlab_ext.c")
    72         ethelabfile = open(Gen_etherlabfile_path,'w')
    72         ethelabfile = open(Gen_etherlabfile_path,'w')
    73         ethelabfile.write(etherlab_ext_code)
    73         ethelabfile.write(etherlab_ext_code)
    74         ethelabfile.close()
    74         ethelabfile.close()
    75         
    75         
       
    76         runtimefile_path = os.path.join(os.path.split(__file__)[0], "runtime_etherlab.py")
    76         return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "", 
    77         return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "", 
    77                 ("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py"))))
    78                 ("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py"))))
    78     
    79     
    79 #--------------------------------------------------
    80 #--------------------------------------------------
    80 #                 Ethercat MASTER
    81 #                 Ethercat MASTER
   206 """
   207 """
   207 
   208 
   208 ProcessVariablesClasses = GenerateClassesFromXSDstring(ProcessVariablesXSD) 
   209 ProcessVariablesClasses = GenerateClassesFromXSDstring(ProcessVariablesXSD) 
   209 
   210 
   210 class _EthercatCTN:
   211 class _EthercatCTN:
   211     
   212 
   212     CTNChildrenTypes = [("EthercatSlave", _EthercatSlaveCTN, "Ethercat Slave")]
   213     CTNChildrenTypes = [("EthercatSlave", _EthercatSlaveCTN, "Ethercat Slave")]
   213     if HAS_MCL:
   214     if HAS_MCL:
   214         CTNChildrenTypes.append(("EthercatCIA402Slave", _EthercatCIA402SlaveCTN, "Ethercat CIA402 Slave"))
   215         CTNChildrenTypes.append(("EthercatCIA402Slave", _EthercatCIA402SlaveCTN, "Ethercat CIA402 Slave"))
   215     EditorType = MasterEditor
   216     EditorType = MasterEditor
   216     
   217     
   244         if config_is_saved and process_is_saved:
   245         if config_is_saved and process_is_saved:
   245             self.CreateBuffer(True)
   246             self.CreateBuffer(True)
   246         else:
   247         else:
   247             self.CreateBuffer(False)
   248             self.CreateBuffer(False)
   248             self.OnCTNSave()
   249             self.OnCTNSave()
       
   250          
       
   251         # ----------- call ethercat mng. function --------------
       
   252         self.CommonMethod = _CommonSlave(self)
   249     
   253     
   250     def GetIconName(self):
   254     def GetIconName(self):
   251         return "Ethercat"
   255         return "Ethercat"
   252     
   256     
   253     def GetContextualMenuItems(self):
   257     def GetContextualMenuItems(self):
   537             if slave is not None:
   541             if slave is not None:
   538                 type_infos = slave.getType()
   542                 type_infos = slave.getType()
   539                 device, module_extra_params = self.GetModuleInfos(type_infos)
   543                 device, module_extra_params = self.GetModuleInfos(type_infos)
   540         if device is not None:
   544         if device is not None:
   541             entries = device.GetEntriesList(limits)
   545             entries = device.GetEntriesList(limits)
       
   546             #print entries
   542             entries_list = entries.items()
   547             entries_list = entries.items()
   543             entries_list.sort()
   548             entries_list.sort()
   544             entries = []
   549             entries = []
   545             current_index = None
   550             current_index = None
   546             current_entry = None
   551             current_entry = None