How to know which data point trigger the call back function in dpConnect logic

Find and share HowTos to various installations / configurations!
16 posts • Page 2 of 2
leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: How to know which data point trigger the call back function in dpConnect logic

Post by leoknipp »

dpSetTimed() is used often and also drivers are using it when the timestamp given by the PLC is used.
Therefore using a check for _stime is not a guarantee that you get the correct result.

Best Regards
Leopold Knipp
Senior Support Specialist

maoyi8212
Posts:9
Joined: Tue Feb 21, 2017 3:47 am

Re: How to know which data point trigger the call back function in dpConnect logic

Post by maoyi8212 »

@Leo @Frenk @Nuno. Thank you for your kindly help.
So now I tried to update my script using dpQueryConnectSingle and I was doing my test like following:

main()
{
int rc;
anytype userData =getUserName();
rc = dpQueryConnectSingle("workCB", true, userData, "SELECT '_original.._value' FROM 'ExampleDP_SumAlert*.' WHERE _DPT=\\"ExampleDP_Text\\"");
DebugN("After the QueryConnectSingle", rc);
}

void workCB(anytype userData, dyn_dyn_anytype val)
{
int i;
DebugN("Callback:",dynlen(val));
for (i = 2; i

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: How to know which data point trigger the call back function in dpConnect logic

Post by fmulder »

Your code seems ok and it should trigger only when the datapoint elements.
Please use the para to look at the datapoints that you monitor. Look at the timestamp of these datapoint elements. They should not change all the time.

I'm pretty sure that a dpQieryConnectSingle() will only fire when the related datapoints actually change.

Good luck

Frenk Mulder

maoyi8212
Posts:9
Joined: Tue Feb 21, 2017 3:47 am

Re: How to know which data point trigger the call back function in dpConnect logic

Post by maoyi8212 »

@Frenk, thanks!

I have checked the the timestamp of these datapoint elements and it actually changes. So the original value means not only the value it self but also the timestamp. right? So maybe I need to check the configuraion of data point itself.

nmnogueira
Posts:125
Joined: Thu May 05, 2011 12:59 pm

Re: How to know which data point trigger the call back function in dpConnect logic

Post by nmnogueira »

Yes, if the timestamp changes, the callback will be triggered. If you are reading the values from a PLC, make sure that the option "Low Level Comparison" is enabled.

maoyi8212
Posts:9
Joined: Tue Feb 21, 2017 3:47 am

Re: How to know which data point trigger the call back function in dpConnect logic

Post by maoyi8212 »

@Nuno, Thank for for your suggestion. It's due to my wrong configuration of "Low level Comparison"

16 posts • Page 2 of 2