1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
Function cipSYNOPTIC_Update() As Boolean
Dim myDevices() As Label = cipSYNOPTIC_ListControls()
Dim DNSconnexion As Boolean = False
Dim myTimeoutTime As Integer = 0
Dim nbrTest As Integer = 0
' Vérification du mode de connexion (IP ou DNS)
If IPCheckBox.Checked Then
' Mode IP
If ((CInt(IPNumber.Text) > 0) And (CInt(IPNumber.Text) < 256)) Then
DNSconnexion = False
End If
Else
' Mode DNS
DNSconnexion = True
End If
' Initialisation du Timeout
If My.Settings.CIP_TimeoutTime < OPTIONS_CIP_DEFAULT_TIME Then
myTimeoutTime = OPTIONS_CIP_DEFAULT_TIME
Else
myTimeoutTime = My.Settings.CIP_TimeoutTime
End If
' Initialisation du nombre de tests à effectuer
If My.Settings.CIP_TimeoutTest > 0 Then
nbrTest = My.Settings.CIP_TimeoutTest
Else
nbrTest = OPTIONS_CIP_DEFAULT_TEST
End If
PingBox(String.Format(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_TIMEOUT_VALUE, myTimeoutTime), 0, StatusRichTextBox)
PingBox(String.Format(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_TESTS_VALUE, nbrTest), 0, StatusRichTextBox)
' ***** PING DE CHAQUE EQUIPEMENT *****
Dim Ping As New Ping
Dim PingReply As PingReply
Dim CurrentAddress As String = Nothing
Dim myEquipment As String = Nothing
' Vérification qu'une demande d'arrêt n'est pas demandée
If Not StopPing Then
' Boucle pour chaque équipement
For Each Device As Label In myDevices
' Si la valeur n'est pas nulle
If Device IsNot Nothing Then
' Récupération des informations de connexion de l'équipement
myEquipment = cipSYNOPTIC_DeviceAddress(CType(Device.Tag, String()), DNSconnexion)
If myEquipment IsNot Nothing Then
CurrentAddress = myEquipment
If Not DNSconnexion Then
CurrentAddress = CIP_DEVICE_STATUS_IP_ADDRESS & IPNumber.Value & "." & CurrentAddress
End If
For PingTest As Integer = 0 To nbrTest - 1
Try
PingBox(String.Format(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_PING_SEND, PingTest + 1, nbrTest, CurrentAddress), 1, StatusRichTextBox)
PingReply = Ping.Send(CurrentAddress, myTimeoutTime)
Try
If PingReply.Status = IPStatus.Success Then
PingBox(String.Format(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_PING_REPLY_OK, CurrentAddress, PingReply.RoundtripTime), 1, StatusRichTextBox)
Device.BackColor = CIP_DEVICE_STATUS_ACTIVE_DEVICE
Exit For
Else
If nbrTest = (PingTest + 1) Then
PingBox(String.Format(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_PING_REPLY_ERROR_A & vbCrLf & PingReply.Status.ToString, CurrentAddress), 3, StatusRichTextBox)
Device.BackColor = CIP_DEVICE_STATUS_ERROR_DEVICE
End If
End If
Catch ex As Exception
If nbrTest = (PingTest + 1) Then
PingBox(String.Format(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_PING_REPLY_ERROR_B & vbCrLf & ex.Message, CurrentAddress), 3, StatusRichTextBox)
Device.BackColor = CIP_DEVICE_STATUS_ERROR_DEVICE
End If
End Try
Catch pingEx As PingException
If nbrTest = (PingTest + 1) Then
PingBox(String.Format(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_PING_REPLY_ERROR_C & vbCrLf & pingEx.Message, CurrentAddress), 3, StatusRichTextBox)
Device.BackColor = CIP_DEVICE_STATUS_ERROR_DEVICE
End If
End Try
If StopPing Then
Exit For
End If
Next
If StopPing Then
Exit For
End If
End If
End If
Next
End If
PingBox(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_SYNOPTIC_ENDING, 0, StatusRichTextBox)
' Mise en forme du bouton
With PingButton
.Text = LANG_CIPMAINFORM_CONNEXION_START_BUTTON_TEXT
.Image = My.Resources.train_network_icon_32
End With
' Désactivation des autres contrôles
IPCheckBox.Enabled = True
IPNumber.Enabled = IPCheckBox.Checked
PingBox(LANG_CIP_MAINFRAME_PINGBOX_MESSAGES_SYNOPTIC_STOPPED, 0, StatusRichTextBox)
Return True
End Function |
Partager