-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIOmsg.vb
157 lines (99 loc) · 4.34 KB
/
IOmsg.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
Option Strict Off
Option Explicit On
Imports System.Drawing
Imports System.Windows.Forms
Imports IODevices
Namespace IODeviceForms 'internal namespace
Friend Class IOmsgForm 'one form per device
Inherits System.Windows.Forms.Form
Private query As IOQuery 'set by calling thread
Public Sub showit(ByVal q As IOQuery) 'called by gpib thread
Dim cberr As Boolean = (q.status And 256) <> 0
If cberr Then q.status -= 256
query = q
Text = q.device.devname + " error"
msg1.ForeColor = Color.Red
lbl_retry.ForeColor = Color.Red
lbl_retry.Visible = True
'cmd_abort.Visible = False
If query.status > 0 Then
If (query.status And 2) = 0 Then 'bit 2 on send(0)/recv(1)
msg1.Text = "error while sending data to " + query.device.devname
Else
msg1.Text = "error while receiving data from " + query.device.devname
End If
'compose info:
txt.Text = ""
txt.Text &= "address: " & query.device.devaddr
txt.Text &= vbCrLf & "command: " & query.cmd
If (query.status And 4) > 0 Then
txt.Text &= vbCrLf & "interface returned error n°" & query.errcode.ToString
End If
txt.Text &= vbCrLf & query.errmsg
'if retry:
If query.task.retry Then
lbl_retry.Text = " retrying ..."
cmd_abort.Visible = True
Timer1.Enabled = True
Else
lbl_retry.Text = "IO operation abandoned"
cmd_abort.Visible = False
Timer1.Enabled = False
End If
ElseIf cberr Then
msg1.Text = query.device.devname + " : error in callback "
txt.Text = "unhandled exception in user callback function"
txt.Text &= vbCrLf & "command: " & query.cmd
txt.Text &= vbCrLf & query.errmsg
lbl_retry.Text = "IO operation completed"
cmd_abort.Visible = False
Timer1.Enabled = False
End If
Show()
End Sub
Private Sub cmd_abort_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmd_abort.Click
query.AbortRetry()
Close()
End Sub
Private Sub cmd_ok_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmd_ok.Click
Close()
End Sub
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
'make it blinking
If lbl_retry.Visible Then
lbl_retry.Visible = False
Else
lbl_retry.Visible = True
End If
Me.Show()
End Sub
Private Sub cmd_clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub cmd_abortall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_abortall.Click
query.AbortRetry() 'abort this (blocking or async)
query.AbortAll() 'abort all async commands in queue
Close()
'Hide()
End Sub
Private Sub IOmsgForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txt.Multiline = True
End Sub
Public Sub shutdownmsg(ByVal devname As String) 'called by iodevice when shutting down
Try
Text = devname
msg1.ForeColor = Color.Red
lbl_retry.Visible = False
cmd_abort.Visible = False
cmd_abortall.Visible = False
cmd_ok.Visible = False
msg1.Text = "shutting down " + devname + " ..."
Show()
WindowState = FormWindowState.Normal
BringToFront()
Catch ex As Exception
End Try
End Sub
Private Sub txt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt.TextChanged
End Sub
End Class
End Namespace