Exemple #1
0
        public ThinkifyReader(string port)
        {
            sC      = new ThinkifySerialConnection(port);
            TagList = new ThinkifyTagList();

            //If a new line comes in
            sC.LineReceivedEvent += new LineReceivedEventHandler(ProcessLine);
            sC.DataReceivedEvent += new DataReceivedEventHandler(ProcessData);

            ReadingActiveValue = false;
            latestTag          = new ThinkifyTag();
        }
Exemple #2
0
        private void ProcessLine(object sender, LineReceivedEventArgs e)
        {
            TagList.ProcessReaderMessage(e.lineReceived);

            if (e.lineReceived.IndexOf("TAG=") == 0)
            {
                ThinkifyTag t = new ThinkifyTag(e.lineReceived);

                if (t.EPC != latestTag.EPC) // A new guy! Reset latest tag.
                {
                    latestTag = t;
                }
                else
                {   //It's the tag we've seen before. Just update the latestTag w/ the new data...
                    latestTag.Update(t);
                }

                TagReadEventArgs ev = new TagReadEventArgs(latestTag);
                RaiseTagReadEvent(ev);
            }


            //Extended reads are enabled. -- update the data for the last tag seen.

            if (e.lineReceived.IndexOf("XRD") == 0)
            {
                bool goodResult = latestTag.UpdateXRDData(e.lineReceived);

                //goodResult = true; //TODO: Look at if we want to use this...
                //OK, we'll only report a Xread event if we have a valid one...
                if (goodResult)
                {
                    TagReadEventArgs ev = new TagReadEventArgs(latestTag);
                    //I can't _believe_ how poorly this language deals with moving from strings to other data types. REALLY?
                    ev.XReadIndex = int.Parse(e.lineReceived[3].ToString());  //Parse doesn't even deal w/Hex! How much "parse"ing is going on, then?
                    RaiseTagXReadEvent(ev);
                }
            }
        }
Exemple #3
0
 public TagReadEventArgs(ThinkifyTag atag)
 {
     tag             = atag;
     this.XReadIndex = -1;
 }