Hello,
I would like to know if there is a function that checks if a dpconnection is active. I have erros trying to disconnect from a function so I need to know if the callback is active.
Regards
dpConnectExists
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: dpConnectExists
You can read the attributes for the _connect config for a dp element to see if and which manager is connected.
The information which dpConnect and which work function it is you cannot get by reading this attribute.
When using dpDisconnect please keep in mind that you have to do the dpDisconnect in the same script where the dpConnect was made, otherwise it will not work.
Best Regards
Leopold Knipp
Senior Support Specialist
The information which dpConnect and which work function it is you cannot get by reading this attribute.
When using dpDisconnect please keep in mind that you have to do the dpDisconnect in the same script where the dpConnect was made, otherwise it will not work.
Best Regards
Leopold Knipp
Senior Support Specialist
- WINOA
- Posts:15
- Joined: Mon Apr 09, 2018 3:24 pm
Re: dpConnectExists
I do have a common library script, both connect and disconnect are in a library. The disconnect its triggered in a callback itself. I have no problem when dpConnect its used just once but when it gets trigger more than once dpDisconnect does not work.
Regards
Regards
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: dpConnectExists
Defining the functions in the same library will not solve the problem that a dpDisconnect will fail.
The script where the function to make the connect and disconnect is called (direct call of dpConnect/dpDisconnect or calling a library function which do the dpConnect/dpDisconnect) must be the same.
Why are you doing a dpDisconnect in the work function for the dpConnect?
Do you need to start the work function only once?
To avoid an error if the dpDisconnect() is called in the work function the second time you can probably use a global variable where you save the information, that dpDisconnect was already called.
Best Regards
Leopold Knipp
Senior Support Specialist
The script where the function to make the connect and disconnect is called (direct call of dpConnect/dpDisconnect or calling a library function which do the dpConnect/dpDisconnect) must be the same.
Why are you doing a dpDisconnect in the work function for the dpConnect?
Do you need to start the work function only once?
To avoid an error if the dpDisconnect() is called in the work function the second time you can probably use a global variable where you save the information, that dpDisconnect was already called.
Best Regards
Leopold Knipp
Senior Support Specialist
- WINOA
- Posts:15
- Joined: Mon Apr 09, 2018 3:24 pm
Re: dpConnectExists
I need to connect to the heartbit to check an amount of seconds. After that the function is finished. So the flow will be: trigger (Connect), count time (Based on heartbit), Action done (Disconnect). As it is right now it works if I trigger only once.
As a solution I thought in adding attribute in para to my object (Unique) that indicate if that particular object is connected to the heartbit. If that has something connected dont do the dp connect.
If you have any suggestion please let me know.
Regards
As a solution I thought in adding attribute in para to my object (Unique) that indicate if that particular object is connected to the heartbit. If that has something connected dont do the dp connect.
If you have any suggestion please let me know.
Regards
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: dpConnectExists
If you just have to wait for receiving a value change of a dp element you can use the function dpWaitForValue(). Then you do not have to make a dpConnect and dpDisconnect in the work function.
For details concerning dpWaitForValue() please have a look at the WinCC OA Documentation.
Best Regards
Leopold Knipp
Senior Support Specialist
For details concerning dpWaitForValue() please have a look at the WinCC OA Documentation.
Best Regards
Leopold Knipp
Senior Support Specialist
- WINOA
- Posts:15
- Joined: Mon Apr 09, 2018 3:24 pm
Re: dpConnectExists
Sorry not sure if I understood it alright. I am counting seconds and after an amount of them I need to trigger the callback. Some seconds after I need to disconnect from there. There is no need to have a callback active for checking the time the whole time.
What you suggest is do actions based on the hearbit number?
Regards
What you suggest is do actions based on the hearbit number?
Regards
- WINOA
- Posts:15
- Joined: Mon Apr 09, 2018 3:24 pm
Re: dpConnectExists
Hello I have finally found a solution. I used the ":_connect.._mancount" property of a dp with dpGet. It gives you back in an array how many connection exist for that particular dp. If the array length is bigger than one, no dpconnect will be establish.
Regards
Regards
- fmulder
- Posts:330
- Joined: Wed Feb 03, 2010 9:46 am
Re: dpConnectExists
Note that your 'count' will also be >0 when:
- you archive a point
- When you have a dp function on a point
I believe your solution is quite tricky.
Please note:
Sometimes it is ok and even better to just implement a simple loop with a delay.
Good luck
Share the fun
Frenk Mulder
- you archive a point
- When you have a dp function on a point
I believe your solution is quite tricky.
Please note:
Sometimes it is ok and even better to just implement a simple loop with a delay.
Code: Select all
while(1)
{
delay( 1 )
dpGet(..)
etc..
}Share the fun
Frenk Mulder