Swing ActiveX Control
|
This chapter, let's make a mini-host to describe programming technique using SwingSecsI Control and SwingSecsII Control. We use Visual Basic for the development language.
|
Specification of mini-host
The specification of mini-host is as follows. Equipment that this mini-host can handle is a ordinary wafer inspection system.
- It is available to handle 'Attempt Online', 'Select Recipe', 'Start Process Program' and 'Measurement Data'.
-
Following messages can be sent:
S1F13W
S2F41W
S6F12
-
Following messages can be received:
S1F14
S2F42
S6F11W
- It is assumed that equipment has already been initialized and ready to use.
- Does not concern about Stream 9 and Function 0.
- Does not watch T3 time out.
|
Let's make a mini-host application
-
Make new project
Launch Visual Basic and select Standard EXE.
-
Insert Swing ActiveX Control
Select "Project" - "Components..." from the menu.
Check on "Swing ActiveX Control module", and then press OK button.
You will find that Swing ActiveX control has appeared in tool box.
-
Paste ActiveX Control
Paste SwingSecsI Control and SwingSecsII Control on the form. I recommend that you paste 2 SwingSecsII Controls for convenience, because you can treat incoming message and outgoing message separately.
In addition, buttons and textbox are put properly (see above). Also buttons can be array for better code.
I don't want to enforce you my programming style. These are all up to you and you can arrange by yourselves.
-
Open serial port
When you open serial port, let's write code in FormLoad Event. You can be ready to communicate right after the application comes up.
.Active = True
If Not .Active Then
MsgBox "Error : Cannot open serial port!"
End If
This is a tiny sample code. I recommend that you put "Open" button and press it to open serial port, if you develop your system application. Sometimes it can not be opened properly, sometimes customer may not want to open from the beginning.
-
Send 'Attempt Online' message
If you send 'Attempt online' command, use Send Method in button pressed event handler function. We are going to use arrayed SwingSecsII Control indexed by 0 for incoming message and 1 for outgoing message. If mini-host sends S1F13 to equipment, that must be empty list.
.List = "s1f13w{}"
SwingSecsI1.Send .Msg
Send Method in SwingSecsI Control requires Msg Property of SwingSecsII Control.
-
Send 'Select Recipe' command
To specify recipe, send PP-SELECT of S2F41.
.List = "s2f41w{<a'PP-SELECT'>{{<a'PPID'><a'" + Text1.Text + "'>}}}"
SwingSecsI1.Send .Msg
-
Start measurement
To start measurement, send START of S2F41.
.List = "s2f41w{<A'START'>{{}}}"
SwingSecsI1.Send .Msg
-
Catch events from equipment
When you receive a message, it is reported as Read Event. At the very beginning of this event handler procedure, set received message to SwingSecsII Control. Doing so will allow you to browse other properties.
.Msg = pszMsg
You will receive S6F11 from equipment. We handle only following CEIDs.
10 | Recipe selected. |
11 | Recipe selection failure. |
20 | Measurement completed. |
30 | Measurement data. |
CEID is located at node '2'. First, we check this value, then do appropriate procedure.
'CEID .Pointer = "2"
Select Case CInt(.Value)
Case 10
MsgBox "Recipe selected."
Case 11
MsgBox "Recipe selection failure."
Case 20
MsgBox "Measurement completed."
Case 30
'Measurement data.
End Select
S6F11 is expecting for reply, so send binary 0 for secondary message.
.List = "s6f12<b 0>"
.Reply pszMsg
SwingSecsI1.Send .Msg
Besides this, you will receive S1F14 and S2F42, you can write the same kind of code.
-
Run application
Making mini-host has been completed. This is very simple but still has a minimum functionality as a host system. But entire source code is as short as 55 lines. It is very clear that it is more easier to develop software using Swing ActiveX control than without using it, if you write same kind of software from the beginning.
Option Explicit
Private Sub Command1_Click(Index As Integer)
With SwingSecsII1(1)
Select Case Index
Case 0
'Attempt online
.List = "s1f13w{}"
Case 1
'Select recipe
.List = "s2f41w{<a'PP-SELECT'>{{<a'PPID'><a'" + Text1.Text + "'>}}}"
Case 2
'Start measurement
.List = "s2f41w{<a'START'>{{}}}"
End Select
SwingSecsI1.Send .Msg
End With
End Sub
Private Sub Form_Load()
With SwingSecsI1
.Active = True
If Not .Active Then
MsgBox "Error : Cannot open serial port!"
End If
End With
End Sub
Private Sub SwingSecsI1_Read(ByVal pszMsg As String)
With SwingSecsII1(0)
.Msg = pszMsg
If .Stream = 1 And .Function = 14 Then
'S1F14
MsgBox "You are online"
End If
If .Stream = 6 And .Function = 11 Then
'S6F11
SwingSecsII1(1).List = "s6f12<b 0>"
SwingSecsII1(1).Reply pszMsg
SwingSecsI1.Send SwingSecsII1(1).Msg
'CEID
.Pointer = "2"
Select Case CInt(.Value)
Case 10
MsgBox "Recipe selected"
Case 11
MsgBox "Recipe selection failure"
Case 20
MsgBox "Measurement completed"
Case 30
'Measurement data
End Select
End If
End With
End Sub
|
|