Structure, Structure -2 – Sensaphone SCADA 3000 Users manual User Manual

Page 188

Advertising
background image

16-2

SCADA 3000 User’s Manual

ARRAYS: This is a more advanced programming type that significantly shortens

and simplifies long programs.

ERROR HANDLING: When a program is compiled, it is scanned for language

related errors. An error message, including the type of error, is displayed.

EDITING TOOL: The SCADA 3000 Windows Software provides an editing

utility that allows you to write, compile, upload, download, run, and start C pro-

grams.

This chapter provides basic instruction in the C language and gives all the commands that

are valid for use with SCADA 3000. Sample programs are included. If you have questions or

problems, please contact our technical support department at (610)558-2700 or via email at

[email protected].

STRUCTURe

Listed below are some examples that will help demonstrate the C language structure. Refer to

the following pages for explanation of the keywords, functions, and commands used within the

sample programs.
1) All programs must begin with the main () function. It must be followed by an open brace {

and closed with an end brace }.

Main ()

{

}

2) A statement is a line of programming code. All statements are placed inside the braces {} and

end with a semicolon (;). For example:

main ()

{

write_uaf(output,0,0,on);

}

This program will turn on output relay 0, on the main board.
3) In the C language, numbers are stored in what are called variables. A variable must be

defined before the main () function. SCADA 3000 allows you to have up to 1024 variables.

intx;

main ()

{

x=12

}

In this program we defined a variable called “x” and set its value equal to 12. Here, x is defined

as an integer. SCADA 3000’s language can define variables as characters (char), integers (int),

or floating point numbers (float). A character can hold a value from -128 to 127 and an integer

can hold a value from -32,768 to 32,767. Both characters and integers must be whole numbers.

A floating point number is one that can have a fractional part (i.e., numbers after the decimal

point). Floating point numbers can be very large or very small, generally between 10-38 and

10+38. Generally speaking, there is no advantage to using variables as int or char types within

the SCADA 3000, and examples from this point on will use only variables of the type float.
The following program will set x equal to the value of input 0 on the main board.

float x;

main ()

{

x=read_uaf(input, 0,0);

}

Advertising