etherlab/EthercatMaster.py
changeset 2459 21164625b393
parent 2456 7373e3048167
child 2643 b98d9e08231f
equal deleted inserted replaced
2458:2a70d5240300 2459:21164625b393
    10 # See COPYING file for copyrights details.
    10 # See COPYING file for copyrights details.
    11 
    11 
    12 from __future__ import absolute_import
    12 from __future__ import absolute_import
    13 import os
    13 import os
    14 from copy import deepcopy
    14 from copy import deepcopy
       
    15 from functools import reduce
    15 from lxml import etree
    16 from lxml import etree
    16 
    17 
    17 import wx
    18 import wx
    18 
    19 
    19 from xmlclass import *
    20 from xmlclass import *
    92         ethelabfile = open(Gen_etherlabfile_path, 'w')
    93         ethelabfile = open(Gen_etherlabfile_path, 'w')
    93         ethelabfile.write(etherlab_ext_code)
    94         ethelabfile.write(etherlab_ext_code)
    94         ethelabfile.close()
    95         ethelabfile.close()
    95 
    96 
    96         return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "",
    97         return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "",
    97                 ("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py"))))
    98                 ("runtime_etherlab.py", open(GetLocalPath("runtime_etherlab.py"))))
    98 
    99 
    99 # --------------------------------------------------
   100 # --------------------------------------------------
   100 #                 Ethercat MASTER
   101 #                 Ethercat MASTER
   101 # --------------------------------------------------
   102 # --------------------------------------------------
   102 
   103 
   248                 self.Config, error = \
   249                 self.Config, error = \
   249                     EtherCATConfigParser.LoadXMLString(config_xmlfile.read())
   250                     EtherCATConfigParser.LoadXMLString(config_xmlfile.read())
   250                 if error is None:
   251                 if error is None:
   251                     config_is_saved = True
   252                     config_is_saved = True
   252             except Exception as e:
   253             except Exception as e:
   253                 error = e.message
   254                 error = str(e)
   254             config_xmlfile.close()
   255             config_xmlfile.close()
   255 
   256 
   256             if error is not None:
   257             if error is not None:
   257                 self.GetCTRoot().logger.write_error(
   258                 self.GetCTRoot().logger.write_error(
   258                     _("Couldn't load %s network configuration file.") % self.CTNName())
   259                     _("Couldn't load %s network configuration file.") % self.CTNName())
   269                 self.ProcessVariables, error = \
   270                 self.ProcessVariables, error = \
   270                     ProcessVariablesParser.LoadXMLString(process_xmlfile.read())
   271                     ProcessVariablesParser.LoadXMLString(process_xmlfile.read())
   271                 if error is None:
   272                 if error is None:
   272                     process_is_saved = True
   273                     process_is_saved = True
   273             except Exception as e:
   274             except Exception as e:
   274                 error = e.message
   275                 error = str(e)
   275             process_xmlfile.close()
   276             process_xmlfile.close()
   276 
   277 
   277             if error is not None:
   278             if error is not None:
   278                 self.GetCTRoot().logger.write_error(
   279                 self.GetCTRoot().logger.write_error(
   279                     _("Couldn't load %s network process variables file.") % self.CTNName())
   280                     _("Couldn't load %s network process variables file.") % self.CTNName())