Function Cicode calling not working

Hello All,

I'm using Citect Scada 2018 R1 update 16. We are struggling to have cicode functions working. How do i call a function from a graphical page.

Below is the current function call. Are we missing anything?

Parents
  • The way you call the function seems correct, however it's possible that your function contains blocking elements, which are not allowed if you call the function directly from graphics or other foreground tasks.

    Examples of blocking elements are:

    - Reading tags using TagRead() commands
    - Using FOR or WHILE loops
    - Using Sleep() or SleepMS() commands
    - Reading from / writing to disk devices or ODBC data sources
    - Executing functions that communicate with alarm-, trend-, report-, or I/O servers in a blocking (synchronous) way
    - Calling VBA-functions or other blocking cicode functions

Reply
  • The way you call the function seems correct, however it's possible that your function contains blocking elements, which are not allowed if you call the function directly from graphics or other foreground tasks.

    Examples of blocking elements are:

    - Reading tags using TagRead() commands
    - Using FOR or WHILE loops
    - Using Sleep() or SleepMS() commands
    - Reading from / writing to disk devices or ODBC data sources
    - Executing functions that communicate with alarm-, trend-, report-, or I/O servers in a blocking (synchronous) way
    - Calling VBA-functions or other blocking cicode functions

Children
  • hello Patrick,

    Thanks for the feedback. i was expecting atleast one cicode funtion to work. if the Calling method used possibly  not the best way, what are the alternative i can try on. A simple function as below i believe should have worked.

  • It looks like writing to all these variables is taking too long to be used as foreground code. It will also likely not work if no user is logged in.

    If you only want these variables to be written to if this page is active, then you could use TaskNew() to execute your function like this: TaskNew("Overview", "", 1+8)

    This way your function is executed as a background task. Mode 1 specifies that the task will end when you switch to another page and Mode 8 will make sure your function is only starting when the previous execution has finished.

    If you want these variables to be written to even when the page is not shown, then consider calling the function periodically from an event on the I/O server.

  • Thanks Patrick. i have one of the graphic pages which is an overview of the entire plant fixed and cannot be changed on one of the 4 monitors at all times, which will then make sure the task is executed . So i will try the TaskNew() and see the outcome.

    i will try also the the second option using the Event if it becomes necessary. Thanks for your assistance. 

  • If your intention is to run this continually to just pass data back and forth between tags like a mailbox, then the graphic is definitely the wrong place to do this from.
    There are half a dozen better ways including as a periodic script, continually in a for loop (After tasknew), on-change of the monitorred tags, as a periodic report, linking the tags directly together, etc etc.