コード例 #1
0
ファイル: FrAntennaPower.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Get Power List
        /// </summary>
        private void GetAntennaPower()
        {
            byte[] powerlist = null;
            string errInfo   = "";

            if (TagOperation.GetAntennaPower(out powerlist, out errInfo))
            {
                if (powerlist != null && powerlist.Length > 0)
                {
                    int val   = powerlist[0];
                    int count = 0;
                    foreach (ComboBindData o in cbdbm.Items)
                    {
                        if (val == (int)o.ValueMember)
                        {
                            cbdbm.SelectedIndex = count;
                            break;
                        }
                        count++;
                    }
                    string strtmp   = "The Power is :{0} dBm.";
                    string strpower = string.Format(strtmp, _startpower + val);
                    AddToStatusAsync(strpower);
                    FormatConvert.SoundSucceed();
                }
            }
            else
            {
                AddToStatusAsync("Query failed," + errInfo);
            }
        }
コード例 #2
0
        protected void UiWriteUserdata_6B()
        {
            AddToStatusAsync("");
            string strdata = tvDataMemo.Text;

            if (strdata == "")
            {
                AddToStatusAsync("Input the write data.");
                tvDataMemo.Focus();
                return;
            }

            string strpwd = tvPassword.Text;

            if (strpwd == "")
            {
                AddToStatusAsync("Input the tag password.");
                tvPassword.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            string strcode = cbTargetTag.SelectedItem.ToString();

            byte[] selcode = null;
            try
            {
                if (strcode != "")
                {
                    selcode = Util.ConvertHexStringToByteArray(strcode);
                }
                uint   offset     = (ushort)(Convert.ToUInt32(tvOffsetAddr.Text));
                uint   length     = (ushort)(Convert.ToUInt32(tvLength.Text));
                byte[] bwritedata = Util.ConvertHexStringToByteArray(strdata);
                byte[] bpwd       = Util.ConvertHexStringToByteArray(strpwd);
                string errInfo    = "";
                bool   ret        = false;
                ret = TagOperation.WriteUserdata_6B(selcode, offset, bwritedata, out errInfo);
                string strmsg = "";
                string strtmp = "";
                if (ret == true)
                {
                    strtmp = "Write {0} bytes.";
                    strmsg = string.Format(strtmp, bwritedata.Length);
                    AddToStatusAsync(strmsg);
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    strtmp = "Write failed, {0}";
                    AddToStatusAsync(string.Format(strtmp, errInfo));
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #3
0
        private void SetOK()
        {
            string err = "";

            try
            {
                ushort tidlen = Convert.ToUInt16(tvDefaultTidLength.Text);

                if (!TagOperation.SetDefualtTidLength(tidlen, out err))
                {
                    this.lbmsg.Text = string.Format("Set Defualt Tid Length Failure,{0}!", err);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }

            try
            {
                ushort ival = 30;
                ival = Convert.ToUInt16(tvScanInterval.Text);

                if (ival < 0)
                {
                    ival = 0;
                }
                else if (ival > 255)
                {
                    ival = 255;
                }

                if (TagOperation.SetScanInterval(ival, out err))
                {
                    if (ival == 0)
                    {
                        TagOperation.SetLoopRead(out err);
                    }
                }
                else
                {
                    this.lbmsg.Text = this.lbmsg.Text + string.Format("Set Defualt Tid Length Failure,{0}!", err);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }
            if (err != "")
            {
                FormatConvert.SoundError(); return;
            }
            FormatConvert.SoundSucceed();
            Close();
        }
コード例 #4
0
        protected void UiWriteEpc()
        {
            AddToStatusAsync("");
            string strdata = tvDataMemo.Text;

            if (strdata == "")
            {
                AddToStatusAsync("Input the write data.");
                tvDataMemo.Focus();
                return;
            }
            string strpwd = tvPassword.Text;

            if (strpwd == "")
            {
                AddToStatusAsync("Input the tag password.");
                tvPassword.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            string strcode = cbTargetTag.SelectedItem.ToString();

            byte[] selcode = null;
            try
            {
                if (strcode != "")
                {
                    selcode = Util.ConvertHexStringToByteArray(strcode);
                }
                byte[] bwritedata = Util.ConvertHexStringToByteArray(strdata);
                byte[] bpwd       = Util.ConvertHexStringToByteArray(strpwd);
                string errInfo    = "";
                string strtmp     = "";
                if (TagOperation.WriteEpc(bpwd, bwritedata, selcode, selCodeArea, out errInfo))
                {
                    strtmp = "Write {0} bytes.";
                    AddToStatusAsync(string.Format(strtmp, bwritedata.Length));
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    //strtmp = CurLanguage.GetMsg("MSG_13");
                    //AddToStatusAsync(string.Format(strtmp, errInfo));
                    AddToStatusAsync(errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #5
0
        protected void UiReadEpc()
        {
            AddToMemoAsync("");
            string strcode = cbTargetTag.SelectedItem.ToString();

            //MessageBox.Show("strCode es: " + strcode);
            byte[] selcode = null;
            if (strcode != "")
            {
                selcode = Util.ConvertHexStringToByteArray(strcode);
                //foreach (byte element in selcode) {
                //    MessageBox.Show("selcode es: " + element.ToString());
                //}
            }

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                string errInfo  = "";
                string strtmp   = "";
                byte[] readdata = null;
                bool   ret      = TagOperation.ReadEpc(selcode, selCodeArea, QValue, out readdata, out errInfo);
                if (ret && readdata != null)
                {
                    //foreach(byte elemet in readdata){
                    //    MessageBox.Show("readdata es: " + elemet.ToString());
                    //}
                    //MessageBox.Show("decode readData: " + BitConverter.ToString(readdata));

                    byte[] tepc = null;
                    int    rssi = 0;
                    string sepc = string.Empty;
                    sepc = Util.ConvertByteArrayToHexString(readdata);
                    AddToMemoAsync(sepc);
                    strtmp = "Acquired data {0} bytes.";
                    AddToStatusAsync(string.Format(strtmp, readdata.Length));
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    //strtmp = CurLanguage.GetMsg("MSG_1");
                    //AddToStatusAsync(string.Format(strtmp, errInfo));
                    AddToStatusAsync(errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #6
0
        protected void UiReadUserdata_6C()
        {
            MessageBox.Show("UiReadUserdata_6C");
            AddToMemoAsync("");
            string strcode = cbTargetTag.SelectedItem.ToString();

            byte[] selcode = null;
            if (strcode != "")
            {
                MessageBox.Show("strCode: " + selcode);
                selcode = Util.ConvertHexStringToByteArray(strcode);
            }

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                uint   offset   = (uint)(Convert.ToUInt32(tvOffsetAddr.Text));
                uint   length   = (uint)(Convert.ToUInt32(tvLength.Text));
                byte[] readdata = null;
                string errInfo  = "";
                string strtmp   = "";
                bool   ret      = TagOperation.ReadUserdata_6C(offset, length, selcode, selCodeArea, out readdata, out errInfo);
                if (ret && readdata != null)
                {
                    if (readdata != null)
                    {
                        foreach (byte element in readdata)
                        {
                            MessageBox.Show("readdata: " + element.ToString());
                        }
                        string str = Util.ConvertByteArrayToHexString(readdata);
                        AddToMemoAsync(str);
                        strtmp = "Acquired data {0} bytes.";
                        AddToStatusAsync(string.Format(strtmp, readdata.Length));
                        FormatConvert.SoundSucceed();
                    }
                }
                else
                {
                    //strtmp = CurLanguage.GetMsg("MSG_1");
                    //AddToStatusAsync(string.Format(strtmp, errInfo));
                    AddToStatusAsync(errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #7
0
        private void SetRssiStatus(bool enable)
        {
            string err = "";

            this.lbmsg.Text = "";
            try
            {
                if (!TagOperation.SetRssiStatus(enable, out err))
                {
                    this.lbmsg.Text = string.Format("Set Rssi Failure,{0}!", err);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
コード例 #8
0
        protected void UiReadUserdata_6B()
        {
            AddToMemoAsync("");
            string strcode = cbTargetTag.SelectedItem.ToString();

            byte[] selcode = null;
            if (strcode != "")
            {
                selcode = Util.ConvertHexStringToByteArray(strcode);
            }

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                uint   offset   = (uint)(Convert.ToUInt32(tvOffsetAddr.Text));
                uint   length   = (uint)(Convert.ToUInt32(tvLength.Text));
                byte[] readdata = null;
                string errInfo  = "";
                string strtmp   = "";
                bool   ret      = TagOperation.ReadUserdata_6B(selcode, offset, length, out readdata, out errInfo);
                if (ret && readdata != null)
                {
                    if (readdata != null)
                    {
                        string str = Util.ConvertByteArrayToHexString(readdata);
                        AddToMemoAsync(str);
                        strtmp = "Acquired data {0} bytes.";
                        AddToStatusAsync(string.Format(strtmp, readdata.Length));
                        FormatConvert.SoundSucceed();
                    }
                }
                else
                {
                    strtmp = "ead failed, {0}!";
                    AddToStatusAsync(string.Format(strtmp, errInfo));
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #9
0
        protected void SetControlValue()
        {
            string err = "";

            try
            {
                ushort tidlen = 0;
                if (TagOperation.GetDefaultTidLength(out tidlen, out err))
                {
                    tvDefaultTidLength.Text = tidlen.ToString();
                }
                else
                {
                    tvDefaultTidLength.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            try
            {
                ushort ival = 30;
                if (TagOperation.GetScanInterval(out ival, out err))
                {
                    tvScanInterval.Text = ival.ToString();
                }
                else
                {
                    tvScanInterval.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            GetRssiStatus();
        }
コード例 #10
0
ファイル: FrAntennaPower.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Set Antenna Power
        /// </summary>
        private void SetAntennaPower()
        {
            if (cbdbm.SelectedIndex < 0)
            {
                return;
            }
            string errInfo = "";
            byte   val     = Convert.ToByte(cbdbm.SelectedValue);

            if (TagOperation.SetAntennaPower(val, out errInfo))
            {
                AddToStatusAsync("Set successfully.");
                FormatConvert.SoundSucceed();
                Close();
                return;
            }
            else
            {
                AddToStatusAsync("Failed," + errInfo);
                FormatConvert.SoundError();
            }
        }
コード例 #11
0
ファイル: FrAntennaPower.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Initialize Power List
        /// </summary>
        /// <returns></returns>
        private bool InitializePowerList()
        {
            List <ComboBindData> antennaPowerList = new List <ComboBindData>();

            string err = "";

            byte[] curfreqs = null;
            bool   iret     = TagOperation.GetPowerList(out curfreqs, out err);

            if (iret && curfreqs != null)
            {
                for (int i = 0; i < curfreqs.Length; i++)
                {
                    if (curfreqs[i] != 0x00)
                    {
                        {
                            antennaPowerList.Add(new ComboBindData(_startpower + i, i));
                        }
                    }
                }
            }

            if (antennaPowerList.Count < 1)
            {
                return(false);
            }

            cbdbm.DataSource    = antennaPowerList;
            cbdbm.DisplayMember = "DisplayMember";
            cbdbm.ValueMember   = "ValueMember";
            if (cbdbm.Items.Count > 0)
            {
                cbdbm.SelectedIndex = 0;
            }

            return(true);
        }
コード例 #12
0
        private void GetRssiStatus()
        {
            ushort val = 0;
            string err = "";

            try
            {
                if (TagOperation.GetRssiStatus(out val, out err))
                {
                    if (val == 1)
                    {
                        chkRssi.Checked = true;
                    }
                    else
                    {
                        chkRssi.Checked = false;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }