Products for USB Sensing and Control
It is currently Tue Jun 18, 2013 12:45 am

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Feb 22, 2011 7:13 am 
Offline
Fresh meat

Joined: Tue Feb 22, 2011 6:55 am
Posts: 3
Hello all,
I have seen many forum posts on here in regards on how to work with multiple RFID phidgets, by simply declaring a new RFID object in the .NET code and explicitly using the .open() call with the serial ID of each phidget I want to open.

However with this application I am writing, we intend to use it at a conference for a simple & fun checkin system tied upto member profiles (all done with webservice stuff later on)

But the problem I am having is that I want to have multiple versions of this application running around the conference. Some rooms we will require a USB hub and say maybe 5 readers attached and in another we might only have 2 attached. So rather than explicitly creating multiple versions of the applications, to specifically assign the number of readers and serial IDs, I would like the application to be clever and work with any number of RFID readers that are attached.

I thought about using the Manager object to loop through the attached Phidget devices, checking to see if its a RFID reader and finding out it's serial number to open up with.

However I am a novice with .NET and I am not sure what I am trying to describe can be achieved?

I have put my project onto BitBucket and here you can find the link to the code behind for the main application logic that I am trying to do.
https://bitbucket.org/warrenbuckley/rfi ... D/Form1.cs

If anyone could help me with this it would be greatly appreciated.

Many Thanks,
Warren :)


Top
 Profile Send private message  
 
PostPosted: Tue Feb 22, 2011 10:53 am 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2359
Location: Canada
You definitely want to use the manager - create a manager object, and register it's attach event, then open it. In it's attach handler, check for a DeviceClass of PhidgetRFID, then create a new RFID object, add it to a global list of PhidgetRFIDs, register it's attach event, and call open using it's serial number. You may also want your manager detach event to find and remove the reader from the global list of readers.

It's close to what you have written - just remember that each new RFID reader needs it's own object - you are re-using the same rfid object each time the manager attach handler runs.
Code:
        private List<RFID> readers = new List<RFID>();
        void phidgManager_Attach(object sender, AttachEventArgs e)
        {
            //Check if the phidget attached is an RFID reader...
            if (e.Device.Class == Phidget.PhidgetClass.RFID)
            {
                RFID newReader = new RFID();
                readers.Add(newReader);

                //Assign the events to that reader...
                newReader.Attach += new AttachEventHandler(rfidItem_Attach);
                newReader.Detach += new DetachEventHandler(rfidItem_Detach);
                newReader.Tag += new TagEventHandler(rfidItem_Tag);
                newReader.TagLost += new TagEventHandler(rfidItem_TagLost);

                //Open the reader with the serial number
                newReader.open(e.Device.SerialNumber);
            }
        }

-Patrick


Top
 Profile Send private message  
 
PostPosted: Tue Feb 22, 2011 11:10 am 
Offline
Fresh meat

Joined: Tue Feb 22, 2011 6:55 am
Posts: 3
Hey Patrick,
Thank you for the fast response. I was just about to reply to this post to say that my friend gave me the same advice about storing the RFID objects in a List and have approached it the same way.

The if check I have done slightly different but I prefer your method so will update my code...

I was using in the PhidgetManager attach event
Code:
if (e.Device.Type == "PhidgetRFID")


With multiple readers then attached, do I need to do any special management with the readers. For example some kind of cycle of turning the antennas on and off or will it be OK?

This is my latest version of the code:
https://bitbucket.org/warrenbuckley/rfi ... D/Form1.cs

Many Thanks
Warren :)


Top
 Profile Send private message  
 
PostPosted: Tue Feb 22, 2011 11:12 am 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2359
Location: Canada
You'll want to try it out - the closer the readers are to each other, the more likely they are to interfere.

-Patrick


Top
 Profile Send private message  
 
PostPosted: Tue Feb 22, 2011 11:22 am 
Offline
Fresh meat

Joined: Tue Feb 22, 2011 6:55 am
Posts: 3
Patrick
Yes I noticed when they were too close together the tag & taglost event were getting fired in quick succession even when the tag was kept still over one reader (it wasn't picked up by the other reader) but when too close neither reader fired the events and now I have tested it with the readers further apart and it seems to work great.

Now I can then focus on the code for detaching a reader when the application is running and then wire it upto a webservice to ping our logic for the attendee members, so we can update a database.

Thanks,
Warren :)


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group