PLCGenerator.py
changeset 1181 21e6db77eb29
parent 1134 1c7a4ad86aa1
child 1183 a01618805821
equal deleted inserted replaced
1180:276a30c68eaa 1181:21e6db77eb29
   652                     option = None
   652                     option = None
   653                 if len(variables) > 0:
   653                 if len(variables) > 0:
   654                     self.Interface.append((varTypeNames[varlist["name"]], option, False, variables))
   654                     self.Interface.append((varTypeNames[varlist["name"]], option, False, variables))
   655                 if len(located) > 0:
   655                 if len(located) > 0:
   656                     self.Interface.append((varTypeNames[varlist["name"]], option, True, located))
   656                     self.Interface.append((varTypeNames[varlist["name"]], option, True, located))
   657         
   657     
       
   658     LITERAL_TYPES = {
       
   659         "T": "TIME",
       
   660         "D": "DATE",
       
   661         "TOD": "TIME_OF_DAY",
       
   662         "DT": "DATE_AND_TIME",
       
   663         "2": "ANY",
       
   664         "8": "ANY",
       
   665         "16": "ANY",
       
   666     }
   658     def ComputeConnectionTypes(self, pou):
   667     def ComputeConnectionTypes(self, pou):
   659         body = pou.getbody()
   668         body = pou.getbody()
   660         if isinstance(body, ListType):
   669         if isinstance(body, ListType):
   661             body = body[0]
   670             body = body[0]
   662         body_content = body.getcontent()
   671         body_content = body.getcontent()
   679                         else:
   688                         else:
   680                             var_type = returntype_content["name"]
   689                             var_type = returntype_content["name"]
   681                     elif var_type is None:
   690                     elif var_type is None:
   682                         parts = expression.split("#")
   691                         parts = expression.split("#")
   683                         if len(parts) > 1:
   692                         if len(parts) > 1:
   684                             var_type = parts[0]
   693                             literal_prefix = parts[0].upper()
       
   694                             var_type = self.LITERAL_TYPES.get(literal_prefix, 
       
   695                                                               literal_prefix)
   685                         elif expression.startswith("'"):
   696                         elif expression.startswith("'"):
   686                             var_type = "STRING"
   697                             var_type = "STRING"
   687                         elif expression.startswith('"'):
   698                         elif expression.startswith('"'):
   688                             var_type = "WSTRING"
   699                             var_type = "WSTRING"
   689                     if var_type is not None:
   700                     if var_type is not None: