Click here to Skip to main content
15,878,970 members
Articles / Desktop Programming / Win32

RFID Motion

Rate me:
Please Sign up or sign in to vote.
2.00/5 (4 votes)
22 Jul 2008Public Domain3 min read 40.1K   1.3K   20   2
BizTalk RFID component to detect directional movement of tags.

Introduction

This article demonstrates a sample BizTalk RFID component to detect the direction in which RFID tags are moving.

Background

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:

  1. EventHandler DLL that can be added to an RFID process
  2. SQL script to create the necessary database structures
  3. Process XML to create and import a test process into RFID Manager
  4. Test scripts to simulate TagReadEvents and TagListEvents to test the component
  5. Sample tag XML files
  6. Source code for the component

The Tag Motion Status is maintained using the following enumerated values:

C#
public enum TAG_STATUS
{
    Error = 0,
    MovedIn,
    MovedOut,
    MovingIn,
    MovingOut
}
public enum MOTION_STATUS
{
    Normal = 0,
    DirectionReversed,
    LocationSkipped,
    NotMoving
}

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 (anideswandikar@hotmail.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 KeyLocation Sequence Number (Loc#)
Device1/Source10
Device1/Source21
Device2/Source12

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:

SQL
SELECT <dbname>..tagmotion.Id,<dbname>..tagmotion.TagID,
<dbname>..tagmotion.LastLocDevice,
<dbname>..tagmotion.LastLocSource,
<dbname>..tagmotion.RecordTime,
<dbname>..tagstatusmaster.StatusDescription,
<dbname>..motionstatusmaster.StatusDescription 
  FROM <dbname>..tagmotion, <dbname>..motionstatusmaster, <dbname>..tagstatusmaster 
where 
<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.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Architect Microsoft
Asia/Pacific Region Asia/Pacific Region
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.

Comments and Discussions

 
GeneralConnect To RFID Reader Pin
Member 413081515-Oct-09 10:44
Member 413081515-Oct-09 10:44 
GeneralRe: Connect To RFID Reader Pin
J imran20-Feb-10 21:19
J imran20-Feb-10 21:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.