|
|
@ -28,8 +28,8 @@ namespace Service.Charger.Client;
|
|
|
|
[Scope("InstancePerDependency")]
|
|
|
|
[Scope("InstancePerDependency")]
|
|
|
|
public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(ChargerClient));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(ChargerClient));
|
|
|
|
|
|
|
|
|
|
|
|
#region 属性
|
|
|
|
#region 属性
|
|
|
|
|
|
|
|
|
|
|
|
public ushort AuthTimes { get; set; } = 0;
|
|
|
|
public ushort AuthTimes { get; set; } = 0;
|
|
|
@ -217,14 +217,20 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 发送鉴权
|
|
|
|
/// 发送鉴权
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public void SendAuth()
|
|
|
|
public Result<bool> SendAuth()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte authCodeKey = ChargerUtils.GetByteRandomNum(); //鉴码KEY[随机数]
|
|
|
|
byte authCodeKey = ChargerUtils.GetByteRandomNum(); //鉴码KEY[随机数]
|
|
|
|
byte[] authCodes = ChargerUtils.GetAuthCodesResult(ChargerConst.AuthCode, authCodeKey); //鉴权码
|
|
|
|
byte[] authCodes = ChargerUtils.GetAuthCodesResult(ChargerConst.AuthCode, authCodeKey); //鉴权码
|
|
|
|
Auth auth = new Auth(IncreAuthTimes(), authCodes, authCodeKey);
|
|
|
|
Auth auth = new Auth(IncreAuthTimes(), authCodes, authCodeKey);
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(auth, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(auth, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(auth.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(auth.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(auth);
|
|
|
|
this.Channel.WriteAndFlushAsync(auth);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -234,66 +240,96 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
/// <param name="changePowerCmdType">功率调节指令类型.默认1 绝对功率值</param>
|
|
|
|
/// <param name="changePowerCmdType">功率调节指令类型.默认1 绝对功率值</param>
|
|
|
|
/// <param name="changePower">0.1kw/位,默认3600</param>
|
|
|
|
/// <param name="changePower">0.1kw/位,默认3600</param>
|
|
|
|
/// <param name="chargeOrderNo">充电流水号</param>
|
|
|
|
/// <param name="chargeOrderNo">充电流水号</param>
|
|
|
|
public string SendRemoteStartCharging(byte socLimit, float changePower = 3600, byte changePowerCmdType = 1,
|
|
|
|
public Result<string> SendRemoteStartCharging(byte socLimit, float changePower = 3600, byte changePowerCmdType = 1,
|
|
|
|
string? chargeOrderNo = null)
|
|
|
|
string? chargeOrderNo = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<string>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(chargeOrderNo))
|
|
|
|
if (string.IsNullOrWhiteSpace(chargeOrderNo))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
chargeOrderNo = ChargerUtils.GenChargeOrderSn();
|
|
|
|
chargeOrderNo = ChargerUtils.GenChargeOrderSn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.Info($"SendRemoteStartCharging soc={socLimit}, changePower={changePower}, changePowerCmdType={changePowerCmdType}, chargeOrderNo={chargeOrderNo}");
|
|
|
|
Log.Info(
|
|
|
|
|
|
|
|
$"SendRemoteStartCharging soc={socLimit}, changePower={changePower}, changePowerCmdType={changePowerCmdType}, chargeOrderNo={chargeOrderNo}");
|
|
|
|
var remoteStartCharging = new RemoteStartCharging(socLimit, changePowerCmdType, changePower, chargeOrderNo);
|
|
|
|
var remoteStartCharging = new RemoteStartCharging(socLimit, changePowerCmdType, changePower, chargeOrderNo);
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(remoteStartCharging, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(remoteStartCharging, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(remoteStartCharging.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(remoteStartCharging.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(remoteStartCharging);
|
|
|
|
this.Channel.WriteAndFlushAsync(remoteStartCharging);
|
|
|
|
|
|
|
|
|
|
|
|
return chargeOrderNo;
|
|
|
|
return Result<string>.Success(chargeOrderNo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 监控平台发送远程停止充电指令
|
|
|
|
/// 监控平台发送远程停止充电指令
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="reason">0 正常停机 1 服务器发现桩异常,强制停机</param>
|
|
|
|
/// <param name="reason">0 正常停机 1 服务器发现桩异常,强制停机</param>
|
|
|
|
public void SendRemoteStopCharging(byte reason = 0)
|
|
|
|
public Result<bool> SendRemoteStopCharging(byte reason = 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RemoteStopCharging remoteStopCharging = new RemoteStopCharging(reason);
|
|
|
|
RemoteStopCharging remoteStopCharging = new RemoteStopCharging(reason);
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(remoteStopCharging, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(remoteStopCharging, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(remoteStopCharging.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(remoteStopCharging.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(remoteStopCharging);
|
|
|
|
this.Channel.WriteAndFlushAsync(remoteStopCharging);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 监控平台发送功率调节指令
|
|
|
|
/// 监控平台发送功率调节指令
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="expectedOperatingPower">期望运行功率</param>
|
|
|
|
/// <param name="expectedOperatingPower">期望运行功率</param>
|
|
|
|
public void SendPowerRegulation(float expectedOperatingPower)
|
|
|
|
public Result<bool> SendPowerRegulation(float expectedOperatingPower)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PowerRegulation powerRegulation = new PowerRegulation(expectedOperatingPower);
|
|
|
|
PowerRegulation powerRegulation = new PowerRegulation(expectedOperatingPower);
|
|
|
|
this.Channel.WriteAndFlushAsync(powerRegulation);
|
|
|
|
this.Channel.WriteAndFlushAsync(powerRegulation);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 倍率 例如,0.单5C位该0值.1C为 5 ,1C 时该值为 10
|
|
|
|
/// 倍率 例如,0.单5C位该0值.1C为 5 ,1C 时该值为 10
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rate"></param>
|
|
|
|
/// <param name="rate"></param>
|
|
|
|
public void SendAdjustChargeRate(float rate)
|
|
|
|
public Result<bool> SendAdjustChargeRate(float rate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AdjustChargeRate adjustChargeRate = new AdjustChargeRate(rate);
|
|
|
|
AdjustChargeRate adjustChargeRate = new AdjustChargeRate(rate);
|
|
|
|
this.Channel.WriteAndFlushAsync(adjustChargeRate);
|
|
|
|
this.Channel.WriteAndFlushAsync(adjustChargeRate);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 监控平台下发辅源控制指令
|
|
|
|
/// 监控平台下发辅源控制指令
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="openFlag">打开辅助电源标志 1:电池包辅助电源导通 0:电池包辅助电源断开</param>
|
|
|
|
/// <param name="openFlag">打开辅助电源标志 1:电池包辅助电源导通 0:电池包辅助电源断开</param>
|
|
|
|
public void SendAuxiliaryPower(byte openFlag)
|
|
|
|
public Result<bool> SendAuxiliaryPower(byte openFlag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AuxiliaryPower auxiliaryPower = new AuxiliaryPower(openFlag);
|
|
|
|
AuxiliaryPower auxiliaryPower = new AuxiliaryPower(openFlag);
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(auxiliaryPower, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(auxiliaryPower, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(auxiliaryPower.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(auxiliaryPower.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(auxiliaryPower);
|
|
|
|
this.Channel.WriteAndFlushAsync(auxiliaryPower);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -302,12 +338,18 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
/// <param name="battery">是否有电池 0:无电池 1:有电池</param>
|
|
|
|
/// <param name="battery">是否有电池 0:无电池 1:有电池</param>
|
|
|
|
/// <param name="connectionState">电接头连接状态 0:未连接 1: 已连接</param>
|
|
|
|
/// <param name="connectionState">电接头连接状态 0:未连接 1: 已连接</param>
|
|
|
|
/// <param name="waterCondition">水接头状态 0:未连接 1: 已连接</param>
|
|
|
|
/// <param name="waterCondition">水接头状态 0:未连接 1: 已连接</param>
|
|
|
|
public void SendBatteryHolderStatus(byte battery, byte connectionState, byte waterCondition)
|
|
|
|
public Result<bool> SendBatteryHolderStatus(byte battery, byte connectionState, byte waterCondition)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BatteryHolderStatus batteryHolderStatus = new BatteryHolderStatus(battery, connectionState, waterCondition);
|
|
|
|
BatteryHolderStatus batteryHolderStatus = new BatteryHolderStatus(battery, connectionState, waterCondition);
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(batteryHolderStatus, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(batteryHolderStatus, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(batteryHolderStatus.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(batteryHolderStatus.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(batteryHolderStatus);
|
|
|
|
this.Channel.WriteAndFlushAsync(batteryHolderStatus);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -315,10 +357,16 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
/// 站控下发 VIN 鉴权的结果
|
|
|
|
/// 站控下发 VIN 鉴权的结果
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="vinresult">VIN 鉴权结果 1:通过 2 不通过</param>
|
|
|
|
/// <param name="vinresult">VIN 鉴权结果 1:通过 2 不通过</param>
|
|
|
|
public void SendAuthenticationVIN(byte vinresult)
|
|
|
|
public Result<bool> SendAuthenticationVIN(byte vinresult)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AuthenticationVIN authenticationVIN = new AuthenticationVIN(vinresult);
|
|
|
|
AuthenticationVIN authenticationVIN = new AuthenticationVIN(vinresult);
|
|
|
|
this.Channel.WriteAndFlushAsync(authenticationVIN);
|
|
|
|
this.Channel.WriteAndFlushAsync(authenticationVIN);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -331,56 +379,86 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
/// <param name="fileSize">文件大小</param>
|
|
|
|
/// <param name="fileSize">文件大小</param>
|
|
|
|
/// <param name="mD5Verification">MD5校验值</param>
|
|
|
|
/// <param name="mD5Verification">MD5校验值</param>
|
|
|
|
/// <param name="url">URL(文件路径)</param>
|
|
|
|
/// <param name="url">URL(文件路径)</param>
|
|
|
|
public void SendUpgradeRequest(byte executionControl, byte downloadTimeout, string versionNumber,
|
|
|
|
public Result<bool> SendUpgradeRequest(byte executionControl, byte downloadTimeout, string versionNumber,
|
|
|
|
string fileName, uint fileSize, string mD5Verification, string url)
|
|
|
|
string fileName, uint fileSize, string mD5Verification, string url)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UpgradeRequest upgradeRequest = new UpgradeRequest(executionControl, downloadTimeout, versionNumber, fileName,
|
|
|
|
UpgradeRequest upgradeRequest = new UpgradeRequest(executionControl, downloadTimeout, versionNumber, fileName,
|
|
|
|
fileSize, mD5Verification, url);
|
|
|
|
fileSize, mD5Verification, url);
|
|
|
|
this.Channel.WriteAndFlushAsync(upgradeRequest);
|
|
|
|
this.Channel.WriteAndFlushAsync(upgradeRequest);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 设置尖峰平谷时间段
|
|
|
|
/// 设置尖峰平谷时间段
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="setPeakValleyTime"></param>
|
|
|
|
/// <param name="setPeakValleyTime"></param>
|
|
|
|
public void SendSetPeakValleyTime(SetPeakValleyTime setPeakValleyTime)
|
|
|
|
public Result<bool> SendSetPeakValleyTime(SetPeakValleyTime setPeakValleyTime)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(setPeakValleyTime, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(setPeakValleyTime, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(setPeakValleyTime.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(setPeakValleyTime.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(setPeakValleyTime);
|
|
|
|
this.Channel.WriteAndFlushAsync(setPeakValleyTime);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 3.4.7 监控平台下发掉线停止充电
|
|
|
|
/// 3.4.7 监控平台下发掉线停止充电
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="enabled"> 0:不使能 1:使能</param>
|
|
|
|
/// <param name="enabled"> 0:不使能 1:使能</param>
|
|
|
|
public void SendOfflineStopCharging(byte enabled)
|
|
|
|
public Result<bool> SendOfflineStopCharging(byte enabled)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OfflineStopCharging offlineStopCharging = new OfflineStopCharging(enabled);
|
|
|
|
OfflineStopCharging offlineStopCharging = new OfflineStopCharging(enabled);
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(offlineStopCharging, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(offlineStopCharging, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(offlineStopCharging.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(offlineStopCharging.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(offlineStopCharging);
|
|
|
|
this.Channel.WriteAndFlushAsync(offlineStopCharging);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 3.4.12 站控设备切换站内/站外充电切换
|
|
|
|
/// 3.4.12 站控设备切换站内/站外充电切换
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="chargeMode">00:无效 01:站内 02:站外</param>
|
|
|
|
/// <param name="chargeMode">00:无效 01:站内 02:站外</param>
|
|
|
|
public void SendChangeChargeMode(byte chargeMode)
|
|
|
|
public Result<bool> SendChangeChargeMode(byte chargeMode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChangeChargeMode req = new ChangeChargeMode(chargeMode);
|
|
|
|
ChangeChargeMode req = new ChangeChargeMode(chargeMode);
|
|
|
|
this.Channel.WriteAndFlushAsync(req);
|
|
|
|
this.Channel.WriteAndFlushAsync(req);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public void SendQueryBattery()
|
|
|
|
public Result<bool> SendQueryBattery()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!Connected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail($"charger-{BinNo} disconnect");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QueryBattery queryBattery = new QueryBattery(ChargerConst.BatteryNo);
|
|
|
|
QueryBattery queryBattery = new QueryBattery(ChargerConst.BatteryNo);
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(queryBattery, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(queryBattery, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(queryBattery.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(queryBattery.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(queryBattery);
|
|
|
|
this.Channel.WriteAndFlushAsync(queryBattery);
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -432,11 +510,11 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
|
|
|
|
|
|
|
|
byte chargeSoc = StaticStationInfo.ChargeSoc;
|
|
|
|
byte chargeSoc = StaticStationInfo.ChargeSoc;
|
|
|
|
float chargePower = StaticStationInfo.ChargePower;
|
|
|
|
float chargePower = StaticStationInfo.ChargePower;
|
|
|
|
string chargeOrderNo = SendRemoteStartCharging(chargeSoc, chargePower);
|
|
|
|
Result<string> chargeOrderNo = SendRemoteStartCharging(chargeSoc, chargePower);
|
|
|
|
|
|
|
|
|
|
|
|
_chargeOrderRepository.Insert(new ChargeOrder()
|
|
|
|
_chargeOrderRepository.Insert(new ChargeOrder()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Sn = chargeOrderNo,
|
|
|
|
Sn = chargeOrderNo.Data,
|
|
|
|
BatteryNo = BatteryNo,
|
|
|
|
BatteryNo = BatteryNo,
|
|
|
|
CmdStatus = 0,
|
|
|
|
CmdStatus = 0,
|
|
|
|
ChargerNo = BinNo,
|
|
|
|
ChargerNo = BinNo,
|
|
|
|