Hi,
Using jRDC and calling the following code:
I get a result set in res.
I looked at the print table function:
I saw that you could iterate through the results using For Each ...
So I ended up with the following code to extract the data which works fine:
The issue I have is I wan to get data values from the rows by indexing in. i.e.
Row(0) of the list and column(1) of the row
I would like to be able to write something like:
I don't only want to iterate over the rows I would like to retrieve the data from the column of a specified row.
ie Get the value of the fifth column of row 273 and put it in a double var.
It's easy in C.
I thought high level languages were supposed to make this sort of thing easier that the low level languages.
I don't know whether I'm just dumb or too old for all of this, but I spent 4 hours in the forum and google trying to figure it out.
Could someone help me, Please!
Best regards
Rob
Using jRDC and calling the following code:
Request Data From jRDC Connection:
'======================================================================================
Sub getPowerDataForHistoricalDisplay
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand
' Get full data set from database for historical records and latest
cmd = CreateCommand("getPwrDataWithAlarmsStartEnd_NLimit7200", Array(navPars.StartTimeJD, navPars.EndTimeJD))
' Log("getPwrDataWithAlarms_Raw_N7200_Ascn")
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
'work with result
'req.PrintTable(res)
getRecords (res)
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
I get a result set in res.
I looked at the print table function:
DBRequestManager.Print Table:
'Prints the table to the logs.
Public Sub PrintTable(Table As DBResult)
Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)
Dim sb As StringBuilder
sb.Initialize
For Each col In Table.Columns.Keys
sb.Append(col).Append(TAB)
Next
Log(sb.ToString)
For Each row() As Object In Table.Rows
Dim sb As StringBuilder
sb.Initialize
For Each record As Object In row
sb.Append(record).Append(TAB)
Next
Log(sb.ToString)
Next
End Sub
I saw that you could iterate through the results using For Each ...
So I ended up with the following code to extract the data which works fine:
Data Retrieval & Gap Filing:
'======================================================================================
Public Sub getRecords (res As DBResult)
Dim ptr As Int
Dim listTemp As List
'
' Dim thisJDList As ListItem
Dim thisJD As Double
Dim nextJD As Double
For Each row() As Object In res.Rows
NWServ.rtData_s.jTimeEmbed = row(0)
NWServ.rtData_s.Frequency = row(1)...
....NWServ.rtData_s.Quality = row(38)
If res.Rows.Size > 1 Then
'Fill the average and graph buffers
NWServ.prefillDisplayBuffers(ptr)
ptr = ptr + 1
End If
If ptr = 1 Then
navPars.StartTimeJD = NWServ.rtData_s.jTimeEmbed
End If
Next
navPars.EndTimeJD = NWServ.rtData_s.jTimeEmbed
NWServ.proc_realtimeData
End Sub
The issue I have is I wan to get data values from the rows by indexing in. i.e.
Row(0) of the list and column(1) of the row
I would like to be able to write something like:
Iteration using a visible index.:
' For k = 0 To res.Rows.Size
deltaTime = (res.Rows(k,0) - lastGoodDataTime) * 3600 * 24
If deltaTime > 3.0 Then
'At least one data point is missing
nMissing = Round(deltaTime)
End If
Next
I don't only want to iterate over the rows I would like to retrieve the data from the column of a specified row.
ie Get the value of the fifth column of row 273 and put it in a double var.
It's easy in C.
I thought high level languages were supposed to make this sort of thing easier that the low level languages.
I don't know whether I'm just dumb or too old for all of this, but I spent 4 hours in the forum and google trying to figure it out.
Could someone help me, Please!
Best regards
Rob