Hello all,
I have a SCADA Basic - Selector related question.
I would like to show (put) all configured trend-variables to a selector, from which I can select then a variable and add it to the trend-viewer. (In future, it could be interesting also to have the ability to filter the selector by branch and description).
So my thought was to read the HDSTrend.dat, split by first "," and put every entry in a global buffer.
<-- start Program
sub setTrendBuffer()
dim line as str;
dim lineSize as integer;
dim i as integer;
dim var as str;
Fclose("..\C\HDSTrend.dat");
Fopen("..\C\HdsTrend.dat", "r");
While(Feof(FileName)==0)
line = Fgets("..\C\HdsTrend.dat", 500);
lineSize = Len(line);
for(i=0;i
When calling the trendviewer-mimic, I just have to load the buffer into the selector. So I do not use the variable-option of the selector, because the filtering is not powerful enough :sick:.
My problem is now, how do I specify the size of the buffer:
I will have to columns (string varname, string vartitle) and n entries.
So I would need 2(two columns of string) * 255(max size of vartitle and varname) * n bytes? it would be to big, no?
Hope someone has experience or do I think the wrong way. Is there maybe a much more easier solution. Like I said above, for the future it could be necessary to implement a powerful "inter-buffer-filter", so the solution has to be open for that.
Thank you guys.
Sorry, I forgot that it has to be possible to filter by branch.
Hi Johannes,
First of all, you can filter by branch using the Regular expressions: ^Br1.Br2 means all variables strating with the branch Br1.Br2
But, I agree it should be good allowing the SELECTOR("VARIABLE"...) instruction allowing filtering using what is called "SQL expressions". You can filter by many things including the description. This is available in configuration but, according the help, not on the Scada Basic. Or maybe it's a documentation mistake. Did you try?
Now, about your code, I think you didn't select the good options.
1. You selected Scada Basic instead VBA which is more adapted of what you want to do.
2. Why saving all in a buffer? Save all in a text file and then load the file in the grid: FileToBuf (no need managing size) then Selector(PUTARRAY).
Here is the code with VBA.
'create files on PcVue startup (you must insert the reference Microsoft scripting runtime
Private Sub fvProject_StartupComplete()
Dim fs As New Scripting.FileSystemObject
Dim tsource As Scripting.TextStream
Dim tdest As Scripting.TextStream
Dim aTmp As Variant
'Make Trend file for Histo.dat
Set tsource = fs.OpenTextFile(ThisProject.Path & "CHisto.dat", ForReading)
Set tdest = fs.CreateTextFile(ThisProject.Path & "TPTrendHisto.dat", True)
While tsource.AtEndOfStream = False
aTmp = Split(tsource.ReadLine, ",")
If aTmp(0) = "TRD" Then
tdest.WriteLine aTmp(1) & "," & Variables(aTmp(1)).Description
End If
Wend
tdest.Close
tsource.Close
'Make Trend file for HDSTrend.dat
Set tsource = fs.OpenTextFile(ThisProject.Path & "CHDSTrend.dat", ForReading)
Set tdest = fs.CreateTextFile(ThisProject.Path & "TPTrendHDS.dat", True)
While tsource.AtEndOfStream = False
aTmp = Split(tsource.ReadLine, ",")
tdest.WriteLine aTmp(0) & "," & Variables(aTmp(0)).Description
Wend
tdest.Close
tsource.Close
End Sub
'Then the code for the mimic including the Grid and 2 buttons: 1 loading the histo trends and 1 loading the HDS trends.
Private Sub Mimic_Open()
grdTrends.ClearAll
End Sub
Private Sub btnHDS_Click()
grdTrends.ClearAll
grdTrends.LoadFromFile ThisProject.Path & "TPTrendHDS.dat", ",", vbCrLf
End Sub
Private Sub btnHisto_Click()
grdTrends.ClearAll
grdTrends.LoadFromFile ThisProject.Path & "TPTrendHisto.dat", ",", vbCrLf
End Sub
I attach the project. I used the project BMS Demo data.
Hello Nico,
thank you for putting me on the right way.
You !!!CAN!!! use the SQL - filter with SCADA - Basic. you have to check the SQL option in the AI-Grid properties and save.
From now you can use sql - filter as Filter with SCADA Basic.
Immediatly an Doc-SPR ... I am on the way... :silly: :silly: :silly: :silly:


