Plotting graph in openSCADA
Автор |
Повідомлення |
Повідомлення створено: 31. 05. 2014 [01:17]
|
ajinkya
Ajinkya Biradar
Автор теми
Зареєстрован(а) с: 17.12.2012
Повідомлення: 23
|
Hello All,
I have a UDP program which extracts the DATA field and appends the values in a text file.
Now I want to plot the values by reading the .txt file and disply in openSCADA user interface.
Can we do such graph plotting here? I mean reading a .txt file and then plotting the graph accordingly.......
The refres duration is also I want to set..... not hard real time though.....
Thanks in advance.....
Happy week end.... :-)
[Повідомлення редагувалось 1 раз(ів), останній раз 31.05.2014 в 01:18.]
|
Повідомлення створено: 02. 06. 2014 [10:33]
|
roman
Roman Savochenko
Moderator Contributor Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
|
"ajinkya" wrote:
Now I want to plot the values by reading the .txt file and disply in openSCADA user interface.
Can we do such graph plotting here? I mean reading a .txt file and then plotting the graph accordingly.......
Load the file, parse and place the data to attribute prm{X}addr of primitive "Diagram" into proper format.
"ajinkya" wrote:
Happy week end.... :-)
Thanks!
Learn, learn and learn better than work, work and work.
|
Повідомлення створено: 09. 06. 2014 [10:25]
|
ajinkya
Ajinkya Biradar
Автор теми
Зареєстрован(а) с: 17.12.2012
Повідомлення: 23
|
Hello Sir,
Thank you for your reply it was helpful.....
I was able to get the basics working after referring to "3.8.5. Element of constructing diagrams/trends (Diagram)"
I have the file graph.txt at "/home/ajinkya/Documents/graph.txt" location which i have given in "Parameter 0 -> address "
Now I have few questions-
What are the next steps I need to take in order to plot the particular value from a row in file?
After looking at AGLKS project I think I need to have some program written Process tab in javalike calc.
But I am not getting how to approach it, kindly guide on this matter or some sudo code will also help.
also the file is getting updated and appended every 6 seconds, will it get read correctly while plotting.
Things I need to do
1. read "/home/ajinkya/Documents/graph.txt" this file
2. go to particular column in a row in the same file grab the value and pass for plotting
3. after 6 seconds(file update) repeat point 1,2.
[Повідомлення редагувалось 1 раз(ів), останній раз 09.06.2014 в 10:27.]
|
Повідомлення створено: 09. 06. 2014 [19:09]
|
roman
Roman Savochenko
Moderator Contributor Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
|
"ajinkya" wrote:
I was able to get the basics working after referring to "3.8.5. Element of constructing diagrams/trends (Diagram)"
I have the file graph.txt at "/home/ajinkya/Documents/graph.txt" location which i have given in "Parameter 0 -> address "
You have to process the file, prepare proper stream and next write this to "Parameter 0 -> address" and do not try direct set the path.
"ajinkya" wrote:
What are the next steps I need to take in order to plot the particular value from a row in file?
Your first step error!
"ajinkya" wrote:
After looking at AGLKS project I think I need to have some program written Process tab in javalike calc.
Yes and I told you about.
"ajinkya" wrote:
But I am not getting how to approach it, kindly guide on this matter or some sudo code will also help.
Here have not ready code by clarity your file format is specific.
As variant you can take function SYS.load() and process the file by lines at help *.parse() for result creation proper format for "Parameter 0 -> address".
"ajinkya" wrote:
also the file is getting updated and appended every 6 seconds, will it get read correctly while plotting.
For the performance optimization you can use object IO if the file only grows.
"ajinkya" wrote:
Things I need to do
1. read "/home/ajinkya/Documents/graph.txt" this file
2. go to particular column in a row in the same file grab the value and pass for plotting
3. after 6 seconds(file update) repeat point 1,2.
Yes, but in previous variant into step 1 you continue reading from last position.
Learn, learn and learn better than work, work and work.
|
Повідомлення створено: 12. 06. 2014 [23:04]
|
ajinkya
Ajinkya Biradar
Автор теми
Зареєстрован(а) с: 17.12.2012
Повідомлення: 23
|
Hello Sir,
I have gone trought the suggested links and written few line of code. I need some more guidance from you.
using SYS.load() gave an error once -->
0|/WorkStation/sub_DAQ/mod_JavaLikeCalc/lib_sys_compile/fnc_P_zeb_phase1_so_rg_PV_Graph1/ | Function 'load' error or not enough parameters
but I guess I had done some other mistake so it got rectified and now its not giving any error.
Still I tried the following code with
1. SYS.fileRead("/home/ajinkya/Documents/graph.txt");
2. SYS.load("/home/ajinkya/Documents/graph.txt");
which one would you recommand, as they are not giving any error.
ev_cur = ev_rez = "";
off=0;
while(true)
{
ev_cur=Special.FLibSYS.strParse(event,0,"\n",off);
if( ev_cur == "" ) break;
graph_str = SYS.fileRead("/home/ajinkya/Documents/graph.txt");
graph_str.parse( <something> );
SYS.messInfo("TEST Wdg","Event: "+ev_cur);
}
event=ev_rez;
Further you guided me to use *.parse() --> string parse(int pos, string sep = ".", int off = 0);
to set the "Parameter 0 -> address".
which I have made use of in the above code but I am not getting how to use the parameters for parse
Here is what I understood regarding parse parameters
"pos" --> question --> is this the position of the variable to be plotted?
"sep" --> is the delimiter/saperater I am guessing , correct?
"off" --> is the offset as mentioned, but what value we should init with.
And after parsing where I will get the address parameter to fill in "Parameter 0 -> address" field?
Like in Test "Diagrams" it is specified to be "/DAQ/System/AutoDA/CPULoad/load"
My graph.txt has following format (all parameters saperated by comma)-->
<packetid, invid, packlen, power, freq, Voltage, current, energy, faultid>
I just want to plot power (4th value), voltage (6th value), current (7th value).
To plot more than one parameter I need to set parameter field to '3', in this case, right?
Also, does adding more than one parameter requires adding one more *.parse() call for each parameter?
[Повідомлення редагувалось 2 раз(ів), останній раз 12.06.2014 в 23:06.]
|
Повідомлення створено: 13. 06. 2014 [13:54]
|
roman
Roman Savochenko
Moderator Contributor Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
|
"ajinkya" wrote:
using SYS.load() gave an error once -->
0|/WorkStation/sub_DAQ/mod_JavaLikeCalc/lib_sys_compile/fnc_P_zeb_phase1_so_rg_PV_Graph1/ | Function 'load' error or not enough parameters
Sure, here no the function present.
"ajinkya" wrote:
1. SYS.fileRead("/home/ajinkya/Documents/graph.txt");
The call is correct.
"ajinkya" wrote:
Further you guided me to use *.parse() --> string parse(int pos, string sep = ".", int off = 0);
I the guided for plain texts with separators.
"ajinkya" wrote:
which I have made use of in the above code but I am not getting how to use the parameters for parse
Here is what I understood regarding parse parameters
"pos" --> question --> is this the position of the variable to be plotted?
It is separated token into position from 0.
"ajinkya" wrote:
"sep" --> is the delimiter/saperater I am guessing , correct?
"ajinkya" wrote:
"off" --> is the offset as mentioned, but what value we should init with.
Pass for scanning by position or pos=0 and scanning from (off==0) up to zero result (all tokens pass).
for(off = 0; (line=graph_str.parse(0,"\n",off).length; ) //by lines
for(off1 = 0; (it=line.parse(0,",",off1).length; ) //by items separated "," into the line
{
...
}
"ajinkya" wrote:
And after parsing where I will get the address parameter to fill in "Parameter 0 -> address" field?
Like in Test "Diagrams" it is specified to be "/DAQ/System/AutoDA/CPULoad/load"
You wrong again!
You need prepare stream from your file into form:
"data:<d tm="1369465209000000" tm_grnd="1369465200000000" per="1000000">
0 3.14
1 3.141
5 3.1415</d>" — data for 10 seconds and period 1 second from "25.05.2013 10:00:00"
And place the to need "prm{X}addr" attribute.
"ajinkya" wrote:
My graph.txt has following format (all parameters saperated by comma)-->
<packetid, invid, packlen, power, freq, Voltage, current, energy, faultid>
I just want to plot power (4th value), voltage (6th value), current (7th value).
To plot more than one parameter I need to set parameter field to '3', in this case, right?
You must set "parNum" to need trends count and next use "prm{X}addr", where {X} is value number.
Learn, learn and learn better than work, work and work.
|
Повідомлення створено: 06. 07. 2014 [10:33]
|
ajinkya
Ajinkya Biradar
Автор теми
Зареєстрован(а) с: 17.12.2012
Повідомлення: 23
|
Hello Sir,
Thank you for the reply.
I could atleast get the simplest form of graph running which is
"line:3.14159265" — horizontal line into value "3.14159265".
ev_cur = ev_rez = "";
off=0;
graph_str = SYS.fileRead("/home/ajinkya/Documents/graph.txt");
for(off = 0; (line=graph_str.parse(0,"\n",off).length); )
for(off1 = 0; (it=line.parse(0,",",off1).length); )
{
PV_Graph_1_prm0addr = "line: 1.414"; // I have not made use of "graph.txt" here yet.
}
event=ev_rez;
Just to check if I am correct I used "line:1.414" and I am able to see the running graph.
Demo data in the file is,
[ajinkya@netlab2 ~]$ cat /home/ajinkya/Documents/graph.txt
1,2,3,4,5,6,7,8,9,10
2,3,4,5,6,7,8,9,10,1
3,4,5,6,7,8,9,10,1,2
4,5,6,7,8,9,10,1,2,3
5,6,7,8,9,10,1,2,3,4
6,7,8,9,10,1,2,3,4,5
7,8,9,10,1,2,3,4,5,6
9,10,1,2,3,4,5,6,7,8
10,1,2,3,4,5,6,7,8,9
I am still not getting how to prepare stream from my file into the following form (to plot say, 1st column from the file "graph.txt")
"data:<d tm="1369465209000000" tm_grnd="1369465200000000" per="1000000">
0 3.14
1 3.141
5 3.1415</d>" — data for 10 seconds and period 1 second from "25.05.2013 10:00:00";
also from where I will get the -- tm, tm_grnd, per -- parameter values.
I have seen in widgets where I have my ZEB_RBCCPS liberary --> PV_graph is one of the widgets and PV_Graph_1 is container's widget.
In its(PV_Graph_1) attribute field "Time" attribute reads [1402712763, 0] where "sek" is 14.06.2014 07:56:03
also "curser" attribute reads [1402713340, 0, white] and "sek" of curser reads 14.06.2014 08:05:40
Are these the fields which are used here in tm, tm_grnd parameters, if yes How do I use/import them while preparing stream from my file in the below format-->
"data:<d tm="1369465209000000" tm_grnd="1369465200000000" per="1000000">
0 3.14
1 3.141
5 3.1415</d>" — data for 10 seconds and period 1 second from "25.05.2013 10:00:00";
Thank you in advance.... :-)
|
Повідомлення створено: 07. 07. 2014 [17:34]
|
roman
Roman Savochenko
Moderator Contributor Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
|
"ajinkya" wrote:
I could atleast get the simplest form of graph running which is
"line:3.14159265" — horizontal line into value "3.14159265".
Yes that is simple way for alarm borders display.
"ajinkya" wrote:
Just to check if I am correct I used "line:1.414" and I am able to see the running graph.
That is correct and you will able to see straight line.
"ajinkya" wrote:
Demo data in the file is,
[ajinkya@netlab2 ~]$ cat /home/ajinkya/Documents/graph.txt
1,2,3,4,5,6,7,8,9,10
2,3,4,5,6,7,8,9,10,1
3,4,5,6,7,8,9,10,1,2
4,5,6,7,8,9,10,1,2,3
5,6,7,8,9,10,1,2,3,4
6,7,8,9,10,1,2,3,4,5
7,8,9,10,1,2,3,4,5,6
9,10,1,2,3,4,5,6,7,8
10,1,2,3,4,5,6,7,8,9
And how here detect assigning the data to different parameters and time?
"ajinkya" wrote:
also from where I will get the -- tm, tm_grnd, per -- parameter values.
From your file data specific, sure.
If you do not known the file's data time or the unspecified then you can take current time by SYS.time(), but elsewhere you need have the data periodic and size for tm_grnd calculate.
Sure you need set the "tm" and attribute "tSek" to same value!
Learn, learn and learn better than work, work and work.
|
Повідомлення створено: 08. 07. 2014 [19:25]
|
ajinkya
Ajinkya Biradar
Автор теми
Зареєстрован(а) с: 17.12.2012
Повідомлення: 23
|
Hello Sir,
I have no date/time in the "graph.txt" file, since I am getting the file updated with current data every 7 minutes.
Also the data is not time critical so I can use SYS.time() as you suggested.
If I have to plot the first column from the demo "graph.txt" file as mentioned in previous reply, how should I go about it?
Also I need your help in preparing the string in the format -->
"data:<d tm="1369465209000000" tm_grnd="1369465200000000" per="1000000">
0 3.14
1 3.141
5 3.1415</d>"
but elsewhere you need have the data periodic and size for tm_grnd calculate.
also how should one calculate tm_grnd if we have to use SYS.time().
|
|
PV_Graph_1_prm0addr = "data:<d tm="1369465209000000" tm_grnd="1369465200000000" per="1000000">
0 3.14
1 3.141
5 3.1415</d>";
|
|
Is this how I will do it? Because either it throws error saying "constant after constant", and if I remove them then there is no result as such. Can you suggest me the correct way to approach this ?
[Повідомлення редагувалось 1 раз(ів), останній раз 08.07.2014 в 19:26.]
|
Повідомлення створено: 09. 07. 2014 [22:41]
|
roman
Roman Savochenko
Moderator Contributor Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
|
"ajinkya" wrote:
Is this how I will do it? Because either it throws error saying "constant after constant", and if I remove them then there is no result as such. Can you suggest me the correct way to approach this ?
Read to the documents about special symbols into the string shielding!
off=0;
graph_str = SYS.fileRead("/home/ajinkya/Documents/graph.txt");
data_str = "";
for(off = 0, vCnt = 0; (line=graph_str.parse(0,"\n",off).length); vCnt++)
data_str += ""+vCnt+" "+line.parse(0,",")+"\n";
curTm = SYS.time();
PV_Graph_1_prm0addr = "data:<d tm='"+curTm+"000000' tm_grnd='"+(curTm-vCnt*7*60)+"000000' per='"+(7*60)+"000000'>"+
data_str+"</d>";
PV_Graph_1_tSek = curTm;
PV_Graph_1_tSize = vCnt*7*60;
Learn, learn and learn better than work, work and work.
|
|
|