beautypg.com

Campbell Scientific CR800 and CR850 Measurement and Control Systems User Manual

Page 227

background image

Section 7. Installation

227

 

'Declarations

Public

rTime(9)

As Long

'(or Float)

Public

rTime2(7)

As Long

'(or Float)

Dim

x

DataTable

(SecondTable,True,-1)

DataInterval

(0,5,Sec,10)

Sample

(1,rTime,NSEC)

Sample

(1,rTime2,NSEC)

EndTable

'Program

BeginProg

Scan

(1,Sec,0,0)

RealTime

(rTime)

For

x = 1

To

7

rTime2(x) = rTime(x)

Next

CallTable

SecondTable

NextScan

EndProg

 

CRBasic Example 46. NSEC —Convert Timestamp to Universal Time 

'Application: the CR800 needs to display Universal Time (UT) in human readable

'string forms. The CR800 can calculate UT by adding the appropriate offset to a

'standard time stamp. Adding offsets requires the time stamp be converted to numeric

'form, the offset applied, then the new time be converted back to string forms.

'These are accomplished by,

'1) reading Public.TimeStamp into a LONG numeric variable.

'2) store it into a type NSEC datum in final data storage.

'3) sample it back into string form using the TableName.FieldName notation.

'Declarations

Public

UTTime(3)

As String

* 30

Dim

TimeLong

As Long

Const

UTC_Offset = -7 * 3600

'-7 hours offset (as seconds)

DataTable

(TimeTable,true,1)

Sample

(1,TimeLong,Nsec)

EndTable

'Program

BeginProg

Scan

(1,Sec,0,0)

'1) read Public.TimeStamp into a LONG numeric variable.

TimeLong = Public.TimeStamp(1,1) + UTC_Offset

'2) store it into a type NSEC datum in Final Data Storage.

CallTable

(TimeTable)