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
Callback for newly created datapoint of certain type
- svhsvh
- Posts:6
- Joined: Tue Sep 19, 2023 3:04 pm
Callback for newly created datapoint of certain type
- hpuchegger
- Posts:86
- Joined: Fri Oct 08, 2021 10:38 am
Re: Callback for newly created datapoint of certain type
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
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
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.
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
Thanks for the response, this is what i was looking for. I will explore the AI Assistant