Section 7. Installation
CRBasic Example 38.
NSEC —Convert Timestamp to Universal Time
'This program example demonstrates the use of NSEC data type to convert a data time stamp
'to universal time.
'
'Application: the CR1000 needs to display Universal Time (UT) in human readable
'string forms. The CR1000 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 memory.
' 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. Note that TimeStamp is a
' system variable, so it is not declared.
TimeLong = Public.TimeStamp(1,1) + UTC_Offset
'2) Store it into a type NSEC datum in final-data memory.
CallTable
(TimeTable)
'3) sample time to three string forms using the TableName.FieldName notation.
'Form 1: "mm/dd/yyyy hr:mm:ss
UTTime(1) = TimeTable.TimeLong(1,1)
'Form 2: "dd/mm/yyyy hr:mm:ss
UTTime(2) = TimeTable.TimeLong(3,1)
'Form 3: "ccyy-mm-dd hr:mm:ss (ISO 8601 Int'l Date)
UTTime(3) = TimeTable.TimeLong(4,1)
NextScan
EndProg
7.9.11 Data Output: Writing High-Frequency Data to Memory
Cards
Related Topics:
•
Memory Card (CRD: Drive) — Overview
(p. 89)
•
Memory Card (CRD: Drive) — Details
(p. 376)
•
Memory Cards and Record Numbers
(p. 466)
•
Data Output: Writing High-Frequency Data to Memory Cards
(p. 205)
•
File-System Errors
(p. 389)
•
Data Storage Devices — List
(p. 653)
205
Summary of Contents for CR1000
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 36: ......
Page 38: ......
Page 40: ......
Page 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Page 96: ......
Page 98: ...98 ...
Page 302: ......
Page 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Page 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Page 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Page 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Page 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Page 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Page 478: ......
Page 506: ......
Page 536: ......
Page 636: ......
Page 642: ......
Page 644: ......
Page 676: ......
Page 677: ......