beautypg.com

1 nsec options, Crbasic example 43. nsec — one element time array – Campbell Scientific CR1000 Measurement and Control System User Manual

Page 224

background image

Section 7. Installation

224 

 

 

produce a time stamp that may be accessed from the program after being
written to a data table. The time of other events, such as alarms, can be stored
using the RealTime() instruction.

• Accessing and storing a time stamp from another datalogger in a PakBus

network.

7.8.10.1 NSEC Options

NSEC is used in a CRBasic program one of the following three ways. In all
cases, the time variable is only sampled with a Sample() instruction,

Reps

=

1

.

1. Time variable is declared As Long. Sample() instruction assumes the time

variable holds seconds since 1990 and microseconds into the second is 0. The
value stored in final data storage is a standard time stamp. See CRBasic
example NSEC — One Element Time Array

(p. 224).

2. Time-variable array dimensioned to (2) and As LongSample() instruction

assumes the first time variable array element holds seconds since 1990 and the
second element holds microseconds into the second. See CRBasic example
NSEC — Two Element Time Array

(p. 225).

3. Time-variable array dimensioned to (7) or (9) and As Long or As Float

Sample() instruction assumes data are stored in the variable array in the
sequence year, month, day of year, hour, minutes, seconds, and milliseconds.
See CRBasic example NSEC — Seven and Nine Element Time Arrays

(p. 225).

CRBasic example NSEC — Convert Time Stamp to Universal Time

(p. 224)

shows

one of several practical uses of the NSEC data type.

CRBasic Example 43. NSEC — One Element Time Array 

'A time stamp is retrieved into variable TimeVar(1) as seconds since 00:00:00

'1 January 1990. Because the variable is dimensioned to 1, NSEC assumes the value =

'seconds since 00:00:00 1 January 1990.

'Declarations

Public

PTemp

Public

TimeVar(1)

As Long

DataTable

(FirstTable,True,-1)

DataInterval

(0,1,Sec,10)

Sample

(1,PTemp,FP2)

EndTable

DataTable

(SecondTable,True,-1)

DataInterval

(0,5,Sec,10)

Sample

(1,TimeVar,Nsec)

EndTable

'Program

BeginProg

Scan(1,Sec,0,0)
TimeVar = FirstTable.TimeStamp
CallTable FirstTable
CallTable SecondTable

NextScan

EndProg