Applies To:
  • CitectSCADA 6.xx, 7.00
  • CitectHMI 6.xx, 7.00

Summary:
Since Sleep() is a blocking function, how can I add delay to a foreground cicode object? Or in another situation where I cannot use the blocking Sleep() function?  

Solution:

PageInfo(7) is incremented every page scan, which by default is 250ms, but is customisable for each page.

When called from a Foreground Cicode object, the function below will run every second Page Scan, effectively adding a 250ms or more delay between calling the function.

IF (StrToInt(PageInfo(7)) > giPrevCount + 1) THEN
    <call other cicode
>
    giPrevCount =
StrToInt(PageInfo(7));
END

To continue the example, the below function will only run every 4 Page Scans, effectively adding a 1 second gap between calling the function.

IF
(StrToInt(PageInfo(7)) > giPrevCount + 4) THEN
    <call other cicode
>
    giPrevCount =
StrToInt(PageInfo(7));
END

Note, If you Increment the page scan to be above a second, you will notice that the counter is still incrementing at around ~400ms prior to version 7.0, this is because the PageInfo(7) increments at both the AnmDelay interval AND the PageScan time. This means that the counter will not be accurate, and is faster than just the PageScan, but still suitable for adding rough delays.

In version 7.0 the counter only increments at the PageScan, which is now effectively the AnmDelay, as version 7.0 onwards use the Pub/Sub backend which no longer polls the devices for data (which is what PageScan used to do.)

In version 7.10 onwards, we reverted back to version 6.10 behaviour.


Keywords:
Once per Page Scan non blocking sleep delay cicode  

Attachments