コード例 #1
0
ファイル: FmMain.cs プロジェクト: samualtang/PMSolution
 /// <summary>
 /// 断开通信连接
 /// </summary>
 void CloseDataChange()
 {
     if (socketCore != null)
     {
         connectSuccess = false;
         modbus.DisConnection();
         RoBotState = false;
         socketCore.Close();
         socketCore = null;
         FirstSend  = true;
         FmInfo.GetTaskInfo("断开与机器人的连接!");
     }
     else
     {
         FmInfo.GetTaskInfo("请先连接服务器!");
     }
     try
     {
         plc.ShapeGroup1.callback -= OnDataChange;
         plc.ShapeGroup2.callback -= OnDataChange;
         plc.ShapeGroup3.callback -= OnDataChange;
         plc.ShapeGroup4.callback -= OnDataChange;
         plc.SpyGroup6.callback   -= OnDataChange;
         FmInfo.GetTaskInfo("异型烟倍速链,常规烟翻版移除事件成功!");
         FmInfo.GetTaskInfo("任务停止发送与接收!");
     }
     catch (NullReferenceException nuller)
     {
         FmInfo.GetTaskInfo("OPC未能创建成功!" + nuller.Message);
     }
     catch (Exception ex)
     {
         FmInfo.GetTaskInfo("异型烟链板机任务停止失败!错误:" + ex.Message);
     }
     FmInfo.Func(2);
 }