Actuellement je développe une application pour un analyseur de spectre mais plusieurs fonction ne marche pas,je programme en C# avec la bonne Dll mais je n'est pas d'exemple de dialogue avec l'analyseur de spectre il n'y a que des exemple en VB6 et je n'est jamais programmer avec alors si vous pouviez me donner le code en C# de ces exemples voila ça me serais très utile.
En vous remercient.
Programming Examples
The following examples are code snippets in Visual Basic (VB6).
Initialize Communication with R&S FSH
Public Function FSHInit(ByVal Port As Integer, ByVal Speed As Long,
Optional ByVal ErrorCode As String) As Boolean
Rem Initialize communication with FSH
Rem Return TRUE if device initialization was successful
Rem Return FALSE otherwise e.g. the device was not found
With MainForm.FSHCommC
.CommPort = Port
.Settings = Trim$(Str$(Speed)) + ",N,8,1"
.InBufferSize = 1000
.PortOpen = True
.InBufferCount = 0
End With
InBuffer = vbNullString
End Function
`-------------------------------------------
Poll R&S FSH until <cr> received
Public Function PollFSH() As String
Dim CrPos As Long
With MainForm.FSHCommC
Do
InBuffer = InBuffer + .Input
DoEvents
CrPos = InStr(1, InBuffer, vbCr)
Loop Until CrPos > 0
PollFSH = Left$(InBuffer, CrPos - 1)
InBuffer = Mid$(InBuffer, CrPos + 1)
End With
End Function
`-------------------------------------------
Send CMD Command to R&S FSH
Public Function FSHCmd(ByVal Command As String) As Boolean
Dim TempError As Integer
InBuffer = vbNullString
FSHCmd = False
With MainForm.FSHCommC
.Output = "cmd" + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
.Output = Command + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
FSHCmd = True
Else
DebugMsg "CMD error" + Str(TempError) + " for command <" + Command + ">"
End If
Else
DebugMsg "CMD error" + Str(TempError) + " for command <" + Command + ">"
End If
End With
End Function
`-------------------------------------------
R&S FSH-K1 Programming Examples
1157.3564.12 83 E-10
Send SET Command to R&S FSH
Public Function FSHSet(ByVal Command As String) As Boolean
Dim TempError As Integer
InBuffer = vbNullString
FSHSet = False
With MainForm.FSHCommC
.Output = "set" + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
.Output = Command + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
FSHSet = True
Else
ErrorMsg "SET error" + Str(TempError) + " for command <" + Command + ">"
End If
Else
ErrorMsg "SET error" + Str(TempError) + " for command <" + Command + ">"
End If
End With
End Function
`-------------------------------------------
Send GET Command to R&S FSH and Read Response
Public Function FSHGet(ByVal Command As String, ByRef Buffer As String) As Boolean
Dim TempError As Integer
InBuffer = vbNullString
FSHGet = False
With MainForm.FSHCommC
.Output = "get" + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
.Output = Command + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
Sleep 50
Buffer = PollFSH
FSHGet = True
Else
ErrorMsg "GET error" + Str(TempError) + " for command <" + Command + ">"
End If
Else
ErrorMsg "GET error" + Str(TempError) + " for command <" + Command + ">"
End If
End With
End Function
`-------------------------------------------
Example: Program Instrument Setup
Private Sub FSHSetup ()
Dim Buffer As String
FSHCmd "REMOTE" ` Set FSH to Remote State
FSHGet "IDN?", Buffer ` Query instrument ID
FSHCmd "PRESET" ` Preset FSH settings
FSHSet "FREQ,950E6" ` Set Center Frequency to 950 MHz
FSHSet "SPAN,5E6" ` Set Span to 5 MHz
FSHCmd "LOCAL" ` Return to Local Mode
End Sub
`-------------------------------------------
Programming Examples R&S FSH-K1
1157.3564.12 84 E-10
Read Binary Trace Data from R&S FSH
Public Function FSHGetTraceBin(ByRef Values() As Long) As Boolean
Dim InBuffer As String
Dim TempError As Integer
InBuffer = vbNullString
FSHGetTraceBin = False
With MainForm.FSHCommC
.Output = "GET" + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
.Output = "TRACEBIN" + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
InBuffer = PollFSHBin(1205) ` 4 x 301 bins with 4 bytes
AsString.Buffer = StrConv(InBuffer, vbFromUnicode)
LSet AsValues = AsString
Values = AsValues.SValues
ReDim Preserve Values(0 To 300)
FSHGetTraceBin = True
Else
ErrorMsg "GET error" + Str(TempError) + " for command <TRACEBIN>"
End If
Else
ErrorMsg "GET error" + Str(TempError) + " for command <TRACEBIN>"
End If
End With
End Function
`-------------------------------------------
Poll Input Buffer until Number of Bytes are Received
Public Function PollFSHBin(ByVal BufferLen As Long) As String
Dim CrPos As Long
With MainForm.FSHCommC
Do
InBuffer = InBuffer + .Input
DoEvents
DebugMsg "BIN-BUFFER-LEN: " + Str(Len(InBuffer))
Loop Until Len(InBuffer) >= BufferLen
PollFSHBin = Left$(InBuffer, BufferLen)
InBuffer = Mid$(InBuffer, BufferLen + 1)
End With
End Function