コード例 #1
0
ファイル: MainForm.cs プロジェクト: yuqiancha/X07_Total
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (btn_ZK1_Close.Enabled)
                {
                    btn_ZK1_Close_Click(sender, e);
                }
                if (btn_ZK1_YC_Close.Enabled)
                {
                    btn_ZK1_YC_Close_Click(sender, e);
                }

                if (btn_CRTa_Open.Enabled == false)
                {
                    ClientAPP.Disconnect(ref ClientAPP.Server_CRTa);
                    ClientAPP.Disconnect(ref ClientAPP.Server_CRTa_Return);
                    btn_CRTa_Open.Enabled  = true;
                    btn_CRTa_Close.Enabled = false;
                    Data.DealCRTa.LedOff();
                    MyLog.Info("关闭连接--USB应答机A");
                }

                Thread.Sleep(100);
                mySaveFileThread.FileClose();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: yuqiancha/X07_Total
        private void buttonCRT_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            switch (btn.Name)
            {
            case "btn_CRTa_Open":
                MyLog.Info("尝试连接--USB应答机A...");
                ClientAPP.Server_CRTa.ServerIP   = ConfigurationManager.AppSettings["Server_CRTa_Ip"];
                ClientAPP.Server_CRTa.ServerPORT = ConfigurationManager.AppSettings["Server_CRTa_Port"];
                ClientAPP.Connect(ref ClientAPP.Server_CRTa);
                if (ClientAPP.Server_CRTa.IsConnected)
                {
                    DealCRT_On(ref Data.DealCRTa);
                    MyLog.Info("连接成功--" + Data.DealCRTa.CRTName + "--遥控端口");
                    new Thread(() => { Fun_Transfer2CRT(ref Data.DealCRTa, ref ClientAPP.Server_CRTa, ref SaveFile.DataQueue_out2); }).Start();
                    new Thread(() => { Fun_RecvFromCRT(ref Data.DealCRTa, ref ClientAPP.Server_CRTa); }).Start();
                }
                else
                {
                    DealCRT_Off(ref Data.DealCRTa);
                    return;
                }
                btn_CRTa_Open.Enabled  = false;
                btn_CRTa_Close.Enabled = true;

                ClientAPP.Server_CRTa_Return.ServerIP   = ConfigurationManager.AppSettings["Server_CRTa_Ip"];
                ClientAPP.Server_CRTa_Return.ServerPORT = "3070";
                ClientAPP.Connect(ref ClientAPP.Server_CRTa_Return);
                if (ClientAPP.Server_CRTa_Return.IsConnected)
                {
                    MyLog.Info("连接成功--" + Data.DealCRTa.CRTName + "--遥测端口");
                    new Thread(() => { Fun_RecvFromCRT_Return(ref Data.DealCRTa, ref ClientAPP.Server_CRTa_Return); }).Start();
                }

                break;

            case "btn_CRTa_Close":
                ClientAPP.Disconnect(ref ClientAPP.Server_CRTa);
                ClientAPP.Disconnect(ref ClientAPP.Server_CRTa_Return);
                btn_CRTa_Open.Enabled  = true;
                btn_CRTa_Close.Enabled = false;
                Data.DealCRTa.LedOff();
                MyLog.Info("关闭连接--USB应答机A");
                break;

            default:
                break;
            }
        }