using log4net; using Service.Charger.Client; using Service.Mgr; using Service.Padar.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() { if (ClientMgr.PlcClient!=null) { return ClientMgr.PlcClient.Auto; } 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; } }