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.
62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using HighWayIot.Log4net;
|
|
using HighWayIot.Plc.PlcEntity;
|
|
using HslCommunication;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HighWayIot.Plc.PlcHelper
|
|
{
|
|
/// <summary>
|
|
/// PLC工位识别工位读取
|
|
/// </summary>
|
|
public class WorkStationHelper
|
|
{
|
|
/// <summary>
|
|
/// RFID10小车工位识别点位写入
|
|
/// </summary>
|
|
/// <param name="rgvStation"></param>
|
|
/// <returns></returns>
|
|
public bool WriteStationSingal(int rgvStationNo, int deviceNo)
|
|
{
|
|
int point = 0x600;
|
|
|
|
//选择是哪个小车
|
|
point += (deviceNo - 1) * 32;
|
|
|
|
//选择是小车的哪个点位
|
|
point += rgvStationNo - 1;
|
|
|
|
bool result = PlcConnect.PlcWrite2($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess;
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// RFID固定工位识别点位读取
|
|
/// </summary>
|
|
public bool[] ReadStationSingal()
|
|
{
|
|
bool[] result = new bool[17];
|
|
|
|
OperateResult<byte[]> PlcResult = PlcConnect.MelsecInstance2.Read("B230", 2);
|
|
|
|
byte[] data = PlcResult.Content;
|
|
|
|
if (PlcResult.IsSuccess == true)
|
|
{
|
|
for (int i = 0; i < 17; i++)
|
|
{
|
|
int dataCount = i / 8;
|
|
int indexCount = i % 8;
|
|
result[i] = data[dataCount].GetBoolByIndex(indexCount);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|