コード例 #1
0
ファイル: FrConfig.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Read TID
        /// </summary>
        private void ReadTID()
        {
            byte[] tagID = null;
            byte[] data;
            string strerr;

            if (TagOperation.ReadTID(tagID, selCodeArea, 1, out data, out strerr))
            {
                tagID = data;
                string tid = Util.ConvertByteArrayToHexWordString(data);
                for (int i = 0; i < cbTargetTag.Items.Count; i++)
                {
                    if (tid == cbTargetTag.Items[i].ToString())
                    {
                        FormatConvert.SoundSucceed();
                        return;
                    }
                }
                cbTargetTag.Items.Add(tid);
                this.cbTargetTag.Text = tid;
                AddToStatusAsync("");
                FormatConvert.SoundSucceed();
            }
            else
            {
                AddToStatusAsync("Read failure," + strerr);
                FormatConvert.SoundError();
            }
        }
コード例 #2
0
        private async void CalculateSonicBoomMenuItem_Click()
        {
            var CalculateArgs = new CalculateSonicBoomEventArgs(
                RocketGeometricalParameters,
                VehicleGeometricalParameters,
                RocketSonicBoomBallistics,
                VehicleSonicBoomBallistics,
                SonicBoomWeatherParameters);
            await Task.Run(() => CalculateSonicBoom(CalculateArgs));

            Action <List <SonicBoomParameters>, DataGridView> SetResults = (SonicBoomParameters, Grid) =>
            {
                Grid.Rows.Clear();
                if ((SonicBoomParameters == null) || (SonicBoomParameters.Count == 0))
                {
                    return;
                }
                Grid.Rows.Add(SonicBoomParameters.Count);
                for (int i = 0; i < SonicBoomParameters.Count; i++)
                {
                    var Row = Grid.Rows[i];
                    var sbp = SonicBoomParameters[i];
                    Row.Cells[0].Value = FormatConvert.ToString(sbp.Time);
                    Row.Cells[1].Value = FormatConvert.ToString(sbp.Height * 1E-3);
                    Row.Cells[2].Value = FormatConvert.ToString(sbp.MachNumber);
                    Row.Cells[3].Value = FormatConvert.ToString(sbp.OverPressure);
                    Row.Cells[4].Value = FormatConvert.ToString(sbp.SoundLevel);
                    Row.Cells[5].Value = FormatConvert.ToString(sbp.ImpactDistance * 1E-3);
                    Row.Cells[6].Value = FormatConvert.ToString(sbp.ImpactDuration);
                }
            };

            SetResults(CalculateArgs.RocketSonicBoomParameters, RocketSonicBoomGrid);
            SetResults(CalculateArgs.VehicleSonicBoomParameters, VehicleSonicBoomGrid);
        }
コード例 #3
0
        /// <summary>
        /// Cancel Epc Filter
        /// </summary>
        private void CancelEpcFilter()
        {
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                string errInfo = "";
                byte[] bcode   = new byte[listBoxAddr.Items.Count];
                byte[] match   = new byte[this.listBoxAddr.Items.Count];
                for (int i = 0; i < match.Length; i++)
                {
                    match[i] = 0x00;
                }

                if (RfidConfig.SetEpcFilter(0x01, bcode, match, out errInfo))
                {
                    AddToStatusAsync("Cancel match EPC.");
                    FormatConvert.SoundSucceed();
                    Close();
                }
                else
                {
                    FormatConvert.SoundError();
                    AddToStatusAsync("Cancel Failed");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #4
0
        /// <summary>
        /// ReadEpc
        /// </summary>
        private void ReadEpc()
        {
            byte[] tagEpc = null;
            byte[] data;
            string strerr;

            TagOperation.RfidConnecte();
            if (TagOperation.ReadEpc(tagEpc, selCodeArea, 1, out data, out strerr))
            {
                tagEpc = data;
                string epc = Util.ConvertByteArrayToHexWordString(data);
                for (int i = 0; i < tvEpcData.Items.Count; i++)
                {
                    if (epc == tvEpcData.Items[i].ToString())
                    {
                        FormatConvert.SoundSucceed();
                        return;
                    }
                }
                tvEpcData.Items.Add(epc);
                this.tvEpcData.Text = epc;
                AddToStatusAsync("");
                FormatConvert.SoundSucceed();
            }
            else
            {
                AddToStatusAsync("Read failure," + strerr);
                FormatConvert.SoundError();
            }
        }
コード例 #5
0
ファイル: FrFrequency.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Query Frequency
        /// </summary>
        private void QueryFrequency()
        {
            byte[] freq    = null;
            string errInfo = "";

            this.lbdisplay.BeginUpdate();
            lbdisplay.Items.Clear();
            this.lbdisplay.DisplayMember = "DisplayMember";
            this.lbdisplay.ValueMember   = "ValueMember";
            if (RfidConfig.GetFrequency(out freq, out errInfo))
            {
                foreach (byte b in freq)
                {
                    string valshow = FrequencyQueryDisplay(b);

                    lbdisplay.Items.Add(new ComboBindData(valshow, b));
                }
                AddToStatusAsync("Search SuccessFully!");
                FormatConvert.SoundSucceed();
            }
            else
            {
                AddToStatusAsync("Search Failed," + errInfo);
                FormatConvert.SoundError();
            }

            this.lbdisplay.EndUpdate();
        }
コード例 #6
0
        /// <summary>
        /// Set Epc Filter
        /// </summary>
        private void SetEpcFilter()
        {
            string errInfo = "";
            string strhex  = FormatConvert.HaxToStr(tvEpcData.Text.Trim());

            if (strhex == "" ||
                strhex.Length != 24)
            {
                AddToStatusAsync("Input tag EPC(12-byte)!");
                tvEpcData.Focus();
                return;
            }
            if (listBoxChooseAddr.Items.Count < 1)
            {
                AddToStatusAsync("Select matched data!");
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                byte[] match = new byte[this.listBoxAddr.Items.Count];
                for (int i = 0; i < match.Length; i++)
                {
                    match[i] = 0x00;
                }
                foreach (object o in this.listBoxChooseAddr.Items)
                {
                    ComboBindData item = (ComboBindData)o;
                    int           iadd = Convert.ToInt32(item.ValueMember);
                    match[iadd] = 0xFF;
                }
                byte[] bcode = Util.ConvertHexStringToByteArray(strhex);

                if (RfidConfig.SetEpcFilter(0x00, bcode, match, out errInfo))
                {
                    AddToStatusAsync("Configure EPC match completed.");
                    FormatConvert.SoundSucceed();
                    Close();
                }
                else
                {
                    FormatConvert.SoundError();
                    AddToStatusAsync("Configure EPC match failed!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #7
0
ファイル: FrConfig.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Set Access PassWord
        /// </summary>
        private void SetAccessPwd()
        {
            string oldpwd  = tvOriAccessPwd.Text;
            string newpwd  = tvNewAccessPwd.Text;
            string strcode = "";

            if (cbTargetTag.Items.Count > 0)
            {
                strcode = cbTargetTag.SelectedItem.ToString();
            }
            if (strcode == "")
            {
                AddToStatusAsync("Please select one tag!");
                cbTargetTag.Focus();
                return;
            }
            if (oldpwd == "")
            {
                AddToStatusAsync("Old password can not empty!");
                tvOriAccessPwd.Focus();
                return;
            }
            if (newpwd == "")
            {
                AddToStatusAsync("New password can not empty!");
                tvNewAccessPwd.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                byte[] bcode   = Util.ConvertHexStringToByteArray(strcode);
                byte[] boldPwd = Util.ConvertHexStringToByteArray(oldpwd);
                byte[] bnewPwd = Util.ConvertHexStringToByteArray(newpwd);
                string errInfo = "";
                if (TagOperation.SetAccessPassword(boldPwd, bnewPwd, bcode, selCodeArea, out errInfo))
                {
                    AddToStatusAsync("Set Access Password Successfully!");
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    AddToStatusAsync("Set Access Password Failed," + errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #8
0
ファイル: FrWriteTags.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Write Epc
        /// </summary>
        protected void UiWriteEpc()
        {
            AddToStatusAsync("");
            string strdata = tvDataMemo.Text;

            if (strdata == "")
            {
                AddToStatusAsync("EPC can not empty!");
                tvDataMemo.Focus();
                return;
            }
            string strpwd = tvPassword.Text;

            if (strpwd == "")
            {
                AddToStatusAsync("PassWord can not empty!");
                tvPassword.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();

            try
            {
                byte[] bwritedata = FormatConvert.getWriteData(strdata);
                byte[] bpwd       = FormatConvert.getPwd(strpwd);
                string errInfo    = "";
                string strtmp     = "";
                if (TagOperation.WriteEpc(bpwd, bwritedata, tagID, selCodeArea, out errInfo))
                {
                    strtmp = "Write: " + bwritedata.Length.ToString() + " byte!";
                    AddToStatusAsync(string.Format(strtmp));
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    AddToStatusAsync("Write failure," + errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #9
0
        public static void RunTest()
        {
            WalletData wallet = new Wallet()
                                .CreationDate(new DateTime(2018, 7, 4, 0, 0, 0, DateTimeKind.Utc))
                                .FolderPath("")
                                .Mnemonic("woman assume obscure neglect today real blue print wrap follow salad shadow")
                                .Name("test2")
                                .Network("StratisTest")
                                .Password("password")
                                .Create;

            NodeWeb nodeWeb = new NodeWeb();

            nodeWeb.Payload = FormatConvert.ObjToJSON(wallet);
            nodeWeb.Port    = "38221";
            nodeWeb.Path    = "api/Wallet/recover";
            nodeWeb.Host    = "localhost";
            nodeWeb.Request();
        }
コード例 #10
0
ファイル: FrKillTag.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Kill Tag
        /// </summary>
        private void KillTag()
        {
            string TitleText = "";

            if (cbTargetTag.SelectedIndex < 0)
            {
                AddToStatusAsync("Plese select one tag epc!");
                return;
            }
            string strepc = cbTargetTag.SelectedItem.ToString();
            string strpwd = tvKillPwd.Text;

            if (strpwd == "")
            {
                AddToStatusAsync("The KillPassWord can not empty!");
                return;
            }
            if (DialogResult.No == MessageBox.Show("Are you sure to kill the tag?", TitleText, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
            {
                return;
            }

            byte[] bepc    = Util.ConvertHexStringToByteArray(strepc);
            byte[] killPwd = Util.ConvertHexStringToByteArray(strpwd);
            string errInfo = "";

            if (TagOperation.KillTag_6C(killPwd, bepc, out errInfo))
            {
                AddToStatusAsync("Kill Tag Successfully.");
                FormatConvert.SoundSucceed();
            }
            else
            {
                AddToStatusAsync("Kill Tag Failed," + errInfo);
                FormatConvert.SoundError();
            }
        }
コード例 #11
0
ファイル: FrFrequency.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Set Frequency
        /// </summary>
        private void SetFrequency()
        {
            string errInfo = "";

            if (lbdisplay.Items.Count < 1)
            {
                AddToStatusAsync("No frequency.");
                return;
            }
            List <byte> freqList = new List <byte>();

            foreach (object b in lbdisplay.Items)
            {
                ComboBindData cbd = (ComboBindData)b;
                freqList.Add(Convert.ToByte(cbd.ValueMember));
            }
            if (freqList.Count > 0)
            {
                if (RfidConfig.SetFrequency(freqList.ToArray(), out errInfo))
                {
                    AddToStatusAsync("Set frequency completed.");
                    FormatConvert.SoundSucceed();
                    Close();
                    return;
                }
                else
                {
                    AddToStatusAsync("Set Failed," + errInfo);
                    FormatConvert.SoundError();
                }
            }
            else
            {
                AddToStatusAsync("No frequency.");
            }
        }
コード例 #12
0
        private async void CalculatEngineNoiseMenuItem_Click()
        {
            dataGridView1.Scroll -= Grid_Scroll;
            dataGridView2.Scroll -= Grid_Scroll;
            dataGridView3.Scroll -= Grid_Scroll;
            var CalculateArgs = new CalculateEngineNoiseEventArgs();
            await Task.Run(() => CalculateEngineNoise(CalculateArgs));

            dataGridView4.Rows[0].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters.MechanicalPower * 1E-6);
            dataGridView4.Rows[1].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters.SoundPower * 1E-6);
            dataGridView4.Rows[2].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters.SoundPowerRatio);
            dataGridView4.Rows[3].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters.SoundMaximalPowerConeHalfAngle);
            dataGridView4.Rows[4].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters.UndisturbedSupersonicFlowLength);
            dataGridView4.Rows[5].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters.DistanceToPointOfMaximalSoundLevel);
            dataGridView4.Rows[6].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters.SupersonicFlowLength);
            dataGridView4.Rows[7].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters._98ProzentSoundPowerRadiatingFlowLength);
            dataGridView4.Rows[8].Cells[1].Value = FormatConvert.ToString(CalculateArgs.FlowSoundParameters.DistanceToPointOfFlowDestruction);
            EngineFrequencyGrid.Rows.Clear();
            EngineFrequencyGrid.Rows.Add(CalculateArgs.FrequencyCharacteristik.Keys.Count);
            int i = 0;

            foreach (var FrequencyCharacteristik in CalculateArgs.FrequencyCharacteristik)
            {
                EngineFrequencyGrid.Rows[i].Cells[0].Value = FormatConvert.ToString(FrequencyCharacteristik.Key);
                EngineFrequencyGrid.Rows[i].Cells[1].Value = FormatConvert.ToString(FrequencyCharacteristik.Value);
                i++;
            }
            EngineFrequencyGraphPane.CurveList.Clear();
            EngineFrequencyGraphPane.AddCurve(
                "",
                CalculateArgs.FrequencyCharacteristik.Select(x => x.Key).ToArray(),
                CalculateArgs.FrequencyCharacteristik.Select(x => x.Value).ToArray(),
                Color.Black,
                SymbolType.None);
            EngineFrequencyGraphPane.AxisChange();
            zedGraphControl3.Invalidate();
            RadiationPatternGrid.Rows.Clear();
            RadiationPatternGrid.Rows.Add(CalculateArgs.RadiationPattern.Keys.Count);
            i = 0;
            foreach (var RadiationPattern in CalculateArgs.RadiationPattern)
            {
                RadiationPatternGrid.Rows[i].Cells[0].Value = FormatConvert.ToString(RadiationPattern.Key);
                RadiationPatternGrid.Rows[i].Cells[1].Value = FormatConvert.ToString(RadiationPattern.Value);
                i++;
            }
            RadiationPatternGraphPane.CurveList.Clear();
            RadiationPatternGraphPane.AddCurve(
                "",
                CalculateArgs.RadiationPattern.Select(x => x.Key).ToArray(),
                CalculateArgs.RadiationPattern.Select(x => x.Value).ToArray(),
                Color.Black,
                SymbolType.None);
            RadiationPatternGraphPane.AxisChange();
            zedGraphControl4.Invalidate();
            EngineAcousticsLoadGrid.Rows.Clear();
            EngineAcousticsLoadGrid.Rows.Add(CalculateArgs.EngineAcousticsLoadAtFrequency.Keys.Count);
            i = 0;
            foreach (var EngineAcousticsLoad in CalculateArgs.EngineAcousticsLoadAtFrequency)
            {
                EngineAcousticsLoadGrid.Rows[i].Cells[0].Value = FormatConvert.ToString(EngineAcousticsLoad.Key);
                EngineAcousticsLoadGrid.Rows[i].Cells[1].Value = FormatConvert.ToString(EngineAcousticsLoad.Value);
                i++;
            }
            textBox32.Text    = FormatConvert.ToString(CalculateArgs.EngineAcousticsLoadSummary);
            pictureBox1.Image = CalculateArgs.EngineSoundContour.Contour;
            Contour           = new DoubleInterpolation(CalculateArgs.EngineSoundContour.X, CalculateArgs.EngineSoundContour.Y, CalculateArgs.EngineSoundContour.SoundLevels);
            dataGridView2.Columns.Clear();
            dataGridView3.Columns.Clear();
            for (int j = 0; j < CalculateArgs.EngineSoundContour.Y.Length; j++)
            {
                dataGridView2.Columns.Add("", "");
                dataGridView3.Columns.Add("", "");
            }
            foreach (var column in dataGridView2.Columns.Cast <DataGridViewColumn>())
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            foreach (var column in dataGridView3.Columns.Cast <DataGridViewColumn>())
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            dataGridView2.Rows.Add();
            for (int j = 0; j < CalculateArgs.EngineSoundContour.Y.Length; j++)
            {
                dataGridView2.Rows[0].Cells[j].Value = FormatConvert.ToString(CalculateArgs.EngineSoundContour.Y[j]);
            }
            dataGridView1.Rows.Clear();
            dataGridView1.Rows.Add(CalculateArgs.EngineSoundContour.X.Length);
            for (i = 0; i < CalculateArgs.EngineSoundContour.X.Length; i++)
            {
                dataGridView1.Rows[i].Cells[0].Value = FormatConvert.ToString(CalculateArgs.EngineSoundContour.X[i]);
                dataGridView3.Rows.Add();
                for (int j = 0; j < CalculateArgs.EngineSoundContour.Y.Length; j++)
                {
                    dataGridView3.Rows[i].Cells[j].Value = FormatConvert.ToString(CalculateArgs.EngineSoundContour.SoundLevels[i, j]);
                }
            }
            dataGridView1.Scroll += Grid_Scroll;
            dataGridView2.Scroll += Grid_Scroll;
            dataGridView3.Scroll += Grid_Scroll;
        }
コード例 #13
0
ファイル: FrWriteTags.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Read Tag Data
        /// </summary>
        private void UiReadData()
        {
            this.lblStatus.Text = "";
            //byte[] selCode = null;
            byte[] data    = null;
            string strerr  = null;
            int    _offset = 0;
            int    _length = 28;
            string errinfo;

            if (rbEpc.Checked)
            {
                if (TagOperation.ReadEpc(tagID, selCodeArea, 1, out data, out strerr))
                {
                    this.tvDataMemo.Text = Util.ConvertByteArrayToHexWordString(data);
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    errinfo = string.Format("Read failure,{0}", strerr);
                    AddToStatusAsync(errinfo);
                    FormatConvert.SoundError();
                }
            }
            else if (rbTid.Checked)
            {
                if (TagOperation.ReadTID(tagID, selCodeArea, 1, out data, out strerr))
                {
                    tagID = data;
                    string tid = Util.ConvertByteArrayToHexWordString(data);
                    for (int i = 0; i < cbtid.Items.Count; i++)
                    {
                        if (tid == cbtid.Items[i].ToString())
                        {
                            this.tvDataMemo.Text = "";
                            FormatConvert.SoundSucceed();
                            return;
                        }
                    }
                    cbtid.Items.Add(tid);
                    this.cbtid.Text      = tid;
                    this.tvDataMemo.Text = "";
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    errinfo = string.Format("Read failure,{0}", strerr);
                    AddToStatusAsync(errinfo);
                    FormatConvert.SoundError();
                }
            }
            else
            {
                if (TagOperation.ReadUserdata_6C((ushort)_offset, (ushort)_length, tagID, selCodeArea, out data, out strerr))
                {
                    this.tvDataMemo.Text = Util.ConvertByteArrayToHexWordString(data);
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    errinfo = string.Format("Read failure,{0}", strerr);
                    AddToStatusAsync(errinfo);
                    FormatConvert.SoundError();
                }
            }
        }
コード例 #14
0
ファイル: FrWriteTags.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Write Userdata_6C
        /// </summary>
        protected void UiWriteUserdata_6C()
        {
            AddToStatusAsync("");
            string strdata = tvDataMemo.Text;

            if (strdata == "")
            {
                AddToStatusAsync("User Data can not empty!");
                tvDataMemo.Focus();
                return;
            }

            string strpwd = tvPassword.Text;

            if (strpwd == "")
            {
                AddToStatusAsync("PassWord can not empty!");
                tvPassword.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();

            try
            {
                uint   offset      = (ushort)(Convert.ToUInt32("0"));
                ushort BlockLength = 4;
                ushort BlockSize   = 6;
                byte[] bwritedata  = FormatConvert.getWriteData(strdata);
                byte[] bpwd        = FormatConvert.getPwd(strpwd);
                string errInfo     = "";
                int    hadlen      = 0;
                bool   ret         = false;
                int    OpWriteMode = this.cbtype.SelectedIndex;

                byte[] selcode = tagID;

                switch (OpWriteMode)
                {
                case 1:
                    ret = TagOperation.BlockWriteData_6C(offset, bpwd, MemoryBank.UserMemory, bwritedata, selcode, selCodeArea, BlockLength, out hadlen, out errInfo);
                    break;

                case 2:
                    ret = TagOperation.BlockEraseData_6C(offset, bpwd, MemoryBank.UserMemory, BlockLength, BlockSize, selcode, selCodeArea, out errInfo);
                    break;

                default:
                    ret = TagOperation.WriteUserdata_6C(offset, bpwd, bwritedata, selcode, selCodeArea, out errInfo);
                    break;
                }

                if (ret == true)
                {
                    string strtmp = "Write: " + bwritedata.Length.ToString() + " byte!";
                    AddToStatusAsync(string.Format(strtmp));
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    AddToStatusAsync("Write failure," + errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #15
0
ファイル: FrConfig.cs プロジェクト: Elielo03/InvengoApp
        /// <summary>
        /// Set Tag Lock
        /// </summary>
        private void SetTagLock()
        {
            int    seloperate = cbLockOperate.SelectedIndex;
            int    selbank    = cbLockArea.SelectedIndex;
            string accessPwd  = tvOriAccessPwd.Text;
            string strcode    = "";

            if (cbTargetTag.Items.Count > 0)
            {
                strcode = cbTargetTag.SelectedItem.ToString();
            }
            if (strcode == "")
            {
                AddToStatusAsync("Please select one tag!");
                cbTargetTag.Focus();
                return;
            }
            if (accessPwd == "")
            {
                AddToStatusAsync("Access password can not empty!");
                tvOriAccessPwd.Focus();
                return;
            }
            if (seloperate < 0)
            {
                AddToStatusAsync("Select operation type!");
                cbLockOperate.Focus();
                return;
            }
            if (selbank < 0)
            {
                AddToStatusAsync("Select operating memory!");
                cbLockArea.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                byte[] bcode      = Util.ConvertHexStringToByteArray(strcode);
                byte[] baccessPwd = Util.ConvertHexStringToByteArray(accessPwd);
                string errInfo    = "";
                if (TagOperation.LockTag_6C(baccessPwd, (byte)seloperate, (byte)selbank, bcode, selCodeArea, out errInfo))
                {
                    if (seloperate == 1)
                    {
                        AddToStatusAsync("Unlock tag successfully.");
                    }
                    else
                    {
                        AddToStatusAsync("Lock tag successfully.");
                        FormatConvert.SoundError();
                    }
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    if (seloperate == 1)
                    {
                        AddToStatusAsync("Unlock failed," + errInfo);
                    }
                    else
                    {
                        AddToStatusAsync("Lock failed," + errInfo);
                    }
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #16
0
 public IdController(FormatConvert formatConvert)
 {
     _formatConvert = formatConvert;
 }
コード例 #17
0
ファイル: MainForm.cs プロジェクト: efendievm/RocketNoise
 public WeatherParametersContainer(
     TextBox NameTextBox,
     TextBox HumidityTextBox,
     TextBox TemperatureTextBox,
     Button AddButton,
     Button ModifyButton,
     Button DeleteButton,
     Button ApplyButton,
     ListBox WeatherParametersListBox,
     Action <List <WeatherParameters> > Apply)
 {
     this.WeatherParametersListBox = WeatherParametersListBox;
     AddButton.Click += (sender, e) =>
     {
         if (weatherParameters == null)
         {
             weatherParameters = new List <WeatherParameters>();
         }
         if (weatherParameters.FindIndex(x => x.Mounth == NameTextBox.Text) != -1)
         {
             MessageBox.Show("Погодные условия с указанным наименованием уже существуют");
             return;
         }
         weatherParameters.Add(new WeatherParameters(
                                   NameTextBox.Text,
                                   Convert.ToDouble(HumidityTextBox.Text),
                                   Convert.ToDouble(TemperatureTextBox.Text) + 273));
         WeatherParametersListBox.Items.Add(NameTextBox.Text);
     };
     ModifyButton.Click += (sender, e) =>
     {
         int Selected = WeatherParametersListBox.SelectedIndex;
         if (Selected == -1)
         {
             return;
         }
         int FirstEqual = weatherParameters.FindIndex(x => x.Mounth == NameTextBox.Text);
         if ((FirstEqual == Selected) || (FirstEqual == -1))
         {
             var weatherParameter = new WeatherParameters(
                 NameTextBox.Text,
                 Convert.ToDouble(HumidityTextBox.Text),
                 Convert.ToDouble(TemperatureTextBox.Text) + 273);
             weatherParameters[Selected] = weatherParameter;
             WeatherParametersListBox.Items[Selected] = NameTextBox.Text;
         }
         else
         {
             MessageBox.Show("Погодные условия с указанным наименованием уже существуют");
             return;
         }
     };
     DeleteButton.Click += (sender, e) =>
     {
         int Selected = WeatherParametersListBox.SelectedIndex;
         if (Selected == -1)
         {
             return;
         }
         weatherParameters.RemoveAt(Selected);
         WeatherParametersListBox.Items.RemoveAt(Selected);
     };
     ApplyButton.Click += (sender, e) => Apply(weatherParameters);
     WeatherParametersListBox.Click += (sender, e) =>
     {
         if (WeatherParametersListBox.SelectedIndex == -1)
         {
             return;
         }
         var SelectedWeatherParameters = weatherParameters[WeatherParametersListBox.SelectedIndex];
         NameTextBox.Text        = SelectedWeatherParameters.Mounth;
         TemperatureTextBox.Text = FormatConvert.ToString(SelectedWeatherParameters.Temperature - 273);
         HumidityTextBox.Text    = FormatConvert.ToString(SelectedWeatherParameters.Humidity);
     };
 }
コード例 #18
0
        private async void CalculatFireTestNoiseMenuItem_Click()
        {
            FrequencyBand frequencyBand;

            if (FireTestInfraBandRadioButton.Checked)
            {
                frequencyBand = FrequencyBand.Infra;
            }
            else if (FireTestUltraBandRadioButton.Checked)
            {
                frequencyBand = FrequencyBand.Ultra;
            }
            else
            {
                frequencyBand = FrequencyBand.Normal;
            }
            var CalculateArgs = new CalculateFireTestNoiseEventArgs(
                frequencyBand,
                new RadiusInterval(
                    Convert.ToDouble(FireTestStartRadiusTextBox.Text),
                    Convert.ToDouble(FireTestFinalRadiusTextBox.Text),
                    Convert.ToDouble(FireTestRadiusStepTextBox.Text)));
            await Task.Run(() => CalculateFireTestNoise(CalculateArgs));

            var Contours = CalculateArgs.FireTestSoundContours;

            FireTestGraphPane.CurveList.Clear();
            for (int i = 0; i < FireTestNoiseSoundLevelContainer.SoundLevels.Count; i++)
            {
                FireTestGraphPane.AddCurve(
                    FireTestNoiseSoundLevelContainer.SoundLevels[i].SoundLevel.ToString(),
                    Contours[i].Points.Select(p => p.X).ToArray(),
                    Contours[i].Points.Select(p => p.Y).ToArray(),
                    FireTestNoiseSoundLevelContainer.SoundLevels[i].Color,
                    SymbolType.None);
            }
            FireTestGraphPane.AxisChange();
            zedGraphControl2.Invalidate();
            var PointsGrid = FireTestNoiseSoundLevelPointsGrid;

            PointsGrid.Columns.Clear();
            foreach (var circle in Contours)
            {
                var s = circle.SoundLevel.ToString() + " дБ";
                if (FireTestNormalBandRadioButton.Checked)
                {
                    s += "A";
                }
                PointsGrid.Columns.Add("", s);
                PointsGrid.Columns.Add("", "");
            }
            foreach (var column in PointsGrid.Columns.Cast <DataGridViewColumn>())
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            PointsGrid.Rows.Add();
            PointsGrid.Rows[0].Frozen = true;
            for (int i = 0; i < PointsGrid.Columns.Count; i++)
            {
                PointsGrid.Rows[0].Cells[i].Value = i % 2 == 0 ? "X, м" : "Y, м";
            }
            PointsGrid.Rows.Add(Contours[0].Points.Count);
            for (int CircleIndex = 0; CircleIndex < Contours.Count; CircleIndex++)
            {
                var contour = Contours[CircleIndex];
                for (int i = 0; i < contour.Points.Count; i++)
                {
                    PointsGrid.Rows[i + 1].Cells[2 * CircleIndex + 0].Value = FormatConvert.ToString(contour.Points[i].X);
                    PointsGrid.Rows[i + 1].Cells[2 * CircleIndex + 1].Value = FormatConvert.ToString(contour.Points[i].Y);
                }
            }
        }
コード例 #19
0
        private async void CalculateFlightNoiseMenuItem_Click()
        {
            FrequencyBand frequencyBand;

            if (FlightInfraBandRadioButton.Checked)
            {
                frequencyBand = FrequencyBand.Infra;
            }
            else if (FlightUltraBandRadioButton.Checked)
            {
                frequencyBand = FrequencyBand.Ultra;
            }
            else
            {
                frequencyBand = FrequencyBand.Normal;
            }
            var CalculateArgs = new CalculateFlightNoiseEventArgs(
                frequencyBand,
                new RadiusInterval(
                    Convert.ToDouble(FlightStartRadiusTextBox.Text),
                    Convert.ToDouble(FlightFinalRadiusTextBox.Text),
                    Convert.ToDouble(FlightRadiusStepTextBox.Text)));
            await Task.Run(() => CalculateFlightNoise(CalculateArgs));

            var Circles = CalculateArgs.FlightSoundCircles;

            FlightGraphPane.CurveList.Clear();
            for (int i = 0; i < FlightNoiseSoundLevelContainer.SoundLevels.Count; i++)
            {
                FlightGraphPane.AddCurve(
                    FlightNoiseSoundLevelContainer.SoundLevels[i].SoundLevel.ToString(),
                    Circles[i].Points.Select(p => p.X).ToArray(),
                    Circles[i].Points.Select(p => p.Y).ToArray(),
                    FlightNoiseSoundLevelContainer.SoundLevels[i].Color,
                    SymbolType.None);
            }
            FlightGraphPane.AxisChange();
            zedGraphControl1.Invalidate();

            var PointsGrid = FlightNoiseSoundLevelPointsGrid;

            PointsGrid.Columns.Clear();
            foreach (var circle in Circles)
            {
                var s = circle.SoundLevel.ToString() + " дБ";
                if (FlightNormalBandRadioButton.Checked)
                {
                    s += "A";
                }
                PointsGrid.Columns.Add("", s);
                PointsGrid.Columns.Add("", "");
            }
            foreach (var column in PointsGrid.Columns.Cast <DataGridViewColumn>())
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            PointsGrid.Rows.Add();
            PointsGrid.Rows[0].Frozen = true;
            for (int i = 0; i < PointsGrid.Columns.Count; i++)
            {
                PointsGrid.Rows[0].Cells[i].Value = i % 2 == 0 ? "X, м" : "Y, м";
            }
            int MaxPointsCount = Circles.Max(c => c.Points.Count);

            if (MaxPointsCount != 0)
            {
                PointsGrid.Rows.Add(MaxPointsCount);
            }

            var CirclesGrid = FlightNoiseSoundLevelCirclesGrid;

            CirclesGrid.Rows.Clear();
            CirclesGrid.Columns[0].HeaderText = "Уровень шума, дБ";
            if (FlightNormalBandRadioButton.Checked)
            {
                CirclesGrid.Columns[0].HeaderText += "A";
            }
            for (int CircleIndex = 0; CircleIndex < Circles.Count; CircleIndex++)
            {
                var circle          = Circles[CircleIndex];
                int CurrentRowIndex = CirclesGrid.Rows.Count;
                CirclesGrid.Rows.Add(4);
                CirclesGrid.Rows[CurrentRowIndex].Cells[0].Value     = circle.SoundLevel;
                CirclesGrid.Rows[CurrentRowIndex + 0].Cells[1].Value = "Левая окружность. МСРН";
                CirclesGrid.Rows[CurrentRowIndex + 1].Cells[1].Value = "Правая окружность. МСРН";
                CirclesGrid.Rows[CurrentRowIndex + 2].Cells[1].Value = "Левая окружность. МСКА";
                CirclesGrid.Rows[CurrentRowIndex + 3].Cells[1].Value = "Правая окружность. МСКА";
                var SoundCircles = new List <FlightSoundCircle>()
                {
                    circle.LeftRocketCircle,
                    circle.RightRocketCircle,
                    circle.LeftVehicleCircle,
                    circle.RightVehicleCircle
                };
                for (int i = 0; i < SoundCircles.Count; i++)
                {
                    CirclesGrid.Rows[i + CurrentRowIndex].Cells[2].Value = FormatConvert.ToString(SoundCircles[i].Distance);
                    CirclesGrid.Rows[i + CurrentRowIndex].Cells[3].Value = FormatConvert.ToString(SoundCircles[i].Radius);
                    CirclesGrid.Rows[i + CurrentRowIndex].Cells[4].Value = FormatConvert.ToString(SoundCircles[i].Time);
                    CirclesGrid.Rows[i + CurrentRowIndex].Cells[5].Value = SoundCircles[i].Mounth;
                }
                for (int i = 0; i < circle.Points.Count; i++)
                {
                    PointsGrid.Rows[i + 1].Cells[2 * CircleIndex + 0].Value = FormatConvert.ToString(circle.Points[i].X);
                    PointsGrid.Rows[i + 1].Cells[2 * CircleIndex + 1].Value = FormatConvert.ToString(circle.Points[i].Y);
                }
            }
            var EffectiveGrid = EffectiveFlightSoundGrid;

            EffectiveGrid.Rows.Clear();
            if ((CalculateArgs.EffectiveFlightSounds == null) || CalculateArgs.EffectiveFlightSounds.Count == 0)
            {
                return;
            }
            foreach (var soundLevel in CalculateArgs.EffectiveFlightSounds)
            {
                int CurrentRowIndex = EffectiveGrid.Rows.Count;
                EffectiveGrid.Rows.Add(2);
                EffectiveGrid.Rows[CurrentRowIndex + 0].Cells[0].Value = FormatConvert.ToString(soundLevel.Distance);
                EffectiveGrid.Rows[CurrentRowIndex + 0].Cells[1].Value = "0";
                EffectiveGrid.Rows[CurrentRowIndex + 0].Cells[2].Value = FormatConvert.ToString(soundLevel.RightMaxSoundLevel);
                EffectiveGrid.Rows[CurrentRowIndex + 0].Cells[3].Value = FormatConvert.ToString(soundLevel.RightEffektiveSoundLevel);
                EffectiveGrid.Rows[CurrentRowIndex + 0].Cells[4].Value = FormatConvert.ToString(soundLevel.RightTimes[0]);
                EffectiveGrid.Rows[CurrentRowIndex + 0].Cells[5].Value = FormatConvert.ToString(soundLevel.RightTimes[1]);
                EffectiveGrid.Rows[CurrentRowIndex + 0].Cells[6].Value = FormatConvert.ToString(soundLevel.RightTimes[2]);
                EffectiveGrid.Rows[CurrentRowIndex + 0].Cells[7].Value = soundLevel.RightWeatherConditions;
                EffectiveGrid.Rows[CurrentRowIndex + 1].Cells[1].Value = "180";
                EffectiveGrid.Rows[CurrentRowIndex + 1].Cells[2].Value = FormatConvert.ToString(soundLevel.LeftMaxSoundLevel);
                EffectiveGrid.Rows[CurrentRowIndex + 1].Cells[3].Value = FormatConvert.ToString(soundLevel.LeftEffektiveSoundLevel);
                EffectiveGrid.Rows[CurrentRowIndex + 1].Cells[4].Value = FormatConvert.ToString(soundLevel.LeftTimes[0]);
                EffectiveGrid.Rows[CurrentRowIndex + 1].Cells[5].Value = FormatConvert.ToString(soundLevel.LeftTimes[1]);
                EffectiveGrid.Rows[CurrentRowIndex + 1].Cells[6].Value = FormatConvert.ToString(soundLevel.LeftTimes[2]);
                EffectiveGrid.Rows[CurrentRowIndex + 1].Cells[7].Value = soundLevel.LeftWeatherConditions;
            }
        }