[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Lift System - No foreign application responded to a DDE initiate (Error 282

albertleng

3/16/2011 2:09:00 PM

Hello All,

I'm working on a project for Lift System which I need to receive a
continuous Lift message via RS232 and decode it and then, based on the
decoded message, send value to
a SCADA software. The lift data is sent to my program every 10~300 ms
non-stop.

In order not to put a heavy load on the SCADA software, i have
implemented
i) Only send change of value to SCADA software
ii) have delay (sleep) after sending each lift status to SCADA
software

FYI, the client allows delay of the status update on the SCADA
software by my program

However, no matter how much delay i put, the SCADA will be unavailable
after few minutes to few hours. The error generated is
1) Error 282 No foreign application responded to DDE initiate
2) Error 286 Timeout while waiting for DDE response

I attach the code fragments which involve receiving of Lift data and
updating of SCADA software. Please kindly advise if there is any
improvement to be made. Thanks a lot!!!


Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)
.
.
.
Private Sub MSComm1_OnComm()
On Error GoTo FixErr

Static InputMsg As String
Dim STXLoc As Integer, ETXLoc As Integer
Dim Message As String
Dim Buffer As String

Static counter As Integer



120
If MSComm1.CommEvent = comEvReceive Then
Buffer = MSComm1.Input
counter = counter + 1

If (counter > CInt(DelayFrequency)) Then
Call FilterValues
counter = 0
Exit Sub
End If
InputMsg = InputMsg & Buffer

'Q: Correct to do so for STX and ETX?
STXLoc = InStr(1, InputMsg, Chr$(&H2))
ETXLoc = InStr(STXLoc + 1, InputMsg, Chr$(&H3))

130 If STXLoc >= 1 And ETXLoc > STXLoc Then
Message = InputMsg

InputMsg = ""
140 Call ProcessLiftMessage(Mid$(Message, STXLoc, ETXLoc - STXLoc
+ 1))
End If
End If

FixErr:
If Err.Number <> 0 Then
Print #LogFNo, Format(Now, "YYYY-MM-DD hh:mm:ss") & " Receiving
Message, Error " & Err.Number & " " & _
Err.Description & " after " & Erl & "."
logFLineNo = logFLineNo + 1
End If
End Sub



Sub FilterValues()
On Error GoTo FixErr

Dim i As Integer


400
For i = 1 To txtELEDIR.UBound

'Elevator Running (direction)
If (txtELEDIR(i).Text <> txtELEDIRbuf(i).Text) Then
Call SendDDE(txtELEDIR(i), txtELEDIR(i).Text)
txtELEDIRbuf(i).Text = txtELEDIR(i).Text
Sleep (500)

End If


'mode
If (txtELEMODE(i).Text <> txtELEMODEbuf(i).Text) Then
Call SendDDE(txtELEMODE(i), txtELEMODE(i).Text)
txtELEMODEbuf(i).Text = txtELEMODE(i).Text

Sleep (500)

End If


'error stat
If (txtELEErr(i).Text <> txtELEErrbuf(i).Text) Then
Call SendDDE(txtELEErr(i), txtELEErr(i).Text)
txtELEErrbuf(i).Text = txtELEErr(i).Text
Sleep (500)

End If



'group stat
If (TxtELEGrp(i).Text <> TxtELEGrpbuf(i).Text) Then
Call SendDDE(TxtELEGrp(i), TxtELEGrp(i).Text)
TxtELEGrpbuf(i).Text = TxtELEGrp(i).Text
Sleep (500)

End If


'emergency stat
If (txtELEEme(i).Text <> txtELEEmebuf(i).Text) Then
Call SendDDE(txtELEEme(i), txtELEEme(i).Text)
txtELEEmebuf(i).Text = txtELEEme(i).Text

Sleep (500)

End If

counter = counter + 1
If (counter > 50) Then
If txtheartbeat.Text = "0" Then
Call SendDDE(txtheartbeat, "0")
txtheartbeat.Text = "1"
Else
Call SendDDE(txtheartbeat, "1")
txtheartbeat.Text = "0"
End If
counter = 0
Sleep (200)
End If

Next i


FixErr:
If Err.Number <> 0 Then
Print #LogFNo, Format(Date, "YYMMDD") & " " & Format(Time,
"HH:mm:ss") & " " & Err.Number & " " & Err.Description & ", Filtering
value after " & Erl & "."
logFLineNo = logFLineNo + 1

End If
End Sub


Private Sub SendDDE(txt As TextBox, value As String)
On Error GoTo FixErr
360
txtPcVue.LinkMode = vbLinkNone
txtPcVue.LinkItem = txt.LinkItem
txtPcVue.Text = value
txtPcVue.LinkMode = vbLinkManual
txtPcVue.LinkPoke

Print #LogFNo, Format(Date, "YYMMDD") & " " & Format(Time,
"HH:mm:ss") & " " & "Send " & value & " to " & txtPcVue.LinkItem & "
for " _
& txt.Tag & "."
logFLineNo = logFLineNo + 1



FixErr:
If Err.Number <> 0 Then
Print #LogFNo, Format(Date, "YYMMDD") & " " & Format(Time,
"HH:mm:ss") & " " & "Sending " & value & " to " & txtPcVue.LinkItem &
", Error " & Err.Number & " " & Err.Description & " after " & Erl &
"."
logFLineNo = logFLineNo + 1

End If
End Sub




6 Answers

(nobody)

3/16/2011 3:57:00 PM

0

"albertleng" <albertleng@gmail.com> wrote in message
news:02e14c88-c27b-4af4-b30f-b1bdade450c2@o21g2000prh.googlegroups.com...
> Hello All,
>
> I'm working on a project for Lift System which I need to receive a
> continuous Lift message via RS232 and decode it and then, based on the
> decoded message, send value to
> a SCADA software. The lift data is sent to my program every 10~300 ms
> non-stop.
>
> In order not to put a heavy load on the SCADA software, i have
> implemented
> i) Only send change of value to SCADA software
> ii) have delay (sleep) after sending each lift status to SCADA
> software
>
> FYI, the client allows delay of the status update on the SCADA
> software by my program
>
> However, no matter how much delay i put, the SCADA will be unavailable
> after few minutes to few hours. The error generated is
> 1) Error 282 No foreign application responded to DDE initiate
> 2) Error 286 Timeout while waiting for DDE response

This sounds like handles to the same object or resource is being open and
not closed, and after around 65536 times, Windows returns an error code.
Since you are using a Timer with period of 10~300 ms, this translates to
655.36 to 19660.8 Seconds, or 10.92 minutes to 5.46 Hours. You can put a
counter in SendDDE to see if this is the case.

This could be caused by either your app or the target app. It maybe related
to DDE, or not, like for example if the target app opens handles to other
stuff but not closing them. To see which one is causing the leak, use Task
Manager and look at "Handle Count" column. Use View-->Select Columns to show
that column.



albertleng

3/16/2011 4:15:00 PM

0

On Mar 16, 11:56 pm, "Nobody" <nob...@nobody.com> wrote:
> "albertleng" <albertl...@gmail.com> wrote in message
>
> news:02e14c88-c27b-4af4-b30f-b1bdade450c2@o21g2000prh.googlegroups.com...
>
>
>
> > Hello All,
>
> > I'm working on a project for Lift System which I need to receive a
> > continuous Lift message via RS232 and decode it and then, based on the
> > decoded message, send value to
> > a SCADA software. The lift data is sent to my program every 10~300 ms
> > non-stop.
>
> > In order not to put a heavy load on the SCADA software, i have
> > implemented
> > i) Only send change of value to SCADA software
> > ii) have delay (sleep) after sending each lift status to SCADA
> > software
>
> > FYI, the client allows delay of the status update on the SCADA
> > software by my program
>
> > However, no matter how much delay i put, the SCADA will be unavailable
> > after few minutes to few hours. The error generated is
> > 1) Error 282 No foreign application responded to DDE initiate
> > 2) Error 286 Timeout while waiting for DDE response
>
> This sounds like handles to the same object or resource is being open and
> not closed, and after around 65536 times, Windows returns an error code.
> Since you are using a Timer with period of 10~300 ms, this translates to
> 655.36 to 19660.8 Seconds, or 10.92 minutes to 5.46 Hours. You can put a
> counter in SendDDE to see if this is the case.
>
> This could be caused by either your app or the target app. It maybe related
> to DDE, or not, like for example if the target app opens handles to other
> stuff but not closing them. To see which one is causing the leak, use Task
> Manager and look at "Handle Count" column. Use View-->Select Columns to show
> that column.

Thanks for your reply.
I'm not using a Timer with period of 10~300ms in my program. What i
meant in my post was that the lift system sends the lift data to my
program via a RS232 port every 10-300ms. The handling of the arrival
of data at RS232 in my program is in MSComm1_OnComm()

(nobody)

3/16/2011 4:23:00 PM

0

albertleng wrote:
> On Mar 16, 11:56 pm, "Nobody" <nob...@nobody.com> wrote:
>> "albertleng" <albertl...@gmail.com> wrote in message
>>
>> news:02e14c88-c27b-4af4-b30f-b1bdade450c2@o21g2000prh.googlegroups.com...
>>
>>
>>
>>> Hello All,
>>
>>> I'm working on a project for Lift System which I need to receive a
>>> continuous Lift message via RS232 and decode it and then, based on
>>> the decoded message, send value to
>>> a SCADA software. The lift data is sent to my program every 10~300
>>> ms non-stop.
>>
>>> In order not to put a heavy load on the SCADA software, i have
>>> implemented
>>> i) Only send change of value to SCADA software
>>> ii) have delay (sleep) after sending each lift status to SCADA
>>> software
>>
>>> FYI, the client allows delay of the status update on the SCADA
>>> software by my program
>>
>>> However, no matter how much delay i put, the SCADA will be
>>> unavailable after few minutes to few hours. The error generated is
>>> 1) Error 282 No foreign application responded to DDE initiate
>>> 2) Error 286 Timeout while waiting for DDE response
>>
>> This sounds like handles to the same object or resource is being
>> open and not closed, and after around 65536 times, Windows returns
>> an error code. Since you are using a Timer with period of 10~300 ms,
>> this translates to 655.36 to 19660.8 Seconds, or 10.92 minutes to
>> 5.46 Hours. You can put a counter in SendDDE to see if this is the
>> case.
>>
>> This could be caused by either your app or the target app. It maybe
>> related to DDE, or not, like for example if the target app opens
>> handles to other stuff but not closing them. To see which one is
>> causing the leak, use Task Manager and look at "Handle Count"
>> column. Use View-->Select Columns to show that column.
>
> Thanks for your reply.
> I'm not using a Timer with period of 10~300ms in my program. What i
> meant in my post was that the lift system sends the lift data to my
> program via a RS232 port every 10-300ms. The handling of the arrival
> of data at RS232 in my program is in MSComm1_OnComm()

It doesn't matter if you are using a Timer specifically, your OnComm event
is called several times a second, and this is close. Also, the timing
figures I posted could be incorrect because you maybe calling SendDDE
several times in the routine.


ralph

3/18/2011 2:15:00 AM

0

On Thu, 17 Mar 2011 20:24:53 -0600, "Larry Serflaten"
<serflaten@gmail.com> wrote:

>
>"albertleng" <albertleng@gmail.com> wrote
>
>> I'm working on a project for Lift System which I need to receive a
>> continuous Lift message via RS232 and decode it and then, based on the
>> decoded message, send value to
>> a SCADA software. The lift data is sent to my program every 10~300 ms
>> non-stop.
>>
>> In order not to put a heavy load on the SCADA software, i have
>> implemented
>> i) Only send change of value to SCADA software
>> ii) have delay (sleep) after sending each lift status to SCADA
>> software
>
>Why did you think Sleep would help after sending DDE information?
>Did you have some text somewhere indicating that should be used?
>It seems odd to me that you would ask the system to transfer data
>and then immediately become unresponsive for so many milliseconds....
>
>
>> Private Sub SendDDE(txt As TextBox, value As String)
>> On Error GoTo FixErr
>> 360
>> txtPcVue.LinkMode = vbLinkNone
>> txtPcVue.LinkItem = txt.LinkItem
>> txtPcVue.Text = value
>> txtPcVue.LinkMode = vbLinkManual
>> txtPcVue.LinkPoke
>
>This is not the correct method of using DDE. It would be similar to
>trying to have a conversation over the phone where, every time you
>wanted to say something, you hang up, and dial their phone number.
>
>It may be the cause of your problem.
>
>Set up the LinkItem and LinkMode once when you want to start
>the DDE conversation, and use LinkPoke to send the new values.
>

Take a look at this series of articles:
"DDE - What is It ?"
http://www.softwaretoolbox.com/tech_support/techexpertisecenter/objectsoftware/ddewhatisit/ddewha...

The link on the bottom to "DDE Servers vs. ActiveX Controls", while
not specific to your question, provides a good high level view of how
DDE works and why it may not be appropriate for your situation (or why
you may need to rearrange things if you have to use it).

-ralph

Larry Serflaten

3/18/2011 2:25:00 AM

0


"albertleng" <albertleng@gmail.com> wrote

> I'm working on a project for Lift System which I need to receive a
> continuous Lift message via RS232 and decode it and then, based on the
> decoded message, send value to
> a SCADA software. The lift data is sent to my program every 10~300 ms
> non-stop.
>
> In order not to put a heavy load on the SCADA software, i have
> implemented
> i) Only send change of value to SCADA software
> ii) have delay (sleep) after sending each lift status to SCADA
> software

Why did you think Sleep would help after sending DDE information?
Did you have some text somewhere indicating that should be used?
It seems odd to me that you would ask the system to transfer data
and then immediately become unresponsive for so many milliseconds....


> Private Sub SendDDE(txt As TextBox, value As String)
> On Error GoTo FixErr
> 360
> txtPcVue.LinkMode = vbLinkNone
> txtPcVue.LinkItem = txt.LinkItem
> txtPcVue.Text = value
> txtPcVue.LinkMode = vbLinkManual
> txtPcVue.LinkPoke

This is not the correct method of using DDE. It would be similar to
trying to have a conversation over the phone where, every time you
wanted to say something, you hang up, and dial their phone number.

It may be the cause of your problem.

Set up the LinkItem and LinkMode once when you want to start
the DDE conversation, and use LinkPoke to send the new values.

See if that helps.
LFS


ralph

3/18/2011 2:31:00 AM

0

On Thu, 17 Mar 2011 21:15:02 -0500, ralph <nt_consulting64@yahoo.net>
wrote:

ha, Clarification.

That response was obviously meant for the OP.
I agree with Larry.

-ralph