Example #1
0
        private void button12_Click(object sender, EventArgs e)
        {
            DialogResult MsgBoxResult = MessageBox.Show("确定要退出程序?",                       //对话框的显示内容
                                                        "操作提示",                           //对话框的标题
                                                        MessageBoxButtons.YesNo,          //定义对话框的按钮,这里定义了YSE和NO两个按钮
                                                        MessageBoxIcon.Question,          //定义对话框内的图表式样,这里是一个黄色三角型内加一个感叹号
                                                        MessageBoxDefaultButton.Button2); //定义对话框的按钮式样


            if (MsgBoxResult == DialogResult.Yes)
            {
                if (pIOPCServer != null)
                {
                    Marshal.ReleaseComObject(pIOPCServer);
                    pIOPCServer = null;
                }
                if (OnlyTaskGorup != null)
                {
                    OnlyTaskGorup.Release();
                }
                if (FinishOnlyGoroup != null)
                {
                    FinishOnlyGoroup.Release();
                }
                if (SpyBiaozhiGroup != null)
                {
                    SpyBiaozhiGroup.Release();
                }
                if (SpecialSmokeGroup1 != null)
                {
                    SpecialSmokeGroup1.Release();
                }
                if (SpecialSmokeGroup2 != null)
                {
                    SpecialSmokeGroup2.Release();
                }
                list_data.Items.Clear();
                updateListBox("任务停止发送!");
                writeLog.Write("任务停止发送!");
                updateControlEnable(true, button10);
            }
            else
            {
                return;
            }
            //  updateControlEnable(true, button10);
        }
Example #2
0
        /// <summary>
        ///特异形烟1线
        /// </summary>
        void sendSSTask1()
        {
            try
            {
                issendone = true;
                int flag = SpyBiaozhiGroup.ReadD(1).CastTo <int>(-1);//发送数据前读标志位
                writeLog.Write("1线特异形烟发送数据前读标志位:" + flag);
                if (flag == 0)
                {
                    string   OutStr = "";
                    object[] datas  = UnPokeService.GetSpecialSmokeData(10, "1", out listSS1B, out OutStr);//获取可发送任务
                    if (int.Parse(datas[0].ToString()) == 0)
                    {
                        updateListBox("1线特异形烟分拣数据发送完毕");

                        return;
                    }
                    writeLog.Write("1线特异形烟分拣线:" + OutStr);
                    updateListBox("1线特异形烟分拣线:" + OutStr);
                    SpecialSmokeGroup1.SyncWrite(datas);
                }
                else
                {
                    writeLog.Write("1线特异形烟标志位读取到异常:" + flag);
                    updateListBox("1线特异形烟标志位读取到异常:" + flag);
                }
            }
            catch (Exception ex)
            {
                writeLog.Write(ex.Message);
                updateListBox(ex.Message);
                Thread.Sleep(10000);
                if (ex.InnerException != null && ex.InnerException.Message != null)
                {
                    writeLog.Write(ex.InnerException.Message);
                    updateListBox(ex.InnerException.Message);
                }
                sendSSTask1();//异常后重新发送
            }
        }