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.

116 lines
3.0 KiB

using Entity.Constant;
using log4net;
5 months ago
using Service.Charger.Client;
5 months ago
using Service.Mgr;
using Service.Padar.Client;
namespace Service.Execute.Api;
public class PlcApi
{
6 months ago
private const int TimeSpan = 60;
private static readonly ILog Log = LogManager.GetLogger("PlcApi");
/// <summary>
/// 数据有效时间。单位秒
/// </summary>
static int DataTimeSeconds = 2;
/// <summary>
/// 是否远程模式
/// </summary>
/// <returns></returns>
public static bool IsRemote()
{
1 month ago
return ClientMgr.PlcClient!.Remote;
}
/// <summary>
5 months ago
/// 是否初始化完成
/// </summary>
/// <returns></returns>
5 months ago
public static bool IsInit()
{
1 month ago
return ClientMgr.PlcClient!.Init;
}
/// <summary>
5 months ago
/// 是否自动
/// </summary>
/// <returns></returns>
5 months ago
public static bool IsAuto()
{
3 months ago
if (ClientMgr.PlcClient!=null)
{
return ClientMgr.PlcClient.Auto;
}
return false;
}
5 months ago
/// <summary>
/// 下发启动换电
/// </summary>
/// <returns></returns>
public static bool StartSwapping(string inBinNo, string outBinNo)
{
StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Plc,SwapConstant.PlcProtocol.StartSwap,
$"出仓位:{outBinNo},入仓位:{inBinNo}" ,(int)SwapConstant.CommunicationType.Send);
Log.Info($"PlcApi StartSwapping param= inBinNo={inBinNo}, outBinNo={outBinNo}");
ClientMgr.PlcClient?.SendStartBatterySwapReq(Convert.ToByte(outBinNo), Convert.ToByte(inBinNo));
5 months ago
Log.Info($"PlcApi StartSwapping done");
return ClientMgr.PlcClient.SwapStart;
}
1 month ago
/// <summary>
/// 电池搬运
/// </summary>
/// <returns></returns>
public static bool StartBatteryMove(string inBinNo, string outBinNo)
{
StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Plc,SwapConstant.PlcProtocol.StartBatteryMove,
$"出仓位:{inBinNo},入仓位:{outBinNo}" ,(int)SwapConstant.CommunicationType.Send);
1 month ago
Log.Info($"PlcApi StartBatteryMove param= inBinNo={inBinNo}, outBinNo={outBinNo}");
ClientMgr.PlcClient?.SendMoveCommandReq(Convert.ToByte(inBinNo), Convert.ToByte(outBinNo));
1 month ago
Log.Info($"PlcApi StartBatteryMove done");
return ClientMgr.PlcClient.SwapStart;
}
5 months ago
/// <summary>
/// 发送初始化命令
/// </summary>
/// <returns></returns>
public static bool Init()
{
Log.Info($"PlcApi Init ");
ClientMgr.PlcClient?.SendInitializeCommandReq();
Log.Info($"PlcApi Init done");
5 months ago
return true;
}
/// <summary>
/// 发送红绿灯
/// </summary>
/// <returns></returns>
public static bool Traffic(byte Light)
{
Log.Info($"PlcApi Init ");
ClientMgr.PlcClient?.SendTrafficLightReq(Light);
Log.Info($"PlcApi Init done");
return true;
}
}