diff --git a/Common/lib/HybirdFrameworkCore.dll b/Common/lib/HybirdFrameworkCore.dll index b3f2f85..36f9605 100644 Binary files a/Common/lib/HybirdFrameworkCore.dll and b/Common/lib/HybirdFrameworkCore.dll differ diff --git a/Common/lib/HybirdFrameworkDriver.dll b/Common/lib/HybirdFrameworkDriver.dll index 66c5b7a..9b51aae 100644 Binary files a/Common/lib/HybirdFrameworkDriver.dll and b/Common/lib/HybirdFrameworkDriver.dll differ diff --git a/Service/Charger/Client/ChargerClient.cs b/Service/Charger/Client/ChargerClient.cs deleted file mode 100644 index eb4f340..0000000 --- a/Service/Charger/Client/ChargerClient.cs +++ /dev/null @@ -1,29 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; -using HybirdFrameworkDriver.Session; -using HybirdFrameworkDriver.TcpClient; -using Service.Charger.Codec; -using Service.Charger.Handler; - -namespace Service.Charger.Client; - -/// -/// 示例程序 -/// -[Scope("InstancePerDependency")] -public class ChargerClient : TcpClient -{ - public void SessionAttr(int sn, int fEqmTypeNo, string eqmCode, string destAddr) - { - var ioSession = SessionMgr.GetSession(Channel.Id.ToString()); - if (ioSession == null) - { - ioSession = new IoSession(Channel); - SessionMgr.RegisterSession(Channel, ioSession); - } - - SessionMgr.SetAttr(ioSession, "charger_sn", sn); - SessionMgr.SetAttr(ioSession, "eqm_type_no", fEqmTypeNo); - SessionMgr.SetAttr(ioSession, "eqm_code", eqmCode); - SessionMgr.SetAttr(ioSession, "dest_addr", destAddr); - } -} \ No newline at end of file diff --git a/Service/Charger/Client/ChargerServer.cs b/Service/Charger/Client/ChargerServer.cs deleted file mode 100644 index 3753b19..0000000 --- a/Service/Charger/Client/ChargerServer.cs +++ /dev/null @@ -1,14 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; -using HybirdFrameworkDriver.TcpServer; -using Service.Charger.Codec; -using Service.Charger.Handler; - -namespace Service.Charger.Client; - -/// -/// 示例程序 -/// -[Scope("InstancePerDependency")] -public class ChargerServer : TcpServer -{ -} \ No newline at end of file diff --git a/Service/Charger/Client/ClientMgr.cs b/Service/Charger/Client/ClientMgr.cs deleted file mode 100644 index 9cbc586..0000000 --- a/Service/Charger/Client/ClientMgr.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Text; -using Autofac; -using HybirdFrameworkCore.Autofac; -using HybirdFrameworkCore.Autofac.Attribute; -using Service.Charger.Msg.Host.Req; - -namespace Service.Charger.Client; - -/// -/// 示例程序 -/// -[Scope("SingleInstance")] -public class ClientMgr -{ - public void InitClient() - { - var auth = new Auth(1, Encoding.UTF8.GetBytes("ddddddddd"), 1); - auth.DestAddr = new byte[] { 0x01, 0x02, 0x03 }; - - var chargerClient2 = AppInfo.Container.Resolve(); - chargerClient2.InitBootstrap("127.0.0.1", 9998); - chargerClient2.BaseConnect(); - chargerClient2.SessionAttr(12, 12, "12", "2"); - chargerClient2.Channel.WriteAndFlushAsync(auth); - - var chargerServer = AppInfo.Container.Resolve(); - chargerServer.Start(9000); - } -} \ No newline at end of file diff --git a/Service/Charger/Codec/Decoder.cs b/Service/Charger/Codec/Decoder.cs deleted file mode 100644 index 9f583d5..0000000 --- a/Service/Charger/Codec/Decoder.cs +++ /dev/null @@ -1,14 +0,0 @@ -using DotNetty.Buffers; -using DotNetty.Codecs; -using DotNetty.Transport.Channels; -using Service.Charger.Msg.Charger.Req; - -namespace Service.Charger.Codec; - -public class Decoder : ByteToMessageDecoder -{ - protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List output) - { - output.Add(new Login()); - } -} \ No newline at end of file diff --git a/Service/Charger/Codec/Encoder.cs b/Service/Charger/Codec/Encoder.cs deleted file mode 100644 index 9b420ac..0000000 --- a/Service/Charger/Codec/Encoder.cs +++ /dev/null @@ -1,14 +0,0 @@ -using DotNetty.Buffers; -using DotNetty.Codecs; -using DotNetty.Transport.Channels; -using HybirdFrameworkDriver.Common; - -namespace Service.Charger.Codec; - -public class Encoder : MessageToByteEncoder -{ - protected override void Encode(IChannelHandlerContext context, IToBytes obj, IByteBuffer output) - { - output.WriteBytes(obj.ToBytes()); - } -} \ No newline at end of file diff --git a/Service/Charger/Common/ChargerConst.cs b/Service/Charger/Common/ChargerConst.cs deleted file mode 100644 index 9955f6d..0000000 --- a/Service/Charger/Common/ChargerConst.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Service.Charger.Common; - -public class ChargerConst -{ - public static readonly byte[] ApciStartChar = { 0x68 /* ,0xEE*/ }; -} \ No newline at end of file diff --git a/Service/Charger/Handler/AuthResHandler.cs b/Service/Charger/Handler/AuthResHandler.cs deleted file mode 100644 index 32b029b..0000000 --- a/Service/Charger/Handler/AuthResHandler.cs +++ /dev/null @@ -1,28 +0,0 @@ -using DotNetty.Transport.Channels; -using HybirdFrameworkCore.Autofac.Attribute; -using HybirdFrameworkDriver.Session; -using log4net; -using Service.Charger.Msg.Charger.Resp; - -namespace Service.Charger.Handler; - -/// -/// 接收到鉴权帧 -/// -/// 1,保存日志到log -/// 2,从SessionMgr中取目的地址,解析后写入ChargerManager -/// 3,保存鉴权状态和充电状态 -/// -/// -[Order(8)] -[Scope("InstancePerDependency")] -public class AuthResHandler : SimpleChannelInboundHandler, IBaseHandler -{ - private static readonly ILog Log = LogManager.GetLogger(typeof(AuthResHandler)); - - protected override void ChannelRead0(IChannelHandlerContext ctx, AuthRes msg) - { - var sn = (int)SessionMgr.GetAttrByKey(ctx.Channel.Id.ToString(), "charger_sn"); - Log.Info($"receive {msg} from {sn}"); - } -} \ No newline at end of file diff --git a/Service/Charger/Handler/IBaseHandler.cs b/Service/Charger/Handler/IBaseHandler.cs deleted file mode 100644 index aa755cc..0000000 --- a/Service/Charger/Handler/IBaseHandler.cs +++ /dev/null @@ -1,7 +0,0 @@ -using DotNetty.Transport.Channels; - -namespace Service.Charger.Handler; - -public interface IBaseHandler : IChannelHandler -{ -} \ No newline at end of file diff --git a/Service/Charger/Handler/LoginHandler.cs b/Service/Charger/Handler/LoginHandler.cs deleted file mode 100644 index 135ecf7..0000000 --- a/Service/Charger/Handler/LoginHandler.cs +++ /dev/null @@ -1,41 +0,0 @@ -using DotNetty.Transport.Channels; -using HybirdFrameworkCore.Autofac.Attribute; -using HybirdFrameworkDriver.Session; -using log4net; -using Service.Charger.Msg.Charger.Req; -using Service.Charger.Msg.Host.Resp; - -namespace Service.Charger.Handler; - -/// -/// 3.3.3 充放电机登陆签到 -/// 监控平台应答充电设备登录签到报文 -/// -/// 1,保存日志到log -/// 2,回复签到应答 -/// 3,保存签到应答日志 -/// -/// -[Order(8)] -[Scope("InstancePerDependency")] -public class LoginHandler : SimpleChannelInboundHandler, IBaseHandler -{ - private static readonly ILog Log = LogManager.GetLogger(typeof(LoginHandler)); - - protected override void ChannelRead0(IChannelHandlerContext ctx, Login msg) - { - msg.ConnProtocolVersion = msg.ConnProtocolVersion0 + "." + msg.ConnProtocolVersion1 + "." + - msg.ConnProtocolVersion2; - msg.ControllerHardwareVersion = msg.ControllerHardwareVersion0 + "." + msg.ControllerHardwareVersion1 + - "." + msg.ControllerHardwareVersion2; - msg.ControllerSoftwareVersion = msg.ControllerSoftwareVersion0 + "." + msg.ControllerSoftwareVersion1 + - "." + msg.ControllerSoftwareVersion2; - var sn = (int)SessionMgr.GetAttrByKey(ctx.Channel.Id.ToString(), "charger_sn"); - Log.Info($"receive {msg} from {sn}"); - - - var logSignMessage = new LogSignMessage(0); - logSignMessage.DestAddr = new byte[] { 0x01, 0x02, 0x03 }; - ctx.Channel.WriteAndFlushAsync(logSignMessage); - } -} \ No newline at end of file diff --git a/Service/Charger/Msg/APCI.cs b/Service/Charger/Msg/APCI.cs deleted file mode 100644 index ed309f9..0000000 --- a/Service/Charger/Msg/APCI.cs +++ /dev/null @@ -1,45 +0,0 @@ -using HybirdFrameworkDriver.Common; -using Service.Charger.Common; - -namespace Service.Charger.Msg; - -public abstract class APCI : IToBytes -{ - /// - /// 报文长度 - /// - public ushort PackLen { get; set; } - - /// - /// 控制域 - /// - public uint CtlArea { get; set; } - - /// - /// 目标地址 - /// - public byte[] DestAddr { get; set; } - - /// - /// 源地址 - /// - public uint SrcAddr { get; set; } - - - public byte[] ToBytes() - { - var bodyBytes = GetBytes(); - var list = new List(); - list.AddRange(ChargerConst.ApciStartChar); - list.AddRange(BitConverter.GetBytes(bodyBytes.Length + 12)); - list.AddRange(BitConverter.GetBytes(CtlArea)); - list.AddRange(DestAddr); - list.AddRange(BitConverter.GetBytes(SrcAddr)); - - list.AddRange(bodyBytes); - - return list.ToArray(); - } - - public abstract byte[] GetBytes(); -} \ No newline at end of file diff --git a/Service/Charger/Msg/ASDU.cs b/Service/Charger/Msg/ASDU.cs deleted file mode 100644 index 08e3ab3..0000000 --- a/Service/Charger/Msg/ASDU.cs +++ /dev/null @@ -1,74 +0,0 @@ -using DotNetty.Buffers; -using HybirdFrameworkCore.Utils; -using Service.Charger.Common; - -namespace Service.Charger.Msg; - -public class ASDU : APCI -{ - /// - /// 帧类型号 - /// - public byte FrameTypeNo { get; set; } - - /// - /// 信息体个数 - /// - public byte MsgBodyCount { get; set; } - - /// - /// 传送原因-3.1.3.2 - /// - public ushort TransReason { get; set; } - - /// - /// 公共地址 - /// - public ushort PublicAddr { get; set; } - - /// - /// 信息体地址-3个字节 - /// - public byte[]? MsgBodyAddr { get; set; } - - - public override byte[] GetBytes() - { - var list = new List(); - list.Add(FrameTypeNo); - list.Add(MsgBodyCount); - list.AddRange(BitConverter.GetBytes(TransReason)); - list.AddRange(BitConverter.GetBytes(PublicAddr)); - list.AddRange(MsgBodyAddr); - - list.AddRange(ModelConvert.Encode(this)); - return list.ToArray(); - } - - - public static void ParseHeader(IByteBuffer byteBuffer, ASDU asdu) - { - var start = ChargerConst.ApciStartChar.Length - 1; - - asdu.PackLen = byteBuffer.GetUnsignedShortLE(start + 1); - asdu.CtlArea = byteBuffer.GetUnsignedInt(start + 3); - asdu.DestAddr = new[] - { - byteBuffer.GetByte(start + 7), - byteBuffer.GetByte(start + 8), - byteBuffer.GetByte(start + 9), - byteBuffer.GetByte(start + 10) - }; - asdu.SrcAddr = byteBuffer.GetUnsignedInt(start + 11); - asdu.FrameTypeNo = byteBuffer.GetByte(start + 15); - asdu.MsgBodyCount = byteBuffer.GetByte(start + 16); - asdu.TransReason = byteBuffer.GetUnsignedShortLE(start + 17); - asdu.PublicAddr = byteBuffer.GetUnsignedShortLE(start + 19); - asdu.MsgBodyAddr = new[] - { - byteBuffer.GetByte(start + 21), - byteBuffer.GetByte(start + 22), - byteBuffer.GetByte(start + 23) - }; - } -} \ No newline at end of file diff --git a/Service/Charger/Msg/Charger/Req/Login.cs b/Service/Charger/Msg/Charger/Req/Login.cs deleted file mode 100644 index d56075b..0000000 --- a/Service/Charger/Msg/Charger/Req/Login.cs +++ /dev/null @@ -1,93 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; - -namespace Service.Charger.Msg.Charger.Req; - -/// -/// 3.3.3 充放电机登陆签到 -/// -public class Login : ASDU -{ - /// - /// 记录类型 - /// - [Property(0, 8)] - public byte RecordType { get; set; } - - /// - /// 监控网关编号 - /// - [Property(8, 16)] - public ushort GatewayNo { get; set; } - - /// - /// 设备属性 - /// - [Property(24, 8)] - public byte EquipType { get; set; } - - /// - /// 通讯协议版本 - /// - [Property(32, 8)] - public byte ConnProtocolVersion0 { get; set; } - - [Property(40, 8)] public byte ConnProtocolVersion1 { get; set; } - [Property(48, 8)] public byte ConnProtocolVersion2 { get; set; } - public string ConnProtocolVersion { get; set; } - - /// - /// 充电控制器硬件版本号 - /// - [Property(56, 8)] - public byte ControllerHardwareVersion0 { get; set; } - - [Property(64, 8)] public byte ControllerHardwareVersion1 { get; set; } - [Property(72, 8)] public byte ControllerHardwareVersion2 { get; set; } - public string ControllerHardwareVersion { get; set; } - - /// - /// 充电控制器软件版本 - /// - [Property(80, 8)] - public byte ControllerSoftwareVersion0 { get; set; } - - [Property(88, 8)] public byte ControllerSoftwareVersion1 { get; set; } - [Property(96, 8)] public byte ControllerSoftwareVersion2 { get; set; } - public string ControllerSoftwareVersion { get; set; } - - /// - /// 充电枪口数目 - /// - [Property(104, 8)] - public byte GunNum { get; set; } - - /// - /// 充电模块数目 - /// - [Property(112, 8)] - public byte GunModuleNum { get; set; } - - /// - /// 额定功率 - /// - [Property(128, 16)] - public ushort RatedPower { get; set; } - - /// - /// 当前功率 - /// - [Property(136, 8)] - public byte CurrentPower { get; set; } - - /// - /// 当前速率 - /// - [Property(144, 8)] - public byte CurrentSpeed { get; set; } - - /// - /// 分流器量程 - /// - [Property(152, 16)] - public ushort DiverterRange { get; set; } -} \ No newline at end of file diff --git a/Service/Charger/Msg/Charger/Resp/AuthRes.cs b/Service/Charger/Msg/Charger/Resp/AuthRes.cs deleted file mode 100644 index 357e162..0000000 --- a/Service/Charger/Msg/Charger/Resp/AuthRes.cs +++ /dev/null @@ -1,34 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; - -namespace Service.Charger.Msg.Charger.Resp; - -/// -/// 3.3.2 充放电机应答鉴权认证 -/// -public class AuthRes : ASDU - -{ - /// - /// 记录类型 - /// - [Property(0, 8)] - public byte RecordType { get; set; } - - /// - /// 连接序号 - /// - [Property(8, 16)] - public ushort ConnSeq { get; set; } - - /// - /// 鉴权结果 - /// - [Property(24, 8)] - public byte AuthResult { get; set; } - - /// - /// 失败原因 - /// - [Property(32, 8)] - public byte FailReason { get; set; } -} \ No newline at end of file diff --git a/Service/Charger/Msg/Host/Req/Auth.cs b/Service/Charger/Msg/Host/Req/Auth.cs deleted file mode 100644 index 492dc4d..0000000 --- a/Service/Charger/Msg/Host/Req/Auth.cs +++ /dev/null @@ -1,57 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; - -namespace Service.Charger.Msg.Host.Req; - -/// -/// 3.3.1 监控平台鉴权认证 -/// -public class Auth : ASDU -{ - public Auth(ushort connseq, byte[] authcodes, byte authcodekey) - { - PackLen = 0; - CtlArea = 0; - SrcAddr = 0; - - FrameTypeNo = 45; - MsgBodyCount = 1; - TransReason = 3; - PublicAddr = 0; - MsgBodyAddr = new byte[] { 0, 0, 0 }; - - RecordType = 24; - ClientType = 1; - ConnSeq = connseq; - AuthCodes = authcodes; - AuthCodeKey = authcodekey; - } - - /// - /// 记录类型 - /// - public byte RecordType { get; set; } - - /// - /// 客户端类型.1站控 2本地控制器 3测试客户端 4TCU模式 0未知设备 - /// - [Property(0, 8)] - public byte ClientType { get; set; } - - /// - /// 连接序号 - /// - [Property(8, 16)] - public ushort ConnSeq { get; set; } - - /// - /// 鉴权码字节数组 - /// - [Property(24, 64)] - public byte[] AuthCodes { get; set; } - - /// - /// 鉴码KEY - /// - [Property(88, 8)] - public byte AuthCodeKey { get; set; } -} \ No newline at end of file diff --git a/Service/Charger/Msg/Host/Resp/LogSignMessage.cs b/Service/Charger/Msg/Host/Resp/LogSignMessage.cs deleted file mode 100644 index 60882c5..0000000 --- a/Service/Charger/Msg/Host/Resp/LogSignMessage.cs +++ /dev/null @@ -1,88 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; - -namespace Service.Charger.Msg.Host.Resp; - -/// -/// 3.3.4 监控平台应答充电设备登录签到报文 -/// -public class LogSignMessage : ASDU -{ - public LogSignMessage(byte result) - { - Result = result; - - CtlArea = 0; - SrcAddr = 0; - FrameTypeNo = 45; - MsgBodyCount = 1; - TransReason = 4; - PublicAddr = 0; - MsgBodyAddr = new byte[] { 0, 0, 0 }; - RecordType = 12; - - var dtime = DateTime.Now; - TimeYear = Convert.ToUInt16(dtime.Year.ToString()); - TimeMonth = Convert.ToByte(dtime.Month); - TimeDay = Convert.ToByte(dtime.Day); - TimeHour = Convert.ToByte(dtime.Hour); - TimeMinute = Convert.ToByte(dtime.Minute); - TimeSecond = Convert.ToByte(dtime.Second); - } - - [Property(0, 8)] public byte RecordType { get; set; } - - /// - /// 结果 - /// 0:成功/确认 - /// 1:失败-平台处理该消息失败 - /// 2:消息有误-消息校验错误/消息长度有误 - /// 4:该设备编码在系统没有找到 - /// 5:该设备编码在系统中异常,可能存在冲突 - /// 6:充电控制器数目不对 - /// 255:其它错误 - /// - [Property(8, 8)] - public byte Result { get; set; } - - /// - /// 年 - /// - [Property(16, 16)] - public ushort TimeYear { get; set; } - - /// - /// 月 - /// - [Property(32, 8)] - public byte TimeMonth { get; set; } - - /// - /// 日 - /// - [Property(40, 8)] - public byte TimeDay { get; set; } - - /// - /// 时 - /// - [Property(48, 8)] - public byte TimeHour { get; set; } - - /// - /// 分 - /// - [Property(56, 8)] - public byte TimeMinute { get; set; } - - /// - /// 秒 - /// - [Property(64, 8)] - public byte TimeSecond { get; set; } - - /// - /// 保留:1位, 默认0xFF - /// - [Property(72, 8)] - public byte Time { get; set; } -} \ No newline at end of file diff --git a/Service/Execute/Api/PlcApi.cs b/Service/Execute/Api/PlcApi.cs index 7817526..e886fa8 100644 --- a/Service/Execute/Api/PlcApi.cs +++ b/Service/Execute/Api/PlcApi.cs @@ -1,9 +1,4 @@ -using HybirdFrameworkDriver.ModbusTcpMaster; using log4net; -using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; -using Service.Cloud.Msg.Cloud.Req; -using Service.Init.Entity; -using Service.Plc; using Service.Plc.Client; namespace Service.Execute.Api; @@ -13,14 +8,14 @@ public class PlcApi private const int TimeSpan = 60; private static readonly ILog Log = LogManager.GetLogger("PlcApi"); - + /// /// 数据有效时间。单位秒 /// static int DataTimeSeconds = 2; - + /// @@ -29,7 +24,7 @@ public class PlcApi /// public static bool IsRemote() { - + var isRemote = PlcMgr.IsRemote(); Log.Info($"PlcApi IsRemove resp={isRemote}"); return isRemote; @@ -110,10 +105,10 @@ public class PlcApi /// public static bool StartSwapping(string inBinNo, string outBinNo) { - + Log.Info($"PlcApi StartSwapping param= inBinNo={inBinNo}, outBinNo={outBinNo}"); var distributeTask = PlcMgr.DistributeTask(ushort.Parse(inBinNo), ushort.Parse(outBinNo), 1); - + Log.Info($"PlcApi StartSwapping resp={distributeTask}"); return distributeTask; } @@ -166,4 +161,5 @@ public class PlcApi Log.Info($"PlcApi ReadPlcTaskStatus resp= {readPlcTaskStatus}"); return readPlcTaskStatus; } -} \ No newline at end of file +} + diff --git a/Service/Init/Entity/ConnectState.cs b/Service/Init/Entity/ConnectState.cs deleted file mode 100644 index 8474612..0000000 --- a/Service/Init/Entity/ConnectState.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Service.Init.Entity -{ - /// - ///PLC连接状态枚举 - /// - public enum ConnectState - { - Disconnect = 0, - Connecting = 1, - Connected = 2 - } -} \ No newline at end of file diff --git a/Service/Init/Entity/PlcInfo.cs b/Service/Init/Entity/PlcInfo.cs deleted file mode 100644 index 32b8e20..0000000 --- a/Service/Init/Entity/PlcInfo.cs +++ /dev/null @@ -1,459 +0,0 @@ -using HybirdFrameworkDriver.ModbusTcpMaster; -using HybirdFrameworkDriver.Session; -using Service.Plc.Msg; - -namespace Service.Init.Entity -{ - public class PlcInfo - { - #region 字段 - - /// - /// 设备编号 - /// - private string _devNo = "001"; - - /// - /// 设备名称 - /// - private string _devname = "换电PLC"; - - /// - /// 服务端连接IP - /// - private string _ipaddr = "172.0.20.48"; - - /// - /// 服务端连接端口 - /// - private int _port = 502; - - /// - /// 站号 - /// - private byte _site = 0x01; - - /// - /// 连接超时时间。单位秒 - /// - private int _connecttimeout = 10; - - /// - /// 保持活跃时间。单位秒 - /// - private int _keepalive = 30; - - /// - /// 连接状态 - /// - private ConnectState _connect_state = ConnectState.Disconnect; - - #endregion 字段 - - public string ChannelId; - - public int EqmSn; - - public HostToPlc hostToPlc = new HostToPlc(); - public PlcToHost plcToHost = new PlcToHost(); - public PlcFault plcFault = new PlcFault(); - - #region - int DataTimeSeconds = 2; - DateTime DataValidityTime = DateTime.Now; - - /// - /// plc是否连接 - /// - public bool Connected { get; set; } - /// - /// plc是否处于远程模式 - /// - public bool RemoteNot - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= DataTimeSeconds) - { - return RemoteNot; - } - else - { - return false; - } - } - set - { - RemoteNot = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 读入口雷达是否感应触发 - /// - public bool EntranceRadar - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return EntranceRadar; - } - else - { - return false; - } - } - set - { - EntranceRadar = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 读取通道定位状态(拍照是否OK) - /// - public bool ChannelLocationState - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return ChannelLocationState; - } - else - { - return false; - } - } - set - { - ChannelLocationState = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 读取plc任务状态电池拆卸中 - /// - public bool BatteryDisassembly - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return BatteryDisassembly; - } - else - { - return false; - } - } - set - { - BatteryDisassembly = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 读取plc任务状态电池入库搬运中 - /// - public bool StorageBatteries - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return StorageBatteries; - } - else - { - return false; - } - } - set - { - StorageBatteries = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 读取plc任务状态电池出库搬运中 - /// - public bool BatteryDelivery - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return BatteryDelivery; - } - else - { - return false; - } - } - set - { - BatteryDelivery = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 读取plc任务状态电池安装中 - /// - public bool BatteryInstallation - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return BatteryInstallation; - } - else - { - return false; - } - } - set - { - BatteryInstallation = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 读取plc任务状态电池安装完成 - /// - public bool BatteryInstallationComplete - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return BatteryInstallationComplete; - } - else - { - return false; - } - } - set - { - BatteryInstallationComplete = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 设置出口灯:绿灯(通知车辆可以驶离) - /// - public bool SetExitLightGreen - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return SetExitLightGreen; - } - else - { - return false; - } - } - set - { - SetExitLightGreen = value; - DataValidityTime = DateTime.Now; - } - } - /// - /// 读出口雷达是否感应触发 - /// - public bool ExitRadarSensingTrigger - { - get - { - if ((DateTime.Now - DataValidityTime).Seconds <= 2) - { - return ExitRadarSensingTrigger; - } - else - { - return false; - } - } - set - { - ExitRadarSensingTrigger = value; - DataValidityTime = DateTime.Now; - } - } - - /// - /// 写入口灯绿 - /// - /// - public bool SendLightGreen() - { - bool bResult = false; - if (Connected) - { - hostToPlc.LightIn.Value = 1000; - bResult = WriteUint16(hostToPlc.LightIn); - } - return bResult; - } - - /// - /// 下发选包数据给plc(入仓位 - /// - /// 1:缓存位舱位号 2-20 电池存储舱位 - /// - public bool SendSelectRuleIn(ushort loc) - { - bool bResult = false; - if (Connected) - { - hostToPlc.EntrySelection.Value = loc; - bResult = WriteUint16(hostToPlc.EntrySelection); - } - return bResult; - } - /// - /// 下发选包数据给plc(出仓位 - /// - /// 1:缓存位舱位号 2-20 电池存储舱位 - /// - public bool SendSelectRuleOut(ushort loc) - { - bool bResult = false; - if (Connected) - { - hostToPlc.ExitSelection.Value = loc; - bResult = WriteUint16(hostToPlc.ExitSelection); - } - return bResult; - } - - /// - /// 写入口灯:红灯 - /// - /// - public bool SendLightRed() - { - bool bResult = false; - if (Connected) - { - hostToPlc.LightIn.Value = 1020; - bResult = WriteUint16(hostToPlc.LightIn); - } - return bResult; - } - /// - /// 下发plc开启换电任务 - /// - /// - public bool SendTaskType() - { - bool bResult = false; - if (Connected) - { - hostToPlc.TaskType.Value = 1; - bResult = WriteUint16(hostToPlc.TaskType); - } - return bResult; - } - /// - /// 设置出口灯:绿灯 - /// - /// - public bool SendLightOutGreen() - { - bool bResult = false; - if (Connected) - { - hostToPlc.LightOut.Value = 1000; - bResult = WriteUint16(hostToPlc.LightOut); - } - return bResult; - } - /// - /// 设置出口灯:红灯 - /// - /// - public bool SendLightOutRed() - { - bool bResult = false; - if (Connected) - { - hostToPlc.LightOut.Value = 1020; - bResult = WriteUint16(hostToPlc.LightOut); - } - return bResult; - } - #endregion - - #region 有料检测 - /// - /// 有料检测 1-20仓 - /// - public byte MaterialDetec01 { get; set; } - public byte MaterialDetec02 { get; set; } - public byte MaterialDetec03 { get; set; } - public byte MaterialDetec04 { get; set; } - public byte MaterialDetec05 { get; set; } - public byte MaterialDetec06 { get; set; } - public byte MaterialDetec07 { get; set; } - public byte MaterialDetec08 { get; set; } - public byte MaterialDetec09 { get; set; } - public byte MaterialDetec10 { get; set; } - public byte MaterialDetec11 { get; set; } - public byte MaterialDetec12 { get; set; } - public byte MaterialDetec13 { get; set; } - public byte MaterialDetec14 { get; set; } - public byte MaterialDetec15 { get; set; } - public byte MaterialDetec16 { get; set; } - public byte MaterialDetec17 { get; set; } - public byte MaterialDetec18 { get; set; } - public byte MaterialDetec19 { get; set; } - public byte MaterialDetec20 { get; set; } - #endregion 有料检测 - - /// - /// 舱位状态 在位状态:0-不在位;1-在位;2-无效 - /// - /// - public List ReturnMaterialDetec() - { - List ret = new List - { - MaterialDetec01,MaterialDetec02 ,MaterialDetec03 ,MaterialDetec04 ,MaterialDetec05 , - MaterialDetec06 ,MaterialDetec07 ,MaterialDetec08 ,MaterialDetec09 ,MaterialDetec10 , - MaterialDetec11 ,MaterialDetec12 ,MaterialDetec13 ,MaterialDetec14 ,MaterialDetec15 , - MaterialDetec16 ,MaterialDetec17 ,MaterialDetec18 ,MaterialDetec19 ,MaterialDetec20 , - }; - return ret; - } - - - public PlcInfo(string channelId, int eqmSn) - { - ChannelId = channelId; - EqmSn = eqmSn; - } - - public bool WriteUint16(ModbusProperty value) - { - bool bResult = false; - ModbusSession session = SessionMgr.GetModbusSession(ChannelId); - bResult = session.Write(value); - return bResult; - } - - public bool Writeint16(ModbusProperty value) - { - bool bResult = false; - ModbusSession session = SessionMgr.GetModbusSession(ChannelId); - bResult = session.Write(value); - return bResult; - } - } -} \ No newline at end of file diff --git a/WebStarter/bin/Debug/net6.0/appsettings.json b/WebStarter/bin/Debug/net6.0/appsettings.json index f2a419d..0c208ae 100644 --- a/WebStarter/bin/Debug/net6.0/appsettings.json +++ b/WebStarter/bin/Debug/net6.0/appsettings.json @@ -1,73 +1,8 @@ { - "ConnectionStrings": { - "ConfigId": "master", - "DbType": "MySql", - "SqlConnection": //"server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;", - "server=127.0.0.1;Port=3306;Database=huanneng_dev;Uid=root;Pwd=anyixing2023!@#;Charset=utf8;" - }, - "Update": { - "AutoUpdate": "false", - "Version": "1.1.0.1", - "Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml" - }, - "Redis": { - "Connection": "106.12.36.89:6379,password=123456", - "InstanceName": "local", - "DefaultDB": "8" - }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } - }, - "AllowedHosts": "*", - ",": null, - "Cryptogram": { - "StrongPassword": "false", // 是否开启密码强度验证 - "PasswordStrengthValidation": "(?=^.{6,16}$)(?=.*\\d)(?=.*\\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\\n).*$", // 密码强度验证正则表达式,必须须包含大小写字母、数字和特殊字符的组合,长度在6-16之间 - "PasswordStrengthValidationMsg": "密码必须包含大小写字母、数字和特殊字符的组合,长度在6-16之间", // 密码强度验证消息提示 - "CryptoType": "SM2", // 密码加密算法:MD5、SM2、SM4 - "PublicKey": "0484C7466D950E120E5ECE5DD85D0C90EAA85081A3A2BD7C57AE6DC822EFCCBD66620C67B0103FC8DD280E36C3B282977B722AAEC3C56518EDCEBAFB72C5A05312", // 公钥 - "PrivateKey": "8EDB615B1D48B8BE188FC0F18EC08A41DF50EA731FA28BF409E6552809E3A111" // 私钥 - }, - //Login - "TokenOptions": { - "SecurityKey": "s4104j1401kopposdfjsfj091541111111111", - "Domain": "*", - "Audience": "jwtAudience", - "Issuer": "jwtIssuer" - }, - "Upload": { - "Path": "Upload/{yyyy}/{MM}/{dd}", // 文件上传目录 - "MaxSize": 20480, // 文件最大限制KB:1024*20 - "ContentType": [ "image/jpg", "image/png", "image/jpeg", "image/gif", "image/bmp", "text/plain", "application/pdf", "application/msword", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "video/mp4" ], - "EnableMd5": false // 启用文件MDF5验证-防止重复上传 - }, - //SysLogin - "JWTSettings": { - "ValidateIssuerSigningKey": true, // 是否验证密钥,bool 类型,默认true - "IssuerSigningKey": "3c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a", // 密钥,string 类型,必须是复杂密钥,长度大于16 - "ValidateIssuer": true, // 是否验证签发方,bool 类型,默认true - "ValidIssuer": "Admin.NET", // 签发方,string 类型 - "ValidateAudience": true, // 是否验证签收方,bool 类型,默认true - "ValidAudience": "Admin.NET", // 签收方,string 类型 - "ValidateLifetime": true, // 是否验证过期时间,bool 类型,默认true,建议true - //"ExpiredTime": 20, // 过期时间,long 类型,单位分钟,默认20分钟,最大支持 13 年 - "ClockSkew": 5, // 过期时间容错值,long 类型,单位秒,默认5秒 - "Algorithm": "HS256", // 加密算法,string 类型,默认 HS256 - "RequireExpirationTime": true // 验证过期时间,设置 false 将永不过期 - }, - - - "SnowId": { - "WorkerId": 1, // 机器码 全局唯一 - "WorkerIdBitLength": 6, // 机器码位长 默认值6,取值范围 [1, 19] - "SeqBitLength": 6, // 序列数位长 默认值6,取值范围 [3, 21](建议不小于4,值越大性能越高、Id位数也更长) - "WorkerPrefix": "adminnet_" // 缓存前缀 - }, - - "HttpContextRequest": { - "Scheme": "http://192.168.2.17:5034" } } diff --git a/WebStarter/obj/Debug/net6.0/staticwebassets.build.json b/WebStarter/obj/Debug/net6.0/staticwebassets.build.json index 4271680..86164bd 100644 --- a/WebStarter/obj/Debug/net6.0/staticwebassets.build.json +++ b/WebStarter/obj/Debug/net6.0/staticwebassets.build.json @@ -1,6 +1,6 @@ { "Version": 1, - "Hash": "kIfehZk8TWWy62IgCKeVJMphEP8JJ0AGeTvs9NqLTfU=", + "Hash": "PUkZxlgk8KRfiyiYD55Dczq9Q9JYZyET99LUbVltauo=", "Source": "WebStarter", "BasePath": "_content/WebStarter", "Mode": "Default", @@ -10,17 +10,17 @@ { "Name": "WebStarter\\wwwroot", "Source": "WebStarter", - "ContentRoot": "D:\\lxw\\work\\pro\\c#\\hn_back_main\\WebStarter\\wwwroot\\", + "ContentRoot": "D:\\RiderProjects\\hn_back_main\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "Pattern": "**" } ], "Assets": [ { - "Identity": "D:\\lxw\\work\\pro\\c#\\hn_back_main\\WebStarter\\wwwroot\\20240523\\0.jpg", + "Identity": "D:\\RiderProjects\\hn_back_main\\WebStarter\\wwwroot\\20240523\\0.jpg", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\lxw\\work\\pro\\c#\\hn_back_main\\WebStarter\\wwwroot\\", + "ContentRoot": "D:\\RiderProjects\\hn_back_main\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240523/0.jpg", "AssetKind": "All", @@ -36,10 +36,10 @@ "OriginalItemSpec": "wwwroot\\20240523\\0.jpg" }, { - "Identity": "D:\\lxw\\work\\pro\\c#\\hn_back_main\\WebStarter\\wwwroot\\20240524\\0.jpg", + "Identity": "D:\\RiderProjects\\hn_back_main\\WebStarter\\wwwroot\\20240524\\0.jpg", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\lxw\\work\\pro\\c#\\hn_back_main\\WebStarter\\wwwroot\\", + "ContentRoot": "D:\\RiderProjects\\hn_back_main\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240524/0.jpg", "AssetKind": "All", @@ -55,10 +55,10 @@ "OriginalItemSpec": "wwwroot\\20240524\\0.jpg" }, { - "Identity": "D:\\lxw\\work\\pro\\c#\\hn_back_main\\WebStarter\\wwwroot\\20240524\\0.png", + "Identity": "D:\\RiderProjects\\hn_back_main\\WebStarter\\wwwroot\\20240524\\0.png", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\lxw\\work\\pro\\c#\\hn_back_main\\WebStarter\\wwwroot\\", + "ContentRoot": "D:\\RiderProjects\\hn_back_main\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240524/0.png", "AssetKind": "All", diff --git a/WinFormStarter/FrmPlc.cs b/WinFormStarter/FrmPlc.cs index 2e3514e..95c1d9b 100644 --- a/WinFormStarter/FrmPlc.cs +++ b/WinFormStarter/FrmPlc.cs @@ -1,19 +1,4 @@ using HslCommunication.ModBus; -using HslCommunication; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using HybirdFrameworkDriver.ModbusTcpMaster; -using HybirdFrameworkDriver.TcpServer; -using Newtonsoft.Json.Linq; -using Service.Init.Entity; -using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace WinFormStarter { diff --git a/WinFormStarter/Program.cs b/WinFormStarter/Program.cs index a16ff66..f0d3250 100644 --- a/WinFormStarter/Program.cs +++ b/WinFormStarter/Program.cs @@ -2,7 +2,6 @@ using Autofac; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Configuration; using log4net.Config; -using Service; using SqlSugar; using SqlSugar.IOC; @@ -59,4 +58,4 @@ internal static class Program var result = MessageBox.Show("系统发生错误,您需要退出系统吗?", "异常", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) Application.Exit(); } -} \ No newline at end of file +}