For my understanding, no matter the value of ExampleDP_SumAlert or ExampleDP_SumAlert1 changes, it will trigger the callback function of workCB(). My question is in the logic of function workCB, is it possible to know which value change(ExampleDP_SumAlert or ExampleDP_SumAlert1) trigger the call back function. If yes, how to get this information?
Re: How to know which data point trigger the call back function in dpConnect logic
Postby Gertjan van Schijndel »
When the value has changed you could get this information by connecting also to the '_value_changed' attribute.
But when the same value is written to the data point element you still do not know which has triggered the call back function, in this it would only be possible with dpConnects on a single data point element or a dpQueryConnectSingle.
Re: How to know which data point trigger the call back function in dpConnect logic
Postby leoknipp »
With the attribute _value_changed and the attribute _value_up you can detect if a _original.._value/_online.._value for a dp element is different to the previous one.
Current value = 2 and new value = 3 the attributes will be
_value_changed = 1
_value_up = 1
Current value = 2 and new value = 2 the attributes will be
_value_changed = 0
_value_up = 0
Current value = 2 and new value = 1 the attributes will be
_value_changed = 1
_value_up = 0
Those attribute cannot be used to detect which dp element has triggered the callback function for a dpConnect() with several dp elements.
Best Regards
Leopold Knipp
Senior Support Specialist
But actually the logic of value_changed1, value_changed2...value_changed100 is the same. I really do not want to write the same logic 100 times in a script. Is there easier way to do that? Many thanks!
Re: How to know which data point trigger the call back function in dpConnect logic
Postby maoyi8212 »
Frenk, Thank you for your suggestion and reply. So if I connect 100 of similar data point, I need to connect the _stime as well, then I need to compare 100 values of _stime to find the biggest one, After I know which timestamp is the biggest one, I should parse the name information of the data point, then do the logic I planned?
My question is that if the numbers of the data point increases, is it possible that the comparison logic spends too much time so the data point has been refreshed already?
Re: How to know which data point trigger the call back function in dpConnect logic
Postby fmulder »
Yes, Nuno is right. The scenario that you describe seems to fit a dpQueryConnectSingle()
First of all some important details:
1) a dpConnect() is always synchronized. This means that a callback function is not called before the previous one has finished executing. This also implies that your callback functions should be fast. if your callback function takes too much time then you might get the mesage '200 pending runs'. This basically means that your UI or script manager is receiving data for a callback, but your callback is not fast enough to process them.
( This rule applies to each specific callback function. If you have multiple panels, or you have multiple threads with callbacks, then they will run in parallel)
2) The scripting is better than you think. You wont easily run into a performance problem
3) The dpQueryConnectSingle() does what you need. It will only give you the modified values
If you only want to respond to new values then the dpQueryConnectSingle() is perfect. It will only send you the new values. If you need to have all values,then you should save them in the callback. Saving them could be done in some dyn_.. or could be done in a mapping (the mapping is faster in looking up date)
Hope this helps
p.s.
The Lab section will hold a document XFile 1. This document explains how the queries work
Re: How to know which data point trigger the call back function in dpConnect logic
Postby leoknipp »
Using a connect to the attribute _stime does not give you the information which dp element has triggered the callback function by searching for those with the newest time stamp.
In WinCC OA you can set an original value with a defined time stamp, e.g. by using dpSetTimed(). Also some of the WinCC OA drivers can use the time stamp given by the PLC.
E.g. a dpConnect for 2 dp elements
DPE1 - value 1 - time stamp 2017.04.18 08:55:00.000
DPE2 - value 2 - time stamp 2017.04.18 06:00:00.000
If now a dpSetTimed is made for DPE2 with the following information the callback function will be triggered
DPE2 - value 3 - time stamp 2017.04.18 07:00:00.000
By comparing the _stime you will find DPE1 as the newer one but this one has not triggered the callback function.
Best Regards
Leopold Knipp
Senior Support Specialist
Re: How to know which data point trigger the call back function in dpConnect logic
Postby fmulder »
Leo is right, but the dpSetTimed() is quite rare. I've hardly ever used or needed it.
In general, looking at the _stime will work, but using the dpQueryConnectSingle() in this case, sounds like a better idea !