예제 #1
0
 private void timerUartRecv_Timeout(object sender, EventArgs e)
 {
     try
     {
         timerUartRecv.Enabled = false;
     }
     catch (Exception ex)
     {
         myUart.Pack_Debug_out(null, "Exception" + "[" + ex.ToString() + "]");
     }
 }
예제 #2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                myConfig.UserName = textBoxUserName.Text;
                myConfig.UserPwd  = textBoxPwd.Text;

                // 校验用户名和密码是否填写
                //if (string.IsNullOrEmpty(textBoxUserName.Text) || string.IsNullOrEmpty(textBoxPwd.Text))
                //{
                //    MessageBox.Show("用户名和密码必须要输入!");
                //    return;
                //}

                // 校验密码是否正确
                if (!checkUser())
                {
                    MessageBox.Show("输入的密码有问题!");
                    myUart.Pack_Debug_out(null, "[UserLogin] login failed!user="******",pwd=" + myConfig.UserPwd);

                    return;
                }

                myUart.Pack_Debug_out(null, "[UserLogin] login succeed!user="******",pwd=" + myConfig.UserPwd);

                myConfig.SaveLogin();

                // 校验成功跳转页面
                if (SerialPort_Open())
                {
                    myConfig.SaveCommunication();
                }
                else
                {
                    //MessageBox.Show("串口打开错误,登录失败");
                }

                this.textBoxUserName.Text = string.Empty;
                this.textBoxPwd.Text      = string.Empty;
                this.Hide();

                FormDeviceInit dev = new FormDeviceInit(this);
                dev.StartPosition = FormStartPosition.CenterScreen;
                //dev.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #3
0
        /// <summary>
        /// 启动客户端,连接至服务器
        /// </summary>
        public void start()
        {
            //设定服务器IP地址
            IPAddress ip = IPAddress.Parse(ipServer);

            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                socket.Connect(new IPEndPoint(ip, portServer));   // 连接服务器

                myUart.Pack_Debug_out(null, "连接服务器" + socket.RemoteEndPoint.ToString() + "完成\n");

                localIpPort = socket.LocalEndPoint.ToString();
                connected   = true;

                Thread thread = new Thread(receiveData);
                thread.Name         = "TCPClientRecv";
                thread.IsBackground = true;
                thread.Start(socket);      // 在新的线程中接收服务器信息
            }
            catch (Exception ex)
            {
                myUart.Pack_Debug_out(null, "连接服务器失败 " + ex.ToString());

                connected = false;
            }
        }
예제 #4
0
 private void MDIParent_Load(object sender, EventArgs e)
 {
     try
     {
         myFormLogo                 = new FormChildLogo();
         myFormLogo.MdiParent       = this;
         myFormLogo.WindowState     = FormWindowState.Maximized;
         myFormLogo.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
         myFormLogo.Text            = "";
         myFormLogo.ControlBox      = false;
         myFormLogo.Show();
     }
     catch (Exception ex)
     {
         myUart.Pack_Debug_out(null, "Exception" + "[" + ex.ToString() + "]");
     }
 }
예제 #5
0
        private void timerHighVoltage_10min_Timeout(object sender, EventArgs e)
        {
            timerHighVoltage_10min.Enabled = false;
            myUart.Pack_Debug_out(null, "HV 10min timeout" + "]");

            myApi.SendHighVoltageDown(0, 0);
            timerUartRecv.Interval = 1000 * 10;
            timerUartRecv.Enabled  = true;
        }