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.

48 lines
1.3 KiB
C#

using HighWayIot.Log4net;
using HslCommunication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Plc.PlcHelper
{
public class RecipeSignal
{
/// <summary>
/// 读取排程信号
/// </summary>
/// <returns></returns>
public Dictionary<int, bool> ReadSchedulingSignal()
{
Dictionary<int, bool> result = new Dictionary<int, bool>();
OperateResult<byte[]> operateResult = PlcConnect.ReadByte2("B901", 8);
if (!operateResult.IsSuccess)
{
LogHelper.Instance.Error("排程监视信息读取失败");
return null;
}
byte[] bytes = operateResult.Content;
int boolIndex = 0;
for (int i = 0x901 - 0x901; i < 0x93E - 0x901 + 1; i++)
{
result.Add(boolIndex, bytes[i / 8].GetBoolByIndex(i % 8));
boolIndex++;
}
for (int i = 0x941 - 0x901; i < 0x97E - 0x901 + 1; i++)
{
result.Add(boolIndex, bytes[i / 8].GetBoolByIndex(i % 8));
boolIndex++;
}
return result;
}
}
}