Improve fix wrong code generation if EN/ENO are used in FBD/LD/SFC
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 09 Aug 2018 13:58:47 +0300
changeset 2275 1bb8afa02409
parent 2274 5cb9ef5351cc
child 2276 ba0fc3e73ce2
Improve fix wrong code generation if EN/ENO are used in FBD/LD/SFC

Commit c9915bc6 "Fix wrong code generation if EN/ENO are used in
FBD/LD/SFC" caused following backtrace in some cases:

File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 476, in GenerateProgram
self.GeneratePouProgram(pou_name)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 258, in GeneratePouProgram
program = pou_program.GenerateProgram(pou)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 1713, in GenerateProgram
self.ComputeProgram(pou)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 997, in ComputeProgram
eno_var = self.GetUsedEno(body, connections)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 929, in GetUsedEno
for invar in blk.inputVariables.getvariable():
File "/home/developer/WorkData/PLC/beremiz/beremiz/xmlclass/xmlclass.py", line 1363, in getattrMethod
return DefaultElementClass.__getattribute__(self, name)
<type 'exceptions.AttributeError'>: 'inOutVariable' object has no attribute 'inputVariables'
PLCGenerator.py
--- a/PLCGenerator.py	Wed Aug 01 14:09:12 2018 +0300
+++ b/PLCGenerator.py	Thu Aug 09 13:58:47 2018 +0300
@@ -926,6 +926,9 @@
         if blk is None:
             return None
 
+        if not hasattr(blk, "inputVariables"):
+            return None
+
         for invar in blk.inputVariables.getvariable():
             if invar.getformalParameter() == "EN":
                 if len(invar.getconnectionPointIn().getconnections()) > 0: