This article demonstrates a sample BizTalk RFID component to detect the direction in which RFID tags are moving.
While developing RFID solutions for applications like inventory management and asset tracking, one of the most common requirements is to find the direction in which the tags are moving. I initially developed a simple component using the BizTalk RFID framework for one of my simple demos. That component used simple memory structures to track tag movement.
Then I started getting inquiries from the field asking for an out-of-the-box component to do this. I personally believe that an out-of-the-box component will not fit all commercial requirements. However, it will be interesting to demonstrate how to implement something like this. Hence, this new generic and almost "out-of-the-box" solution to detect directionality of tag movement.
Using the code
The component has the following parts:
- EventHandler DLL that can be added to an RFID process
- SQL script to create the necessary database structures
- Process XML to create and import a test process into RFID Manager
- Test scripts to simulate
TagListEvents to test the component
- Sample tag XML files
- Source code for the component
The Tag Motion Status is maintained using the following enumerated values:
public enum TAG_STATUS
Error = 0,
public enum MOTION_STATUS
Normal = 0,
Tag Status tells you about the directional movement of the tag. Tag is Moving Out, Tag has Moved Out etc. Motion Status is like a special status that tells you about some special motion situations like Not Moving or Direction Reversed.
Some of you might be thinking that the enumeration structures must be swapped. Motion Status should be Tag Status and Tag Status must be Motion Status. Call me and I will explain (email@example.com).
Next will be the EventHandler parameters. Two important parameters are Motion Sequence and Motion Timeout. Motion Sequence is a semicolon separated string of DeviceName/SourceName structures. A combination of DeviceName/SourceName defines a unique location at which a tag could be detected and, hence, each combination must be unique in the string. The location sequence is defined by the position of the location key. For example, Device1/Source1;Device1/Source2;Device2/Source1 would translate into:
||Location Sequence Number (Loc#)
So Tag moving from Loc#0 to Loc#1 will be marked as "Moving out", from Loc#1 to Loc#2 will be marked as "Moved out", and from Loc#2 to Loc#1 will be marked as "Moving In". If a tag jumps from Loc#0 to Loc#2, then it will be marked as "Moved Out" and "Location Skipped" and so on and so forth.
Motion Timeout parameter, if set to > 0, indicates that if a Tag is continuously detected at a particular location for more than the Timeout minutes specified in this parameter, then the tag will be marked as "Not Moving".
The Tag and Motion status are stored in a database table called "TagMotion". The script for creating this table along with other lookup tables is provided with the code under the SQL folder. Currently the lookup tables mock the hard-coded values of the enumerations in the EventHandler code. Given enough motivation, I will write a version where these enumerations can be configured using the database tables.
To test the component, run EventHandlerSampleSetup.cmd to setup a RFIDMotionTest process. Ensure that the RFIDMotionTest process is created and started in the RFID Manager. Then run EventHandlerSampleTagListEvents.cmd or EventHandlerSampleTagReadEvents.cmd depending on what event you wish to test. Open SQL Server Management Studio, select the database under which you created the TagMotion and other tables, and execute the following query:
FROM <dbname>..tagmotion, <dbname>..motionstatusmaster, <dbname>..tagstatusmaster
<dbname>..tagstatusmaster.StatusCode = <dbname>..tagmotion.TagStatus and
<dbname>..motionstatusmaster.StatusCode = <dbname>..tagmotion.MotionStatus
You will see the results showing the Tag Status and the Motion Status for every tag detected. The RFIDMotionTest application is attached to a logical device. If you have a physical device, then bind the logical device to the physical device for tracking real tags.
I currently work as a Technology Architect at the Microsoft Technology Center, Bangalore. I head the Application Platform Practice at the MTC, which includes .Net Migration, .Net Adoption, BizTalk, BizTalk RFID and such.
Before working for Microsoft I worked for Netflix as a Senior Software Engineer.