The datapoints that I want to query come from a list generated like this:
dyn_string dps = dpNames ("Machine*.**");
and I want all changes to these datapoints in this timerange:
time time_start = makeTime(2017, 1,1);
time time_end = makeTime(2017, 1,2);
I don't think I can do this with dpGetPeriod() because it only allows a discrete list of dps.
I could do it with a loop like this:
dyn_dyn_time times;
dyn_dyn_anytype values;
for (int i = 1; i
How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
Did you try with dpQuery() ?
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
No I didn't because I don't know how to make the query string
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
E.g.
SELECT '_original.._value' FROM 'Machine*.**' TIMERANGE("2017.01.01 00:00:00","2017.01.02 23:59:59",1,0)
you can get this string interactively by using the SQL-query panel from the SysMgm
SELECT '_original.._value' FROM 'Machine*.**' TIMERANGE("2017.01.01 00:00:00","2017.01.02 23:59:59",1,0)
you can get this string interactively by using the SQL-query panel from the SysMgm
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
Thanks Martin, the SQL Query panel is very helpful in playing wiith the parameters for the query string to find out what I really want to do.
In my application, I need to make a snapshot of a long list of datapoints at one particular period of time.
For that I set the start and end times of the TIMERANGE to the same value and the amount of bonus data to 1.
That way I get a maximum of 2 values per datapoint.
The first values is the one I want, that was valid at the time of my snapshot.
There is a second value for a datapoint only exists if it changed since the time I am querying for, and I just ignore these.
The SQL query panel doesn't let start and end times to be the same and tells me that end time is before start time, because the case where both times are equal is not considered.
Am I right that this is only an error in the time comparison in the SQL query panel and that such queries are in fact allowed?
My script worked great with a list of about 1000 datapoints separated by commas in the FROM part of the query string, resulting in a query string length of about 35KB.
The query execution actually took a couple of seconds, I was surprised that it was that fast!
I actually need to make the snapshot for about 5000 datapoints though, resulting in a query string that is about 180kB long.
When I tried that out, the event manager went into blocking mode and didn't recover so I had to kill it with the -9 option.
Could it be that there is a maximum length of 64kB for the query string?
If not what else could the problem be?
If that is the case I could quite easily divide up my datapoint list and make several queries with string lengths < 64K,
which would still be fast enough.
Or is there is a better way to do this too?
In my application, I need to make a snapshot of a long list of datapoints at one particular period of time.
For that I set the start and end times of the TIMERANGE to the same value and the amount of bonus data to 1.
That way I get a maximum of 2 values per datapoint.
The first values is the one I want, that was valid at the time of my snapshot.
There is a second value for a datapoint only exists if it changed since the time I am querying for, and I just ignore these.
The SQL query panel doesn't let start and end times to be the same and tells me that end time is before start time, because the case where both times are equal is not considered.
Am I right that this is only an error in the time comparison in the SQL query panel and that such queries are in fact allowed?
My script worked great with a list of about 1000 datapoints separated by commas in the FROM part of the query string, resulting in a query string length of about 35KB.
The query execution actually took a couple of seconds, I was surprised that it was that fast!
I actually need to make the snapshot for about 5000 datapoints though, resulting in a query string that is about 180kB long.
When I tried that out, the event manager went into blocking mode and didn't recover so I had to kill it with the -9 option.
Could it be that there is a maximum length of 64kB for the query string?
If not what else could the problem be?
If that is the case I could quite easily divide up my datapoint list and make several queries with string lengths < 64K,
which would still be fast enough.
Or is there is a better way to do this too?
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
The function 'dpGetAsynch' does what you want. I think you can also pass a dyn_string for the dp-argument(s) just like the dpGet function.
- fmulder
- Posts:330
- Joined: Wed Feb 03, 2010 9:46 am
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
You could also use a dp group in your query (instead of a long lost of dp names).
Good luck
Share the fun
Frenk Mulder
Good luck
Share the fun
Frenk Mulder
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
I tried passing a dyn_string list of datapoints to dpGetAsynch(), that works(!) even though the help (in WinCC 3.14) for dpGetAsynch() does not mention that this is allowed. Instead it says that only a discrete list of one or more datapoints can be passed to it:
Synopsis
int dpGetAsynch(time t, string dp1, &var1 [, string dp2, &var2 ...]);
Thanks a lot for the tip, Gertjan!.
I also tried Frenk's tip by creating a group named MyGroup with the dpe filter ExtCox001.MelDrv001.Spd*Stt The group administration check shows that the group contains 6 datapoint elements but an SQL query with FROM 'MyGroup' returns no values in the table
An SQL query with FROM 'ExtCox001.MelDrv001.Spd*Stt' returns the values I expect though.
What am I doing wrong?
Synopsis
int dpGetAsynch(time t, string dp1, &var1 [, string dp2, &var2 ...]);
Thanks a lot for the tip, Gertjan!.
I also tried Frenk's tip by creating a group named MyGroup with the dpe filter ExtCox001.MelDrv001.Spd*Stt The group administration check shows that the group contains 6 datapoint elements but an SQL query with FROM 'MyGroup' returns no values in the table
An SQL query with FROM 'ExtCox001.MelDrv001.Spd*Stt' returns the values I expect though.
What am I doing wrong?
- fmulder
- Posts:330
- Joined: Wed Feb 03, 2010 9:46 am
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
I'd say that FROM 'MyGroup' sounds ok ?
I have no idea.
I have no idea.
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: How do i get the changes of all datapoints that I have in a dyn_string over a specific period of time
If you are using a DP group in a SQL query you have to use the DPGROUP keyword.
FROM '{DPGROUP(_DpGroup00001_Public)}'
Instead of the group name you have to pass the datapoint name for the _DpGroup datapoint, _DpGroup00001_Public in the given example.
Best Regards
Leopold Knipp
Senior Support Specialist
FROM '{DPGROUP(_DpGroup00001_Public)}'
Instead of the group name you have to pass the datapoint name for the _DpGroup datapoint, _DpGroup00001_Public in the given example.
Best Regards
Leopold Knipp
Senior Support Specialist