# HG changeset patch # User Andrey Skvortsov # Date 1484221075 -10800 # Node ID 0779c1b18c01b228f59c097bfa8c9ea45b9d7e11 # Parent be3f6873179892634041e0f120463580425841cc check before program generation whether SFC step, that is referenced by SFC jump, does exists diff -r be3f68731798 -r 0779c1b18c01 PLCGenerator.py --- a/PLCGenerator.py Wed Jan 11 14:15:45 2017 +0300 +++ b/PLCGenerator.py Thu Jan 12 14:37:55 2017 +0300 @@ -1387,6 +1387,10 @@ def GenerateSFCJump(self, jump, pou): jump_target = jump.gettargetName() + if not pou.hasstep(jump_target): + pname = pou.getname() + msg = _("SFC jump in pou \"{a1}\" refers to non-existent SFC step \"{a2}\"").format( a1 = pname, a2 = jump_target) + raise PLCGenException, msg if jump.connectionPointIn is not None: instances = [] connections = jump.connectionPointIn.getconnections() diff -r be3f68731798 -r 0779c1b18c01 plcopen/plcopen.py --- a/plcopen/plcopen.py Wed Jan 11 14:15:45 2017 +0300 +++ b/plcopen/plcopen.py Thu Jan 12 14:37:55 2017 +0300 @@ -1245,6 +1245,14 @@ self.interface.remove(varlist) break setattr(cls, "removepouVar", removepouVar) + + def hasstep(self, name=None): + if self.getbodyType() in ["SFC"]: + for instance in self.getinstances(): + if isinstance(instance, PLCOpenParser.GetElementClass("step", "sfcObjects")) and TextMatched(instance.getname(), name): + return True + return False + setattr(cls, "hasstep", hasstep) def hasblock(self, name=None, block_type=None): if self.getbodyType() in ["FBD", "LD", "SFC"]: