Example #1
0
        /// <summary>
        /// 傳送指令
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Send_Click(object sender, EventArgs e)
        {
            //聚焦輸入框
            TB_CmdToSend.Focus();
            //取得輸入的指令
            string cmd = TB_CmdToSend.Text;

            //沒有輸入指令
            if (cmd == "")
            {
                return;
            }
            //輸入的指令加入換行
            cmd = cmd + "\r\r\n";
            //顯示指令
            ShowCMD("");
            ShowCMD(cmd);
            //寫入指令
            LoraHandle.GetObj.Write(cmd);
            //將指令加入歷史紀錄
            HistoryCmd.Add(TB_CmdToSend.Text);
            //設定指令歷史紀錄索引
            HistoryIndex = HistoryCmd.Count - 1;
            //清空輸入框
            TB_CmdToSend.Text = "";
        }
Example #2
0
 /// <summary>
 /// 將指令寫入
 /// </summary>
 /// <param name="cmd"></param>
 private void Write(string cmd)
 {
     ShowCMD("");
     ShowCMD(cmd + "\r\n");
     //聚焦輸入框
     TB_CmdToSend.Focus();
     //寫入指令
     LoraHandle.GetObj.Write(cmd);
 }
Example #3
0
 /// <summary>
 /// 表單載入事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Form1_Load(object sender, EventArgs e)
 {
     //顯示/隱藏按鈕
     EnableBtn(false);
     //設定Comport選項
     SetComport();
     //設定Slot通道選項
     SetSlotPassage();
     //建立委派的物件
     dataShow = new DataShow(ShowCMD);
     //輸入對話框聚焦
     TB_CmdToSend.Focus();
 }
Example #4
0
        /// <summary>
        /// 連線按鈕
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Connect_Click(object sender, EventArgs e)
        {
            //輸入框聚焦
            TB_CmdToSend.Focus();
            //無Comport
            if (CB_Comport.SelectedIndex < 0)
            {
                return;
            }
            //切換啟用/不啟用
            Btn_Connect.Status = !Btn_Connect.Status;
            string portName = CB_Comport.SelectedItem.ToString();

            //ON
            if (Btn_Connect.Status)
            {
                //設定程式標題
                ShowCMD("");
                ShowCMD(string.Format("Connect to \"{0}\"", portName));
                this.Text = "M/S_Edit..........Connection";
                //關閉序列埠選取功能
                CB_Comport.Enabled = false;
                //連接序列埠
                LoraHandle.GetObj.Connect(portName, SerialPort_DataReceived);
                //掛載Mode變更事件
                LoraHandle.GetObj.ModeChange += GetObj_ModeChange;
                //取得LoraMode
                Btn_GetMode_Click(this, null);
                //打開功能按鈕
                EnableBtn(true);
                //Master、Slave設定畫面顯示
                Panel_M_S_Setting.Show();
            }
            //OFF
            else
            {
                //設定程式標題
                ShowCMD("");
                ShowCMD(string.Format("Disconnect from \"{0}\"", portName));
                this.Text = "M/S_Edit..........Disconnection";
                //打開序列埠選取功能
                CB_Comport.Enabled = true;
                //斷開序列埠
                LoraHandle.GetObj.DisConnect(SerialPort_DataReceived);
                //關閉功能按鈕
                EnableBtn(false);
                //Master、Slave設定畫面隱藏
                Panel_M_S_Setting.Hide();
            }
        }
Example #5
0
 /// <summary>
 /// 移除所有Slave
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Btn_RemoveSlave_Click(object sender, EventArgs e)
 {
     //清除指令集
     WriteSeq.Clear();
     //輸入框聚焦
     TB_CmdToSend.Focus();
     //遍歷所有Slave(32個)
     for (int i = 1; i <= 32; i++)
     {
         //加入移除Slave指令
         WriteSeq.Add(LoraCMD.LoraRemoveSlaveNode + i + "\r");
     }
     //開啟自動寫入功能
     Open_Auto_Write();
 }