tcopen-app-templates
tcopen-app-templates copied to clipboard
[BUG] TcoControlledZone input variable nullpointer check
Describe the bug inDoorCircuit is passed as a pointer to interface therefore a check is needed before using the underlying object, otherwise dereferencing the nullobject will cause PLC to crash, which is annoying and harder to find.
To Reproduce Set up an object with valid CUs, control buttons and keys (all of which get checked for null!) But "Forget" to set Door circuit.
Expected behavior Messenger reporting programming error and PLC not crashing.
Additional context The use of input variables for Air pressure and Estop active will make it hard to report to application developer that these are not set explicitly without them having to examine the source.
Also, may I suggest to replace this:
IF _controlButtons[0] = 0 OR _controlKeyMode[0] = 0 OR _controlKeyNormalService[0] = 0 THEN THIS^.Messenger.Programming('<#Missing link to control panel components (Buttons, Mode Keys, Normal/Service)! No function is being executed!#>'); RETURN; END_IF
with this:
Messenger.OnCondition(_controlButtons[0] = 0).Programming('<#Missing link to control buttons!#>'); Messenger.OnCondition(_controlKeyMode[0] = 0).Programming('<#Missing link to Mode key!#>'); Messenger.OnCondition(_controlKeyNormalService[0] = 0).Programming('<#Missing link to Normal/Service key!#>');
As the RETURN here is not necessary as it is checked prompty before use everywhere in the code. Furthermore, a more refined message will aid the application programmer in pinpointing the issue quicker.