# HG changeset patch # User Laurent Bessard # Date 1369770722 -7200 # Node ID 21e6db77eb296dee719d754277ee281de184cfdf # Parent 276a30c68eaad388e3b959b11e6d5005d98ade7e Fixed bug in PLC code generated with binary, octal and hexadecimal literals diff -r 276a30c68eaa -r 21e6db77eb29 PLCGenerator.py --- a/PLCGenerator.py Tue May 28 17:52:57 2013 +0200 +++ b/PLCGenerator.py Tue May 28 21:52:02 2013 +0200 @@ -654,7 +654,16 @@ self.Interface.append((varTypeNames[varlist["name"]], option, False, variables)) if len(located) > 0: self.Interface.append((varTypeNames[varlist["name"]], option, True, located)) - + + LITERAL_TYPES = { + "T": "TIME", + "D": "DATE", + "TOD": "TIME_OF_DAY", + "DT": "DATE_AND_TIME", + "2": "ANY", + "8": "ANY", + "16": "ANY", + } def ComputeConnectionTypes(self, pou): body = pou.getbody() if isinstance(body, ListType): @@ -681,7 +690,9 @@ elif var_type is None: parts = expression.split("#") if len(parts) > 1: - var_type = parts[0] + literal_prefix = parts[0].upper() + var_type = self.LITERAL_TYPES.get(literal_prefix, + literal_prefix) elif expression.startswith("'"): var_type = "STRING" elif expression.startswith('"'):