Ejemplo n.º 1
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (toolStripButton1.Text == "开始")
     {
         if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
         {
             MessageBox.Show("输入的端口号格式有问题!!");
             return;
         }
         toolStripButton1.Text = "停止";
         tcpAsyncServer.Start();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器启动\r\n");
         NetLog("\r\n");
         timer1.Enabled = true;
         DateTime dt = DateTime.Now;
         fileHY = System.Windows.Forms.Application.StartupPath + "\\TextLog\\HY" + String.Format("{0:D4}{1:D2}{2:D2}{3:D2}{4:D2}{5:D2}", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileHY, false);
         //this.Text = tcpAsyncServer.TCPServerName + ":" + tcpAsyncServer.TCPServerPort;
     }
     else
     {
         toolStripButton1.Text = "开始";
         tcpAsyncServer.Stop();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器停止\r\n");
         NetLog("\r\n");
         mcuClientContext = null;
         timer1.Enabled   = false;
     }
 }
Ejemplo n.º 2
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (toolStripButton1.Text == "开始")
     {
         if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
         {
             MessageBox.Show("输入的端口号格式有问题!!");
             return;
         }
         toolStripButton1.Text = "停止";
         tcpAsyncServer.Start();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器启动\r\n");
         NetLog("\r\n");
         timer1.Enabled = true;
         DateTime dt = DateTime.Now;
         string   filePT, fileMS, fileTC, fileLA;
         filePT = System.Windows.Forms.Application.StartupPath + "\\TextLog\\PT" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), filePT, false);
         fileMS = System.Windows.Forms.Application.StartupPath + "\\TextLog\\MS" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileMS, false);
         fileTC = System.Windows.Forms.Application.StartupPath + "\\TextLog\\TC" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileTC, false);
         fileLA = System.Windows.Forms.Application.StartupPath + "\\TextLog\\LA" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileLA, false);
     }
     else
     {
         toolStripButton1.Text = "开始";
         tcpAsyncServer.Stop();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器停止\r\n");
         NetLog("\r\n");
         //bPic = false;
         timer1.Enabled   = false;
         mcuClientContext = null;
     }
 }
Ejemplo n.º 3
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (toolStripButton1.Text == "开始")
     {
         toolStripButton1.Text = "停止";
         tcpAsyncServer.Start();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器启动\r\n");
         NetLog("\r\n");
         timer1.Enabled = true;
         //this.Text = tcpAsyncServer.TCPServerName + ":" + tcpAsyncServer.TCPServerPort;
     }
     else
     {
         toolStripButton1.Text = "开始";
         tcpAsyncServer.Stop();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器停止\r\n");
         NetLog("\r\n");
         //bPic = false;
         timer1.Enabled   = false;
         mcuClientContext = null;
     }
 }
Ejemplo n.º 4
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     tcpAsyncServer.Stop();
 }