private void FrmAGVRevSIMZECallServer_Shown(object sender, EventArgs e)
 {
     try
     {
         Process[] processByName = Process.GetProcessesByName("PlcSMICECallAGV");
         if (processByName.Length > 1)
         {
             this.FormClosing -= this.FrmAGVRevSIMZECallServer_FormClosing;
             MessageBox.Show("已有PLC进程运行");
             Application.Exit();
             return;
         }
         //绑定日志显示
         delshowMessage = AddMessage;
         //绑定事件
         DelegateState.DispatchStateEvent += this.AddMessage;
         this.tmClear.Interval             = 1000 * 60 * 1;//五分钟回收一次内存
         this.tmClear.Enabled              = true;
         this.notifyIcon1    = new System.Windows.Forms.NotifyIcon(this.components);
         notifyIcon1.Visible = false;
         InitAndStartServer();
     }
     catch (Exception ex)
     { MessageBox.Show(ex.Message); }
 }
Exemple #2
0
        //启动
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                lblAGVID.Focus();
                tcpAgv.ReceiveMes      -= ViewSendCommd;
                tcpAgv.ServerCarStates -= ViewS;
                delshowMessage          = null;
                sconfig.Port            = Convert.ToInt32(tbPort.Text);
                bool IsSuccess = tcpAgv.Setup(sconfig);
                //启动服务
                if (tcpAgv.Start())
                {
                    XtraMessageBox.Show("启动成功", "提示", MessageBoxButtons.OK);
                    //tcpAgv.ServerCarStates += ViewS;
                    //delshowMessage = ItemsAdd;
                }
                else
                {
                    XtraMessageBox.Show("启动失败", "提示", MessageBoxButtons.OK);
                }

                if (checkAutomaticManual.Checked == true)
                {
                    tcpAgv.ServerCarStates += ViewS;
                    delshowMessage          = ItemsAdd;
                }
                else
                {
                    tcpAgv.ReceiveMes += ViewSendCommd;
                    delshowMessage     = ItemsAdd;
                }
            }
            catch (Exception ex)
            { throw ex; }
            finally
            {
                //tcpAgv.ReceiveMes += ViewSendCommd;
                //delshowMessage = ItemsAdd;
            }
        }