You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB

using Entity.Constant;
using HslCommunication.Enthernet;
5 months ago
using HybirdFrameworkCore.Autofac.Attribute;
5 months ago
using HybirdFrameworkCore.Entity;
5 months ago
using HybirdFrameworkDriver.TcpClient;
2 months ago
using log4net;
using Service.Execute;
using Service.Execute.Model;
5 months ago
using Decoder = Service.Padar.Codec.Decoder;
using Encoder = Service.Padar.Codec.Encoder;
namespace Service.Padar.Client;
[Scope]
public class PadarClient : TcpClient<IBaseHandler, Decoder, Encoder>
5 months ago
{
private readonly String DEVICE_CODE = "radar";
5 months ago
/// <summary>
/// 0-雷达不工作1-无车2-无电池3-角度偏移过大4-车辆靠后5-车辆靠前6-车辆到位
/// </summary>
public byte CarState = new byte();
5 months ago
public static readonly byte[] StartChar = { 0xFE, 0x68 };
//
public static byte serialNum = 0;
5 months ago
private static readonly ILog Log = LogManager.GetLogger(typeof(PadarClient));
5 months ago
public bool Connect()
{
base.BaseConnect();
Log.Info($"padar connect succeed");
return Connected;
}
1 month ago
public override ILog Logger()
{
return Log;
}
5 months ago
/// <summary>
/// 0-关闭雷达 1-开启
5 months ago
/// </summary>
/// <param name="byte3">0-关闭雷达 1-开启雷达</param>
/// <returns></returns>
public Result<bool> PadarControl(byte byte3)
{
byte[] sendBytes = new byte[4];
sendBytes[0] = 0xFE;
sendBytes[1] = 0x68;
if (serialNum > byte.MaxValue)
serialNum = 0;
sendBytes[2] = serialNum;
serialNum++;
sendBytes[3] = byte3;
this.Channel.WriteAndFlushAsync(sendBytes);
StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Radar,
byte3 == 0 ? SwapConstant.RadarProtocol.Close : SwapConstant.RadarProtocol.Open,
sendBytes.ToString(), (int)SwapConstant.CommunicationType.Send);
5 months ago
return Result<bool>.Success();
}
5 months ago
}