I'm using a multi-dimensional array in a CR3000 program (Std.32.05) to support a variable number of identical sensors:
Const NUM = 5 'How many sensors? Use SDI-12 addresses 1..NUM Const SDI = 7 'Which control port? Const INTV = 30 'Scan interval in seconds; minimum 5sec per sensor Dim i Public nr(NUM,10) 'x,1 incoming shortwave radiation 'x,2 outgoing shortwave radiation 'x,3 incoming longwave radiation 'x,4 outgoing longwave radiation 'x,5 mV signal incoming LW 'x,6 sensor body tmpr incoming LW 'x,7 mV signal outgoing LW 'x,8 sensor body tmpr outgoing LW 'x,9 calculated albedo 'x,10 calculated net radiation
I'd like to collate data values and apply a meaningful label using `FieldNames` but when I try to access higher-level array dimensions in data tables like so...
DataTable(tsdata,True,-1) Sample(NUM,nr(-1,1)(),IEEE4) FieldNames("R_SW_in("+CTYPE(NUM,String)+")") EndTable BeginProg Scan (INTV,Sec,0,0) For i = 1 To NUM Step 1 SDI12Recorder(nr(i,-1)(),SDI,CTYPE(i,String),"C0!",1,0,4,1) 'radiation SDI12Recorder(nr(i,-5)(),SDI,CTYPE(i,String),"C3!",1,0,4,1) 'mV + temp nr(i,9) = IIF((nr(i,1)>10) AND (nr(i,1)>=nr(i,2)),nr(i,2)/nr(i,1),0) nr(i,10) = nr(i,1) - nr(i,2) + nr(i,3) - nr(i,4) 'net rad Next CallTable tsdata NextScan EndProg
....the results are mysterious data values and field name labels that seem to contain an extra dimension:
"TOA5","nr_audit","CR3000","9669","CR3000.Std.32.05","CPU:sn500_test.CR3","18914","tsdata" "TIMESTAMP","RECORD","R_SW_in(1,1)","R_SW_in(1,2)","R_SW_in(1,3)","R_SW_in(1,4)","R_SW_in(1,5)" "TS","RN","","","","","" "","","Smp","Smp","Smp","Smp","Smp" "2023-07-06 21:53:30",0,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41 "2023-07-06 21:54:00",1,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41 "2023-07-06 21:54:30",2,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41 "2023-07-06 21:55:00",3,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41 "2023-07-06 21:55:30",4,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41 "2023-07-06 21:56:00",5,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41 "2023-07-06 21:56:30",6,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41 "2023-07-06 21:57:00",7,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41 "2023-07-06 21:57:30",8,1.793662E-42,1.793662E-42,1.228378E-41,1.228378E-41,1.228378E-41
However, if I copy the mutlidimensional array slice into a standard array...
Public R_SW_in(NUM) DataTable(tsdata,True,-1) Sample(NUM,R_SW_in(),IEEE4) EndTable BeginProg Scan (INTV,Sec,0,0) For i = 1 To NUM Step 1 SDI12Recorder(nr(i,-1)(),SDI,CTYPE(i,String),"C0!",1,0,4,1) 'radiation SDI12Recorder(nr(i,-5)(),SDI,CTYPE(i,String),"C3!",1,0,4,1) 'mV + temp nr(i,9) = IIF((nr(i,1)>10) AND (nr(i,1)>=nr(i,2)),nr(i,2)/nr(i,1),0) nr(i,10) = nr(i,1) - nr(i,2) + nr(i,3) - nr(i,4) 'net rad Next R_SW_in() = nr(-1,1)() CallTable tsdata NextScan EndProg
...then I get the results I was hoping for:
"TOA5","nr_audit","CR3000","9669","CR3000.Std.32.05","CPU:sn500_test.CR3","27354","tsdata" "TIMESTAMP","RECORD","R_SW_in(1)","R_SW_in(2)","R_SW_in(3)","R_SW_in(4)","R_SW_in(5)" "TS","RN","","","","","" "","","Smp","Smp","Smp","Smp","Smp" "2023-07-06 22:06:00",0,-3.96,-3.71,-5.71,-4.01,-3.92 "2023-07-06 22:06:30",1,-3.65,-3.59,-3.78,-4.05,-4.1 "2023-07-06 22:07:00",2,-3.45,-3.38,-3.26,-3.43,-3.21 "2023-07-06 22:07:30",3,-3.14,-3.21,-4.43,-3.89,-3.74 "2023-07-06 22:08:00",4,-3.31,-3.1,-4.79,-3.34,-3.42 "2023-07-06 22:08:30",5,-3.15,-3.24,-4.37,-4.6,-4.24 "2023-07-06 22:09:00",6,-4.12,-3.62,-4.53,-3.68,-3.56 "2023-07-06 22:09:30",7,-3.06,-3.55,-4.86,-4.48,-4.17 "2023-07-06 22:10:00",8,-4.02,-3.67,-4.54,-4.5,-4.88
Am I doing something wrong? Is there a better way to sample array slices into a data table?
This post is under review.
It seems that the field name label encoding has an error. You should check and try again. doodle baseball
This post is under review.