Ejemplo n.º 1
0
 /// <summary>
 /// 开关按钮按下事件
 /// </summary>
 private void btnSwitch_Click(object sender, EventArgs e)
 {
     if (ifSwitchOn)
     {
         _transceiver.Stop();
     }
     else
     {
         if (!_ifSetPort)
         {
             MessageBox.Show("请先配置串口!", "串口未配置", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         if (string.IsNullOrEmpty(txtSettingFilePath.Text))
         {
             MessageBox.Show("请先配置伪指令代码!", "伪指令代码未配置", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         SwitchOn();
         _transceiver.Start(CommandReader.LoadCommands(txtSettingFilePath.Text), int.Parse(txtCycle.Text));
     }
 }