
Synergy Controller Technical Manual, Revision H
Page 284
Visual Basic Code: Receiving
Receiving with Serial Ports
‘ MSComm1 is the name of the Microsoft Comm component
Private Sub MSComm1_OnComm(Index As Integer)
Select Case MSComm1(Index).CommEvent
Case comEvSend
' SThreshold # of characters in transmit buffer.
Case comEvEOF
' An EOF character was found in the input stream
Case comEvReceive
‘ Received RThreshold # of chars
‘ Receive the data and write the result in the response text box
txtIn(Index).Text = txtIn(Index) & MSComm1(Index).Input
End Select
End Sub
Receiving with GPIB
' The GPIB control has no receive event, it must be queried for a response.
’ timerGPIB counts down from 2 to 0, decrementing in the Timer1 function.
‘ Timer1 fires every 250 milliseconds This allows us to check for a response 4 times a second.
timerGPIB = 2
GPIBResult = "" 'tracks GPIB reply - see Timer1 function
' While loop will exit after receives a reply or times out - see Timer1 function
While timerGPIB > 0
DoEvents
Wend
‘ If we don’t receive a reply in 1 second, time out
If GPIBResult = "" Then 'no reply
txtIn(Index).Text = "Timeout: " & TMWControl1.TimeOut/1000 & "seconds."
Else ‘ Write the reply to the response text box
txtIn(Index).Text = GPIBResult 'GPIB value
End If
‘--- Timer1 function: fires every 250 ms ---
‘ Timer1 queries 4 times per second and jumps out of while loop once every 1 second
If timerGPIB > 0 Then
' Check for a response to the previous Send query
TMWControl1.Enter result$
' If we receive a result we break the previous Do Events loop
If result$ <> "" Then
‘Set global variable to response value
GPIBResult = result$
timerGPIB = 0
‘ Breaks out of previous While loop and records response
Else
' Increment timerGPIB
timerGPIB = timerGPIB – 1
End If
End If
Receiving with TCP/IP
‘ tcpClient1 is the name of the Microsoft TCP Client component
Private Sub tcpClient1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
' Get data
tcpClient1.GetData strData
‘ Write the response in the response test box
txtIn(3).Text = Replace(strData, vbCrLf, "", 1, -1, vbBinaryCompare)
End Sub
Summary of Contents for Synergy Compact
Page 14: ...Synergy Controller Technical Manual Revision H Page 14 2 0 SPECIFICATIONS 2 1 Data Sheet...
Page 71: ...Synergy Controller Technical Manual Revision H Page 71...
Page 106: ...Synergy Controller Technical Manual Revision H Page 106...
Page 123: ...Synergy Controller Technical Manual Revision H Page 123...
Page 141: ...Synergy Controller Technical Manual Revision H Page 141 TE1151 6 Triac Output Board Schematic...
Page 142: ...Synergy Controller Technical Manual Revision H Page 142 TE1708 6 Relay Board Schematic...
Page 188: ...Synergy Controller Technical Manual Revision H Page 188...
Page 274: ...Synergy Controller Technical Manual Revision H Page 274 Synergy Controller Step Syntax...
Page 294: ...Synergy Controller Technical Manual Revision H Page 294...
Page 312: ...Synergy Controller Technical Manual Revision H Page 312...
Page 345: ...Synergy Controller Technical Manual Revision H Page 345...
Page 346: ...Synergy Controller Technical Manual Revision H Page 346...