You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.3 KiB
C#

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