Callback for newly created datapoint of certain type

Find and share HowTos to various installations / configurations!
4 posts • Page 1 of 1
svhsvh
Posts:6
Joined: Tue Sep 19, 2023 3:04 pm

Callback for newly created datapoint of certain type

Post by svhsvh »

Hi,

The use of DpConnect() is firing a callback when the value of a datapoint changes. Is there a function or a way to fire a callback when a new datapoint is created for a certian datapoint type?

Kind regards,
Stef

hpuchegger
Posts:86
Joined: Fri Oct 08, 2021 10:38 am

Re: Callback for newly created datapoint of certain type

Post by hpuchegger »

I also wasn't sure how this could be done. In such cases its interesting what our AI Assistant at our online documentation delivers. This was the result:

In WinCC OA, there isn't a direct function that triggers a callback specifically when a new data point of a certain type is created. However, you can use the dpQueryConnectSingle() or dpQueryConnectAll() functions to monitor changes in data points that match a specific query condition. This allows you to receive notifications when data points are created or modified based on your query.

For example, you can use a SQL query to filter data points by their type and connect to them. When a new data point that meets the criteria is created, your callback function will be triggered. Here's a brief overview of how you can implement this:

1. Use dpQueryConnectSingle() or dpQueryConnectAll() with a query that specifies the data point type you are interested in.
2. Define a callback function that will handle the updates.

Here’s a sample usage of dpQueryConnectSingle():

let id = winccoa.dpQueryConnectSingle(
queryConnectCB,
true,
`SELECT '_online.._value' FROM '*' WHERE _DPT="YourDataPointType"`
);

In this example, replace "YourDataPointType" with the actual type you want to monitor. The callback queryConnectCB will be called whenever a data point of that type is created or updated.

Br, Herbert

gschijndel
Posts:376
Joined: Tue Jan 15, 2019 3:12 pm

Re: Callback for newly created datapoint of certain type

Post by gschijndel »

The dpQueryConnectSingle function seems to be the most practical in this case. The values of a newly created datapoint have as timetamp a null-time (0).

Another way would be using the sysConnect or sysConnectUserData function with as event 'dpCreated'/'dpRenamed', but it cannot be limited to a certain type.

svhsvh
Posts:6
Joined: Tue Sep 19, 2023 3:04 pm

Re: Callback for newly created datapoint of certain type

Post by svhsvh »

Thanks for the response, this is what i was looking for. I will explore the AI Assistant

4 posts • Page 1 of 1