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#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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("排程监视PLC点位读取失败检查PLC连接情况");
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;
}
}
}