private void BtnKnifeInitial_Click(object sender, System.EventArgs e)
 {
     if (WBFMSystem.lPSerialPort.IsOpen)
     {
         byte[] init = ComFormatPackage.ConstructCommandInfo(SETCommandNames.LBL07);
         WBFMSystem.lPSerialPort.Write(init, 0, init.Length);
     }
 }
 private void BtnBoxOpen_Click(object sender, EventArgs e)
 {
     byte[] Message = ComFormatPackage.ConstructCommandInfo(EVTCommandNames.PODOF);
     lPSerialPort.Write(Message, 0, Message.Length);
 }
        private void WBFMSystem_Load(object sender, EventArgs e)
        {
            //if (this.LabelConnectInfo.Text == "未连接到内网")
            //{
            //    IPAddress iPAddress = IPAddress.Parse("127.0.0.1");
            //    IPEndPoint endPoint = new IPEndPoint(iPAddress, 3340);
            //    socket.Connect(endPoint);
            //    //socket.BeginConnect(endPoint, new AsyncCallback(ConnectCallback1), null);
            //    //socket.BeginConnect(endPoint, new AsyncCallback((ar) =>
            //    //{
            //    //    this.Invoke(new EventHandler(delegate
            //    //    {
            //    //        LabelConnectInfo.Text += "ReConnecting..";
            //    //    }));
            //    //}), null);
            //}

            //byte[] _deviceName = Encoding.UTF8.GetBytes(DeviceInfo.DeviceName());
            //socket.Send(_deviceName, 0, _deviceName.Length, SocketFlags.None);

            UIBLL.CustomizeMove <Panel, Label>(this.PanelTopic, this.LabelTopic, this);
            try
            {
                lPSerialPort = new SerialPort();

                //Type type = lPSerialPort.GetType();
                //FieldInfo fieldInfo = type.GetField("defaultBaudRate", BindingFlags.NonPublic | BindingFlags.Instance);
                //int a = (int)fieldInfo.GetValue(lPSerialPort);

                lPSerialPort.PortName = SPBLL.LPSerialPortName();
                lPSerialPort.Open();

                if (lPSerialPort.DsrHolding)
                {
                    this.LabelCurrentOperation.Text = "就绪";

                    //byte[] ms = new byte[1024];
                    byte[] Message = ComFormatPackage.ConstructCommandInfo(GETCommandNames.MAPRD);
                    lPSerialPort.Write(Message, 0, Message.Length);

                    //lPSerialPort.ReadTimeout = 1000;
                    //byte[] qew = new byte[1024];
                    //lPSerialPort.Read(qew, 0, qew.Length);

                    //byte[] qew2 = new byte[lPSerialPort.BytesToRead];
                    //lPSerialPort.Read(qew2, 0, qew2.Length);

                    lPSerialPort.DataReceived += BtnBoxOpen_Click;

                    //LPSerialPortTran lPSerialPortTran = new LPSerialPortTran(SystemSetting.GetLPSerialPort);
                    //lPSerialPortTran(lPSerialPort);
                }
                else
                {
                    this.LabelCurrentOperation.Text = "初始化失败!";
                    LogMessage logInfo = new LogMessage();
                    logInfo.OperationTime      = DateTime.Now;
                    logInfo.ExceptionInfo      = "初始化失败";
                    this.TextBoxErrorLog.Text += new LogFormat().ErrorFormat(logInfo);
                    MessageBox.Show("默认串口号错误!");
                }
            }
            catch
            {
            }
        }
 private void LPSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     byte[] Message = ComFormatPackage.ConstructCommandInfo(SETCommandNames.LON07);
     lPSerialPort.Write(Message, 0, Message.Length);
 }