PLCControler.py
changeset 1953 5736d25bb393
parent 1951 bbd1e1744c91
child 1954 b113d7de4899
equal deleted inserted replaced
1952:0c20fc810d61 1953:5736d25bb393
    34 from collections import OrderedDict, namedtuple
    34 from collections import OrderedDict, namedtuple
    35 
    35 
    36 from lxml import etree
    36 from lxml import etree
    37 
    37 
    38 import util.paths as paths
    38 import util.paths as paths
    39 from util.TranslationCatalogs import NoTranslate
       
    40 from plcopen import *
    39 from plcopen import *
    41 from plcopen.types_enums import *
    40 from plcopen.types_enums import *
    42 from plcopen.XSLTModelQuery import  _StringValue, _BoolValue, _translate_args
    41 from plcopen.XSLTModelQuery import _StringValue, _BoolValue, _translate_args
    43 from plcopen.InstancesPathCollector import InstancesPathCollector
    42 from plcopen.InstancesPathCollector import InstancesPathCollector
    44 from plcopen.POUVariablesCollector import POUVariablesCollector
    43 from plcopen.POUVariablesCollector import POUVariablesCollector
    45 from plcopen.InstanceTagnameCollector import InstanceTagnameCollector
    44 from plcopen.InstanceTagnameCollector import InstanceTagnameCollector
    46 from plcopen.VariableInfoCollector import VariableInfoCollector
    45 from plcopen.VariableInfoCollector import VariableInfoCollector
    47 from graphics.GraphicCommons import *
    46 from graphics.GraphicCommons import *
    48 from PLCGenerator import *
    47 from PLCGenerator import *
    49 
    48 
    50 duration_model = re.compile("(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m(?!s))?(?:([0-9]{1,2})s)?(?:([0-9]{1,3}(?:\.[0-9]*)?)ms)?")
    49 duration_model = re.compile("(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m(?!s))?(?:([0-9]{1,2})s)?(?:([0-9]{1,3}(?:\.[0-9]*)?)ms)?")
    51 
    50 
    52 ScriptDirectory = paths.AbsDir(__file__)
    51 ScriptDirectory = paths.AbsDir(__file__)
       
    52 
    53 
    53 
    54 class LibraryResolver(etree.Resolver):
    54 class LibraryResolver(etree.Resolver):
    55     """Helper object for loading library in xslt stylesheets"""
    55     """Helper object for loading library in xslt stylesheets"""
    56 
    56 
    57     def __init__(self, controller, debug=False):
    57     def __init__(self, controller, debug=False):
   585                             ComputePouName(words[1]), debug)]
   585                             ComputePouName(words[1]), debug)]
   586         return []
   586         return []
   587 
   587 
   588     def GetPouInstanceTagName(self, instance_path, debug=False):
   588     def GetPouInstanceTagName(self, instance_path, debug=False):
   589         project = self.GetProject(debug)
   589         project = self.GetProject(debug)
   590         if project is not None :
   590         if project is not None:
   591             return self.InstanceTagnameCollector.Collect(project,
   591             return self.InstanceTagnameCollector.Collect(project,
   592                                                          debug,
   592                                                          debug,
   593                                                          instance_path)
   593                                                          instance_path)
   594 
   594 
   595     def GetInstanceInfos(self, instance_path, debug=False):
   595     def GetInstanceInfos(self, instance_path, debug=False):
  1108             current_varlist.appendvariable(tempvar)
  1108             current_varlist.appendvariable(tempvar)
  1109         return varlist_list
  1109         return varlist_list
  1110 
  1110 
  1111     def GetVariableDictionary(self, object_with_vars, tree=False, debug=False):
  1111     def GetVariableDictionary(self, object_with_vars, tree=False, debug=False):
  1112         variables = []
  1112         variables = []
  1113         factory = self.VariableInfoCollector.Collect(object_with_vars,
  1113         self.VariableInfoCollector.Collect(object_with_vars,
  1114                                                      debug, variables, tree)
  1114                                            debug, variables, tree)
  1115         return variables
  1115         return variables
  1116 
  1116 
  1117     # Add a global var to configuration to configuration
  1117     # Add a global var to configuration to configuration
  1118     def AddConfigurationGlobalVar(self, config_name, var_type, var_name,
  1118     def AddConfigurationGlobalVar(self, config_name, var_type, var_name,
  1119                                   location="", description=""):
  1119                                   location="", description=""):
  1262         # Verify that the pou has an interface
  1262         # Verify that the pou has an interface
  1263         if pou.interface is not None:
  1263         if pou.interface is not None:
  1264             # Return the return type if there is one
  1264             # Return the return type if there is one
  1265             return_type = pou.interface.getreturnType()
  1265             return_type = pou.interface.getreturnType()
  1266             if return_type is not None:
  1266             if return_type is not None:
  1267                 factory = self.VariableInfoCollector.Collect(return_type, 
  1267                 factory = self.VariableInfoCollector.Collect(return_type,
  1268                                                              debug, [], tree)
  1268                                                              debug, [], tree)
  1269                 if tree:
  1269                 if tree:
  1270                     return [factory.GetType(), factory.GetTree()]
  1270                     return [factory.GetType(), factory.GetTree()]
  1271                 return factory.GetType()
  1271                 return factory.GetType()
  1272 
  1272