Exemplo n.º 1
0
        void adx_StatusConnected(object sender, ConnectEventArg e)
        {
            try
            {
                this.BeginInvoke(new MethodInvoker(delegate()
                {
                    switch (e.Status)
                    {
                    case CommState.CONNECT_OK:
                        ShowResultState("通讯连接正常,设备未确定连接成功,需要发送通讯指令有回复确定!");
                        break;

                    case CommState.DISCONNECT_OK:
                        ShowResultState("断开链接成功!");
                        break;

                    case CommState.CONNECT_FAIL:
                        ShowResultState("链接失败!");
                        break;

                    case CommState.DISCONNECT_FAIL:
                        ShowResultState("断开成功!");
                        break;

                    case CommState.DISCONNECT_EXCEPT:
                        ShowResultState("远程异常断开!");
                        break;

                    default:
                        break;
                    }
                    btnConnect.Text = adx.IsConnected ? "DisConnect" : "Connect";
                }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 通讯状态异步显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ADRcp_StatusConnected(object sender, ConnectEventArg e)
        {
            try
            {
                this.Invoke(new MethodInvoker(delegate()
                {
                    pnlConnect.Enabled = true;
                    Application.DoEvents();

                    switch (e.Status)
                    {
                    case CommState.CONNECT_OK:
                        if (IniSettings.Communication == CommType.USB)
                        {
                            try
                            {
                                int intVer = Convert.ToInt32(e.Msg);
                                rtxtRes.AppendText("USB Version> :V" + intVer / 256 + "." + intVer % 256 / 16 + intVer % 16);
                            }
                            catch { }
                        }
                        btnDisConnect.Enabled = true;
                        btnConnected.Enabled  = false;
                        rtxtRes.AppendText("CONNECTED OK> " + e.Msg + "(" + SystemPub.ADRcp.ToString() + ")\r\n");
                        this.BeginInvoke(new MethodInvoker(delegate()
                        {
                            Application.DoEvents();
                            Thread.Sleep(200);
                            Application.DoEvents();
                            Thread.Sleep(200);
                            Application.DoEvents();
                            Thread.Sleep(200);
                            Application.DoEvents();
                            this.Close();
                        }));
                        break;

                    case CommState.CONNECT_FAIL:
                        btnDisConnect.Enabled = false;
                        btnConnected.Enabled  = true;
                        rtxtRes.AppendText("ERROR> " + e.Msg + "(" + SystemPub.ADRcp.ToString() + ")\r\n");
                        break;

                    case CommState.DISCONNECT_OK:
                        btnDisConnect.Enabled = false;
                        btnConnected.Enabled  = true;
                        rtxtRes.AppendText("DISCONNECT OK> " + e.Msg + "(" + SystemPub.ADRcp.ToString() + ")\r\n");
                        break;

                    case CommState.DISCONNECT_FAIL:
                        btnDisConnect.Enabled = false;
                        btnConnected.Enabled  = true;
                        rtxtRes.AppendText("ERROR> " + e.Msg + "(" + SystemPub.ADRcp.ToString() + ")\r\n");
                        break;

                    case CommState.DISCONNECT_EXCEPT:
                        btnDisConnect.Enabled = false;
                        btnConnected.Enabled  = true;
                        rtxtRes.AppendText("ERROR> " + e.Msg + "(" + SystemPub.ADRcp.ToString() + ")\r\n");
                        break;

                    default:
                        break;
                    }
                }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 3
0
        void Instance_Connected(object sender, ConnectEventArg e)
        {
            try
            {
                this.Invoke(new MethodInvoker(delegate()
                {
                    if (e.Status == CommState.O_CONNECT || e.Status == CommState.F_CONNECT)
                    {
                        tsmiConnect.Enabled = true;
                        if (fwt.IsAlive)
                        {
                            Thread.Sleep(2000);
                            fwt.Close();
                        }
                        Application.DoEvents();
                        if (e.Status == CommState.O_CONNECT)
                        {
                            if (UserSettings.Communication == UserSettings.CommType.USB)
                            {
                                try
                                {
                                    int intVer = Convert.ToInt32(e.Msg);

                                    tsStatusBr.Text = "V" + intVer / 256 + "." + intVer % 256 / 16 + intVer % 16;
                                }
                                catch { tsStatusBr.Text = ""; }
                            }
                            tsStatusPortOpen.Text = "CONNECT";
                            DisplayMsgString("CONNECT> Connect Succeed...   " + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                            tsmiConnect.Text = BaseSettings.AppsLanguage == BaseSettings.LngType.CHN ? "断开(&C)" : "DIS&CONNECT";
                            StartReadInfo();
                        }
                        else if (e.Status == CommState.F_CONNECT)
                        {
                            m_bAlive = false;
                            DisplayMsgString("ERROR> " + e.Msg + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                            tsmiConnect.Text = BaseSettings.AppsLanguage == BaseSettings.LngType.CHN ? "联机(&C)" : "&CONNECT";
                        }

                        tsmiComm.Enabled = !tsmiRCPLogging.Visible;
                    }
                    else if (e.Status == CommState.O_DISCNT || e.Status == CommState.F_DISCNT || e.Status == CommState.E_DISCNT)
                    {
                        tsmiConnect.Enabled = true;
                        if (e.Status == CommState.O_DISCNT)
                        {
                            m_bAlive = false;
                            DisplayMsgString("CONNECT> DisConnect succeed...  " + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                        }
                        else if (e.Status == CommState.E_DISCNT)
                        {
                            DisplayMsgString("ERROR> Error communication to disconnect...  " + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                        }
                        else
                        {
                            DisplayMsgString("ERROR> " + e.Msg + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                        }

                        tsmiConnect.Text = BaseSettings.AppsLanguage == BaseSettings.LngType.CHN ? "联机(&C)" : "&CONNECT";

                        if (ucPassive1 != null)
                        {
                            ucPassive1.Hide();
                        }

                        pnlInformation.Controls.Clear();

                        if (UserSettings.Communication != UserSettings.CommType.USB && m_bAlive)
                        {
                            m_bAlive = false;
                            tsmiConnect_Click(new object(), new EventArgs());
                        }
                    }
                }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 4
0
        void Instance_Connected(object sender, ConnectEventArg e)
        {
            try
            {
                this.Dispatcher.Invoke(new Action(delegate()
                {
                    if (e.Status == CommState.CONNECT_OK || e.Status == CommState.CONNECT_FAIL)
                    {
                        DoEvents();
                        if (e.Status == CommState.CONNECT_OK)
                        {
                            // tsStatusPortOpen.Text = "CONNECT";
                            // DisplayMsgString("CONNECT> Connect Succeed...   " + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                            //tsmiConnect.Text = IniSettings.GetLanguageString("DIS&CONNECT", "断开(&C)");
                            StartReadInfo();
                            //RFID_Com_Label.Foreground = Brushes.Red;
                            BtnConnect.Content     = "Disconnect";
                            BtnConnect.Foreground  = Brushes.Red;
                            BtnStartRead.IsEnabled = true;
                        }
                        else if (e.Status == CommState.CONNECT_FAIL)
                        {
                            //m_bAlive = false;
                            DisplayMsgString("ERROR> " + e.Msg + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                            // tsmiConnect.Text = IniSettings.GetLanguageString("&CONNECT", "联机(&C)");
                        }

                        //tsmiComm.Enabled = !tsmiRCPLogging.Visible;
                    }
                    else if (e.Status == CommState.DISCONNECT_OK || e.Status == CommState.DISCONNECT_FAIL || e.Status == CommState.DISCONNECT_EXCEPT)
                    {
                        //tsmiConnect.Enabled = true;
                        if (e.Status == CommState.DISCONNECT_OK)
                        {
                            m_bAlive = false;
                            DisplayMsgString("CONNECT> DisConnect succeed...  " + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                        }
                        else if (e.Status == CommState.DISCONNECT_EXCEPT)
                        {
                            DisplayMsgString("ERROR> Error communication to disconnect...  " + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                        }
                        else
                        {
                            DisplayMsgString("ERROR> " + e.Msg + "(" + SystemPub.ADSio.ToString() + ")\r\n");
                        }

                        //   tsmiConnect.Text = IniSettings.GetLanguageString("&CONNECT", "联机(&C)");

                        //  if (ucPassive1 != null) ucPassive1.Hide();

                        //   pnlInformation.Controls.Clear();

                        if (IniSettings.Communication != IniSettings.CommType.USB && m_bAlive)
                        {
                            m_bAlive = false;
                            //tsmiConnect_Click(new object(), new EventArgs());
                        }
                    }
                }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }