using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.PlcUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode
{
public class PlcCommunicationUtil
{
string DmName;
BasePlcHelper Plc = BasePlcHelper.Instance;
///
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
///
/// 数据块属性名
///
private DataKeyValue GetDataNameValue(string dmValue)
{
return new DataKeyValue(DmName + dmValue);
}
///
/// 从PLC中读取值
///
/// 要读取的属性
///
private int GetDataToInt(String dmValue)
{
return GetDataNameValue(dmValue).NowValue.ToInt();
}
///
/// 向PLC中写入值
///
/// 要写入的属性
/// 写入的值
private void SetDataValue(String dmValue, int value)
{
Plc.PlcWriteByDataKey(GetDataNameValue(dmValue), new Object[] { value });
}
}
}