Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 23 of 28

HawkEye 1500 Series Reference & Programmers Manual, pages 221 to 230

Pages 221 to 230 of 276

The original document is the PDF (1.3 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

Filed in the catalog under the Microscan HE1510, RVSI CiMatrix HE1510 and Siemens HE1510

Page 221

Important Objects

–

•

Provides general message broadcasting. The “magic glue” property of the MiCoordinator also can come in handy for applications that simply want to send a general message to other MiCoordinator users. Calling the BroadcastMessage method allows you to send a message string to all other MiCoordinator users, who will receive it via the OnBroadcastMessage event.

MiASCIIConnection, MiImageConnection, and MiReportConnection, These objects represent low-level connections to a device. The MiASCIIConnection permits sending and receiving ASCII characters to/from a device, and is the only type of connection possible via a serial port. Using a MiASCIIConnection, images and reports are transferred using the XMODEM protocol. The MiImageConnection and MiReportConnection objects are for transferring images and reports using TCP over Ethernet. Note: We recommended that you not use these connection objects directly, as they are wrapped within the easier to use connection objects described next.

•

Rev 2.4.1, Nov 2008

ImageConnection, ReportConnection, These objects wrap the low-level connections described above and make custom programming much easier. Most custom applications will start by declaring one or both of these objects. Each combines a MiASCIIConnection (to send/receive ASCII data such as commands), a MiCoordinator (so a connection can be established automatically to the focus device), and either a MiImageConnection or a MiReportConnection. It also abstracts the differences between serial and TCP based connections by using an ASCII protocol to transmit images over a serial port, and TCP if an Ethernet connection is available. It also provides some convenient properties to test the connection, such as IsConnected, IsSerial, etc. The lower level connections are also available as properties. Many of the events from the contained MiConnections, MiCoordinator, and the focus device, are reflected to the user. It is also possible to disable the auto-connect behavior of these controls.

HawkEye 1500 Reference & Programmers Manual

2-3

2 ReadRunner Programming of the MiCoordinator. This, in turn, will cause the OnDeviceFocus message to be sent to every other MiCoordinator object within the same process. Note that this does not actually make a connection. However, the ImageConnection and ReportConnection objects, as well as some of the user interface objects, use a MiCoordinator and make their connections as a result of receiving the OnDeviceFocus event.

Page 222

Chapter

2-4

2

ReadRunner Programming Reference

•

MiCycleReport, After a connection is established, an OnNewRecord event is sent each time new data (image or report) is available. The parameter provided in this event is a MiCycleReport object. The same data type is provided in both image and report cases except that reports have an empty field for the image. There is a great deal of data provided in each MiCycleReport, including counters, pass/fail status, decoded data, timing information, photometry data, ROI data, etc.

•

MiImageView, This control permits an easy way to view images contained in a MiCycleReport. It has options to display the decoded data and ROI as an overlay on the image. Multiple images can be displayed by enabling the Filmstrip Mode property. There is also the ability to overlay custom graphics and, in fact, you can even create and overlay custom draggable user interface objects with handles, such as an ROI.

•

ReportGrid, A control that displays most of the data contained in a MiCycleReport in a spreadsheet format. You place this control directly on a form and then call its NewRecord method when you receive the OnNewRecord event from a connection.

•

ReportChart, A control that displays timing and trend data from the MiCycleReport. You place this control directly on a form and then call its NewRecord method when you receive the OnNewRecord event from a connection.

•

Terminal, This control automatically connects to the focus device and permits sending ASCII commands, much like a dumb terminal. It provides programmable buttons that can send automatically a series of commands when pressed.

•

Application, AppSetting, Sending commands to a HawkEye™ 1500 is very straightforward simply by using the CommandSend method of an ImageConnection or ReportConnection. To query the state of most settings, you can send a command followed by a “?”. Often, it is the case that you might desire to query the state of a setting, change one thing (such as photometry gain while leaving the exposure alone) and send the command back with the change. You can use the Application object to make this logic easier to manage. The Application object provides methods for querying a setting and accessing the parameters individually. It is capable of querying any number of settings. When you write the settings back, only the settings that has actually changed will be written.

HawkEye 1500 Reference & Programmers Manual

Rev 2.4.1, Nov

Page 223

Example 1, A Simple Monitoring Application

Example 1, A Simple Monitoring Application •

Scan the network and enumerate all found HawkEye™ 1500s in a dropdown box.

•

Establish an image connection to the camera selected in the dropdown.

•

Draw each image as received from the camera.

This application can be “written” by writing no code at all. Although the sample project is included, it’s worth the 3 minutes or less to walk through this example manually. 1.

Open Visual Basic and create a new “Standard EXE” project.

2.

Select Project->Components… and check the Microscan ReadRunner ActiveX Library (RRKIT.OCX). Notice the new component icons that appear in the component toolbar.

3.

Select the CameraDropdown form.

4.

Select the ImageView form.

component and place across the top of the component and size to occupy the rest of the

CameraDropdown

ImageView

5.

Rev 2.4.1, Nov 2008

You’re done. You can now run the application.

HawkEye 1500 Reference & Programmers Manual

2-5

2 ReadRunner Programming

Here’s an application that has an apparently challenging set of goals:

Page 224

Chapter

2

ReadRunner Programming Reference

How This Works The two components used in this application, CameraDropdown and ImageView, both use the MiCoordinator object. The CameraDropdown control first clears the Device List in the MiCoordinator, and then handles the OnDeviceDiscovered event, filling up the dropdown for each newly discovered camera on the network. When a device is selected via the dropdown, the DeviceFocusSet method is called with the name of the chosen device. The ImageView control uses an ImageConnection, which will establish automatically a connection as a response to the Device Focus being set. Once the connection is established, each image will be received via the ImageConnection.OnNewRecord event. The MiCycleReport provided in this event is then passed to the MiImageView.NewRecord method, which will display the image and any overlay graphics.

Taking This Example Further It is instructive to add some other controls to the current example.

2-6

1.

Expand the dimensions of the form as much as possible to allow other controls to be placed on it.

2.

Select the Cameras

3.

Select the Report Toolbar

4.

Select the Terminal control and position along the bottom of the form. and place on the form.

control and place on the form.

HawkEye 1500 Reference & Programmers Manual

Rev 2.4.1, Nov

Page 225

Example 1, A Simple Monitoring Application

Terminal Control

2 ReadRunner Programming

Report Toolbar

Terminal

Cameras

5.

You’re done. You may now run the application. You can send commands to the selected unit via the Terminal. The Cameras spreadsheet control shows detailed status of cameras on the network. The Report Toolbar shows some basic counters.

Summary This example illustrates some of the power behind the ReadRunner development environment. Impressive capability is possible without even writing a line of code.

Rev 2.4.1, Nov 2008

HawkEye 1500 Reference & Programmers Manual

2-7

Page 226

Chapter

2

ReadRunner Programming Reference

Example 2, Handling Images and Reports In most cases, it is likely that the data coming from a connection to a HawkEye™ 1500 will need to be manipulated in some way, perhaps simply to note pass/fail status, or perhaps to log data or images to a file. In this event, we will need to take control over some of the automatic functionality illustrated by the previous example. Even so, the programming is not at all difficult. The goals of this example are: •

Establish two connections to an HawkEye™ 1500, one for images and one for reports.

•

Update a text label with the decode string, and change the background color of the label to green for decode pass and red for decode fail.

•

Update a displayed image – but only show failures.

This time, we will be using all three libraries. Again, although the sample code is included, it is worth the time to work through this example from scratch. 1.

Create a new “Standard EXE” project.

2.

Select Project->References… and check the Microscan HawkEye™ Reader Object Type Library (MIOBJ.DLL).

3.

Select Project->Components… and check BOTH the Microscan ReadRunner ActiveX Library (RRKIT.OCX) and the Microscan HawkEye™ Reader ActiveX Library (MIOBJUI.DLL). Notice the new component icons that appear in the component toolbar.

4.

Select the CameraDropdown form.

5.

Select a standard Label control and place on the form. In the VB properties window, change the BorderStyle for Label1 to “Fixed Single”.

6.

Select the MiImageView component and place across the top of the component and position on the form.

Note: This is NOT the same as the ImageView component we used in the previous example. Here’s how the form should look:

2-8

HawkEye 1500 Reference & Programmers Manual

Rev 2.4.1, Nov

Page 227

Example 2, Handling Images and Reports

ReadRunner Programming

2

7.

Now, we’re going to have to write some code. Go to the Code window for Form1 (View->Code, or double click on the form). First declare, create, and clean up the connections: Option Explicit

' Declare connections WithEvents so we’ll receive events Private WithEvents iconn As ImageConnection Private WithEvents rconn As ReportConnection Private Sub Form_Load() ' create the connection objects Set iconn = New ImageConection Set rconn = New ReportConnection End Sub Private Sub Form_Unload(Cancel As Integer) ' cleanup when exiting Set iconn = Nothing Set rconn = Nothing End Sub

Rev 2.4.1, Nov 2008

HawkEye 1500 Reference & Programmers Manual

2-9

Page 228

Chapter

2

ReadRunner Programming Reference

8.

Select the rconn object in the VB Object dropdown, and then select the OnNewRecord event (if this didn’t happen automatically). This will make an event handling subroutine for you to fill in. Enter the following code: Private Sub rconn_OnNewRecord(ByVal objReport As MIOBJLib.IMiCycleReport) Label1 = objReport.ReportDecode.DecodeDataFormatted If objReport.Passed Then Label1.BackColor = vbGreen Else Label1.BackColor = vbRed End If End Sub

9.

Select the iconn object in the VB Object dropdown, and then select the OnNewRecord event. Enter the following code for the event handler: Private Sub iconn_OnNewRecord(ByVal objReport As MIOBJLib.IMiCycleReport) ' only display failed images If Not objReport.Passed Then MiImageView1.NewRecord objReport End If End Sub

10.

You’re done. You can now run the project.

How This Works By default, the ImageConnection and ReportConnection objects will connect automatically to the focus device as selected by the CameraDropdown. When the connections are established, OnNewRecord events are sent whenever there is new data available on the connection. The object passed as the parameter in this event is the MiCycleReport object – the same object is used for both images and reports. This object contains a great deal of detail about the completed cycle and is well worth browsing with the VB object browser. We use the DecodeDataFormatted field to fill the label with text, and the Passed Boolean to determine the label background color and to decide whether to display the image.

Taking This Example Further When the “<no camera>” option is selected from the CameraDropdown – thereby disconnecting, we may want to clear the contents of the label as well as

2-10

HawkEye 1500 Reference & Programmers Manual

Rev 2.4.1, Nov

Page 229

Example 2, Handling Images and Reports the displayed image. This will illustrate how to do something when a connection status changes. 1.

2

Select the rconn object in the VB Object dropdown, and then select the OnConnectionReset event. Enter the following code:

ReadRunner Programming

Private Sub rconn_OnConnectionReset() If Not rconn.IsConnected Then Label1 = "" Label1.BackColor = &H8000000F MiImageView1.ClearRecords End If End Sub

Note: Although the report and image connections both raise the OnConnectionReset event, in this example, we can assume they are both connected to the same camera, so we can put the logic in only one place. 2.

The OnConnectionReset event handler is a convenient place to put initialization logic. Therefore, call the event procedure directly from the Form_Load method: Private Sub Form_Load() ' create the connection objects Set iconn = New ImageConection Set rconn = New ReportConnection ' call OnConnectionReset directly so ' initialization logic is all in one place rconn_OnConnectionReset End Sub

3.

Rev 2.4.1, Nov 2008

Now, when you run the project, the image and label controls will be cleaned up as expected when you disconnect.

HawkEye 1500 Reference & Programmers Manual

2-11

Page 230

Chapter

2

ReadRunner Programming Reference

Example 3, Connecting to Two Cameras at Once It is likely that most applications will only connect to a single camera at a time. Therefore, the default behavior simplifies this case. However, this behavior can be overridden, if necessary. Here is an example that connects to two cameras.

2-12

1.

Create a new “Standard EXE” project.

2.

Select Project->References… and check the Microscan HawkEye™ Reader Object Type Library (MIOBJ.DLL).

3.

Select Project->Components… and check BOTH the Microscan ReadRunner ActiveX Library (RRKIT.OCX) and the Microscan HawkEye™ Reader ActiveX Library (MIOBJUI.DLL).

4.

Select the CameraDropdown component and place one stretching about half way across the top of the form. Then, select another one and place it next to the first one.

5.

Select the MiImageView component and position it below the first CameraDropdown. Then, add a second MiImageView control under the second CameraDropdown.

6.

Enter the code:

HawkEye 1500 Reference & Programmers Manual

Rev 2.4.1, Nov