This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmErrorDialog.vb
229 lines (207 loc) · 8.8 KB
/
frmErrorDialog.vb
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
Option Strict Off
Option Explicit On
Friend Class frmErrorDialog
Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
Public Sub New()
MyBase.New()
If m_vb6FormDefInstance Is Nothing Then
If m_InitializingDefInstance Then
m_vb6FormDefInstance = Me
Else
Try
'For the start-up form, the first instance created is the default instance.
If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
m_vb6FormDefInstance = Me
End If
Catch
End Try
End If
End If
'This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
If Disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(Disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
Public ToolTip1 As System.Windows.Forms.ToolTip
Public WithEvents cmdOK As System.Windows.Forms.Button
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents rtbErrorText As System.Windows.Forms.RichTextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.cmdOK = New System.Windows.Forms.Button
Me.rtbErrorText = New System.Windows.Forms.RichTextBox
Me.SuspendLayout()
'
'cmdOK
'
Me.cmdOK.BackColor = System.Drawing.SystemColors.Control
Me.cmdOK.Cursor = System.Windows.Forms.Cursors.Default
Me.cmdOK.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdOK.ForeColor = System.Drawing.SystemColors.ControlText
Me.cmdOK.Location = New System.Drawing.Point(198, 212)
Me.cmdOK.Name = "cmdOK"
Me.cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.cmdOK.Size = New System.Drawing.Size(99, 35)
Me.cmdOK.TabIndex = 1
Me.cmdOK.Text = "OK"
'
'rtbErrorText
'
Me.rtbErrorText.Location = New System.Drawing.Point(16, 16)
Me.rtbErrorText.Name = "rtbErrorText"
Me.rtbErrorText.ReadOnly = True
Me.rtbErrorText.Size = New System.Drawing.Size(456, 184)
Me.rtbErrorText.TabIndex = 2
Me.rtbErrorText.Text = ""
'
'frmErrorDialog
'
Me.AcceptButton = Me.cmdOK
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(485, 278)
Me.Controls.Add(Me.rtbErrorText)
Me.Controls.Add(Me.cmdOK)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Location = New System.Drawing.Point(227, 244)
Me.Name = "frmErrorDialog"
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "TxSL Error"
Me.ResumeLayout(False)
End Sub
#End Region
#Region "Upgrade Support "
Private Shared m_vb6FormDefInstance As frmErrorDialog
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As frmErrorDialog
Get
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New frmErrorDialog()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set
m_vb6FormDefInstance = Value
End Set
End Property
#End Region
'*****************************************************************************
'file: frmErrorDialog.frm
'file: frmErrorDialog.frx
'
'These files support the identification and display of TxSL generated errors,
'and of errors that are generated and trapped by the VB process.
'Note that most TxSL errors will be identified via dialog boxes that
'are owned by the TxSL process, and will not be directly visible to the VB process.
'The most common errors generated by the VB
'process associated with reading bar codes, and are generated by
'the HandleBarCode sub of frmMain.
'The following code sample shows how error handling would most likely
'be implemented.
'Public Sub cmdRun_Click() 'TxSLErrorTrapSite
'On Error GoTo LocalErrorHandler
'LocalSource = ":" + Me.Name + ":cmdRun_Click " 'Used to track where the error happened
''Got here by someone pressing the run key on the operator interface, or
''possible by a hardware button has been pressed. The event sub for the
''hardware button would have called this sub.
'
''Check to make sure that we are in a state that can accept a run command.
''This means that we are NOT "no testplan", or NOT "Running"
'
'TxSLState = TestExecSL1.Testplan.State
'Select Case TxSLState
' Case TestplanState.NoTestplan, TestplanState.TestplanRunning
' Beep
' Exit Sub
' Case Else
' 'continue
'End Select
'
'ConfigButtonsAfterRun
'TestExecSL1.Testplan.Run
'
'Exit Sub
'LocalErrorHandler:
' frmErrorDialog.ErrorHandler Err.Number, Err.Source + LocalSource, Err.Description
'End Sub
'*****************************************************************************
Dim NewErrorDialog As frmErrorDialog
Private S1 As String
Private S2 As String
Private S3 As String
Private S4 As String
Private S5 As String
Private S6 As String
Private S7 As String
Private S8 As String
Private Const TxSLErrorStart As Integer = 45000
Private Const OpuiErrorOffset As Integer = 100
Private Const TxSLErrorEnd As Integer = 46000
Public ErrorCount As Short
'A list of errors that could get generated by the operator interface.
Public Enum TxSLOpuiError
NoIoSession = TxSLErrorStart + OpuiErrorOffset + 1
ScannerNotInitialized = TxSLErrorStart + OpuiErrorOffset + 2
EmptyBarCode = TxSLErrorStart + OpuiErrorOffset + 3
UnRecognizedBarCode = TxSLErrorStart + OpuiErrorOffset + 4
ImproperBarCodeLength = TxSLErrorStart + OpuiErrorOffset + 5
ImproperState = TxSLErrorStart + OpuiErrorOffset + 6
InvalidMinMaxValuesForTpmArrays = TxSLErrorStart + OpuiErrorOffset + 7
TestplanUutCountGreaterThanOperatorInterfaceCapability = TxSLErrorStart + OpuiErrorOffset + 8
EmptyTestplanRegistry = TxSLErrorStart + OpuiErrorOffset + 9
TooLongBarcode = TxSLErrorStart + OpuiErrorOffset + 10
End Enum
Private Function TxSLError(ByRef ErrorNumber As Integer) As Boolean
'A simple function that determines if the error is owned by TxSL.
If ErrorNumber >= TxSLErrorStart And ErrorNumber <= TxSLErrorEnd Then
TxSLError = True
Else
TxSLError = False
End If
End Function
Public Sub ErrorHandler(ByRef ErrorNumber As Integer, ByRef LocalSource As String, ByRef ErrorDescription As String)
If TxSLError(ErrorNumber) Then
S1 = "HP TxSL Error"
S2 = "An error was either detected by the TxSL control or detected by error handling in this application." & " Execution continues if possible. If the error was generated during execution of a testplan, the test system may have been left in a powered and potentially dangerous state."
S3 = "The following information is known about the error:"
S4 = "Number: " & ErrorNumber
S5 = "Description: " & ErrorDescription
S6 = "First Detected: " & LocalSource
S8 = "Press OK to exit from this dialog"
'Construct the big prompt string, out of all the component parts.
S7 = S2 & vbCrLf & vbCrLf & S3 & vbCrLf & vbCrLf & S4 & vbCrLf & S5 & vbCrLf & S6 & vbCrLf & vbCrLf & vbCrLf & S8
NewErrorDialog = New frmErrorDialog
frmMain.rtbViewErrors.Visible = True
frmMain.rtbViewErrors.Text = LangLookup((modLocalization.txslLangIndex.gnerror))
NewErrorDialog.Text = S1
NewErrorDialog.rtbErrorText.Text = S7
VB6.ShowForm(NewErrorDialog, VB6.FormShowConstants.Modeless, frmMain.DefInstance) 'This form needs to be shown modeless
NewErrorDialog.cmdOK.Focus() 'we can't set the focus before we show it
Me.ErrorCount = Me.ErrorCount + 1
Else 'If it wasn't a recognized error, simply rebroadcast it
Err.Raise(Err.Number, Err.Source & LocalSource, Err.Description & vbCrLf & "First Detected at: " & LocalSource)
End If
End Sub
Private Sub cmdOK_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdOK.Click
frmMain.rtbViewErrors.Visible = False
Me.ErrorCount = Me.ErrorCount - 1
Me.Close()
End Sub
End Class