<< Click to Display Table of Contents >> Strategy - Avoiding Triggers at Startup |
![]() ![]() ![]() |
Strategy Controller Events can be incorrectly triggered when SpecView goes online (or at startup).
For example, a Log Report for a process should be generated when the process ends, but it is possible for the Log Report to be inadvertently generated when SpecView Starts (goes online).
This happens if the Program Status is read as 'Stopped' and causes a Log Report to be generated erroneously, when it should be generated ONLY when the state changes from Running to NotRunning.
Likewise, if the Program Status is read as 'Running' this will cause the start time of the process to be reset.
Writing the Strategy correctly can prevent this, for example:
When SpecView initially reads the Program Status on the controller it sees the value as though it has just been changed, therefore the Strategy needs to be written with this in mind...
Therefore, we need another Boolean (User Variable) to combine with the Program Status to determine if the process was running or not when SpecView started (went online).
This table shows how these Booleans are combined, so that Strategy can determine if the program was running or not at startup:
Program Status |
Program Running |
|
Running |
Off |
Set StartDateTime to now, Set ProgramRunning to On |
Running |
On |
Do nothing |
Stopped |
Off |
Do nothing |
Stopped |
On |
Set StopDateTime, Log Report, Set ProgramRunning to Off |
To do this create a Boolean User Variable (called for example 'Program Running') that tracks whether the process is running and only allows the Log Report to be done ONLY if the process state changes to Stopped and the Boolean 'Program Running' indicates that it was running.
This way if SpecView is started again, the Boolean 'Program Running' will say it is not running and therefore avoid the Log Report being triggered incorrectly.
Therefore, in the Strategy Event for the Process Start, which is triggered when the controller indicates that the program state has changed to Running:
In the 'Event Control' section of the Event click 'Enable on Boolean' and choose Program Running and the value as 'Off'.
Also add an Action to set Program Running to On
In the Strategy Event for the Process Stop, which is triggered when the controller indicates that the process state is Stopped:
In the 'Event Control' section of the Event click 'Enable on Boolean' and choose Program Running and the value as 'On'.
Also add an Action to set Program Running to Off
The 'Enable on Boolean' box is used as an 'AND' statement which works in conjunction with the primary instruction (so that both parts of the event box have to be true for the actions to be triggered).
The result of making these changes is to prevent the Log Report being generated erroneously when SpecView starts, and similarly to prevent the start time of the process being reset.
For Program Status = Running:
And for the Program Status = Stopped: