Exemple #1
0
        /// <summary>
        /// 清空列表按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnMCClear_Click(object sender, EventArgs e)
        {
            atCommands = new List <ATCommand>(20);
            for (int i = 0; i < atCommands.Capacity; i++)
            {
                ATCommand temp = new ATCommand();
                temp.Command  = "";
                temp.HEX      = false;
                temp.Note     = "双击添加注释!!!";
                temp.Function = "";
                temp.Module   = "";
                atCommands.Add(temp);
            }
            copyCommand();
            GroupBox groupbox = panel1.FindForm().Controls.Find("gboxMCL", true)[0] as GroupBox;

            groupbox.Text = "多条指令";
            PanelAddItems(panel1);
        }
Exemple #2
0
        public MultiControl(int multiCount, Panel container, PortControl portControl)
        {
            _portControl             = portControl;
            MultiCommands            = new MultiCommands();
            atCommands               = MultiCommands.Commands;
            MultiCommands.Circle     = false;
            MultiCommands.CircleTime = 1000;
            MultiCommands.Count      = multiCount;
            atCommands               = new List <ATCommand>();
            for (int i = 0; i < MultiCommands.Count; i++)
            {
                ATCommand atCommand = new ATCommand();
                atCommand.Index = i;
                atCommands.Add(atCommand);
            }
            //atCommandsTemp = atCommands;
            copyCommand();
            panel1            = container;
            panel1.Scroll    += Panel1_Scroll;
            panel1.MouseMove += Panel1_MouseMove;
            PanelAddItems(panel1);

            btnSave             = panel1.FindForm().Controls.Find("btnMCPDSave", true)[0] as Button;
            btnRead             = panel1.FindForm().Controls.Find("btnMCPDRead", true)[0] as Button;
            cboxMCCircle        = panel1.FindForm().Controls.Find("cboxMCCircle", true)[0] as CheckBox;
            cboxMCCircle.Click += CboxMCCircle_Click;
            btnSave.Click      += BtnSave_Click;
            btnRead.Click      += BtnRead_Click;
            Button btnMCClear = panel1.FindForm().Controls.Find("btnMCClear", true)[0] as Button;

            btnMCClear.Click += BtnMCClear_Click;

            Button btnAddItem = panel1.FindForm().Controls.Find("btnMCAddOne", true)[0] as Button;
            Button btnSubItem = panel1.FindForm().Controls.Find("btnMCSubOne", true)[0] as Button;

            btnAddItem.Click += BtnAddItem_Click;
            btnSubItem.Click += BtnSubItem_Click;

            rbAll = panel1.FindForm().Controls.Find("rbAll", true)[0] as RadioButton;
            rbSel = panel1.FindForm().Controls.Find("rbSelected", true)[0] as RadioButton;
        }
Exemple #3
0
        //序列化xml
        public void XMLUnitWrite(ModuleCommand module, List <ATCommand> atCommands)
        {
            List <ATCommand> fullList = new List <ATCommand>(32);

            for (int i = atCommands.Count - 1; i >= 0; i--)
            {
                if (atCommands[i].Command != null && atCommands[i].Command.Trim() != "")
                {
                    for (int j = 0; j <= i; j++)
                    {
                        ATCommand a = new ATCommand();
                        a.Module   = module.Module;
                        a.Function = module.Function;
                        a.HEX      = atCommands[j].HEX;
                        a.Index    = atCommands[j].Index;
                        a.Note     = atCommands[j].Note;
                        a.Command  = atCommands[j].Command;
                        fullList.Add(a);
                    }
                    break;
                }
            }
            if (fullList.Count > 0)
            {
                XMLUnitWrite(fullList);
            }
            else
            {
                if (module.Module != "" && module.Function != "")
                {
                    atCommands[0].Module   = module.Module;
                    atCommands[0].Function = module.Function;
                    fullList.Add(atCommands[0]);
                }
                XMLUnitWrite(fullList);
            }
        }
        public ATCommandResult Execute(GprsDtuConnection conn, ATCommand cmd, ushort timeout = 2)
        {
            var r = new ATCommandResult();

            if (!conn.IsOnline)
            {
                r.IsOK = false;
                r.GetJsonResult(cmd.ToATString());
                return(r);
            }
            try
            {
                logger.InfoFormat("======> AtCommand:{0}-{1} ,timeout={2}", conn.DtuID, cmd.ToATString(), timeout);
                DtuMsg result = conn.Ssend(Encoding.ASCII.GetBytes(cmd.ToATString()), timeout);

                r.ResultBuffer = result.Databuffer;
                string bufstr = string.Empty;
                if (r.ResultBuffer != null)
                {
                    bufstr = Encoding.ASCII.GetString(result.Databuffer);
                }
                r.IsOK = ((bufstr.Contains("OK")) || ("Remote Config Ready" == bufstr)) ||
                         cmd.ToATString().Contains("RESET");
                // r.GetJsonResult(cmd.ToATString());
                r.Elapsed = result.Elapsed;
                // System.Console.WriteLine("> {0}\r\n< {1} : {2}", cmd.ToATString(), bufstr, r.IsOK? "successed":"failed");
                logger.InfoFormat("======> AtCommand:{0}-{1} ,result: {2}, {3} ", conn.DtuID, cmd.ToATString(), bufstr,
                                  r.IsOK ? "successed" : "failed");
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("CommandExecutor Error: {0}", ex);
            }
            r.GetJsonResult(cmd.ToATString());
            return(r);
        }
Exemple #5
0
        internal void AddOneItem()
        {
            ATCommand atcommand = new ATCommand();

            //atcommand.Index = atCommands.Count - 1;
            if (atCommands.Count < 100)
            {
                int index = atCommands.Count;
                if (tBoxFocused != null)
                {
                    index = Int32.Parse(tBoxFocused.Name.Replace(tbox + panelFlag, ""));
                    //tBoxFocused = null;
                    atcommand.Index = index;
                    ATCommand tempCommand = new ATCommand();
                    for (int i = index; i < atCommands.Count; i++)
                    {
                        tempCommand     = atCommands[i];
                        atCommands[i]   = atcommand;
                        atcommand       = tempCommand;
                        atcommand.Index = i + 1;
                    }
                    atCommands.Add(atcommand);
                }
                else
                {
                    atcommand.Index = atCommands.Count - 1;
                    atCommands.Add(atcommand);
                }

                PanelAddItems();
            }
            else
            {
                return;
            }
        }
Exemple #6
0
 /// <summary>
 /// Sends the AT command.
 /// </summary>
 /// <param name="command">The command.</param>
 public virtual void SendCommand(ATCommand command) => SendCommand(command.Command);
 public void Enqueue(ATCommand command)
 {
     _queue.Enqueue(command);
 }
Exemple #8
0
        public void TestATCommandNodeDiscover()
        {
            var cmd = new ATCommand(AT.NodeDiscover);

            Assert.AreEqual(new byte[] { 0x08, 0x00, (byte)'N', (byte)'D' }, cmd.ToByteArray());
        }
Exemple #9
0
 public void Add(ATCommand cmd)
 {
     this.AtCommands.Add(cmd);
 }
Exemple #10
0
        private IAsyncEnumerable <string> Execute(ATCommand command)
        {
            var stream = connection.GetStream();

            return(command.Execute(stream));
        }
Exemple #11
0
        private void btnSwitchCam_Click(object sender, EventArgs e)
        {
            ATCommand command = _droneClient.Configuration.Video.Channel.Set(VideoChannelType.Next).ToCommand();

            _droneClient.Send(command);
        }
 public void Enqueue(ATCommand command)
 {
     _queue.Enqueue(command);
 }