Esempio n. 1
0
        public ReadTags(NotifyIcon notifyIcon)
        {
            try
            {
                InitializeComponent();
                dgTagResult.DataSource = tagdb.TagList;
                //Set the column width of datagrid
                AddGridStyles();

                properties = Utilities.GetProperties();

                playBeep.SoundLocation = properties["decodewavefile"];
                playBeep.LoadAsync();
                playStopAudio.SoundLocation = properties["endscanwavefile"];
                playStopAudio.LoadAsync();
                playStartAudio.SoundLocation = properties["startscanwavefile"];
                playStartAudio.LoadAsync();

                setStatus(Status.READY);
                pvtNotifyIcon = notifyIcon;

                //For battery level
                status = new CoreDLL.SYSTEM_POWER_STATUS_EX();

                tmrBackLightControl          = new System.Windows.Forms.Timer();
                tmrBackLightControl.Interval = 1000 * 30;// Timer will tick every 30 seconds
                tmrBackLightControl.Tick    += new EventHandler(tmrBackLightControl_Tick);

                //Pistol grip read handler
                pistolTriggerEvent          = new SystemState(SystemProperty.HeadsetPresent);
                pistolTriggerEvent.Changed += new ChangeEventHandler(pistolTriggerEvent_Changed);
                pistolTriggerEvent.DisableApplicationLauncher();
            }
            catch (Exception ex)
            {
                logger.Error("In ReadTags: " + ex.ToString());
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        // TODO: Merge common functionality between KeyboardWedgeRead and ReadTags.ReadtheTags
        private void KeyboardWedgeRead()
        {
            List<SendInputWrapper.INPUT> inputList = new List<SendInputWrapper.INPUT>();
            string startIndicator = ".";

            // Signal start of read
            inputList.Clear();
            AddKeypresses(inputList, startIndicator);
            SendInput(inputList);

            properties = Utilities.GetProperties();

            SoundPlayer startSound = new SoundPlayer(properties["startscanwavefile"]);
            if (properties["audiblealert"].ToLower() == "yes")
            {
                startSound.Play();
            }
            SoundPlayer stopSound = new SoundPlayer(properties["endscanwavefile"]);
            stopSound.LoadAsync();

            CoreDLL.SYSTEM_POWER_STATUS_EX status = new CoreDLL.SYSTEM_POWER_STATUS_EX();
            //Check the battery power level
            if (CoreDLL.GetSystemPowerStatusEx(status, false) == 1)
            {
                if (status.BatteryLifePercent <= 5)
                {
                    if (status.ACLineStatus == 0)
                    {
                        MessageBox.Show("Battery level is low to read tags");
                        return;
                    }
                }
            }
            try
            {
                TagReadData[] reads;

                //Utilities.PowerManager.PowerNotify += new PowerManager.PowerEventHandler(PowerManager_PowerNotify);
                using (ThingMagic.RFIDSearchLight.ReadMgr.Session rsess = ThingMagic.RFIDSearchLight.ReadMgr.GetSession())
                {
#if DEBUG
                    if (properties["audiblealert"].ToLower() == "yes")
                    {
                        startSound.Play();
                    }
#endif

                    int radioPower = 0;
                    if (properties["readpower"].ToString() == "")
                    {
                        radioPower = 2300;//While reading read power should be max
                    }
                    else
                    {
                        radioPower = Convert.ToInt32(properties["readpower"].ToString());
                    }
  
                    //Set the region
                    string region = properties["region"];
                    try
                    {
                        Utilities.SwitchRegion(region);
                    }
                    catch (ArgumentException)
                    {
                        MessageBox.Show(
                            "Unknown Region: " + region + "\r\n" +
                            "Please run RFIDSearchLight to initialize the region."
                            );
                    }
                    
                    rsess.Reader.ParamSet("/reader/powerMode", Reader.PowerMode.FULL);
                    rsess.Reader.ParamSet("/reader/radio/readPower", radioPower);
                    rsess.Reader.ParamSet("/reader/antenna/txRxMap", new int[][] { new int[] { 1, 1, 1 } });
                    List<int> ant = new List<int>();
                    ant.Add(1);
                    //set the tag population settings
                    rsess.Reader.ParamSet("/reader/gen2/target", Gen2.Target.A);//default target
                    string tagPopulation = properties["tagpopulation"];
                    switch (tagPopulation)
                    {
                        case "small":
                            rsess.Reader.ParamSet("/reader/gen2/q", new Gen2.StaticQ(2));
                            rsess.Reader.ParamSet("/reader/gen2/session", Gen2.Session.S0);
                            rsess.Reader.ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M4);
                            break;
                        case "medium":
                            rsess.Reader.ParamSet("/reader/gen2/q", new Gen2.StaticQ(4));
                            rsess.Reader.ParamSet("/reader/gen2/session", Gen2.Session.S1);
                            rsess.Reader.ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M4);
                            break;
                        case "large":
                            rsess.Reader.ParamSet("/reader/gen2/q", new Gen2.StaticQ(6));
                            rsess.Reader.ParamSet("/reader/gen2/session", Gen2.Session.S2);
                            rsess.Reader.ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M2);
                            break;
                        default: break;
                    }
                    //set the read plan and filter
                    TagFilter filter;
                    int addressToRead = int.Parse(properties["selectionaddress"]);
                    Gen2.Bank bank = Gen2.Bank.EPC;
                    switch (properties["tagselection"].ToLower())
                    {
                        case "None":
                        case "epc": bank = Gen2.Bank.EPC; break;
                        case "tid": bank = Gen2.Bank.TID; break;
                        case "user": bank = Gen2.Bank.USER; break;
                        case "reserved": bank = Gen2.Bank.RESERVED; break;
                        default: break;

                    }
                    if ("yes" == properties["ismaskselected"])
                    {
                        filter = new Gen2.Select(true, bank, (uint)addressToRead * 8, (ushort)(properties["selectionmask"].Length * 4), ByteFormat.FromHex(properties["selectionmask"]));
                    }
                    else
                    {
                        filter = new Gen2.Select(false, bank, (uint)addressToRead * 8, (ushort)(properties["selectionmask"].Length * 4), ByteFormat.FromHex(properties["selectionmask"]));
                    }
                    //set the read plan
                    SimpleReadPlan srp;
                    if (properties["tagselection"].ToLower() == "none")
                    {
                        srp = new SimpleReadPlan(new int[] { 1 }, TagProtocol.GEN2, null, 0);
                    }
                    else
                    {
                        srp = new SimpleReadPlan(new int[] { 1 }, TagProtocol.GEN2, filter, 0);
                    }
                    rsess.Reader.ParamSet("/reader/read/plan", srp);

                    double readDuration = Convert.ToDouble(properties["scanduration"].ToString()) * 1000;
                    int readTimeout = Convert.ToInt32(readDuration);

                    //Do a sync read for the readduration
#if DEBUG
                    if (properties["audiblealert"].ToLower() == "yes")
                    {
                        startSound.Play();
                    }
#endif
                    reads = rsess.Reader.Read(readTimeout);

                    rsess.Reader.ParamSet("/reader/powerMode", Reader.PowerMode.MINSAVE);
                    if (properties["audiblealert"].ToLower() == "yes")
                    {
                        stopSound.Play();
                    }
                    // Clear start indicator
                    inputList.Clear();
                    for (int i = 0; i < startIndicator.Length; i++)
                    {
                        AddKeypresses(inputList, new byte[] {
                            // Don't send Backspace -- that's one of our hotkeys,
                            // so it'll put us in an infinite loop.
                            (byte)Keys.Left,
                            (byte)Keys.Delete,
                        });
                    }
                    SendInput(inputList);
                }

                inputList.Clear();
                //HideWindow();
                bool timestamp = false, rssi = false, position = false;
                string[] metadata = properties["metadatatodisplay"].Split(',');
                //Metadata boolean variables
                foreach (string mdata in metadata)
                {
                    switch (mdata.ToLower())
                    {
                        case "timestamp": timestamp = true; break;
                        case "rssi": rssi = true; break;
                        case "position": position = true; break;
                        default: break;
                    }
                }
                string metadataseparator = properties["metadataseparator"];
                byte metadataseparatorInByte = 0x00;
                switch (metadataseparator.ToLower())
                {
                    //The byte representation of special characters can be found here - http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
                    case "comma": metadataseparatorInByte = 0xBC; break;
                    case "space": metadataseparatorInByte = 0x20; break;
                    case "enter": metadataseparatorInByte = 0x0D; break;
                    case "tab": metadataseparatorInByte = 0x09; break;
                    default: break;
                }
                //Print the epc in caps
                AddKeypress(inputList, (byte)Keys.Capital);  // Toggle Caps Lock

                //Print the tag reads
                foreach (TagReadData dat in reads)
                {
                    string tagData = string.Empty;
                    string epc = string.Empty;
                    if (properties["displayformat"] == "base36")
                    {
                        epc = ConvertEPC.ConvertHexToBase36(dat.EpcString);
                    }
                    else
                    {
                        epc = dat.EpcString;
                    }

                    AddKeypresses(inputList, properties["prefix"].ToUpper());
                    AddKeypresses(inputList, epc.ToUpper());
                    AddKeypresses(inputList, properties["suffix"].ToUpper());

                    if (timestamp)
                    {
                        AddKeypress(inputList, metadataseparatorInByte);
                        AddKeypresses(inputList, dat.Time.ToString("yyyy-MM-dd-HH-mm-ss"));
                    }
                    if (rssi)
                    {
                        AddKeypress(inputList, metadataseparatorInByte);
                        AddKeypresses(inputList, dat.Rssi.ToString());
                    }
                    if (position)
                    {
                        AddKeypress(inputList, metadataseparatorInByte);
                        AddKeypresses(inputList, GpsMgr.LatLonString);
                    }

                    switch (properties["multipletagseparator"].ToLower())
                    {
                        case "comma": AddKeypress(inputList, 0xBC); break;
                        case "space": AddKeypress(inputList, 0x20); break;
                        case "enter": AddKeypress(inputList, 0x0D); break;
                        case "tab": AddKeypress(inputList, 0x09); break;
                        case "pipe":
                            AddInput(inputList, SHIFT_DOWN);
                            AddKeypress(inputList, 0xDC);
                            AddInput(inputList, SHIFT_UP);
                            break;
                        default: break;
                    }
                    // Send keystrokes after each tag read record -- input buffer
                    // isn't big enough to hold more than a few lines
                    SendInput(inputList);
                    inputList.Clear();
                }
                //Turn caps lock back off
                AddKeypress(inputList, (byte)Keys.Capital);  // Toggle Caps Lock
                SendInput(inputList);
            }
            
            catch (Exception ex)
            {
                logger.Error("In KeyboardWedgeRead(): " + ex.ToString());
                //MessageBox.Show(ex.Message);
                //Debug.Log(ex.ToString());
            }
        }
Esempio n. 3
0
        // TODO: Merge common functionality between KeyboardWedgeRead and ReadTags.ReadtheTags
        private void KeyboardWedgeRead()
        {
            List <SendInputWrapper.INPUT> inputList = new List <SendInputWrapper.INPUT>();
            string startIndicator = ".";

            // Signal start of read
            inputList.Clear();
            AddKeypresses(inputList, startIndicator);
            SendInput(inputList);

            properties = Utilities.GetProperties();

            SoundPlayer startSound = new SoundPlayer(properties["startscanwavefile"]);

            if (properties["audiblealert"].ToLower() == "yes")
            {
                startSound.Play();
            }
            SoundPlayer stopSound = new SoundPlayer(properties["endscanwavefile"]);

            stopSound.LoadAsync();

            CoreDLL.SYSTEM_POWER_STATUS_EX status = new CoreDLL.SYSTEM_POWER_STATUS_EX();
            //Check the battery power level
            if (CoreDLL.GetSystemPowerStatusEx(status, false) == 1)
            {
                if (status.BatteryLifePercent <= 5)
                {
                    if (status.ACLineStatus == 0)
                    {
                        MessageBox.Show("Battery level is low to read tags");
                        return;
                    }
                }
            }
            try
            {
                TagReadData[] reads;

                //Utilities.PowerManager.PowerNotify += new PowerManager.PowerEventHandler(PowerManager_PowerNotify);
                using (ThingMagic.RFIDSearchLight.ReadMgr.Session rsess = ThingMagic.RFIDSearchLight.ReadMgr.GetSession())
                {
#if DEBUG
                    if (properties["audiblealert"].ToLower() == "yes")
                    {
                        startSound.Play();
                    }
#endif

                    int radioPower = 0;
                    if (properties["readpower"].ToString() == "")
                    {
                        radioPower = 2300;//While reading read power should be max
                    }
                    else
                    {
                        radioPower = Convert.ToInt32(properties["readpower"].ToString());
                    }

                    //Set the region
                    string region = properties["region"];
                    try
                    {
                        Utilities.SwitchRegion(region);
                    }
                    catch (ArgumentException)
                    {
                        MessageBox.Show(
                            "Unknown Region: " + region + "\r\n" +
                            "Please run RFIDSearchLight to initialize the region."
                            );
                    }

                    rsess.Reader.ParamSet("/reader/powerMode", Reader.PowerMode.FULL);
                    rsess.Reader.ParamSet("/reader/radio/readPower", radioPower);
                    rsess.Reader.ParamSet("/reader/antenna/txRxMap", new int[][] { new int[] { 1, 1, 1 } });
                    List <int> ant = new List <int>();
                    ant.Add(1);
                    //set the tag population settings
                    rsess.Reader.ParamSet("/reader/gen2/target", Gen2.Target.A);//default target
                    string tagPopulation = properties["tagpopulation"];
                    switch (tagPopulation)
                    {
                    case "small":
                        rsess.Reader.ParamSet("/reader/gen2/q", new Gen2.StaticQ(2));
                        rsess.Reader.ParamSet("/reader/gen2/session", Gen2.Session.S0);
                        rsess.Reader.ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M4);
                        break;

                    case "medium":
                        rsess.Reader.ParamSet("/reader/gen2/q", new Gen2.StaticQ(4));
                        rsess.Reader.ParamSet("/reader/gen2/session", Gen2.Session.S1);
                        rsess.Reader.ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M4);
                        break;

                    case "large":
                        rsess.Reader.ParamSet("/reader/gen2/q", new Gen2.StaticQ(6));
                        rsess.Reader.ParamSet("/reader/gen2/session", Gen2.Session.S2);
                        rsess.Reader.ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M2);
                        break;

                    default: break;
                    }
                    //set the read plan and filter
                    TagFilter filter;
                    int       addressToRead = int.Parse(properties["selectionaddress"]);
                    Gen2.Bank bank          = Gen2.Bank.EPC;
                    switch (properties["tagselection"].ToLower())
                    {
                    case "None":
                    case "epc": bank = Gen2.Bank.EPC; break;

                    case "tid": bank = Gen2.Bank.TID; break;

                    case "user": bank = Gen2.Bank.USER; break;

                    case "reserved": bank = Gen2.Bank.RESERVED; break;

                    default: break;
                    }
                    if ("yes" == properties["ismaskselected"])
                    {
                        filter = new Gen2.Select(true, bank, (uint)addressToRead * 8, (ushort)(properties["selectionmask"].Length * 4), ByteFormat.FromHex(properties["selectionmask"]));
                    }
                    else
                    {
                        filter = new Gen2.Select(false, bank, (uint)addressToRead * 8, (ushort)(properties["selectionmask"].Length * 4), ByteFormat.FromHex(properties["selectionmask"]));
                    }
                    //set the read plan
                    SimpleReadPlan srp;
                    if (properties["tagselection"].ToLower() == "none")
                    {
                        srp = new SimpleReadPlan(new int[] { 1 }, TagProtocol.GEN2, null, 0);
                    }
                    else
                    {
                        srp = new SimpleReadPlan(new int[] { 1 }, TagProtocol.GEN2, filter, 0);
                    }
                    rsess.Reader.ParamSet("/reader/read/plan", srp);

                    double readDuration = Convert.ToDouble(properties["scanduration"].ToString()) * 1000;
                    int    readTimeout  = Convert.ToInt32(readDuration);

                    //Do a sync read for the readduration
