Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            iniFileOP.iniFilePath = System.Windows.Forms.Application.StartupPath + "\\miConfig.ini";
            if (iniFileOP.Read("Work Setting", "bPrint") == "1")
            {
                bPrint = true;
            }
            else
            {
                bPrint = false;
            }
            pathPDF        = iniFileOP.Read("Work Setting", "pathPDF");
            CurveDataTable = new Hashtable();
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.TCPServerPort           = 8000;
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(easyStringPacket.SaveDataProcessCallbackProc);
            tcpAsyncServer.Start();
            textBox1.AppendText("服务启动" + "\r\n");
            byte[] xx = NetPacket.MakeStringPacket("123");

            this.reportViewer1.RefreshReport();
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);


            mcuClientContext = null;
            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");
            listView1_Resize(null, null);
            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);
        }
Example #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CP1616_NoAddr_Packet.bVerify = false;
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
            if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
            {
                MessageBox.Show("输入的端口号格式有问题!!");
                return;
            }
            toolStripButton1.Text = "停止";
            mcuClientContext      = null;
            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);
        }
Example #4
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;
     }
 }
Example #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
            tcpAsyncServer.TCPServerPort           = 6000;

            mcuClientContext = null;

            toolStripButton1.Text = "停止";
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            listView1_Resize(null, null);
            timer1.Enabled = true;
        }
Example #6
0
        public Form1()
        {
            InitializeComponent();
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);

            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");
            listView1_Resize(null, null);
        }
Example #7
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;
     }
 }
Example #8
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;
     }
 }
Example #9
0
        static void Main(string[] args)
        {
            TCPAsyncServer server = new TCPAsyncServer(args[0], Convert.ToInt32(args[1]));

            server.Start();
        }
Example #10
0
 public void Start()
 {
     _socket.Start();
 }