plcopen/plcopen.py
changeset 1739 ec153828ded2
parent 1736 7e61baa047f0
child 1740 b789b695b5c6
equal deleted inserted replaced
1738:d2e979738700 1739:ec153828ded2
    32 import util.paths as paths
    32 import util.paths as paths
    33 
    33 
    34 """
    34 """
    35 Dictionary that makes the relation between var names in plcopen and displayed values
    35 Dictionary that makes the relation between var names in plcopen and displayed values
    36 """
    36 """
    37 VarTypes = {"Local" : "localVars", "Temp" : "tempVars", "Input" : "inputVars",
    37 VarTypes = {
    38             "Output" : "outputVars", "InOut" : "inOutVars", "External" : "externalVars",
    38     "Local":    "localVars",
    39             "Global" : "globalVars", "Access" : "accessVars"}
    39     "Temp":     "tempVars",
       
    40     "Input":    "inputVars",
       
    41     "Output":   "outputVars",
       
    42     "InOut":    "inOutVars",
       
    43     "External": "externalVars",
       
    44     "Global":   "globalVars",
       
    45     "Access":   "accessVars"
       
    46 }
    40 
    47 
    41 searchResultVarTypes = {
    48 searchResultVarTypes = {
    42     "inputVars": "var_input",
    49     "inputVars":  "var_input",
    43     "outputVars": "var_output",
    50     "outputVars": "var_output",
    44     "inOutVars": "var_inout"
    51     "inOutVars":  "var_inout"
    45 }
    52 }
    46 
    53 
    47 """
    54 """
    48 Define in which order var types must be displayed
    55 Define in which order var types must be displayed
    49 """
    56 """
   851             elif base_type_name in ["string", "wstring"]:
   858             elif base_type_name in ["string", "wstring"]:
   852                 basetype_name = base_type_name.upper()
   859                 basetype_name = base_type_name.upper()
   853             # Array derived directly from an elementary type
   860             # Array derived directly from an elementary type
   854             else:
   861             else:
   855                 basetype_name = base_type_name
   862                 basetype_name = base_type_name
   856             return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "%s..%s" % (x.getlower(), x.getupper()), vartype_content.getdimension())), basetype_name)
   863             return "ARRAY [%s] OF %s" % (",".join(map(lambda x: "%s..%s" % (x.getlower(), x.getupper()), vartype_content.getdimension())), basetype_name)
   857         # Variable type is an elementary type
   864         # Variable type is an elementary type
   858         return vartype_content_name
   865         return vartype_content_name
   859     setattr(cls, "gettypeAsText", gettypeAsText)
   866     setattr(cls, "gettypeAsText", gettypeAsText)
   860 
   867 
   861     def Search(self, criteria, parent_infos=[]):
   868     def Search(self, criteria, parent_infos=[]):
  1077         "ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars]/ppx:variable")
  1084         "ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars]/ppx:variable")
  1078     block_outputs_xpath = PLCOpen_XPath(
  1085     block_outputs_xpath = PLCOpen_XPath(
  1079         "ppx:interface/*[self::ppx:outputVars or self::ppx:inOutVars]/ppx:variable")
  1086         "ppx:interface/*[self::ppx:outputVars or self::ppx:inOutVars]/ppx:variable")
  1080     def getblockInfos(self):
  1087     def getblockInfos(self):
  1081         block_infos = {
  1088         block_infos = {
  1082             "name" : self.getname(),
  1089             "name": self.getname(),
  1083             "type" : self.getpouType(),
  1090             "type": self.getpouType(),
  1084             "extensible" : False,
  1091             "extensible": False,
  1085             "inputs" : [],
  1092             "inputs": [],
  1086             "outputs" : [],
  1093             "outputs": [],
  1087             "comment" : self.getdescription()}
  1094             "comment": self.getdescription()}
  1088         if self.interface is not None:
  1095         if self.interface is not None:
  1089             return_type = self.interface.getreturnType()
  1096             return_type = self.interface.getreturnType()
  1090             if return_type is not None:
  1097             if return_type is not None:
  1091                 block_infos["outputs"].append(
  1098                 block_infos["outputs"].append(
  1092                     ("OUT", _getvariableTypeinfos(return_type), "none"))
  1099                     ("OUT", _getvariableTypeinfos(return_type), "none"))
  2073     setattr(cls, "setconditionContent", setconditionContent)
  2080     setattr(cls, "setconditionContent", setconditionContent)
  2074 
  2081 
  2075     def getconditionContent(self):
  2082     def getconditionContent(self):
  2076         if self.condition is not None:
  2083         if self.condition is not None:
  2077             content = self.condition.getcontent()
  2084             content = self.condition.getcontent()
  2078             values = {"type" : content.getLocalTag()}
  2085             values = {"type": content.getLocalTag()}
  2079             if values["type"] == "reference":
  2086             if values["type"] == "reference":
  2080                 values["value"] = content.getname()
  2087                 values["value"] = content.getname()
  2081             elif values["type"] == "inline":
  2088             elif values["type"] == "inline":
  2082                 values["value"] = content.gettext()
  2089                 values["value"] = content.gettext()
  2083             elif values["type"] == "connectionPointIn":
  2090             elif values["type"] == "connectionPointIn":