
Lift System - No foreign application responded to a DDE initiate (Error 282)
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