Exemplo n.º 1
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (IsConnected)
            {
                return;
            }

            if (!this.CheckTel())
            {
                ShowMessageAndAddLog("电话只能为11位数字");
                return;
            }
            this.clienManager = new UDPClientManager();
            this.client       = this.clienManager.ConnServer(this.textYuMing.Text.Trim(), (int)this.numericPort.Value);
            if (this.client != null)
            {
                this.IsConnected = true;
                this.StartRead();
                AddLog("已连接服务器");
            }
            else
            {
                this.IsConnected = false;
            }
            this.RefreshText();
        }
Exemplo n.º 2
0
        // 服务控制
        private void Start()
        {
            if (this.loginInfo == null)
            {
                AddErrorTrace("登录传递的DTU信息为空对象");
                return;
            }
            this.curTitle               = this.Text + "---" + this.loginInfo.PumpName + "-" + this.loginInfo.DTUID;
            this.Text                   = this.curTitle;
            this.clienManager           = new UDPClientManager();
            this.clienManager.evtError += AddErrorTrace;//添加报错信息
            this.client                 = this.clienManager.ConnServer(this.loginInfo.IP, this.loginInfo.Port);
            if (this.client != null)
            {
                this.IsConnected = true;
                AddDebugTrace("已连接服务器");
                this.RefrehViewValue();

                this.StartListen(); //开始监听线程
                this.StartHeart();  //开始心跳线程
                this.StartAutoPLCDataServer();
                this.StartPLCDataServer();
            }
            else
            {
                this.IsConnected = false;
                AddErrorTrace("连接服务器" + this.loginInfo.IP + "失败");
                return;
            }
        }
Exemplo n.º 3
0
 private void Stop()
 {
     if (this.IsConnected == false || this.client == null || this.clienManager == null)
     {
         return;
     }
     this.StopPLCDataServer();
     this.StopHeart();
     this.StoptListen();
     this.clienManager.ClearSelf();
     this.clienManager = null;
 }
Exemplo n.º 4
0
 private void bttnIsDisconnect_Click(object sender, EventArgs e)
 {
     if (!this.IsConnected)
     {
         MessageBox.Show("没有可断开的服务器");
     }
     this.StopRead();
     this.clienManager.ClearSelf();
     this.client       = null;
     this.clienManager = null;
     this.IsConnected  = false;
     this.AddLog("已断开服务器连接");
     this.RefreshText();
 }
Exemplo n.º 5
0
 public TestHome(UDPClient client, UDPClientManager clienManager)
 {
     this.client       = client;
     this.clienManager = clienManager;
     InitializeComponent();
 }