Пример #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);
        }
Пример #2
0
 /// <summary>
 ///特异形烟2线
 /// </summary>
 void sendSSTask2( )
 {
     try
     {
         issendone = true;
         int flag = SpyBiaozhiGroup.ReadD(2).CastTo <int>(-1);//发送数据前读标志位
         writeLog.Write("2线特异形烟发送数据前读标志位:" + flag);
         if (flag == 0)
         {
             string   OutStr = "";
             object[] datas  = UnPokeService.GetSpecialSmokeData(10, "2", out listSS2A, out OutStr);//获取可发送任务
             if (int.Parse(datas[0].ToString()) == 0)
             {
                 updateListBox("2线特异形烟分拣数据发送完毕");
                 return;
             }
             writeLog.Write("2线特异形烟分拣线:" + OutStr);
             updateListBox("2线特异形烟分拣线:" + OutStr);
             SpecialSmokeGroup2.SyncWrite(datas);
         }
         else
         {
             writeLog.Write("2线特异形烟标志位读取到异常:" + flag);
             updateListBox("2线特异形烟标志位读取到异常:" + 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);
         }
         sendSSTask2();//异常后重新发送
     }
 }