Campbell Scientific CR3000 Micrologger User Manual
Page 227

Section 7. Installation
227
A: A common caution is, “The destination variable should not be used in more
than one sequence to avoid using the variable when it contains old data.”
However, there are more elegant ways to handle the root problem. There is
nothing unique about SerialIn() with regard to understanding how to correctly
write to and read from global variables using multiple sequences. SerialIn() is
writing into an array of characters. Many other instructions write into an array of
values (characters, floats, or longs), e.g., Move(), MoveBytes(), GetVariables(),
SerialInRecord(), SerialInBlock(), etc. In all cases, when writing to an array of
values, it is important to understand what you are reading, if you are reading it
asynchronously, i.e., reading it from some other task that is polling for the data at
the same time as it is being written, whether that other task is some other machine
reading the data, like LoggerNet, or a different “Sequence”, or task, within the
same machine. If the process is relatively fast, like the Move() instruction, and an
asynchronous process is reading the data, this can be even worse because the
“reading old data” will happen less often but is more insidious because it is so
rare. It is good to know that we have ways of correctly dealing with this general
problem of a different task reading data than is writing data, like semaphores, or
like recording the data in a data table from the same task and then have LoggerNet
read from the data table.
7.8.9 TrigVar and DisableVar — Controlling Data Output and
Processing
TrigVar
is the third parameter in the DataTable() instruction. It controls whether
or not a data record is written to final storage.
TrigVar
control is subject to other
conditional instructions such as the DataInterval() and DataEvent() instructions.
DisableVar
is the last parameter in most output processing instructions, such as
Average(), Maximum(), Minimum(), etc. It controls whether or not a particular
measurement or value is included in the affected output-processing function.
For individual measurements to affect summary data, output processing
instructions such as Average() must be executed whenever the data table is called
from the program — normally once each Scan. For example, for an average to be
calculated for the hour, each measurement must be added to a total over the hour.
This accumulation of data is not affected by
TrigVar
.
TrigVar
controls only the
moment when the final calculation is performed and the processed data (the
average) are written to the data table. For this summary moment to occur,
TrigVar
and all other conditions (such as DataInterval() and DataEvent()) must be true.
Expressed another way, when
TrigVar
is false, output processing instructions (for
example, Average()) perform intermediate processing but not their final
processing, and a new record will not be created.
Note In many applications, output records are solely interval based and
TrigVar
is
always set to TRUE (-1). In such applications, DataInterval() is the sole
specifier of the output trigger condition.
Figure Data from TrigVar Program
(p. 228)
shows data produced by CRBasic
example Using TrigVar to Trigger Data Storage
(p. 228),
which uses
TrigVar
rather
than DataInterval() to trigger data storage.