#if DEBUG
                    if (properties["audiblealert"].ToLower() == "yes")
                    {
                        startSound.Play();
                    }
#endif
                    reads = rsess.Reader.Read(readTimeout);

                    rsess.Reader.ParamSet("/reader/powerMode", Reader.PowerMode.MINSAVE);
                    if (properties["audiblealert"].ToLower() == "yes")
                    {
                        stopSound.Play();
                    }
                    // Clear start indicator
                    inputList.Clear();
                    for (int i = 0; i < startIndicator.Length; i++)
                    {
                        AddKeypresses(inputList, new byte[] {
                            // Don't send Backspace -- that's one of our hotkeys,
                            // so it'll put us in an infinite loop.
                            (byte)Keys.Left,
                            (byte)Keys.Delete,
                        });
                    }
                    SendInput(inputList);
                }

                inputList.Clear();
                //HideWindow();
                bool     timestamp = false, rssi = false, position = false;
                string[] metadata = properties["metadatatodisplay"].Split(',');
                //Metadata boolean variables
                foreach (string mdata in metadata)
                {
                    switch (mdata.ToLower())
                    {
                    case "timestamp": timestamp = true; break;

                    case "rssi": rssi = true; break;

                    case "position": position = true; break;

                    default: break;
                    }
                }
                string metadataseparator       = properties["metadataseparator"];
                byte   metadataseparatorInByte = 0x00;
                switch (metadataseparator.ToLower())
                {
                //The byte representation of special characters can be found here - http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
                case "comma": metadataseparatorInByte = 0xBC; break;

                case "space": metadataseparatorInByte = 0x20; break;

                case "enter": metadataseparatorInByte = 0x0D; break;

                case "tab": metadataseparatorInByte = 0x09; break;

                default: break;
                }
                //Print the epc in caps
                AddKeypress(inputList, (byte)Keys.Capital);  // Toggle Caps Lock

                //Print the tag reads
                foreach (TagReadData dat in reads)
                {
                    string tagData = string.Empty;
                    string epc     = string.Empty;
                    if (properties["displayformat"] == "base36")
                    {
                        epc = ConvertEPC.ConvertHexToBase36(dat.EpcString);
                    }
                    else
                    {
                        epc = dat.EpcString;
                    }

                    AddKeypresses(inputList, properties["prefix"].ToUpper());
                    AddKeypresses(inputList, epc.ToUpper());
                    AddKeypresses(inputList, properties["suffix"].ToUpper());

                    if (timestamp)
                    {
                        AddKeypress(inputList, metadataseparatorInByte);
                        AddKeypresses(inputList, dat.Time.ToString("yyyy-MM-dd-HH-mm-ss"));
                    }
                    if (rssi)
                    {
                        AddKeypress(inputList, metadataseparatorInByte);
                        AddKeypresses(inputList, dat.Rssi.ToString());
                    }
                    if (position)
                    {
                        AddKeypress(inputList, metadataseparatorInByte);
                        AddKeypresses(inputList, GpsMgr.LatLonString);
                    }

                    switch (properties["multipletagseparator"].ToLower())
                    {
                    case "comma": AddKeypress(inputList, 0xBC); break;

                    case "space": AddKeypress(inputList, 0x20); break;

                    case "enter": AddKeypress(inputList, 0x0D); break;

                    case "tab": AddKeypress(inputList, 0x09); break;

                    case "pipe":
                        AddInput(inputList, SHIFT_DOWN);
                        AddKeypress(inputList, 0xDC);
                        AddInput(inputList, SHIFT_UP);
                        break;

                    default: break;
                    }
                    // Send keystrokes after each tag read record -- input buffer
                    // isn't big enough to hold more than a few lines
                    SendInput(inputList);
                    inputList.Clear();
                }
                //Turn caps lock back off
                AddKeypress(inputList, (byte)Keys.Capital);  // Toggle Caps Lock
                SendInput(inputList);
            }

            catch (Exception ex)
            {
                logger.Error("In KeyboardWedgeRead(): " + ex.ToString());
                //MessageBox.Show(ex.Message);
                //Debug.Log(ex.ToString());
            }
        }
