Image

The event handler components of BizTalk RFID provide a method for capturing the stream of information from RFID devices. The ability to execute synchronous commands completes the device interaction story, allowing tags to be commissioned, device properties to be changed on the fly, and lights to be turned on and off via I/O ports. The term commissioning in an RFID context refers to the act of preparing an RFID tag (and accompanying label, etc.) for use. This typically involves programming the ID (for UHF tags), writing any user memory, and printing a physical label. The primary goals of this chapter are the following:

  • Establishing synchronous connections to a BizTalk RFID server
  • Managing devices from .NET applications
  • Performing common RFID-related tasks such as tag printing from .NET applications

All of the examples in this chapter will use the following baseline configuration of simulated readers (as shown in Figure 6-1). Exercise 6-1 introduces the setup of this configuration.

  • Two RFID readers (Dock Door Portal and Conveyer A)
  • One RFID printer (Warehouse A)
Image

Figure 6-1. Baseline configuration for exercises in Chapter 6

Exercise 6-1. Setting Up the Baseline Configuration

Connecting BizTalk RFID to Your Application

The first step in connecting your application to BizTalk RFID is adding the necessary proxy references and using statements. The ManagementWebServiceProxies assembly exposes all of the synchronous management features provided by BizTalk RFID through a series of proxy objects (shown in Table 6-1).

  1. From Visual Studio, create your base project (typically either a Windows Forms or console application).
  2. Add the following assembly references to your project (these are typically found in C:Program FilesMicrosoft BizTalk RFIDin):
    • Microsoft.Rfid.ManagementWebServiceProxies.dll
    • Microsoft.Rfid.Design
    • Microsoft.Rfid.SpiSdk

Image

Processes

RFID processes may also be manipulated through the use of synchronous commands (via the ProcessManagerProxy class). These commands allow processes to be registered, started, and stopped. One of the common tasks in external applications relating to RFID processes is retrieving the list of active processes for use in tag simulation. The only “direct” way to push simulated events into a running process is to use the AddEventToProcessPipeline command, which requires a process and a logical device name. The code in Exercise 6-2 uses the ProcessManagerProxy class to obtain the list of processes from the BizTalk RFID server and dump the list of logical devices and event handlers assigned to each.

ImageNote This exercise requires that the baseline configuration (from Exercise 6-1) is set up and running on the target BizTalk RFID server.

Exercise 6-2. Obtaining a List of Registered Processes

ImageNote You use the Start Without Debugging command to run the application, as it will leave the command window open until a key is pressed.

Devices

The management proxies provide full access to the list of devices configured on a BizTalk RFID server. This allows external applications to inspect the list of provisioned devices, configure devices with specific properties, and add new devices (though this would more commonly be done through RFID Manager, or automated through a PowerShell script or rfidclientconsole.exe command-line tool). One of the common tasks when implementing synchronous commands against BizTalk RFID is obtaining a list of device names (as the BizTalk RFID device name is required to open a connection before issuing commands to RFID devices).

Exercise 6-3 demonstrates how to use the synchronous API to obtain a list of all registered devices.

Exercise 6-3. Obtaining a List of Registered Devices

The rest of the examples in this chapter will assume that a list of physical and logical device names have been obtained from a BizTalk RFID server.

Device Management

The most commonly used synchronous commands relate to controlling and configuring RFID devices as well as printing RFID tags. The two key scenarios are callbacks from an asynchronous command handler and device control from an external application.

Synchronous callbacks are commonly used to implement business logic such as turning on lights or buzzers through I/O ports. From an event handler component, a synchronous call-back is made to an RFID device (commonly the device that raised the event, but not always) to perform an I/O change or property update.

Device control from an external application is typically used to implement scenarios such as tag printing, commissioning, or automated configuration. From a .NET application, synchronous commands are issued to an RFID device.

We’ll cover how to set up the synchronous command proxies for both .NET applications and event handler components, and manage device connections. Then we’ll walk through each of the four core synchronous command types (RFID, configuration, printing, and vendor-specific). For each of these examples, the proxy class used will be the DeviceManagerProxy; however, the same framework code will work for any of the other proxy classes.

Implementing Synchronous Calls from .NET Applications

The most common use of the synchronous commands described in this chapter is creating a stand-alone .NET application (console, GUI, etc.) that can interact with RFID devices. This provides for such functionality as synchronous tag reads, printing tags, and configuring devices.

Implementing Device Callbacks

An alternate scenario for using these commands is when performing a synchronous callback within an event handler. Take the scenario wherein the overall RFID solution must flash a light when an invalid tag read is received (e.g., a tag read indicating a type of product that doesn’t belong on the conveyer belt that the RFID reader is monitoring).

