private void ShowTcpipParaInfo(TcpipParameters info)
        {
            try
            {
                txtTCPIP.Text = info.IPToString();

                txtTCPMask.Text = info.MaskToString();

                txtTCPGateway.Text = info.GateWayToString();

                txtTCPPort.Text = info.Port.ToString();

                txtTCPMac.Text = info.MacToString();

                txtRemoteIP.Text = info.RemoteIPToString();

                txtRemotePort.Text = info.RemotePort.ToString();

                cmbIsServer.SelectedIndex = info.Server;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private TcpipParameters GetTcpipParaInfo()
        {
            TcpipParameters bpiTemp = new TcpipParameters();

            bpiTemp.SetIP(txtTCPIP.Text);

            bpiTemp.SetMask(txtTCPMask.Text);

            bpiTemp.SetGateWay(txtTCPGateway.Text);

            bpiTemp.Port = Convert.ToInt32(txtTCPPort.Text);

            bpiTemp.SetMac(txtTCPMac.Text);

            bpiTemp.SetRemoteIP(txtRemoteIP.Text);

            bpiTemp.RemotePort = Convert.ToInt32(txtRemotePort.Text);

            bpiTemp.Server = cmbIsServer.SelectedIndex;
            return(bpiTemp);
        }
        private void SetTcpip()
        {
            if (!RegexBase.IsIPv4(txtTCPIP.Text.ToString().Trim()))
            {
                MessageStatus.Show("IP地址错误!", "IP Address Error!", (int)CommRtn.FAIL);
                return;
            }

            if (!RegexBase.IsIPv4(txtTCPMask.Text.ToString().Trim()))
            {
                MessageStatus.Show("子网掩码错误!", "Subnet Mask Error!", (int)CommRtn.FAIL);
                return;
            }

            if (!RegexBase.IsIPv4(txtTCPGateway.Text.ToString().Trim()))
            {
                MessageStatus.Show("网关地址错误!", "GateWay Error!", (int)CommRtn.FAIL);
                return;
            }
            if (!RegexBase.IsMac(txtTCPMac.Text.ToString().Trim()))
            {
                MessageStatus.Show("Mac地址错误!", "Mac Address Error!", (int)CommRtn.FAIL);
                return;
            }

            if (!RegexBase.IsIPv4(txtRemoteIP.Text.ToString().Trim()))
            {
                MessageStatus.Show("RemoteIP地址错误!", "RemoteIP Address Error!", (int)CommRtn.FAIL);
                return;
            }

            TcpipParameters newTemp = GetTcpipParaInfo();

            if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetTcpip(SystemPub.ADRcp.Address, newTemp.ToArray())))
            {
            }
        }
        private void SetTcpip()
        {
            if (!RegexBase.IsIPv4(txtTCPIP.Text.ToString().Trim()))
            {
                MessageBox.Show(IniSettings.GetLanguageString("IP Address Error!", "IP地址错误!"));
                return;
            }

            if (!RegexBase.IsIPv4(txtTCPMask.Text.ToString().Trim()))
            {
                MessageBox.Show(IniSettings.GetLanguageString("Subnet Mask Error!", "子网掩码错误!"));
                return;
            }

            if (!RegexBase.IsIPv4(txtTCPGateway.Text.ToString().Trim()))
            {
                MessageBox.Show(IniSettings.GetLanguageString("GateWay Error!", "网关地址错误!"));
                return;
            }
            if (!RegexBase.IsMac(txtTCPMac.Text.ToString().Trim()))
            {
                MessageBox.Show(IniSettings.GetLanguageString("Mac Address Error!", "Mac地址错误!"));
                return;
            }

            if (!RegexBase.IsIPv4(txtRemoteIP.Text.ToString().Trim()))
            {
                MessageBox.Show(IniSettings.GetLanguageString("RemoteIP Address Error!", "RemoteIP地址错误!"));
                return;
            }

            TcpipParameters newTemp = GetTcpipParaInfo();

            PassiveCommand.SetTcpip(SystemPub.ADRcp, newTemp.ToArray());
            //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetTcpip(SystemPub.ADRcp.Address, newTemp.ToArray()))) { }
        }
        public void ParseRsp(ProtocolStruct Data)
        {
            switch (Data.Code)
            {
            case PassiveRcp.RCP_CMD_TCPIP:
                if (Data.Length > 0 && Data.Type == 0)
                {
                    TcpipParameters bpiTemp = new TcpipParameters();
                    bpiTemp.AddRange(Data.Payload);
                    ShowTcpipParaInfo(bpiTemp);
                }
                else if (Data.Type == 0)
                {
                    string stren = "Set the IP parameters under the network connection need restart the equipment!";
                    string strcn = "设置IP参数需要重启设备!";
                    string aMsg  = IniSettings.GetLanguageString(stren, strcn);
                    MessageBox.Show(aMsg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case PassiveRcp.RCP_CMD_INFO:
                if (Data.Length > 0 && Data.Type == 0)
                {
                    string strInfo = Encoding.ASCII.GetString(Data.Payload, 0, Data.Length);

                    SystemPub.ADRcp.Mode    = strInfo.Substring(18, 1);
                    SystemPub.ADRcp.Version = strInfo.Substring(19, 5);
                    SystemPub.ADRcp.Address = Convert.ToInt32(strInfo.Substring(29, 5));

                    txtOldAddr.Text = SystemPub.ADRcp.Address.ToString();
                }
                else if (Data.Type == 0)
                {
                    PassiveCommand.GetInformation(SystemPub.ADRcp);
                    //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetInformation())) { }
                }
                break;

            case PassiveRcp.RCP_CMD_SECRET:
                break;

            case PassiveRcp.RCP_CMD_SOFTRESET:
                break;

            case PassiveRcp.RCP_CMD_INITSYRIS:
                break;

            case PassiveRcp.RCP_CMD_REMOTE:
                break;

            case PassiveRcp.RCP_CMD_TIME:
                if (Data.Length > 0 && Data.Type == 0)
                {
                    string y  = Data.Payload[0].ToString("00");
                    string m  = Data.Payload[1].ToString("00");
                    string d  = Data.Payload[2].ToString("00");
                    string w  = Data.Payload[3].ToString("00");
                    string h  = Data.Payload[4].ToString("00");
                    string mi = Data.Payload[5].ToString("00");
                    string se = Data.Payload[6].ToString("00");
                    string D  = string.Format("20{0}-{1}-{2} {3}:{4}:{5}", y, m, d, h, mi, se);         //2010-02-28 14:48:03
                    txtReaderTime.Text = DateTime.Parse(D).ToString();
                }
                break;
            }
        }
        private void DefaultTcpip()
        {
            TcpipParameters bpiTemp = new TcpipParameters();

            ShowTcpipParaInfo(bpiTemp);
        }