How can I use dpDisconnect/dpQueryDisconnect from a different script as connecting?

To disconnect a datapoint connections made via dpConnect, dpQueryConnectSingle, dpQeuryConnectAll or dpConnectUserData, the function call of dpDisconnect / dpDisconnectUserData / dpQueryDisconnect needs to be in the same script.

So it is not possible to do a dpConnect in an init script and dpDisconnect via a button click. It is also not possible to do a dpConnect via a button click and execute the dpDisconnect with a click on another button.

 

A possible solution for that is to use a hidden textfiled that triggers the dpConnect/dpDisconnect on text change:

1) Place a text filed on the panel.

2) Set the text field to invisible.

3) Implement in the text change event the following:

main(){

if(sNewText == “”) //to avoid a recursion

               return;

if(sNewText == "1")

               dpConnect (….);

else if(sNewText == "0")

               dpDisconnect(…)

               this.text = “”; //have to reset the text field, otherwise the text change event would not be triggered with the same set text

}

 

4) The clicked script of the button for dpConnect: textField.text = “1”;

5) The clicked script of the button to dpDisconnect: textField.text = “0”;

 

Date added:
Last revised:
Hits:
5.394
Version:
ALL Versions
Rating:
Rating: 1.0. 1 vote(s). No rating done at all.
Your vote was '' (0 of 5) You are an anonymous user.
You may log on to do personalized votings
Click the rating bar to rate this item Please log on to do ratings
  • Notification

    FE user cannot be identified! (1403201096)

Tags:
Programming / Scripting, User Interface, WinCC Open Architecture, HMI