i did not understand his method
This is modified version of the idea MrPike suggested:
- Add a BasicLabel to the form
- Set its Name property to "CommLossBasicLabel"
- Set its AutoSize property to False
- Set its Size property to approximately (104, 18)
- Set its PLCAddressValue property to available integer register address, ex. 40001
- Add a timer to the form
- Set its Name property to "CommLossTimer"
- Set its Interval property to 500
Don't make any other changes to these 2 controls since you would be using them for comm loss indication only.
Then add either version of the following code, run the app and test it by disconnecting the slave:
Private Sub CommLossTimer_Tick(sender As Object, e As EventArgs) Handles CommLossTimer.Tick
If CommLossBasicLabel.BackColor = Color.Black Then
CommLossBasicLabel.BackColor = Color.Red
Else
CommLossBasicLabel.BackColor = Color.Black
End If
End Sub
Private Sub CommLossBasicLabel_TextChanged(sender As Object, e As EventArgs) Handles CommLossBasicLabel.TextChanged
If CommLossBasicLabel.Text = "BasicLabel" Then Exit Sub 'First Run
Dim dummy As Integer
If Integer.TryParse(CommLossBasicLabel.Text, dummy) Then
CommLossTimer.Enabled = False
CommLossBasicLabel.BackColor = Color.Black
Else
CommLossTimer.Enabled = True
CommLossBasicLabel.Value = "Disconnected"
End If
End Sub
Private Sub CommLossTimer_Tick(sender As Object, e As EventArgs) Handles CommLossTimer.Tick
CommLossBasicLabel.Highlight = Not CommLossBasicLabel.Highlight
End Sub
Private Sub CommLossBasicLabel_TextChanged(sender As Object, e As EventArgs) Handles CommLossBasicLabel.TextChanged
If CommLossBasicLabel.Text = "BasicLabel" Then Exit Sub 'First Run
Dim dummy As Integer
If Integer.TryParse(CommLossBasicLabel.Text, dummy) Then
CommLossTimer.Enabled = False
CommLossBasicLabel.Highlight = False
Else
CommLossTimer.Enabled = True
CommLossBasicLabel.Value = "Disconnected"
End If
End Sub
Your other suggestions don't appear to be viable options.