예제 #1
0
        void m_BCreader_BarcodeRead(object sender, BarcodeReadEventArgs bre)
        {
            string sBarcode;
            int    iSymID = bre.Symbology;

            sBarcode = bre.strDataBuffer;
            //remove unneeded chars
            sBarcode = sBarcode.Replace(" ", "");
            sBarcode = sBarcode.Replace("-", "");
            //test the barcode
            if (!VWGTLTAG.CheckBarCode(sBarcode))
            {
                Add2List(VWGTLTAG.LastError);
                ChangeStatus(eStatus.BarCodeErr);
                return;
            }
            //store data
            sFilter     = sBarcode.Substring(0, 4);
            sSupplierID = sBarcode.Substring(4, 9);
            sItemNumber = sBarcode.Substring(13, 9);
            System.Diagnostics.Debug.WriteLine("Barcode Data:\nFilter: " + sFilter + "\nSupplierID: " + sSupplierID + "\nItemNumber: " + sItemNumber);

            //set the barcode data
            ChangeStatus(eStatus.ReadTag);
            txtBarcodeData.Text = sBarcode;
            txtTagID.Text       = "";
            txtTagData.Text     = "";
            txtTagDataStr.Text  = "";
        }
예제 #2
0
        private void btnEncodeFilter_Click(object sender, EventArgs e)
        {
            vwtag = new ip4scanNtag.VWGTLTAG(txtBoxFilter.Text,
                                             txtSupplier.Text,
                                             txtItemNumber.Text,
                                             txtBoxID.Text);
            txtTagHex.Text = vwtag.GetHex();

            txtTagRead.Text = vwtag.ToString();
        }
예제 #3
0
 private void btnDecodeTagFromHex_Click(object sender, EventArgs e)
 {
     if (!VWGTLTAG.IsValidTag(txtTagHex.Text))
     {
         txtTagHex.BackColor = Color.Red;
         return;
     }
     else
     {
         txtTagHex.BackColor = Color.LightGreen;
     }
     ip4scanNtag.VWGTLTAG vwtag1 = new ip4scanNtag.VWGTLTAG(txtTagHex.Text);
     //read values
     txtBoxFilter.Text  = vwtag1.sFilter;
     txtSupplier.Text   = vwtag1.iSupplierID.ToString();
     txtItemNumber.Text = vwtag1.iItemNumber.ToString();
     txtBoxID.Text      = vwtag1.BoxID.ToString();
 }
예제 #4
0
        private bool ExecuteCMD(string tCMD)
        {
            string tMsg = null;

            Add2List("Sending->" + tCMD);
            try
            {
                if (m_Reader.IsConnected)
                {
                    tMsg = m_Reader.Execute(tCMD);
                }
                else
                {
                    ChangeStatus(eStatus.Offline);
                    Add2List("Reader disconnected, please Connect");
                    return(false);
                }
            }
            catch (BasicReaderException eBRI)
            {
                Add2List("BasicReaderException: " + eBRI.ToString());
                //MessageBox.Show("BasicReaderException: IDL ERR occured for CMD: " + tCMD + "\r\n" + eBRI.ToString());
                ChangeStatus(eStatus.Offline);
                return(false);
            }
            //"H112233445566778899001122 HE2001040\r\nOK>"
            Add2List("--->" + tMsg);
            //Show TAG ID
            if (sCurrentCMD.Equals("READ TAGID"))
            {
                sbyte[] aFieldSeparator = { (sbyte)' ' };
                sbyte[] aRespBuf        = tools.StrToSByteArray(tMsg);
                Tag[]   tags            = BRIParser.GetTags(aRespBuf, aFieldSeparator);
                if (tags == null)
                {
                    return(false);
                }
                if (tags.GetLength(0) == 1)
                {
                    //only one tag should be visible
                    //save the last 22Bits as Box ID
                    if (VWGTLTAG.IsValidTag(tags[0].ToString()) == false)
                    {
                        DialogResult ant = MessageBox.Show("Tag does not meet specs. Overwrite?", "VW tag demo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                        if (ant == DialogResult.Yes)
                        {
                            UInt32 uBox = vwTag.BoxID;
                            vwTag       = new VWGTLTAG();
                            vwTag.BoxID = uBox;
                        }
                        else
                        {
                            ChangeStatus(eStatus.InvalidTag);
                            return(false);
                        }
                    }
                    else
                    {
                        vwTag = new VWGTLTAG(tags[0].ToString()); //create a new tag with the tag data read
                    }
                    //read the box id from the tag
                    iCurrentBoxID = vwTag.BoxID;
                    txtBoxID.Text = iCurrentBoxID.ToString();

                    //fill txtbox with data from tag
                    txtTagDataStr.Text = vwTag.sFilter + " " +
                                         vwTag.iSupplierID.ToString() + " " +
                                         vwTag.iItemNumber.ToString();

                    System.Diagnostics.Debug.WriteLine("READ TAGID tag data: " + vwTag.ToString());
                    //tagKey is the same as tag data
                    //System.Diagnostics.Debug.WriteLine("READ TAGID: tags[0].tagkey: " + tools.Hex2Asc(sByteArrayToString(tags[0].TagKey)));

                    //store TAGID
                    sHexCurrentTagID = tags[0].TagFields.FieldArray[0].DataString.Substring(1);
                    ChangeStatus(eStatus.WriteTag);
                }
                else
                {
                    //only one tag should be visible
                    ChangeStatus(eStatus.TooManyTags);
                }

                //read tag data (aka EPCID)
                if (tMsg.StartsWith("H"))
                {
                    string s;
                    s = tMsg.Substring(1, tMsg.IndexOf(" ") - 1);
                    txtTagData.Text = s;
                    s             = tMsg.Substring(s.Length + 1);
                    s             = tools.CopyToR(s);
                    s             = s.Substring(s.IndexOf("H") + 1);
                    txtTagID.Text = s;
                }
            }

            if (sCurrentCMD.Equals("ATTRIB TAGTYPE=EPCC1G2") == true)
            {
                if (tMsg.IndexOf("OK") >= 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if (tMsg.IndexOf("ERR") >= 0 && sCurrentCMD.Equals("ATTRIB SCHEDOPT=1") == false)
            {
                //MessageBox.Show("Warning, BRI ERR occured for: " + tCMD + "\r\n" + tMsg);
                Add2List("Warning, BRI ERR occured for: " + tCMD + "\r\n" + tMsg);
                return(false);
            }

            if (sCurrentCMD.StartsWith("W "))
            {
                if (tMsg.IndexOf("ERR") >= 0 && CurrentStatus == eStatus.WriteTag)
                {
                    ChangeStatus(eStatus.WriteTagError);
                    return(false);
                }

                if (tMsg.IndexOf("WROK") >= 0 && (CurrentStatus == eStatus.WriteTagError) || (CurrentStatus == eStatus.WriteTag))
                {
                    HighBeep.Play();
                    ChangeStatus(eStatus.ReadBarcode);
                    if (tMsg.StartsWith("H"))//"H303033353032393035343135 HE2001040 WROK\r\nOK>"
                    {
                        string s;
                        s = tMsg.Substring(1, tMsg.IndexOf(" ") - 1);
                        txtTagData.Text = s;
                        System.Diagnostics.Debug.WriteLine("WROK: tag data string: " + s);
                        s = tMsg.Substring(s.Length + 1);
                        s = tools.CopyToR(s);
                        s = s.Substring(s.IndexOf("H") + 1);
                        //"E2001040 WROK"
                        txtTagID.Text = s.Substring(1, s.IndexOf(" ") - 1);
                        System.Diagnostics.Debug.WriteLine(s);
                    }
                }
            }
            return(true);
        }