What happens when a Start Chart command is used on a chart that has been stopped, but has not fully stopped yet?
I have a chart (MyChartA) that initializes and device, then monitors some inputs to raise alarms if those inputs are not within prescribed ranges. It continues monitoring these values until an external chart stops it. This chart goes something like this:
*powerLevel = someNumber;
*deviceSwitch = 1;
while ( true ) {
DelaySec(2);
if ( *powerFeedback < lowerLimit ) then
PowerAlarm = 101;
elseif (*powerFeedback :L> upperLimit ) then
PowerAlarm = 102;
endif
wend
It is started from another chart (MyProcessChart). This other chart goes something like this:
// Do some initialization
Start Chart MyChartA
// Wait for process to complete.
Stop Chart MyChartA
I observer that if I run MyProcessChart back-to-back, that sometimes MyChartA does not start. If I set breakpoints and step through the start and stop chart statements, MyChartA always starts as it should. However if I run without breakpoints, I can look at the status of MyChartA when MyProcessChart is in the Wait for process to complete. logic. The first time I tun MyProcessChart, MyChartA is running, but the second time MyProcessChart gets to that portion of the logic, MyChartA is not running.
My guess is that if MyChartA is in the DelaySec() block when it is stopped, and the Start MyChartA the second running of MyProcessChart gets executed before the 2 second delay is up, then MyChartA does not get properly started.
The problem goes away if I explicitly wait for MyChartA to stop:
// Do some initialization
Start Chart MyChartA
// Wait for process to complete.
Stop Chart MyChartA
// Wait for MyChartA to stop
while IsRunning(MyChartA)
DelayMSec(1);
wend
Is that correct, or is there something else going on?