modbus 字序bug处理

master
rszn 5 months ago
parent be570cc21b
commit 25d9ad8d8e

@ -30,7 +30,6 @@ namespace Service.Charger.Client;
[Scope("InstancePerDependency")]
public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
{
#region 属性
/// <summary>
@ -52,7 +51,6 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
public bool IsCharged { get; set; } = false;
/// <summary>
/// 站外两枪时是否在充电
/// </summary>
@ -61,6 +59,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
[1] = false,
[2] = false
};
/// <summary>
/// 充电桩连接状态
/// </summary>
@ -161,6 +160,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// 充电桩的遥测
/// </summary>
public ConcurrentDictionary<byte, PileUploadTelemetry> PileUploadTelemetry = new();
/// <summary>
/// 充电桩的遥信
/// </summary>
@ -170,6 +170,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// 充电桩状态信息
/// </summary>
public ConcurrentDictionary<byte, ChargerPile> ChargerPile = new();
/// <summary>
///充电机实时充电功率
/// </summary>
@ -460,7 +461,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
BitUtls.BytesToHexStr(setPeakValleyTime.ToBytes());
this.Channel.WriteAndFlushAsync(setPeakValleyTime);
Log().Info($"SendSetPeakValleyTime{CurrentCmd} to chargeOrderNo={BinNo}");
Log().Info($"SendSetPeakValleyTime{CurrentCmd} to chargeOrderNo={BinNo}");
return Result<bool>.Success();
}
@ -498,6 +499,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
this.Channel.WriteAndFlushAsync(req);
return Result<bool>.Success();
}
/// <summary>
/// 3.7.1 监控平台远程启动充电桩充电
/// </summary>
@ -507,7 +509,8 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// <param name="changePowerCmdType">功率调节参数</param>
/// <param name="chargeOrderNo"></param>
/// <returns>充电流水号</returns>
public Result<string> SendStartOutCharger(byte pn, byte socValue, short changePower=360,byte changePowerCmdType=1 ,
public Result<string> SendStartOutCharger(byte pn, byte socValue, short changePower = 360,
byte changePowerCmdType = 1,
string? chargeOrderNo = null)
{
if (!Connected)
@ -523,12 +526,14 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
Log().Info(
$"SendStartOutCharger pn={pn}, socValue={socValue}, changePower={changePower}, changePowerCmdType={changePowerCmdType}, chargeOrderNo={chargeOrderNo}");
PileStartCharge pileStartCharge = new PileStartCharge(pn, socValue, changePowerCmdType, changePower,chargeOrderNo);
PileStartCharge pileStartCharge =
new PileStartCharge(pn, socValue, changePowerCmdType, changePower, chargeOrderNo);
this.Channel.WriteAndFlushAsync(pileStartCharge);
return Result<string>.Success(chargeOrderNo);
}
/// <summary>
/// 3.7.3 监控平台远程停止充电桩充电
/// </summary>
@ -544,7 +549,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
Log().Info(
$"SendStartOutCharger pn={pn}, stopReason={stopReason}");
PileStopCharge pileStopCharge=new PileStopCharge(pn,stopReason);
PileStopCharge pileStopCharge = new PileStopCharge(pn, stopReason);
this.Channel.WriteAndFlushAsync(pileStopCharge);
return Result<string>.Success();
@ -556,17 +561,18 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// <param name="pn"></param>
/// <param name="expectedOperatingPower"></param>
/// <returns></returns>
public Result<bool> SendPileAdjustPower(byte pn,float expectedOperatingPower)
public Result<bool> SendPileAdjustPower(byte pn, float expectedOperatingPower)
{
if (!Connected)
{
return Result<bool>.Fail($"charger-{BinNo} disconnect");
}
PileAdjustPower powerRegulation = new PileAdjustPower(pn,expectedOperatingPower);
PileAdjustPower powerRegulation = new PileAdjustPower(pn, expectedOperatingPower);
this.Channel.WriteAndFlushAsync(powerRegulation);
return Result<bool>.Success();
}
/// <summary>
///
/// </summary>
@ -592,7 +598,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// <summary>
///
/// </summary>
public Result<bool> StartCharge(byte chargeSoc, float chargePower)
public Result<bool> StartCharge(byte chargeSoc, float chargePower)
{
if (string.IsNullOrWhiteSpace(BinNo))
{
@ -616,12 +622,12 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
return Result<bool>.Fail($"charger-{BinNo} battery not exist");
}
if (binInfo.AmtLock == 1)
if (binInfo.AmtLock == 1)
{
return Result<bool>.Fail($"仓-{BinNo} 被锁定");
}
if (binInfo.CanChargeFlag == 0)
if (binInfo.CanChargeFlag == 0)
{
return Result<bool>.Fail($"仓-{BinNo} 被禁用");
}

Loading…
Cancel
Save