diff --git a/HybirdFrameworkCore/bin/Debug/net6.0/HybirdFrameworkCore.deps.json b/HybirdFrameworkCore/bin/Debug/net6.0/HybirdFrameworkCore.deps.json index 0965e5d..7a1223c 100644 --- a/HybirdFrameworkCore/bin/Debug/net6.0/HybirdFrameworkCore.deps.json +++ b/HybirdFrameworkCore/bin/Debug/net6.0/HybirdFrameworkCore.deps.json @@ -8,6 +8,7 @@ ".NETCoreApp,Version=v6.0": { "HybirdFrameworkCore/1.0.0": { "dependencies": { + "AutoMapper": "12.0.1", "Autofac": "7.0.1", "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", "Microsoft.Extensions.Configuration.Json": "7.0.0", @@ -30,6 +31,17 @@ } } }, + "AutoMapper/12.0.1": { + "dependencies": { + "Microsoft.CSharp": "4.7.0" + }, + "runtime": { + "lib/netstandard2.1/AutoMapper.dll": { + "assemblyVersion": "12.0.0.0", + "fileVersion": "12.0.1.0" + } + } + }, "log4net/2.0.15": { "dependencies": { "System.Configuration.ConfigurationManager": "4.5.0" @@ -41,6 +53,7 @@ } } }, + "Microsoft.CSharp/4.7.0": {}, "Microsoft.Extensions.Configuration/7.0.0": { "dependencies": { "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", @@ -283,6 +296,13 @@ "path": "autofac/7.0.1", "hashPath": "autofac.7.0.1.nupkg.sha512" }, + "AutoMapper/12.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-hvV62vl6Hp/WfQ24yzo3Co9+OPl8wH8hApwVtgWpiAynVJkUcs7xvehnSftawL8Pe8FrPffBRM3hwzLQqWDNjA==", + "path": "automapper/12.0.1", + "hashPath": "automapper.12.0.1.nupkg.sha512" + }, "log4net/2.0.15": { "type": "package", "serviceable": true, @@ -290,6 +310,13 @@ "path": "log4net/2.0.15", "hashPath": "log4net.2.0.15.nupkg.sha512" }, + "Microsoft.CSharp/4.7.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==", + "path": "microsoft.csharp/4.7.0", + "hashPath": "microsoft.csharp.4.7.0.nupkg.sha512" + }, "Microsoft.Extensions.Configuration/7.0.0": { "type": "package", "serviceable": true, diff --git a/HybirdFrameworkDriver/Session/IoSession.cs b/HybirdFrameworkDriver/Session/IoSession.cs index 88a8d88..6496749 100644 --- a/HybirdFrameworkDriver/Session/IoSession.cs +++ b/HybirdFrameworkDriver/Session/IoSession.cs @@ -1,5 +1,4 @@ using System.Collections.Concurrent; -using DotNetty.Buffers; using DotNetty.Transport.Channels; using log4net; @@ -25,7 +24,7 @@ public class IoSession public ConcurrentDictionary BusinessMap { get; } = new(); - public void Send(IByteBuffer buffer) + public void Send(Object buffer) { Channel.WriteAndFlushAsync(buffer); } diff --git a/HybirdFrameworkDriver/Session/SessionMgr.cs b/HybirdFrameworkDriver/Session/SessionMgr.cs index 4ef69dd..a09b507 100644 --- a/HybirdFrameworkDriver/Session/SessionMgr.cs +++ b/HybirdFrameworkDriver/Session/SessionMgr.cs @@ -1,5 +1,4 @@ using System.Collections.Concurrent; -using DotNetty.Buffers; using DotNetty.Transport.Channels; using log4net; @@ -83,9 +82,9 @@ public class SessionMgr } - public static void Broadcast(IByteBuffer buffer, ConcurrentDictionary dictionary) + public static void Broadcast(Object buffer) { - foreach (var session in dictionary.Values) session.Send(buffer); + foreach (var session in Dictionary.Values) session.Send(buffer); } public static object GetAttr(IoSession session, string key) diff --git a/HybirdFrameworkDriver/TcpServer/ServerListenerHandler.cs b/HybirdFrameworkDriver/TcpServer/ServerListenerHandler.cs index d5e7597..0b06ba1 100644 --- a/HybirdFrameworkDriver/TcpServer/ServerListenerHandler.cs +++ b/HybirdFrameworkDriver/TcpServer/ServerListenerHandler.cs @@ -13,6 +13,8 @@ public class ServerListenerHandler : ChannelHandlerAdapter where TH { private static readonly ILog Log = LogManager.GetLogger(typeof(ServerListenerHandler)); + public Action? ChannelInActiveAction { get; set; } + public override void ChannelRegistered(IChannelHandlerContext context) { base.ChannelRegistered(context); @@ -35,6 +37,11 @@ public class ServerListenerHandler : ChannelHandlerAdapter where TH public override void ChannelInactive(IChannelHandlerContext context) { base.ChannelInactive(context); + if (ChannelInActiveAction != null) + { + ChannelInActiveAction(); + } + SessionMgr.UnregisterSession(context.Channel); Log.Info("inactive " + context.Channel); } diff --git a/HybirdFrameworkDriver/TcpServer/TcpServer.cs b/HybirdFrameworkDriver/TcpServer/TcpServer.cs index 5afc53b..bb5096d 100644 --- a/HybirdFrameworkDriver/TcpServer/TcpServer.cs +++ b/HybirdFrameworkDriver/TcpServer/TcpServer.cs @@ -2,6 +2,7 @@ using Autofac; using Autofac.Core; using DotNetty.Codecs; +using DotNetty.Common.Internal.Logging; using DotNetty.Handlers.Logging; using DotNetty.Handlers.Timeout; using DotNetty.Transport.Bootstrapping; @@ -10,6 +11,8 @@ using DotNetty.Transport.Channels.Sockets; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; using log4net; +using Microsoft.Extensions.Logging; +using LogLevel = DotNetty.Handlers.Logging.LogLevel; namespace HybirdFrameworkDriver.TcpServer; @@ -27,9 +30,18 @@ public class TcpServer : IDisposable where TH : IChannelHandler private static ServerBootstrap? bootstrap; private int _port = 9000; + + public LogLevel? LogLevel { get; set; } + + public Action? ChannelInActiveAction { get; set; } public TcpServer() { + + if (LogLevel != null) + { + InternalLoggerFactory.DefaultFactory.AddProvider(new Log4NetProvider()); + } bossGroup = new MultithreadEventLoopGroup(); workerGroup = new MultithreadEventLoopGroup(); bootstrap = new ServerBootstrap(); @@ -40,9 +52,12 @@ public class TcpServer : IDisposable where TH : IChannelHandler .Handler(new LoggingHandler()) .ChildHandler(new ActionChannelInitializer(channel => { - var serverListenerHandler = new ServerListenerHandler(); + var serverListenerHandler = new ServerListenerHandler + { + ChannelInActiveAction = ChannelInActiveAction + }; var pipeline = channel.Pipeline; - pipeline.AddLast(new LoggingHandler("")); + pipeline.AddLast(new LoggingHandler()); pipeline.AddLast(serverListenerHandler); pipeline.AddLast(new IdleStateHandler(0, 0, 180)); //检测空闲连接 //业务handler ,这里是实际处理业务的Handler diff --git a/Service/Car/Handler/ElecMsgHandler.cs b/Service/Car/Handler/ElecMsgHandler.cs new file mode 100644 index 0000000..fa85d6e --- /dev/null +++ b/Service/Car/Handler/ElecMsgHandler.cs @@ -0,0 +1,33 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Car.Msg.Car.Req; +using Service.Car.Msg.Host.Resp; +using Service.Car.Server; + +namespace Service.Car.Handler; + +/// +/// +/// +[Order(8)] +[Scope("InstancePerDependency")] +public class ElecMsgHandler : SimpleChannelInboundHandler, IBaseHandler +{ + /// + /// + /// + /// + /// + /// + protected override void ChannelRead0(IChannelHandlerContext ctx, ElecMsg msg) + { + CarServerMgr.CarServer.Connected = true; + CarServerMgr.CarServer.ElecMsg = msg; + ElecMsgResp resp = new ElecMsgResp( 0) + { + CarNo = msg.CarNo + }; + resp.InitCurrentTime(); + ctx.Channel.WriteAndFlushAsync(resp); + } +} \ No newline at end of file diff --git a/Service/Car/Handler/HeartBeatMsgHandler.cs b/Service/Car/Handler/HeartBeatMsgHandler.cs new file mode 100644 index 0000000..3ea7c56 --- /dev/null +++ b/Service/Car/Handler/HeartBeatMsgHandler.cs @@ -0,0 +1,34 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Car.Msg.Car.Req; +using Service.Car.Msg.Host.Resp; +using Service.Car.Server; + +namespace Service.Car.Handler; + +/// +/// +/// +[Order(8)] +[Scope("InstancePerDependency")] +public class HeartBeatMsgHandler : SimpleChannelInboundHandler, IBaseHandler +{ + /// + /// + /// + /// + /// + /// + protected override void ChannelRead0(IChannelHandlerContext ctx, HeartBeatMsg msg) + { + CarServerMgr.CarServer.Connected = true; + CarServerMgr.CarServer.CarNo = msg.CarNo; + CarServerMgr.CarServer.HeartBeatMsg = msg; + HeartBeatMsgResp resp = new HeartBeatMsgResp( CarServerMgr.CarServer.StationStatus) + { + CarNo = msg.CarNo + }; + resp.InitCurrentTime(); + ctx.Channel.WriteAndFlushAsync(resp); + } +} \ No newline at end of file diff --git a/Service/Car/Handler/LockMsgRespHandler.cs b/Service/Car/Handler/LockMsgRespHandler.cs new file mode 100644 index 0000000..7767cfe --- /dev/null +++ b/Service/Car/Handler/LockMsgRespHandler.cs @@ -0,0 +1,26 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Car.Msg.Car.Resp; +using Service.Car.Server; + +namespace Service.Car.Handler; + +/// +/// +/// +[Order(8)] +[Scope("InstancePerDependency")] +public class LockMsgRespHandler : SimpleChannelInboundHandler, IBaseHandler +{ + /// + /// + /// + /// + /// + /// + protected override void ChannelRead0(IChannelHandlerContext ctx, LockMsgResp msg) + { + CarServerMgr.CarServer.Connected = true; + CarServerMgr.CarServer.LockMsgResp = msg; + } +} \ No newline at end of file diff --git a/Service/Car/Handler/SetParamMsgRespHandler.cs b/Service/Car/Handler/SetParamMsgRespHandler.cs new file mode 100644 index 0000000..ce38623 --- /dev/null +++ b/Service/Car/Handler/SetParamMsgRespHandler.cs @@ -0,0 +1,26 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Car.Msg.Car.Resp; +using Service.Car.Server; + +namespace Service.Car.Handler; + +/// +/// +/// +[Order(8)] +[Scope("InstancePerDependency")] +public class SetParamMsgRespHandler : SimpleChannelInboundHandler, IBaseHandler +{ + /// + /// + /// + /// + /// + /// + protected override void ChannelRead0(IChannelHandlerContext ctx, SetParamMsgResp msg) + { + CarServerMgr.CarServer.Connected = true; + CarServerMgr.CarServer.SetParamMsgResp = msg; + } +} \ No newline at end of file diff --git a/Service/Car/Handler/SettleConfirmMsgRespHandler.cs b/Service/Car/Handler/SettleConfirmMsgRespHandler.cs new file mode 100644 index 0000000..1691804 --- /dev/null +++ b/Service/Car/Handler/SettleConfirmMsgRespHandler.cs @@ -0,0 +1,26 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Car.Msg.Car.Resp; +using Service.Car.Server; + +namespace Service.Car.Handler; + +/// +/// +/// +[Order(8)] +[Scope("InstancePerDependency")] +public class SettleConfirmMsgRespHandler : SimpleChannelInboundHandler, IBaseHandler +{ + /// + /// + /// + /// + /// + /// + protected override void ChannelRead0(IChannelHandlerContext ctx, SettleConfirmMsgResp msg) + { + CarServerMgr.CarServer.Connected = true; + CarServerMgr.CarServer.SettleConfirmMsgResp = msg; + } +} \ No newline at end of file diff --git a/Service/Car/Handler/UnLockMsgRespHandler.cs b/Service/Car/Handler/UnLockMsgRespHandler.cs new file mode 100644 index 0000000..5035728 --- /dev/null +++ b/Service/Car/Handler/UnLockMsgRespHandler.cs @@ -0,0 +1,27 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Car.Msg.Car.Resp; +using Service.Car.Server; + +namespace Service.Car.Handler; + +/// +/// +/// +[Order(8)] +[Scope("InstancePerDependency")] +public class UnLockMsgRespHandler : SimpleChannelInboundHandler, IBaseHandler +{ + /// + /// + /// + /// + /// + /// + protected override void ChannelRead0(IChannelHandlerContext ctx, UnLockMsgResp msg) + { + CarServerMgr.CarServer.Connected = true; + CarServerMgr.CarServer.UnLockMsgResp = msg; + } + +} \ No newline at end of file diff --git a/Service/Car/Msg/Host/Req/LockMsg.cs b/Service/Car/Msg/Host/Req/LockMsg.cs index 01884cf..3faba14 100644 --- a/Service/Car/Msg/Host/Req/LockMsg.cs +++ b/Service/Car/Msg/Host/Req/LockMsg.cs @@ -8,4 +8,10 @@ public class LockMsg : BaseMsg /// [Property(248, 8)] public byte Command { get; set; } = 0x55; + + public LockMsg() + { + Cmd = 0x05; + Length = 33; + } } \ No newline at end of file diff --git a/Service/Car/Msg/Host/Req/SetParamMsg.cs b/Service/Car/Msg/Host/Req/SetParamMsg.cs index 2a1d61d..74d3bd9 100644 --- a/Service/Car/Msg/Host/Req/SetParamMsg.cs +++ b/Service/Car/Msg/Host/Req/SetParamMsg.cs @@ -81,4 +81,10 @@ public class SetParamMsg: BaseMsg /// [Property(536, 24, scale: 0.01, round: 2)] public double ElectricityToBeSettled { get; set; } + + public SetParamMsg() + { + Cmd = 0x11; + Length = 70; + } } \ No newline at end of file diff --git a/Service/Car/Msg/Host/Req/SettleConfirmMsg.cs b/Service/Car/Msg/Host/Req/SettleConfirmMsg.cs index d21ca79..3bcce9b 100644 --- a/Service/Car/Msg/Host/Req/SettleConfirmMsg.cs +++ b/Service/Car/Msg/Host/Req/SettleConfirmMsg.cs @@ -8,4 +8,10 @@ public class SettleConfirmMsg : BaseMsg /// [Property(248, 8)] public byte Command { get; set; } = 0x55; + + public SettleConfirmMsg() + { + Cmd = 0x09; + Length = 33; + } } \ No newline at end of file diff --git a/Service/Car/Msg/Host/Req/UnLockMsg.cs b/Service/Car/Msg/Host/Req/UnLockMsg.cs index 4591a80..2163fdf 100644 --- a/Service/Car/Msg/Host/Req/UnLockMsg.cs +++ b/Service/Car/Msg/Host/Req/UnLockMsg.cs @@ -2,10 +2,16 @@ namespace Service.Car.Msg.Host.Req; -public class UnLockMsg: BaseMsg +public class UnLockMsg : BaseMsg { /// /// [Property(248, 8)] public byte Command { get; set; } = 0x55; + + public UnLockMsg() + { + Cmd = 0x07; + Length = 33; + } } \ No newline at end of file diff --git a/Service/Car/Msg/Host/Resp/ElecMsgResp.cs b/Service/Car/Msg/Host/Resp/ElecMsgResp.cs index 1746d5b..ba91c4a 100644 --- a/Service/Car/Msg/Host/Resp/ElecMsgResp.cs +++ b/Service/Car/Msg/Host/Resp/ElecMsgResp.cs @@ -15,6 +15,8 @@ public class ElecMsgResp : BaseMsg /// public ElecMsgResp(byte result) { + Cmd = 0x02; + Length = 33; this.Result = result; } } \ No newline at end of file diff --git a/Service/Car/Msg/Host/Resp/HeartBeatMsgResp.cs b/Service/Car/Msg/Host/Resp/HeartBeatMsgResp.cs index 39f8362..956e78d 100644 --- a/Service/Car/Msg/Host/Resp/HeartBeatMsgResp.cs +++ b/Service/Car/Msg/Host/Resp/HeartBeatMsgResp.cs @@ -9,4 +9,11 @@ public class HeartBeatMsgResp : BaseMsg /// [Property(248, 8)] public byte HostStatus { get; set; } + + public HeartBeatMsgResp(byte hostStatus) + { + Cmd = 0x04; + Length = 33; + HostStatus = hostStatus; + } } \ No newline at end of file diff --git a/Service/Car/Server/CarServer.cs b/Service/Car/Server/CarServer.cs index 3528bbc..79c3c8a 100644 --- a/Service/Car/Server/CarServer.cs +++ b/Service/Car/Server/CarServer.cs @@ -1,10 +1,50 @@ -using HybirdFrameworkDriver.TcpServer; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkDriver.TcpServer; using Service.Car.Codec; using Service.Car.Handler; +using Service.Car.Msg.Car.Req; +using Service.Car.Msg.Car.Resp; namespace Service.Car.Server; +[Scope("SingleInstance")] public class CarServer : TcpServer { + /// + /// 客户端连接状态 + /// + public bool Connected { get; set; } + public string? CarNo { get; set; } + + public HeartBeatMsg? HeartBeatMsg { get; set; } + + /// + /// 1 待机 2 换电 + /// + public byte StationStatus { get; set; } + + /// + /// 度电数据车载设备连接上换电站的 Wifi 网络时,主动上送度电数据报文(命令代码: 0x01),发送周期 60s,服务器回复相应的报文(命令代码:0x02) + /// + public ElecMsg? ElecMsg { get; set; } + + public LockMsgResp? LockMsgResp { get; set; } + public UnLockMsgResp? UnLockMsgResp { get; set; } + public SetParamMsgResp? SetParamMsgResp { get; set; } + public SettleConfirmMsgResp? SettleConfirmMsgResp { get; set; } + + public CarServer() : base() + { + this.ChannelInActiveAction = () => + { + Connected = false; + HeartBeatMsg = null; + ElecMsg = null; + LockMsgResp = null; + UnLockMsgResp = null; + SetParamMsgResp = null; + SettleConfirmMsgResp = null; + }; + } } \ No newline at end of file diff --git a/Service/Car/Server/CarServerMgr.cs b/Service/Car/Server/CarServerMgr.cs new file mode 100644 index 0000000..ce76254 --- /dev/null +++ b/Service/Car/Server/CarServerMgr.cs @@ -0,0 +1,15 @@ +using Autofac; +using HybirdFrameworkCore.Autofac; + +namespace Service.Car.Server; + +public class CarServerMgr +{ + public static CarServer? CarServer { get; set; } + + public static void InitServer() + { + CarServer = AppInfo.Container.Resolve(); + CarServer.Start(5588); + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/CarController.cs b/WebStarter/Controllers/CarController.cs new file mode 100644 index 0000000..5ddd6dd --- /dev/null +++ b/WebStarter/Controllers/CarController.cs @@ -0,0 +1,128 @@ +using HybirdFrameworkDriver.Session; +using log4net; +using Microsoft.AspNetCore.Mvc; +using Service.Car.Msg.Host.Req; +using Service.Car.Server; +using WebStarter.Dto.Req; +using WebStarter.Dto.Resp; + +namespace WebStarter.Controllers; + +/// +/// 车辆管理 +/// +[ApiController] +[Route("[controller]")] +public class CarController : ControllerBase +{ + private static readonly ILog Log = LogManager.GetLogger(typeof(CarController)); + + /// + /// 获取车辆数据 + /// + /// + [HttpGet("/getCarInfo")] + public CarInfoResp GetCarInfo() + { + CarInfoResp carInfoResp = new CarInfoResp() + { + Connected = CarServerMgr.CarServer?.Connected ?? false, + CarNo = CarServerMgr.CarServer?.HeartBeatMsg?.CarNo, + ElecMsg = CarServerMgr.CarServer?.ElecMsg, + HeartBeatMsg = CarServerMgr.CarServer?.HeartBeatMsg + }; + return carInfoResp; + } + + /// + /// 锁车 + /// + /// 发送结果 + [HttpGet("/lock")] + public bool Lock() + { + Log.Info("Lock "); + if (CarServerMgr.CarServer == null || (CarServerMgr.CarServer?.Connected ?? false)) + { + return false; + } + + CarServerMgr.CarServer.LockMsgResp = null; + SessionMgr.Broadcast(new LockMsg()); + + return true; + } + + /// + /// 解锁 + /// + /// 发送结果 + [HttpGet("/unLock")] + public bool UnLock() + { + Log.Info("UnLock "); + if (CarServerMgr.CarServer == null || (CarServerMgr.CarServer?.Connected ?? false)) + { + return false; + } + + CarServerMgr.CarServer.UnLockMsgResp = null; + SessionMgr.Broadcast(new UnLockMsg()); + + return true; + } + + /// + /// 结算 + /// + /// 发送结果 + [HttpGet("/SettleConfirm")] + public bool SettleConfirm() + { + Log.Info("SettleConfirm "); + if (CarServerMgr.CarServer == null || (CarServerMgr.CarServer?.Connected ?? false)) + { + return false; + } + + CarServerMgr.CarServer.SettleConfirmMsgResp = null; + SessionMgr.Broadcast(new SettleConfirmMsg()); + + return true; + } + + /// + /// 设置参数 + /// + /// + [HttpPost("/setParam")] + public bool SetParam(SetParam setParam) + { + Log.Info("SetParam"); + if (CarServerMgr.CarServer == null || (CarServerMgr.CarServer?.Connected ?? false)) + { + return false; + } + + CarServerMgr.CarServer.SetParamMsgResp = null; + SetParamMsg setParamMsg = new SetParamMsg() + { + AccDischargeCount = setParam.AccDischargeCount, + AccFallbackCount = setParam.AccFallbackCount, + AccChargeCount = setParam.AccChargeCount, + AccKgce = setParam.AccKgce, + ThisTimeRealDischarge = setParam.ThisTimeRealDischarge, + LastTimeBalanceDischarge = setParam.LastTimeBalanceDischarge, + ThisTimeRealFeedbackPower = setParam.ThisTimeRealFeedbackPower, + LastTimeBalanceFeedbackPower = setParam.LastTimeBalanceFeedbackPower, + ThisTimeRealChargeCount = setParam.ThisTimeRealChargeCount, + LastTimeBalanceChargeCount = setParam.LastTimeBalanceChargeCount, + ThisTimeRealKgce = setParam.ThisTimeRealKgce, + LastTimeBalanceKgce = setParam.LastTimeBalanceKgce, + ElectricityToBeSettled = setParam.ElectricityToBeSettled, + }; + SessionMgr.Broadcast(setParamMsg); + + return true; + } +} \ No newline at end of file diff --git a/WebStarter/Dto/Req/SetParam.cs b/WebStarter/Dto/Req/SetParam.cs new file mode 100644 index 0000000..d24598b --- /dev/null +++ b/WebStarter/Dto/Req/SetParam.cs @@ -0,0 +1,69 @@ +namespace WebStarter.Dto.Req; + +public class SetParam +{ + /// + /// 车辆累计放电量 + /// + public double AccDischargeCount { get; set; } + + /// + /// 车辆累计回馈电量 + /// + public double AccFallbackCount { get; set; } + + /// + /// 车辆累计插枪充电量 + /// + public double AccChargeCount { get; set; } + + /// + /// 5 车辆累计综合能耗 + /// + public double AccKgce { get; set; } + + /// + /// 6 本次实时放电量 + /// + public double ThisTimeRealDischarge { get; set; } + + /// + /// 7 上一次结算放电量 + /// + public double LastTimeBalanceDischarge { get; set; } + + /// + /// 8 本次实时回馈电量 + /// + public double ThisTimeRealFeedbackPower { get; set; } + + /// + /// 9 上一次结算回馈电量 + /// + public double LastTimeBalanceFeedbackPower { get; set; } + + /// + /// 10 本次实时插枪充电量 + /// + public double ThisTimeRealChargeCount { get; set; } + + /// + /// 11 上一次结算插枪充电量 + /// + public double LastTimeBalanceChargeCount { get; set; } + + /// + /// 12 本次实时综合能耗 + /// + public double ThisTimeRealKgce { get; set; } + + /// + /// 13 上一次结算综合能耗 + /// + public double LastTimeBalanceKgce { get; set; } + + /// + /// 14 待结算电费电量 + /// + public double ElectricityToBeSettled { get; set; } +} \ No newline at end of file diff --git a/WebStarter/Dto/Resp/CarInfoResp.cs b/WebStarter/Dto/Resp/CarInfoResp.cs new file mode 100644 index 0000000..40e04c5 --- /dev/null +++ b/WebStarter/Dto/Resp/CarInfoResp.cs @@ -0,0 +1,29 @@ +using Service.Car.Msg.Car.Req; + +namespace WebStarter.Dto.Resp; + +/// +/// 车辆数据 +/// +public class CarInfoResp +{ + /// + /// 连接状态 + /// + public bool Connected { get; set; } + + /// + /// 车牌号 + /// + public string? CarNo { get; set; } + + /// + /// 度电数据 + /// + public ElecMsg? ElecMsg { get; set; } + + /// + /// 状态数据 + /// + public HeartBeatMsg? HeartBeatMsg { get; set; } +} \ No newline at end of file diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index 7f85404..2cecbe5 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -4,6 +4,7 @@ using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Configuration; using HybirdFrameworkCore.Entity; using HybirdFrameworkCore.Redis; +using Service.Car.Server; using SqlSugar; using SqlSugar.IOC; @@ -92,4 +93,5 @@ app.MapControllers(); AppInfo.Container = app.Services.GetAutofacRoot(); +CarServerMgr.InitServer(); app.Run(); \ No newline at end of file diff --git a/WebStarter/bin/Debug/net6.0/SqlSugar.dll b/WebStarter/bin/Debug/net6.0/SqlSugar.dll index d892921..5946740 100644 Binary files a/WebStarter/bin/Debug/net6.0/SqlSugar.dll and b/WebStarter/bin/Debug/net6.0/SqlSugar.dll differ diff --git a/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.DependencyInjection.dll b/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.DependencyInjection.dll index 1034ee6..97525f7 100644 Binary files a/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.DependencyInjection.dll and b/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.DependencyInjection.dll differ diff --git a/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.Logging.dll b/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.Logging.dll index 6df35e1..9e2d7f9 100644 Binary files a/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.Logging.dll and b/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.Logging.dll differ diff --git a/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.Options.dll b/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.Options.dll index 8a2a8c8..604b602 100644 Binary files a/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.Options.dll and b/WinFormStarter/bin/Debug/net6.0-windows/Microsoft.Extensions.Options.dll differ diff --git a/WinFormStarter/bin/Debug/net6.0-windows/SqlSugar.dll b/WinFormStarter/bin/Debug/net6.0-windows/SqlSugar.dll index d892921..5946740 100644 Binary files a/WinFormStarter/bin/Debug/net6.0-windows/SqlSugar.dll and b/WinFormStarter/bin/Debug/net6.0-windows/SqlSugar.dll differ