In this situation, one of the event handlers would open a connection to the reader from which the event was received and execute a synchronous command to manipulate one of the digital output ports.

Managing Device Connections

Every command issued to an RFID device requires an open device connection (either explicit or implicit). Managing these device connections is crucial to implementing a well-behaved and performant system. Many RFID devices only support a single “administrative” connection for issuing synchronous commands; as such, it is safer to treat RFID device connections like database connections—as a scarce resource. When issuing synchronous commands, follow these guidelines for establishing device connections:

  • Only hold the device connection open as long as you’re actively issuing commands. Especially in larger installations, keeping a connection open and idle may block another user (such as a system administrator) from connecting to the device.
  • If you are issuing a block of commands in close sequence, keep the connection open for the entire set. Rapidly opening and closing connections to issue a set of commands may reduce performance.
  • Wrap the DeviceConnection object in a using statement (when developing in C#) to ensure that the object is disposed of properly.
  • Use the Open method rather than OpenAdministrationConnection for normal task execution. The OpenAdministrationConnection method should be reserved for use by administrative interfaces as it can interfere with existing connections. Also, there’s no guarantee that the OpenAdministrationConnection method will be fully implemented by the device vendor, so mileage may vary.

ImageNote As a developer, you have the choice of either explicitly managing the connection (as per the preceding list) or requesting that BizTalk RFID automatically manage the connection to execute a single command. Think of this as similar to using ADO.NET TableAdapter objects vs. manually opening a DbConnection object. With the TableAdapter, the underlying ADO.NET opens a connection, executes a predetermined command, and closes the connection. BizTalk RFID device connections work the same way. If you want to execute a single command, the ExecuteDedicatedCommand method will handle the device connection. If you want to execute a sequence of commands, it is more efficient to manage the device connection manually.

The baseline code for establishing a device connection and issuing commands is shown in Listing 6-9.

Listing 6-9. Establishing a Connection to an RFID Device Through the DeviceConnection Class

using (DeviceConnection dc = new DeviceConnection(deviceName))
{
 try
 {
  dc.Open();
  // Do stuff here
  dc.Close();
 }
 catch (Exception ex0)
 {
  // Error handling and reporting
 }
}

The deviceName argument should be pulled from the list of registered devices.

Standard Commands

Standard commands are those “baked into” the Device Service Provider Interface (DSPI), and provide functionality that is common across a set of RFID devices. For example, the GetProperty command is implemented by all devices, but the PrintTag command would generally only be supported by RFID printers. The information about which devices support which standard (and extended commands) is available through the provider capability and metadata collections.

It is important to remember that not all device providers (or devices) are created equal. Different providers support different commands, and often implement them in different ways. In some situations, one provider will support multiple devices (such as devices based on the Intel R1000 chip), but not all of the devices will support the feature in question (such as I/O).

Always test your application with physical hardware to ensure that things work the way you expect. Tables 6-2 through 6-6 display the standard commands, along with a description of how they are commonly used.

Table 6-2 describes the general RFID commands, which are general purpose RFID commands that are not specific to a particular protocol or technology (such as HF or EPC Gen 2).

Image

Table 6-3 describes the UHF RFID commands. These are standard RFID commands that are more suited to UHF devices and tags.

Image

Table 6-4 describes the HF RFID commands. These are standard RFID commands that are more suited to HF devices and tags.

Image

Table 6-5 describes the commands that are used to configure and manage devices. All of the device management features provided by RFID Manager can be replicated through the use of the commands in this list. These functions are typically used when automating certain device management scenarios (such as automating the upload of new firmware to a set of devices managed by different BizTalk RFID servers).

Image

Table 6-6 describes the printing commands. There are a wide range of commands for commissioning and printing RFID tags. Most of these relate to the management of the print templates that are used to generate the physical printing, as well as the sequence of RFID data.

Image

Calling any of the standard commands follows the same general pattern:

  1. Establish a connection to the target RFID device.
  2. Create the appropriate command object (i.e., for a PrintTag command, create an instance of the PrintTagCommand class).
  3. For executing a series of commands in sequence (such as programming a set of device properties), open a connection with DeviceManagerProxy.OpenConnection and send commands with the DeviceManagerProxy.ExecuteCommandForConnection method.
  4. For executing a single command, use the DeviceManagerProxy. ExecuteDedicatedCommand method (this automatically opens and closes the required DeviceConnection).
  5. Parse the command object returned for a valid response object.

ImageNote Each of the command objects returns a specific response object. The response class types for each command are documented in the DSPI reference.

Calling several of the most commonly used standard commands is demonstrated in Exercises 6-4 through 6-7. As not every device supports all of the standard commands (e.g., it makes little sense for a reader to implement support for printing commands), some mechanism is required to determine which commands are supported by a particular device.

Each vendor is responsible for surfacing this information through the DeviceCapabilities list. This list can be accessed through the provider metadata, as shown in Exercise 6-4. To find out if a device supports a particular command, check the capabilities list. For example, if a particular device has the GetTags entry in the capabilities list, it will support the GetTags command.

Exercise 6-4. Obtaining a List of Tags Seen by the Reader (GetTagsCommand)

Exercise 6-5. Reprogramming an EPC Tag with a New ID (WriteIdCommand)

Exercise 6-6. Changing the Digital Output Port Value

Exercise 6-7. Reading the Current Timestamp (GetProperty/Time)

Vendor Commands

Vendor commands and properties are the extensibility points by which the unique capabilities of each hardware device are surfaced by individual vendors. Custom properties are employed to expose the full depth of the configuration experience for a specific device while maintaining a common interface. Custom commands are used to enable functionality that falls outside the standard command set, such as pulsing an I/O port. Understanding how to determine which vendor commands are available and how to invoke them is critical in taking full advantage of the unique capabilities of certain hardware devices.

Exercise 6-8 demonstrates how to retrieve the list of available vendor commands and examine the command metadata. Understanding the metadata is the key to being able to successfully invoke vendor commands, as demonstrated in Exercise 6-9.

Exercise 6-8. Retrieving the List of Vendor Commands (Provider Metadata)

ImageNote This metadata shows the command PulseOutputCommand, which pulses one of the output lines on an Alien reader for a specified period of time (this command is commonly used to flash lights in a light stack). The command has two parameters. The first, TimeInterval, takes an integer value between 1 and 30000, and represents the length of time of the pulse. The second, Port, represents one of the eight output ports on the Alien device.

Exercise 6-9. Executing a Vendor-Specific Command

ImageNote The command and parameter names must match the metadata descriptions exactly. For example, attempting to execute the PulseOutput command rather than the PulseOutputCommand command will fail.

Common Tasks

This section covers two of the common “synchronous” tasks: printing tags (with visual labels) and simulating tag reads (for use in testing or validation).

Simulating Tag Reads

At one point or another, most developers will need to simulate a stream of RFID data in order to test or validate a particular scenario or business process. As alluded to earlier in this chapter, the AddEventToProcessPipeline command allows tag data to be pushed into a running process, providing an ideal entry point for simulated data. This section will demonstrate how to generate simulated single tag and tag list (multiple tags) events and inject them into a running process.

In order to inject simulated RFID data, the following pieces of information are required:

  • The event to simulate (such as a TagReadEvent or a TagListEvent). Generating these events is demonstrated next.
  • The name of the process into which to inject the event. This may be obtained from the ProcessManagerProxy class.
  • The logical reader source from which the event will appear to originate. This may also be obtained from the ProcessManagerProxy class.

Any object deriving from RfidEventBase may be simulated; however, the most useful types will tend to be TagReadEvent and TagListEvent objects. To generate a TagReadEvent, the tag ID (and sometimes tag data) fields are required. Creating the simulated tag data can be a little tricky (especially in scenarios with specific tag IDs or behavior), but the process of actually pushing the tags into a specific process is straightforward in its implementation.

The process of writing an application to simulate tag events is demonstrated in Exercise 6-10.

Exercise 6-10. Writing an Application to Simulate Tag Reads

Conclusion

The synchronous command functionality in BizTalk RFID is the key method of creating custom applications for configuring devices, printing tags, and controlling I/O. By matching .NET applications with the interface provided by the ManagementWebProxy assembly, any of the functionality provided by RFID Manager or the rfidclientconsole.exe application can be included in your own applications.

CASE STUDY: PERSONALIZING ADVERTISING

Industry: Travel.

Overview: In many countries, organizations can display personal information about consumers as long as they are on company property. In a high-class travel agency of one European nation, customers are greeted at the door by a wall-sized display of personalized information and targeted advertising. The retrieval of this information is initiated by the read of an RFID tag embedded in the customer’s bank card (used in all transactions, including ATMs). Once the customer has been identified, the database retrieves the personalized information and calculates advertising that would appeal to this consumer based on previous transactions and travel.

Results: Customers are confronted with advertisements that appeal specifically to their needs. For instance, business travelers who frequent specific cities are shown discount fare options at hotels in areas where they have stayed in the past.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset