VEGA VEGASCAN 850 VEGA-ASCII signal output Manuel d'utilisation
Page 19

Sortie signal VEGA-ASCII VEGASCAN 850
19
Exemple de programme pour la requête VEGASCAN 850
InAction = InAction - 1
' ? Grenze erreicht
If InAction = 0 Then
' Werte anzeigen
DisplayValues
End If
End If
End Sub
Private Sub DecodeFrame(Rec As String)
Dim idx As Integer
Dim Value As Long
Dim PlsString As String
Dim SingleValue As String
Dim p As Integer
' Alle characters aufsammeln
ReceiveBuffer = ReceiveBuffer + Rec
' Schon 1 Wert empfangen
p = InStr(ReceiveBuffer, Chr$(13))
If p > 0 Then
' -> Einzelnen Wert ausschneiden
SingleValue = Left$(ReceiveBuffer, p -
1)
ReceiveBuffer = Mid$(ReceiveBuffer, p +
1)
Else
SingleValue = ""
End If
If Len(SingleValue) > 9 Then
' Frame pruefen
' =001#FAULTCR
' =001#- 100.1CR
If Left(SingleValue, 1) = "=" Then
If Mid$(SingleValue, 5, 1) = "#"Then
idx = Val(Mid$(SingleValue, 2,3))
If Mid$(SingleValue, 9, 1) > "9"
Then
Status(idx) = False
Else
Status(idx) = True
' Zahlenwert ausschneiden
PlsString = Mid$(SingleValue,
6)
' Vorzeichen or ' '
beachten
If Mid$(PlsString, 1, 1) =
" " Then
PlsString =
Mid$(PlsString, 2)
End If
' Wenn '.' im Telegramm ->
entfernen
p = InStr(PlsString, ".")
If p > 0 Then
PlsString =
Left$(PlsString, p - 1) +
Mid$(PlsString, p + 1)
End If
' Ende erkennen
p = InStr(PlsString, "%")
If p > 0 Then
PlsString =
Left$(PlsString, p - 1)
End If
' Text in Zahl wandeln
PLS(idx) = CLng(PlsString)
End If
' Ende erreicht ?
If idx = (StartIndex + LenIndex)
- 1 Then
' Fehlerzaehler = 0
InAction = 0
' Werte Anzeigen
DisplayValues
End If
End If
End If
End If
End Sub
Public Sub DisplayValues()
Dim i As Integer
Dim Disp As String
' Anzeige loeschen
List1.Clear
' Schleife ueber alle Werte
For i = StartIndex To (StartIndex +
LenIndex) - 1
' Anzeige Text aufbereiten
Disp = "PLS " + Format$(i, "000")
+ " = "
If Status(i) Then
Disp = Disp + Format$(PLS(i),
"000000000")
Else
Disp = Disp + "---"
End If
' Anzeigen
List1.AddItem Disp
Next i
End Sub
Public Sub ClearValues()
Dim i As Integer
' Alle Statusinformation loeschen
For i = StartIndex To (StartIndex +
LenIndex) - 1
Status(i) = False
Next i
End Sub