using log4net;
using Service.Charger.Client;
namespace Service.Execute.Api;
public class PlcApi
{
private const int TimeSpan = 60;
private static readonly ILog Log = LogManager.GetLogger("PlcApi");
///
/// 数据有效时间。单位秒
///
static int DataTimeSeconds = 2;
///
/// 是否远程模式
///
///
public static bool IsRemote()
{
return ClientMgr.PlcClient.Remote;
}
public static bool IsInit()
{
return ClientMgr.PlcClient.Init;
}
public static bool IsAuto()
{
return ClientMgr.PlcClient.Auto;
}
///
/// 入口雷达检测
///
///
public static bool EntranceRadar()
{
/*var entranceRadar = PlcMgr.EntranceRadar();
Log.Info($"PlcApi EntranceRadar resp={entranceRadar}");
return entranceRadar;*/
return false;
}
///
/// 出口雷达检测
///
///
public static bool ExitRadar()
{
/*var exitRadar = PlcMgr.ExitRadar();
Log.Info($"PlcApi ExitRadar resp={exitRadar}");*/
return false;
}
///
/// 写入口灯
/// 红灯:1020
/// 绿灯:1000
///
///
///
public static bool WriteEntranceLamp(ushort data)
{
/*Log.Info($"PlcApi writeEntranceLamp start data={data}");
var writeEntranceLamp = PlcMgr.WriteEntranceLamp(data);
Log.Info($"PlcApi writeEntranceLamp resp={writeEntranceLamp}");
return writeEntranceLamp;*/
return false;
}
///
/// 写出口灯
/// 红灯:1020
/// 绿灯:1000
///
///
///
public static bool WriteExistLamp(ushort data)
{
/*Log.Info($"PlcApi WriteExistLamp start data={data}");
var writeExistLamp = PlcMgr.WriteExistLamp(data);
Log.Info($"PlcApi WriteExistLamp resp={writeExistLamp}");
return writeExistLamp;*/
return false;
}
///
/// 下发选包
///
/// 入仓位,仓位号
/// 出仓位,仓位号
///
public static bool DistributeSelectPack(string inBinNo, string outBinNo)
{
/*Log.Info($"PlcApi DistributeSelectPack start inBinNo={inBinNo} outBinNo={outBinNo}");
return PlcMgr.DistributeBinNo(inBinNo, outBinNo);*/
return false;
}
///
/// 下发启动换电
///
///
public static bool StartSwapping(string inBinNo, string outBinNo)
{
Log.Info($"PlcApi StartSwapping param= inBinNo={inBinNo}, outBinNo={outBinNo}");
ClientMgr.PlcClient?.SendStartBatterySwapReq(Convert.ToByte(outBinNo), Convert.ToByte(inBinNo));
Log.Info($"PlcApi StartSwapping done");
return ClientMgr.PlcClient.SwapStart;
}
//初始化
public static bool Init()
{
Log.Info($"PlcApi Init ");
ClientMgr.PlcClient?.SendInitializeCommandReq();
Log.Info($"PlcApi Init done");
return true;
}
///
/// 读取任务状态
///
///
public static bool ReadTaskStatus(ushort taskNo)
{
/*Log.Info($"PlcApi ReadTaskStatus param= taskNo={taskNo}");
var readTaskStatus = PlcMgr.ReadTaskStatus(taskNo);
Log.Info($"PlcApi ReadTaskStatus resp={readTaskStatus}");
return readTaskStatus;*/
return false;
}
///
/// plc上使能
///
///
public static bool HoldOn()
{
/*Log.Info($"PlcApi start HoldOn ");
var holdOn = PlcMgr.HoldOn();
Log.Info($"PlcApi HoldOn resp={holdOn}");
return holdOn;*/
return false;
}
///
/// 查看拍照状态
///
///
public static ushort ChannelStatus()
{
/*Log.Info($"PlcApi start ChannelStatus ");
PlcMgr.ResetPlc();
var channelStatus = PlcMgr.ChannelStatus();
Log.Info($"PlcApi ChannelStatus resp= {channelStatus}");
return channelStatus;*/
return 0;
}
///
/// 读plc任务状态
///
/// 6未连接
public static int ReadPlcTaskStatus()
{
/*Log.Info($"PlcApi start ReadPlcTaskStatus ");
var readPlcTaskStatus = PlcMgr.ReadPlcTaskStatus();
Log.Info($"PlcApi ReadPlcTaskStatus resp= {readPlcTaskStatus}");
return readPlcTaskStatus;*/
return -1;
}
}