04.01.2015 Views

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Section 7. Installation<br />

'Declarations<br />

Public rTime(9) As Long<br />

Public rTime2(7) As Long<br />

Dim x<br />

'(or Float)<br />

'(or Float)<br />

DataTable(SecondTable,True,-1)<br />

DataInterval(0,5,Sec,10)<br />

Sample(1,rTime,NSEC)<br />

Sample(1,rTime2,NSEC)<br />

EndTable<br />

'Program<br />

BeginProg<br />

Scan(1,Sec,0,0)<br />

RealTime(rTime)<br />

For x = 1 To 7<br />

rTime2(x) = rTime(x)<br />

Next<br />

CallTable SecondTable<br />

NextScan<br />

EndProg<br />

CRBasic Example 46.<br />

NSEC —Convert Timestamp to Universal Time<br />

'Application: the <strong>CR1000</strong> needs to display Universal Time (UT) in human readable<br />

'string forms. The <strong>CR1000</strong> can calculate UT by adding the appropriate offset to a<br />

'standard time stamp. Adding offsets requires the time stamp be converted to numeric<br />

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

'These are accomplished by,<br />

'1) reading Public.TimeStamp into a LONG numeric variable.<br />

'2) store it into a type NSEC datum in final data storage.<br />

'3) sample it back into string form using the TableName.FieldName notation.<br />

'Declarations<br />

Public UTTime(3) As String * 30<br />

Dim TimeLong As Long<br />

Const UTC_Offset = -7 * 3600<br />

'-7 hours offset (as seconds)<br />

DataTable(TimeTable,true,1)<br />

Sample(1,TimeLong,Nsec)<br />

EndTable<br />

'Program<br />

BeginProg<br />

Scan(1,Sec,0,0)<br />

'1) read Public.TimeStamp into a LONG numeric variable.<br />

TimeLong = Public.TimeStamp(1,1) + UTC_Offset<br />

'2) store it into a type NSEC datum in Final Data Storage.<br />

CallTable(TimeTable)<br />

226

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!