启动和停止充电完成帧修改数据

master
smartwyy 6 months ago
parent ad42868002
commit c2ebbeb006

@ -144,7 +144,7 @@ namespace Entity.DbModel.Station
public int? BatteryEnterSeq {get;set;}
/// <summary>
/// Desc:充电状态;0-未知1-正在充电2-无电池3-禁用
/// Desc:充电状态;0-未知1-正在充电2-无电池3-禁用4-充电停止
/// Default:0
/// Nullable:True
/// </summary>

@ -124,7 +124,7 @@ public class Decoder : ByteToMessageDecoder
45 => recordType switch
{
1 => ModelConvert.Decode<FinishStartCharging>(bytes),
3 => ModelConvert.Decode<StopCharging>(bytes),
3 => ModelConvert.Decode<FinishStopCharging>(bytes),
6 => ModelConvert.Decode<PowerRegulationRes>(bytes),
10 => ModelConvert.Decode<AuxiliaryPowerRes>(bytes),
11 => ModelConvert.Decode<Login>(bytes),

@ -2,6 +2,7 @@
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
@ -22,6 +23,8 @@ namespace HybirdFrameworkServices.Charger.Handler
[Scope("InstancePerDependency")]
public class FinishStartChargingHandler : SimpleChannelInboundHandler<FinishStartCharging>, IBaseHandler
{
public BinInfoRepository BinInfoRepository { get; set; }
private static readonly ILog Log = LogManager.GetLogger(typeof(FinishStartChargingHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, FinishStartCharging msg)
{
@ -29,23 +32,23 @@ namespace HybirdFrameworkServices.Charger.Handler
{
Log.Info($"receive {msg} from {sn}");
msg.VehIdeNum = Encoding.ASCII.GetString(msg.Vin);
int chargeStatus = 0;
if (msg.Result == 0)
{
client.IsCharged = true;
chargeStatus = 1;
}
else if (msg.Result == 1)
{
client.IsCharged = false;
}
int update = BinInfoRepository.Update(t => t.ChargeStatus == chargeStatus, t => t.No == client.BinNo);
Log.Info($"update {update} start charge finish status {chargeStatus} for {client.BinNo}");
StartChargingFinishedRes msgRespond = new StartChargingFinishedRes(0, 0);
ctx.Channel.WriteAndFlushAsync(msgRespond);
}
else
{
StartChargingFinishedRes msgRespond = new StartChargingFinishedRes(1, 2);
ctx.Channel.WriteAndFlushAsync(msgRespond);
}
}
}
}

@ -1,6 +1,7 @@
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
@ -16,15 +17,33 @@ namespace Service.Charger.Handler
/// </summary>
[Order(8)]
[Scope("InstancePerDependency")]
public class StopChargingHandler : SimpleChannelInboundHandler<StopCharging>, IBaseHandler
public class FinishStopChargingHandler : SimpleChannelInboundHandler<FinishStopCharging>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(StopChargingHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, StopCharging msg)
public BinInfoRepository BinInfoRepository { get; set; }
private static readonly ILog Log = LogManager.GetLogger(typeof(FinishStopChargingHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, FinishStopCharging msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.IsCanSendStopCmd = false;
int chargeStatus = 0;
if (msg.Result == 0)
{
client.IsStopped = true;
chargeStatus = 4;
}
else
{
client.IsStopped = false;
}
int update = BinInfoRepository.Update(t => t.ChargeStatus == chargeStatus, t => t.No == client.BinNo);
Log.Info($"update {update} start charge finish status {chargeStatus} for {client.BinNo}");
ChargingStopFsdRes stopFsdRes = new ChargingStopFsdRes(0);
ctx.Channel.WriteAndFlushAsync(stopFsdRes);
}

@ -5,7 +5,7 @@ namespace Service.Charger.Msg.Charger.Req
/// <summary>
/// 3.3.11 充放电机上送充电停止帧
/// </summary>
public class StopCharging : ASDU
public class FinishStopCharging : ASDU
{
/// <summary>
/// 记录类型
Loading…
Cancel
Save