using System; using System.Collections.Generic; using System.Linq; using System.Text; using Mesnac.Action.Feeding.Qingquan.BasicInfo; namespace Mesnac.Action.Feeding.Qingquan.FeedingPlc { /// /// 胶料称输送控制类 /// public class RunShuSongHandler { /// /// 执行胶料称输送控制 /// public static void Execute() { int RubSL = UpLoadRubSL(); //读取送料信号 if (RubSL != 1) //1:准备好了 { return; } bool result = DownloadRubSL(); //将送料信号准备好标志置0 双方约定 result =DownloadRubShuSong(1, "取消锁"); //取消胶料秤控制 0:全锁 1:放行 2:锁自动 } #region 读取胶料秤允许送料标志 /// /// 读取胶料秤允许送料标志 /// /// public static int UpLoadRubSL() { int result = 0; try { result = PlcData.Instance.RubSL.LastValue.ToInt(); } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("读取胶料秤允许送料标志失败:" + ex.Message, ex); } return result; } #endregion #region 读取胶料秤送料标志 /// /// 读取胶料秤送料标志 /// /// public static int UpLoadRubSLAllow() { int result = 0; try { result = PlcData.Instance.RubShusong.LastValue.ToInt(); } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("读取胶料秤送料标志失败:" + ex.Message, ex); } return result; } #endregion #region 胶料秤送料标志复位 /// /// 下传胶料秤胶料是否允许送料,1允许,0不允许,因为是复位所以直接下传0 /// /// 成功返回true,失败返回false public static bool DownloadRubSL() { bool result = false; try { result = PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.RubSL, new object[] { 0 }, false); if (result == false) { ICSharpCode.Core.LoggingService.Warn("PLC通讯故障:[下传胶料秤送料标志到PLC]"); } } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("下传胶料秤送料标志失败:" + ex.Message, ex); return false; } return result; } #endregion #region 下传胶料秤传送控制 /// /// 下传胶料秤输送控制,用于条码扫描,扫描正确传1可以输送否则传0 /// /// 要下传的值 /// 描述说明 /// 成功返回true,失败返回false public static bool DownloadRubShuSong(int nNumber, string strMsg) { bool result = false; try { result = PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.RubShusong, new object[] { nNumber }, false); if (result == false) { ICSharpCode.Core.LoggingService.Warn("PLC通讯故障:[下传胶料秤传送控制到PLC]"); } } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("下传胶料秤传送控制失败:" + ex.Message, ex); } return result; } #endregion } }