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>
@ -50,9 +49,8 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// 是否已经开始充电
/// </summary>
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>
@ -69,7 +68,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
[1] = false,
[2] = false
};
public bool IsStopped { get; set; } = false;
public bool IsCanSendStopCmd { get; set; } = true;
@ -151,30 +150,32 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// 充电机遥测数据
/// </summary>
public UploadTelemetryData UploadTelemetryData = new UploadTelemetryData();
/// <summary>
/// 充放电机上传单体动力蓄电池电压极值统计
/// </summary>
public VoltageExtremumStatistics? VoltageExtremumStatistics = new VoltageExtremumStatistics();
/// <summary>
/// 充电桩的遥测
/// </summary>
public ConcurrentDictionary<byte, PileUploadTelemetry> PileUploadTelemetry = new();
/// <summary>
/// 充电桩的遥信
/// </summary>
public ConcurrentDictionary<byte, PileUploadRemoteSignal> PileUploadRemoteSignal = new();
/// <summary>
/// 充电桩状态信息
/// </summary>
public ConcurrentDictionary<byte, ChargerPile> ChargerPile = new();
/// <summary>
///充电机实时充电功率
/// </summary>
public float RealTimeChargePower { get; set; } = 0;
/// <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>
@ -541,32 +546,33 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
{
return Result<string>.Fail($"充电机{BinNo}未连接");
}
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();
}
/// <summary>
/// 3.7.9 监控平台发送充电桩功率调节指令
/// </summary>
/// <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