VEGA VEGASCAN 850 VEGA-ASCII signal output Manuale d'uso
Pagina 19

Uscita del segnale VEGA-ASCII VEGASCAN 850
19
Esempio di un programma di richiesta VEGASCAN 850
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
' Riunire tutti i caratteri
ReceiveBuffer = ReceiveBuffer + Rec
' Ricevere già un valore
p = InStr(ReceiveBuffer, Chr$(13))
If p > 0 Then
' -> Ritagliare un singolo valore
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
' Ritagliare valore numerico
PlsString = Mid$(SingleValue,
6)
' Considerare segno
oppure ' '
If Mid$(PlsString, 1, 1)=
" " Then
PlsString =
Mid$(PlsString, 2)
End If
' Se'.' nella stringa ->
rimuovere
p = InStr(PlsString, ".")
If p > 0 Then
PlsString =
Left$(PlsString, p - 1) +
Mid$(PlsString, p + 1)
End If
' Riconoscere fine
p = InStr(PlsString, "%")
If p > 0 Then
PlsString =
Left$(PlsString, p - 1)
End If
' Commutare il testo in cifre
PLS(idx) = CLng(PlsString)
End If
' Raggiunta la fine ?
If idx = (StartIndex + LenIndex)
- 1 Then
' Conteggio errori = 0
InAction = 0
' Indicare valori
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
' Loop su tutti i valori
For i = StartIndex To (StartIndex +
LenIndex) - 1
' Ampliare indicazione testo
Disp = "PLS " + Format$(i,
"000")
+ " = "
If Status(i) Then
Disp = Disp + Format$(PLS(i),
"000000000")
Else
Disp = Disp + "---"
End If
' Indicare
List1.AddItem Disp
Next i
End Sub
Public Sub ClearValues()
Dim i As Integer
' Cancellare tutte le informazioni di stato
For i = StartIndex To (StartIndex +
LenIndex) - 1
Status(i) = False
Next i
End Sub