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.

51 lines
1.4 KiB
C#

using Mesnac.Equips;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using static PLCManager.PlcData;
namespace Mesnac.Action.Compressor.Sys
{
public class BasePlcHelper
{
private static BasePlcHelper _this = null;
public static BasePlcHelper Instance
{
get
{
if (null == _this)
_this = new BasePlcHelper();
return _this;
}
}
private BasePlcHelper()
{
foreach (PropertyInfo pi in this.GetType().GetProperties())
{
if (pi.PropertyType == typeof(DataKeyValue))
{
DataKeyValue data = new DataKeyValue(pi.Name);
pi.SetValue(this, data, null);
}
}
}
public bool PlcRead(string equipName, string block, int start, int len, out object[] dataValue)
{
bool iflag = false;
dataValue = null;
foreach (Mesnac.Equips.BaseEquip equip in Factory.Instance.AllEquips.Values)
{
if (equip.Name == equipName)
{
iflag = equip.Read(block, start, len, out dataValue);
return iflag;
}
}
return false;
}
}
}