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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
| Private Sub TextBox1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
If TextBox1.Text = "" Then
MsgBox("Please Re Enter Your Board Serial Number !")
TextBox1.Focus()
'leave control and switch to next operations
Exit Sub
End If
End If
TextBox1.Text = ""
Dim SN As String = TextBox1.Text
Try
'STEP1: ERROR SOC CHECK
Dim listFiles_Soc As FileInfo() = Dir1.GetFiles()
Dim listFiles_EMC As FileInfo() = Dir2.GetFiles()
Dim file1 As FileInfo
Dim file2 As FileInfo
Dim fileFound As Boolean = False
'check if the SN flashed corresponds to the right soc file
For Each file1 In listFiles_Soc
If file1.ToString.Contains(SN) Then
'move to the file and open it
Dim MyFile As Stream = File.OpenRead(rep1 + "\" + file1.ToString)
Dim MyLine As StreamReader = New StreamReader(MyFile, System.Text.Encoding.ASCII)
'Read the File Line by Line from the first to the end
MyLine.BaseStream.Seek(0, SeekOrigin.Begin)
'btest varible indique que l'erreur est non existante au prealable dans chaque ligne
Dim btest As Boolean = False
'.peek défini le caractère suivant, si =-1 alors c'est qu'il n'y a plus de caractère et la fin du fichier est donc atteinte
While MyLine.Peek() > -1
Dim rep As String = MyLine.Peek
Dim line As String = MyLine.ReadLine
soc_msg.Text = ""
'test if the line contains any error soc
If line.Contains(SOC_Erreur0) Then
btest = True
soc_msg.Text = +SOC_Erreur0 + vbNewLine
Panel1.BackColor = Color.Red
End If
'ERROR TYPE2
If line.Contains(SOC_Erreur00) Then
btest = True
soc_msg.Text = +SOC_Erreur00 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur01) Then
btest = True
soc_msg.Text += +SOC_Erreur01 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur02) Then
btest = True
soc_msg.Text += +SOC_Erreur02 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur03) Then
btest = True
soc_msg.Text += +SOC_Erreur03 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur04) Then
btest = True
soc_msg.Text += +SOC_Erreur04 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur05) Then
btest = True
soc_msg.Text += +SOC_Erreur05.ToString + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur06) Then
btest = True
soc_msg.Text += +SOC_Erreur06 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur07) Then
btest = True
soc_msg.Text += +SOC_Erreur07 + vbNewLine
Panel1.BackColor = Color.Red
End If
'ERROR TYPE 3:
If line.Contains(SOC_Erreur10) Then
btest = True
soc_msg.Text = +SOC_Erreur10 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur11) Then
btest = True
soc_msg.Text += +SOC_Erreur11 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur12) Then
btest = True
soc_msg.Text += +SOC_Erreur12 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur13) Then
btest = True
soc_msg.Text += +SOC_Erreur13 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur14) Then
btest = True
soc_msg.Text += +SOC_Erreur14 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur15) Then
btest = True
soc_msg.Text += +SOC_Erreur15 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur16) Then
btest = True
soc_msg.Text += +SOC_Erreur16 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur17) Then
btest = True
soc_msg.Text += +SOC_Erreur17 + vbNewLine
Panel1.BackColor = Color.Red
End If
'ERROR TYPE 4:
If line.Contains(SOC_Erreur20) Then
btest = True
soc_msg.Text = +SOC_Erreur20 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur21) Then
btest = True
soc_msg.Text += +SOC_Erreur21 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur22) Then
btest = True
soc_msg.Text += +SOC_Erreur22 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur23) Then
btest = True
soc_msg.Text += +SOC_Erreur23 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur24) Then
btest = True
soc_msg.Text += +SOC_Erreur24 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur25) Then
btest = True
soc_msg.Text += +SOC_Erreur25 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur26) Then
btest = True
soc_msg.Text += +SOC_Erreur26 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur27) Then
btest = True
soc_msg.Text += +SOC_Erreur27 + vbNewLine
Panel1.BackColor = Color.Red
End If
'ERROR TYPE5
If line.Contains(SOC_Erreur30) Then
btest = True
soc_msg.Text = +SOC_Erreur30 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur31) Then
btest = True
soc_msg.Text += +SOC_Erreur31 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur32) Then
btest = True
soc_msg.Text += +SOC_Erreur32 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur33) Then
btest = True
soc_msg.Text += +SOC_Erreur33 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur34) Then
btest = True
soc_msg.Text += +SOC_Erreur34 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur35) Then
btest = True
soc_msg.Text += +SOC_Erreur35 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur36) Then
btest = True
soc_msg.Text += +SOC_Erreur36 + vbNewLine
Panel1.BackColor = Color.Red
ElseIf line.Contains(SOC_Erreur37) Then
btest = True
soc_msg.Text += +SOC_Erreur37 + vbNewLine
Panel1.BackColor = Color.Red
End If
If Not btest Then
soc_msg.Text = "NO ERRORS FOUND"
Panel1.BackColor = Color.Lime
End If
End While
MyLine.Close()
MyFile.Close()
fileFound = True
End If
If Not fileFound Then
soc_msg.Text = "SOC Log File Not Found"
Panel1.BackColor = Color.Orange
End If
Next 'move to the repertory EMC
'check if the SN flashed corresponds to the right soc file
For Each file2 In listFiles_EMC
If file2.ToString.Contains(SN) Then
'move to the file and open it
Dim MyFile2 As Stream = File.OpenRead(rep2 + "\" + file2.ToString)
Dim MyLine2 As StreamReader = New StreamReader(MyFile2, System.Text.Encoding.ASCII)
MyLine2.BaseStream.Seek(0, SeekOrigin.Begin)
Dim btest As Boolean = False
fileFound = True
While MyLine2.Peek() > -1
Dim rep2 As String = MyLine2.Peek
Dim line2 As String = MyLine2.ReadLine
soc_msg.Text = ""
If line2.Contains(EMC_Erreur) Then
btest = True
emc_msg.Text = +EMC_Erreur
Panel2.BackColor = Color.Red
End If
If Not btest Then
emc_msg.Text = "NO ERROR FOUND "
Panel2.BackColor = Color.Lime
End If
End While
MyLine2.Close()
MyLine2.Close()
fileFound = True
End If
Next
If Not fileFound Then
emc_msg.Text = "EMC Log File Not FOUND"
Panel2.BackColor = Color.Orange
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub |
Partager