|
Synopsis
int dpQueryConnectAll(string workfunc, bool wantsanswer, anytype userData, string query,[ int blockingTime]); |
Parameter
Parameter |
Meaning |
workfunc |
Name of the work function |
wantsanswer |
Defines whether the work function is to be called later during registration |
userData |
User-defined data which is passed as parameter to the callback function. |
query |
The query as an SQL statement
CAUTION! Note that for the Connect functions only DPE's of one system may be specified.
Note If the query returns more than 80% of the systems data point elements, a general subscription will be performed instead of the query connect. Inside the callback function only the elements which are returned by the sql query will be used. |
delay |
Timerange in [ms] where the call of the CB-Function from open queries is blocked. Without the entry the value is taken from the config file (see queryHLBlockedTime), with 0 nothing is blocked, otherwise the delay has to be given in [ms](<=32767). |
Return value
dpQueryConnectAll() returns 0, -1 in the event of an error. Note The return value only indicates whether a CONNECT message was sent, but not whether the execution of the function (query) was successful. The error is written to the thread after the function has been executed and can be retrieved with a subsequent call to the function getLastError(). See also Error Handling. |
Error
Errors can be retrieved with getLastError(). This includes missing arguments (also of the work function), undefined functions, incorrect arguments ( for example, no Control expression). The usage of not initialized variables for the parameter userData will raise an error. |
Description
The function dpQueryConnectAll() initializes registration to a work function workfunc, which is called when changes are made to attributes and when data points and configurations are created. Restrictions such as FIRST or LAST xx in the SQL string are not taken into consideration. The optional parameter delay allows a time definition for blocking queries. That means that the work function is not called immediately after value change, but awaiting the time (indicated with delay) and finally the open queries are transferred at one time to the work function. Note A connect to all elements in the database is
only possible for _original, _online and _offline
configs, for example: Caution Note that if you use a delay parameter in the dpQueryConnectAll() and different DPs change at different times during the delay ( for example, three different DPs change at different times within the delay), the result table (which is selected via the query and returned in the variable) is returned three times. Caution A query with the SQL statement SELECT ALERT ..., must not be used because of performance reasons! |
The first parameter workfunc denotes the work function to be called when changes are made. It must therefore be able to process the entire table. The registered function work() must have the following transfer parameters. |
void workfunc(anytype userData, dyn_dyn_anytype result) |
Parameter |
Meaning |
userData |
User-defined data which is passed as parameter to the callback function. |
result |
Result of the query (table for dpQueryConnectAll()) |
Identifier is the specific name to assign the function, result is the result of the query. For dpQueryConnectAll() this means the entire table. |
If the second parameter wantsanswer is "true", then immediately after the announcement the work function with the current table is called. The query itself is a string "query" containing the SQL SELECT statement. For details on the used SQL dialect in WinCC OA see the chapter SQL. |
Example |
The work function leaf is announced. The query returns all original values of the leafs for the data point "Motor1":. |
main()
{ string query; anytype userData; //_LEAF returns the leaves of the DPs query = "SELECT '_original.._value' FROM 'Motor1' WHERE _LEAF"; userData = getUserName(); dpQueryConnectAll("blatt", TRUE, userData , query); } void blatt(anytype userData, dyn_dyn_anytype tab) //tab contains the entire table including the values without changes { int z; for(z=2;z<=dynlen(tab);z++) { //........... } } |
Assignment
Data point function, waiting Control function |
Availability
UI, CTRL, DP, W |
See also
dpQuery(), dpQueryDisconnect(), dpQueryConnectSingle(), isRefresh(), isAnswer(), Basics SQL in Control |
V 3.11 SP1
Copyright ETM professional control GmbH 2013 All Rights Reserved