Esempio n. 4
0
        public ReadTags(NotifyIcon notifyIcon)
        {
            try
            {
                InitializeComponent();
                dgTagResult.DataSource = tagdb.TagList;
                //Set the column width of datagrid
                AddGridStyles();

                properties = Utilities.GetProperties();

                playBeep.SoundLocation = properties["decodewavefile"];
                playBeep.LoadAsync();
                playStopAudio.SoundLocation = properties["endscanwavefile"];
                playStopAudio.LoadAsync();
                playStartAudio.SoundLocation = properties["startscanwavefile"];
                playStartAudio.LoadAsync();

                setStatus(Status.READY);
                pvtNotifyIcon = notifyIcon;

                //For battery level
                status = new CoreDLL.SYSTEM_POWER_STATUS_EX();

                tmrBackLightControl = new System.Windows.Forms.Timer();
                tmrBackLightControl.Interval = 1000 * 30;// Timer will tick every 30 seconds
                tmrBackLightControl.Tick += new EventHandler(tmrBackLightControl_Tick);

                //Pistol grip read handler
                pistolTriggerEvent = new SystemState(SystemProperty.HeadsetPresent);
                pistolTriggerEvent.Changed += new ChangeEventHandler(pistolTriggerEvent_Changed);
                pistolTriggerEvent.DisableApplicationLauncher();
            }
            catch (Exception ex)
            {
                logger.Error("In ReadTags: " + ex.ToString());
                MessageBox.Show(ex.Message);
            }
        }