I have a few issues with the formatting of the Table outputs in the CR1000 using CRBasic and I am wondering if anyone can help me tailor the formatting to my preferences.
Here is what I want to know:
1. Any way to change format of Timestamp? I want one column with date and one column with time? Also I want time to have hh:mm:ss format instead of just hh:mm format.
2. Any way to move Record Number before the timestamp, as in, move it to the first column, instead of the second?
3. Any way to remove Wind Direction from the WindVector command? I don't need it and it messes up my table formatting. Basically, I don't want to record Wind Direction in my Table. I only need Wind Speed. However, I can't figure out how not to record Wind Direction in my table while also recording Wind Speed.
Thanks,
Mark
Can you post some example code?
Here is some code. It includes "Dummy" where I typically do the modified TimeStamp myself. That is where I want the time format as I've described.
WindVector is included in the table as well. But I just want Wind_speed and not wind_direction, but they are part of WindVector option 1 and there is no option with only wind speed.
DataTable(Loop1,True,-1)
DataInterval(0,6,sec,10)
Sample(1,Dummy, FP2)
Sample(1,G_total,IEEE4)
Sample(1,Flow_mass(1),IEEE4)
Sample(1,T_amb,IEEE4)
Sample(1,T_in(1),IEEE4)
Sample(1,T_out(1),IEEE4)
Sample(1,G_diff,IEEE4)
WindVector(1,wind_speed,wind_direction,IEEE4,disable_flag,0,0,1)
FieldNames("mean_wind_speed,wind_direction")
Sample(1,tilt,FP2)
Sample(1,azimuth,FP2)
Sample(1,T_flow(1),IEEE4)
Sample(1,Flow(1),IEEE4)
Sample(1,Batt_Volt,FP2)
Sample(1,PTemp_C,FP2)
EndTable
This should get you what you want (well almost):
Public rTime(9) 'declare as public and dimension rTime to 9
Alias rTime(1) = Year 'assign the alias Year to rTime(1)
Alias rTime(2) = Month 'assign the alias Month to rTime(2)
Alias rTime(3) = DOM 'assign the alias Day to rTime(3)
Alias rTime(4) = Hour 'assign the alias Hour to rTime(4)
Alias rTime(5) = Minute 'assign the alias Minute to rTime(5)
Alias rTime(6) = Second 'assign the alias Second to rTime(6)
Alias rTime(7) = uSecond 'assign the alias uSecond to rTime(7)
Alias rTime(8) = WeekDay 'assign the alias WeekDay to rTime(8)
Alias rTime(9) = Day_of_Year 'assign the alias Day_of_Year to rTime(9)
Public date As String * 25 'this will be year:month:day
Public time As String * 25 'this will be hour:min:sec
Public battV 'then whatever other variables... here
DataTable (Table1, 1,-1 ) 'set up data table
DataInterval( 0, 1,Sec, 0 ) 'set up data table
Sample(1,date,String)
Sample (1,time,String)
Sample (1,battV,FP2) 'add whatever else you want to see in your table
EndTable
BeginProg
Scan ( 1,Sec, 1, 0 )
RealTime( rTime )
date=rTime(1) & ":" & rTime(2) & ":" & rTime(3) 'here we specify
time=Hour & ":" & Minute & ":" & Second
CallTable Table1
NextScan
EndProg
The data that you get from a data table in the datalogger is always going to have Timestamp (in our "standard" format) and record number as your first and second columns, regardless of what type of manipulation you do to pull those values out of the table (or from RealTime) and store them back into a table.
The best way to do what you want is the post process the data using Split, which comes in LoggerNet, PC400, and RTDAQ. I've provided more information in-line below.
1. Any way to change format of Timestamp? I want one column with date and one column with time? Also I want time to have hh:mm:ss format instead of just hh:mm format.
Split has a date function that you use on the select line. The date function will let you format the timestamp in just about any way imaginable using Windows format codes. Search for the term "Special Functions" in the help, or put your cursor on the select line and press F1 and choose the Special Functions link.
2. Any way to move Record Number before the timestamp, as in, move it to the first column, instead of the second?
On the select line in Split, an "element number" is used to identify each column of data. You can put those element numbers in any order, and that is how your data will appear in the output file.
3. Any way to remove Wind Direction from the WindVector command? I don't need it and it messes up my table formatting. Basically, I don't want to record Wind Direction in my Table. I only need Wind Speed. However, I can't figure out how not to record Wind Direction in my table while also recording Wind Speed.
You can pick and choose what you want to appear in the output file for Split, by putting those elements on the select line.
So, as an example, say you have the following columns in your data set:
Timestamp, record number, airtemp, windspeed, winddir, precip
(element 1 2 3 4 5 6
and you want:
Record number, 2 column timestamp, air temp, precip, windspeed
You might put the following on the Select Line:
2, date("mmm d, yyyy";1;1;1;1), date("hh:mm:ss";1;1;1;1),3,6,4
which would give you something like:
99, "Jun 1, 1990", "12:45:00",23,0.3,5
Using edate rather than date will strip off the quotes.
Once you have the PAR (the Split file) parsing the data as you like, it can be set up to run as a Task in LoggerNet's Task Master. The task type could be set up to run after data collection.
Split's syntax can be hard to get your head around, but the help documents it quite well. Setting up a PAR file in the task master is also documented in the LoggerNet help.
Regards,
Dana
Thanks Dana, Thanks BigD. The solution from BigD has actually worked quite well, so it may not be necessary to delve into the the Split features at this time. But useful for future reference!