Applies To:
  • CitectSCADA 1.00 1.01 1.10 1.11 1.20 2.00 2.01 3.00

Summary:
Question: Can you do conditional compiling in Citect. I want to be able to remove my debug code on the project which will run on the plant, while keeping this code for my development system. 

Solution:
You cannot do conditional compilation in cicode however the following procedure works very well. You write a function which will display the information required or do some debug operation. This function will only do what is required depending on a global cicode variable which you can read out of the INI file. This method has the dissadvantage that your debug code always remains in your running project (this can be very handy if you need to debug on your plant). This causes only a tiny overhead to your system as my tests so Citect will executed over 30,000 lines of raw cicode per second (486/66). So each call to the function will take about 0.1 ms to be executed. You will also get some extra memory used as the cicode will still be loaded into memory, however this tends to be small as cicode is compiled into a binary format.

The function may look something like this:

FUNCTION
MyTraceFunction(STRING sMsg)

   IF bTraceMode THEN
      ! send trace message to kernel or device or whatever
      TraceMsg(sMsg); ! send to kernel
      Prompt(sMsg); ! send to operator
   END
END

At startup you can read the bTraceMode variable from the INI file, or you may want to read this variable sometimes while Citect is running so you don't have to restart.Putting the variable in the INI file also works well with the above INI maintenance method. Eg:

! At startup or in While loop or from command on a page.
bTraceMode = ParameterGet("Debug", "MyTrace", "0");

Then in your code you can call this function in various places:

MyTraceFunction("message to trace");
a = b + c;
MyTraceFunction("Value of a " + a : ####);
IF bTrigger THEN
   MyTraceFunction("bTrigger is TRUE");
   ....
END

 

Keywords:
 

Attachments