Simplicity Synergy X9 Specifications Page 183

  • Download
  • Add to my manuals
  • Print
  • Page
    / 352
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 182
Synergy Nano Technical Manual, Revision -
Page 183
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
Page view 182
1 2 ... 178 179 180 181 182 183 184 185 186 187 188 ... 351 352

Comments to this Manuals

No comments