Hello Everyone,
Currently I am writing a code for interpreting the data from a Nortek Signature ADCP (with wave processing capabilities inbuilt). I am able to read and store the wave data which comes as a single string per burst, like this:
$PNORW,120720,093150,1,4,0.89,-9.00,1.13,1.49,1.41,1.03,9.00,190.03,80.67,113.52,0.54,0.00,1024,0,1.19,144.11,0D8B*7B
SerialInRecord (ComRS232,rawString,36,0,&h0D0A,NBytesReturned,11
NEMOchecksum = HexToDec(Right(rawString,2))
rawString = Left(rawString,Len(rawString)-3)
SplitStr (subStrings(),rawString,",",400,5)
If subStrings(1)="PNORW" Then
wavesTimestamp = subStrings(2) + subStrings(3)
significantWaveHeight=subStrings(8)
peakWavePeriod=subStrings(10)
peakWaveDirection=subStrings(11)
CallTable (Wave)
EndIf
However, I am trying to do the same for current values, but the string structure is coming in different structure like this: i.e. coming in 51 lines, one line for each bin or cellnumber.
$PNORC,102115,090715,1,0.56,-0.80,-1.99,1.33,0.98,305.2,C,80,88,67,78,13,17,10,18*22
$PNORC,102115,090715,2,0.56,-0.80,-1.99,1.33,0.98,305.2,C,80,88,67,78,13,17,10,18*22
$PNORC,102115,090715,3,0.56,-0.80,-1.99,1.33,0.98,305.2,C,80,88,67,78,13,17,10,18*22
$PNORC,102115,090715,5,0.56,-0.80,-1.99,1.33,0.98,305.2,C,80,88,67,78,13,17,10,18*22
$PNORC,102115,090715,6,0.56,-0.80,-1.99,1.33,0.98,305.2,C,80,88,67,78,13,17,10,18*22
$PNORC,102115,090715,7,0.56,-0.80,-1.99,1.33,0.98,305.2,C,80,88,67,78,13,17,10,18*22
......
$PNORC,102115,090715,50,0.56,-0.80,-1.99,1.33,0.98,305.2,C,80,88,67,78,13,17,10,18*22
$PNORC,102115,090715,51,0.56,-0.80,-1.99,1.33,0.98,305.2,C,80,88,67,78,13,17,10,18*22
Therefore, the aim is to create a table where each line correspond to one burst with 51 columns representing bin numbers with east, north and error velocity for each bin, like this:
"TIMESTAMP","RECORD","currentTimestamp","waterLevelPres","waterTemp","startBin","stepBin","stopBin","binData(1,1)","binData(1,2)","binData(1,3)","binData(2,1)","binData(2,2)","binData(2,3)","binData(3,1)","binData(3,2)","binData(3,3)...binData(51,1), binData(51,2), binData(51,3)".
I am almost there, but instead of get one line with 51 columns, I am getting 51 lines repeating the values in 51 columns.
startBin = 1
stopBin=51
My loop is like this, but it is not workiing properly:
If subStrings(1)="PNORC" Then
For c = startBin To stopBin
binData(c,1)=subStrings(5) ' east velocity position in the serial in string
binData(c,2)=subStrings(6) ' north velocity position in the serial in string
binData(c,3)=subStrings(7)-subStrings(8) 'error velocity
Next c
currentTimestamp = subStrings(2) + subStrings(3)
CallTable (CurrentBurst)
EndIf
NextScan
In resume, I would like to create a table where my columns represent my bins values and telemetry is giving me it linewise. Then I would like to scan line by line and retrieve some elements bases on position of the element in the substring.
Has anyone can guide me on that, please? I am quite noob on CR Basic programming sintax, but I feel like is just some detail I am missing.
full snippet of the code is like this:
startBin =1
stopBin = 51
stepBin = 1
Scan (1,Sec,3,0)
SerialInRecord (ComRS232,rawString,36,0,&h0D0A,NBytesReturned,11)
NEMOchecksum = HexToDec(Right(rawString,2))
rawString = Left(rawString,Len(rawString)-3)
SplitStr (subStrings(),rawString,",",400,5)
If subStrings(1)="PNORW" Then
wavesTimestamp = subStrings(2) + subStrings(3)
significantWaveHeight=subStrings(8)
peakWavePeriod=subStrings(10)
peakWaveDirection=subStrings(11)
CallTable (WaveBurst)
EndIf
If subStrings(1)="PNORS" Then
waterLevelPres = subStrings(11)
waterTemp = subStrings(12)
EndIf
If subStrings(1)="PNORC" Then
For c = startBin To stopBin
'ensNum = subStrings(4)
binData(c,1)=subStrings(5)
binData(c,2)=subStrings(6)
binData(c,3)=subStrings(7)-subStrings(8)
Next c
currentTimestamp = subStrings(2) + subStrings(3)
CallTable (CurrentBurst)
EndIf
NextScan
Best regards,
This post is under review.