Arrays, Arrays -10 – Sensaphone SCADA 3000 Users manual User Manual
Page 196
16-10
SCADA 3000 User’s Manual
WRITE_REC FUNCTION - used to write a single DataLog record to the DataLogger.
Summary:
write_rec();
Description
The write_rec function is used to write a single DataLog record to the DataLogger. All values
selected for logging on the DataLogger programming form will be logged once when this
function executes, regardless of whether or not the DataLogger is actually running or not. This
function is useful for event driven datalogging functions such as when an I/O point goes out
of range or when an alarm exists. Do not allow this function to execute continuously or large
amounts of data will accumulate in the datalogger. Also, do not allow this function to execute
more often than once a second because the DataLogger can only resolve timestamps to the
nearest second and will throw out records with identical time stamps.
Example:
/* This program will write a datalog record once per minute */
/* if input 0 is greater than 100 */
int last_minute;
main ()
{
if (read_uaf(input,0,0)>100.0) /* if input 0 is greater than
100*/
{
if (minutes != last_minute) /* is it a new minute? */
{
write_rec();
/* then write a datalog record
*/
last_minute=minutes;
/* reset minute check */
}
}
}
/*
End
of
program
*/
ARRAYS
Arrays allow you to store a lot of related information in a convenient, organized fashion. An
array lets you use one line of programming to create a series of variables. These variables share
the same basic name and are distinguished from one another by a numerical tag.
Example:
float count[10];
This means that an array named count has 10 members or “elements”, with each element hav-
ing its own value, starting with 0 and ending with 9. The first element is count[0], the second
element is count[1], and so on up to count[9]. The type float means that the actual numerical
value of each element is a float.
Example:
count[2] = 2.45
count[4] = 55000
count[9] = -200000