Differences between standard c and scada 3000 c – Sensaphone SCADA 3000 Users manual User Manual
Page 203
16-17
Chapter 16: Programming in C
DIFFeReNCeS BeTWeeN STANDARD C AND SCADA 3000 C
For those of you who are familiar with C programming, note that there are some differences
between standard C and SCADA 3000’s C compiler. The following items will be helpful to be
aware of:
1) In SCADA 3000, every IF, ELSE, FOR, DO, and WHILE must have a set of brackets {}
after it.
2) Condition clauses must be grouped together into pairs.
Standard C will allow:
IF ((condition 1) && (condition2) && (condition3))
SCADA 3000 requires:
IF (((condition1) && (condition2)) && (condition3))
3) There are no shortcut statements such as :
i++;
red+=5; or
bits&=5;
However, statements such as the following are allowed if placed inside parentheses:
IF ((x=read_uaf(input,0,5))==0)
4) Bitwise operators are not implemented. There are no:
bitmask = bitmask &4;
5) Variables declared before the main statement retain their values after the program has been
executed. This provides the programmer with nonvolatile memory between runs of the pro-
gram. This is useful for accumulating, timing, and most SCADA 3000 applications.
6) There are no user defined functions or procedures.
7) Suggested programming philosophy:
Avoid the use of WHILE loops. This will lengthen the execution and response
time of your C program and serves no advantage. Write your programs such that
they run ‘straight through’ and exit. If your program is checking for a certain
condition to occur, using a WHILE loop will cause your program to concentrate
on that one condition unnecessarily. Since the program will execute at regular
time intervals, you can use an IF statement and achieve the same or even better
results.
For example, we need a program to set output 3 on whenever input 1 closes. Listed below is
an example of how this would be done using a WHILE loop:
main ()
{
if (read_uaf(input,0,1)==0)
{
write_uaf(output,0,3,on);
while (read_uaf(input,0,1)==0);
{
}
write_uaf(output,0,3,off);
}
}
In this program, when input 1 closes, output 3 will be turned on. The program will hold out-
put 3 on as long as input 1 is closed. Unfortunately, this program will get stuck in the WHILE
loop, waiting for input 1 to open. Critical actions may be missed because the program was
forced to wait.