In my earlier post, I gave an overview of the various approaches in which you can add/register a device with BizTalk RFID.  Now that you have the device added, I am sure you can't wait to configure it and start putting it to use. So, how do you use BizTalk RFID to configure it as well as do certain operations on it?  I will explain both the RFID manager part of it as well using the Object Model to do this programmatically, in that order. 

A. Configuration (using RFID Manager): This can involve setting properties on the device, for e.g. the Regulatory Region or the event mode.  In RFID Manager, right-click on a device, and then select Properties. RFID Manager will first attempt connect to the device; if the device is online, it will retrieve the latest values for the properties from the device ("current property profile") and display the properties in the Properties Dialog. If RFID Manager is not able to connect to the device, it will display the last known version of the property values: in this case, you will notice that you will only be able to view the properties and not edit them. The device needs to be online to be able to edit the properties as well. What about the properties of a device's sources/antennae? You can view the important properties of the antennae in the Sources tab of the Device Properties dialog; to view the rest, you can go the Custom tab of this dialog and select a particular source to view its other properties.

B. Operations (using RFID Manager): RFID Manager provides support for certain common operations on a device: one example is to view tags from a device. You can right-click on a device, and then select View Tags. You will be able to configure the refresh interval as well. There are other such device operations as well that are supported from RFID Manager.

C. Configuration/Operations (Programmatic):  Now, on to the programmatic part: most of the device configuration and operations can be represented as "Commands" in the BizTalk RFID Device Service Provider Interface (DSPI). For e.g. you have a GetCurrentPropertyProfileCommand to get the latest property profile from a device, or a SetPropertyCommand to set the value for a particular device property. Similarly, you have a "GetTagsCommand" or "PrintTagCommand" for various device operations. From the Object Model perspective, the execution of these commands are synchronous in nature. You need to open a connection to the device before you can execute a command on it. I will give you two approaches by which you can achieve this:

1. Using DeviceConnection (recommended): 

The DeviceConnection class is the recommended approach when you want to do programmatic configuration/operations on a device.

for e.g. to get the current property profile, here's a rough idea of how you can use the DeviceConnection class (Note: exception handling not included in the below samples):

using (DeviceConnection deviceConnection = new DeviceConnection("localhost","ContosoTestDevice"))
{
    deviceConnection.Open(); // open a connection to the device
   
PropertyProfile properties = deviceConnection.GetCurrentPropertyProfile();
}

for e.g. to kill a tag:

using (DeviceConnection deviceConnection = new DeviceConnection("localhost","ContosoTestDevice"))
{
    deviceConnection.Open();
   
byte[] tagId = new byte[] {1, 2, 3, 4, 5, 6, 7, 8};
    deviceConnection.KillTag(tagId);
}

[You will have to add a reference to Microsoft.Rfid.Client.dll]

Overall, there are lot of other such methods in the DeviceConnection class for various configurations/operations on a device. The typical pattern for each operation/configuration method is that you will find a simpler overload for the most common usage, and you will find a more advanced usage if you want to specify more options (for e.g. if you want to perform the operation/configuration on a particular source of a device, there is an overload where you can specify the source name). You can use this class from a standalone application or from your own BizTalk RFID event handler that is part of a RFID business process.

2. Using DeviceManagerProxy:

The DeviceManagerProxy provides support for:

  • Opening a connection to a device : OpenConnection(),
  • Executing a command on the device/source : ExecuteCommandForConnection(),
  • Closing the connection to the device: CloseConnection()

In this, you will have to build a "Command" object and execute it - for e.g. to build a SetPropertyCommand to modify the location property,

PropertyKey locationKey = new PropertyKey(StandardDevicePropertyGroups.General, // General Group
                                                                  GeneralPropertyGroup.Location); // Location Property
EntityProperty locationProperty = new EntityProperty(locationKey, "New Location");
SetPropertyCommand setPropertyCommand = new SetPropertyCommand(locationProperty);

DeviceConnection uses this model internally, and it is recommended to use the DeviceConnection model rather than using the DeviceManagerProxy directly.