예제 #1
0
        private void initData()
        {
            d = new Database();
            d.Error += new Database.error(d_Error);

            Server s = new Server(serverAddress, 8888);

            t = new Terminal(s);

            tbPeriod.Text = "5";//默认5秒发送一次
            tbTerminalID.Text = t.Phone.ToString();
            tbTerminalNo.Text = t.TerminalNo.ToString();
            tbRegId.Text = t.Phone;
            tbRegNo.Text = t.TerminalNo.ToString();

            cbNetType.SelectedIndex = t.NetType;
            maskedTextBox1.Text = t.Version;

            t_ConnectState(t.ConState);
            t.ConnectState += new Terminal._ConnectState(t_ConnectState);
            t.Message += new Terminal._Message(t_Message);
        }
예제 #2
0
 void t_ConnectState(Terminal.State state)
 {
     try
     {
         this.Invoke((EventHandler)delegate
         {
             switch (state)
             {
                 case Terminal.State.Connect: tsslConnectState.Text = "连接状态"; tspbRun.Enabled = true; break;
                 case Terminal.State.disConnect: tsslConnectState.Text = "断开状态"; tspbRun.Enabled = false; break;
                 case Terminal.State.Send: tsslConnectState.Text = "发送状态"; tspbRun.Enabled = true; break;
                 case Terminal.State.Recv: tsslConnectState.Text = "接收状态"; tspbRun.Enabled = true; break;
             }
         });
     }
     catch { }
 }