diff --git a/ConsoleStarter/ExportDb.cs b/ConsoleStarter/ExportDb.cs index ea1fe73..fdcfd7f 100644 --- a/ConsoleStarter/ExportDb.cs +++ b/ConsoleStarter/ExportDb.cs @@ -36,7 +36,8 @@ public class ExportDb private readonly SqlSugarClient Db = new(new ConnectionConfig { ConnectionString = - "server=106.12.36.89;Database=chassis_track_swap0;Uid=remote_user;Pwd=Rszn123;Charset=utf8;", + //"server=106.12.36.89;Database=chassis_track_swap0;Uid=remote_user;Pwd=Rszn123;Charset=utf8;", + "server=127.0.0.1;Port=3306;Database=huanneng_dev;Uid=root;Pwd=anyixing2023!@#;Charset=utf8;", DbType = DbType.MySql, IsAutoCloseConnection = true, InitKeyType = InitKeyType.Attribute diff --git a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs index 08521d0..81b3ae0 100644 --- a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs +++ b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs @@ -45,69 +45,69 @@ public static class ModbusDecoder } foreach (var field in fields) - switch (field) - { - case ModbusProperty boolProperty: - { - SetPropertyValue(startRegisterNo, boolProperty, decodeUseBytes); - //SetPropertyValue(boolProperty.RegisterNo, boolProperty, decodeUseBytes); - break; - } - case ModbusProperty byteProperty: - { - SetPropertyValue(startRegisterNo, byteProperty, decodeUseBytes); - //SetPropertyValue(byteProperty.RegisterNo, byteProperty, decodeUseBytes); - break; - } - case ModbusProperty sbyteProperty: - { - //SetPropertyValue(sbyteProperty.RegisterNo, sbyteProperty, decodeUseBytes); - SetPropertyValue(startRegisterNo, sbyteProperty, decodeUseBytes); - break; - } - case ModbusProperty shortProperty: - { - SetPropertyValue(startRegisterNo, shortProperty, decodeUseBytes); - //SetPropertyValue(shortProperty.RegisterNo, shortProperty, decodeUseBytes); - break; - } - case ModbusProperty ushortProperty: - { - SetPropertyValue(startRegisterNo, ushortProperty, decodeUseBytes); - // SetPropertyValue(ushortProperty.RegisterNo, ushortProperty, decodeUseBytes); - break; - } - case ModbusProperty intProperty: - { - SetPropertyValue(startRegisterNo, intProperty, decodeUseBytes); - // SetPropertyValue(intProperty.RegisterNo, intProperty, decodeUseBytes); - break; - } - case ModbusProperty uintProperty: - { - SetPropertyValue(startRegisterNo, uintProperty, decodeUseBytes); - // SetPropertyValue(uintProperty.RegisterNo, uintProperty, decodeUseBytes); - break; - } - case ModbusProperty floatProperty: + switch (field) { - SetPropertyValue(startRegisterNo, floatProperty, decodeUseBytes, true); - // SetPropertyValue(floatProperty.RegisterNo, floatProperty, decodeUseBytes); - break; + case ModbusProperty boolProperty: + { + SetPropertyValue(startRegisterNo, boolProperty, decodeUseBytes); + //SetPropertyValue(boolProperty.RegisterNo, boolProperty, decodeUseBytes); + break; + } + case ModbusProperty byteProperty: + { + SetPropertyValue(startRegisterNo, byteProperty, decodeUseBytes); + //SetPropertyValue(byteProperty.RegisterNo, byteProperty, decodeUseBytes); + break; + } + case ModbusProperty sbyteProperty: + { + //SetPropertyValue(sbyteProperty.RegisterNo, sbyteProperty, decodeUseBytes); + SetPropertyValue(startRegisterNo, sbyteProperty, decodeUseBytes); + break; + } + case ModbusProperty shortProperty: + { + SetPropertyValue(startRegisterNo, shortProperty, decodeUseBytes); + //SetPropertyValue(shortProperty.RegisterNo, shortProperty, decodeUseBytes); + break; + } + case ModbusProperty ushortProperty: + { + SetPropertyValue(startRegisterNo, ushortProperty, decodeUseBytes); + // SetPropertyValue(ushortProperty.RegisterNo, ushortProperty, decodeUseBytes); + break; + } + case ModbusProperty intProperty: + { + SetPropertyValue(startRegisterNo, intProperty, decodeUseBytes); + // SetPropertyValue(intProperty.RegisterNo, intProperty, decodeUseBytes); + break; + } + case ModbusProperty uintProperty: + { + SetPropertyValue(startRegisterNo, uintProperty, decodeUseBytes); + // SetPropertyValue(uintProperty.RegisterNo, uintProperty, decodeUseBytes); + break; + } + case ModbusProperty floatProperty: + { + SetPropertyValue(startRegisterNo, floatProperty, decodeUseBytes, true); + // SetPropertyValue(floatProperty.RegisterNo, floatProperty, decodeUseBytes); + break; + } + case ModbusProperty doubleProperty: + { + SetPropertyValue(startRegisterNo, doubleProperty, decodeUseBytes); + // SetPropertyValue(doubleProperty.RegisterNo, doubleProperty, decodeUseBytes); + break; + } + case ModbusProperty stringProperty: + { + SetPropertyValue(startRegisterNo, stringProperty, decodeUseBytes); + // SetPropertyValue(stringProperty.RegisterNo, stringProperty, decodeUseBytes); + break; + } } - case ModbusProperty doubleProperty: - { - SetPropertyValue(startRegisterNo, doubleProperty, decodeUseBytes); - // SetPropertyValue(doubleProperty.RegisterNo, doubleProperty, decodeUseBytes); - break; - } - case ModbusProperty stringProperty: - { - SetPropertyValue(startRegisterNo, stringProperty, decodeUseBytes); - // SetPropertyValue(stringProperty.RegisterNo, stringProperty, decodeUseBytes); - break; - } - } return t; } diff --git a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusProperty.cs b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusProperty.cs index 3cdc04f..607fd55 100644 --- a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusProperty.cs +++ b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusProperty.cs @@ -6,7 +6,7 @@ public class ModbusProperty : IModbusProperty /// /// 寄存器编号 /// 根据类型:Register为第几个寄存器 - /// 根据类型:Register 为 几个寄存器 + /// 根据类型:Register 为 几个寄存器(2byte) /// Register/Bit /// 精度 /// 保留几位小数 diff --git a/Service/Plc/Client/PlcClient.cs b/Service/Plc/Client/PlcClient.cs index e14af51..84305a8 100644 --- a/Service/Plc/Client/PlcClient.cs +++ b/Service/Plc/Client/PlcClient.cs @@ -25,11 +25,13 @@ public class PlcClient : ModbusTcpMaster private void BatchRead(ModbusTcpMaster master) { + PlcMgr.SendHear(); var bytes01 = master.BatchReadHolderRegister(1, 115); if (bytes01 != null) { PlcMgr.DataValidityTime = DateTime.Now; - ModbusDecoder.Decode(bytes01, PlcMgr.HostToPlcData); + + ModbusDecoder.Decode(bytes01, PlcMgr.HostToPlcData); } var bytes02 = master.BatchReadHolderRegister(201, 222); diff --git a/Service/Plc/Client/PlcMgr.cs b/Service/Plc/Client/PlcMgr.cs index 2b28ae1..d0e878a 100644 --- a/Service/Plc/Client/PlcMgr.cs +++ b/Service/Plc/Client/PlcMgr.cs @@ -161,6 +161,29 @@ public class PlcMgr return false; } + public static bool SendHear() + { + if (PlcClient != null) + { + HostToPlc writeHostToPlc = new HostToPlc(); + writeHostToPlc.Years.Value = (ushort)DateTime.Now.Year; + writeHostToPlc.Month.Value = (ushort)DateTime.Now.Month; + writeHostToPlc.Day.Value = (ushort)DateTime.Now.Day; + writeHostToPlc.Hour.Value = (ushort)DateTime.Now.Hour; + writeHostToPlc.Points.Value = (ushort)DateTime.Now.Minute; + writeHostToPlc.Seconds.Value = (ushort)DateTime.Now.Second; + + bool write1 = PlcClient.WriteValue(writeHostToPlc.Years); + bool write2 = PlcClient.WriteValue(writeHostToPlc.Month); + bool write3 = PlcClient.WriteValue(writeHostToPlc.Day); + bool write4 = PlcClient.WriteValue(writeHostToPlc.Hour); + bool write5 = PlcClient.WriteValue(writeHostToPlc.Points); + bool write6 = PlcClient.WriteValue(writeHostToPlc.Seconds); + return write1 && write2&& write3 && write4&& write5 && write6; + } + return true; + } + /// /// 查看拍照状态 /// diff --git a/Service/Plc/Msg/HostToPlc.cs b/Service/Plc/Msg/HostToPlc.cs index c116148..82388a1 100644 --- a/Service/Plc/Msg/HostToPlc.cs +++ b/Service/Plc/Msg/HostToPlc.cs @@ -71,7 +71,7 @@ namespace Service.Plc.Msg /// 对时时钟:年 /// public ModbusProperty Years { get; set; } = new(40016); - public ModbusProperty Standby3 { get; set; } = new(40017, length: 4); // 备用3 + //public ModbusProperty Standby3 { get; set; } = new(40017, length: 4); // 备用36 //public ModbusProperty ChargingStatus { get; set; } = new(40021, length: 40); // 仓位充电状态 /// /// 仓位充电状态 @@ -340,7 +340,7 @@ namespace Service.Plc.Msg /// 电池包锁止异常,暂停命令 0:无命令;1000:暂停使能 /// public ModbusProperty StopCommand { get; set; } = new(40105); - public ModbusProperty Standby4 { get; set; } = new(40106, length: 5); // 备用4 + //public ModbusProperty Standby4 { get; set; } = new(40106, length: 5); // 备用4 /// /// 任务类型 /// 0.无任务 diff --git a/Service/Plc/Msg/PlcFault.cs b/Service/Plc/Msg/PlcFault.cs index 599cec9..ade3939 100644 --- a/Service/Plc/Msg/PlcFault.cs +++ b/Service/Plc/Msg/PlcFault.cs @@ -4,15 +4,10 @@ namespace Service.Plc.Msg { public class PlcFault { - public ModbusProperty ErrorCode01 { get; set; } = new(40701); // 错误码 - public ModbusProperty ErrorCode02 { get; set; } = new(40702); // 错误码 - public ModbusProperty ErrorCode03 { get; set; } = new(40703); // 错误码 - public ModbusProperty ErrorCode04 { get; set; } = new(40704); // 错误码 - public ModbusProperty ErrorCode05 { get; set; } = new(40705); // 错误码 - public ModbusProperty ErrorCode06 { get; set; } = new(40706); // 错误码 - public ModbusProperty ErrorCode07 { get; set; } = new(40707); // 错误码 - public ModbusProperty ErrorCode08 { get; set; } = new(40708); // 错误码 - public ModbusProperty ErrorCode09 { get; set; } = new(40709); // 错误码 - public ModbusProperty ErrorCode10 { get; set; } = new(40710); // 错误码 + public ModbusProperty ErrorCode01 { get; set; } = new(40701,length :2); // 错误码 + public ModbusProperty ErrorCode03 { get; set; } = new(40703,length :2); // 错误码 + public ModbusProperty ErrorCode05 { get; set; } = new(40705,length :2); // 错误码 + public ModbusProperty ErrorCode07 { get; set; } = new(40707,length :2); // 错误码 + public ModbusProperty ErrorCode09 { get; set; } = new(40709, length: 2); // 错误码 } } diff --git a/Service/Plc/Msg/PlcToHost.cs b/Service/Plc/Msg/PlcToHost.cs index 826973f..08d232c 100644 --- a/Service/Plc/Msg/PlcToHost.cs +++ b/Service/Plc/Msg/PlcToHost.cs @@ -65,38 +65,38 @@ namespace Service.Plc.Msg /// /// 备用 /// - public ModbusProperty value09 { get; set; } = new(40211, length: 30); + //public ModbusProperty<1> value09 { get; set; } = new(40211, length: 30); #region 舱位状态 bit0:有料检测 Bit1:有料检测开关故障 - public ModbusProperty MaterialDetec01 { get; set; } = new(40241,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec02 { get; set; } = new(40242,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec03 { get; set; } = new(40243,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec04 { get; set; } = new(40244,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec05 { get; set; } = new(40245,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec06 { get; set; } = new(40246,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec07 { get; set; } = new(40247,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec08 { get; set; } = new(40248,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec09 { get; set; } = new(40249,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec10 { get; set; } = new(40250,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec11 { get; set; } = new(40251,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec12 { get; set; } = new(40252,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec13 { get; set; } = new(40253,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec14 { get; set; } = new(40254,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec15 { get; set; } = new(40255,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec16 { get; set; } = new(40256,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec17 { get; set; } = new(40257,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec18 { get; set; } = new(40258,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec19 { get; set; } = new(40259,0,2,ModbusDataType.Bit); - public ModbusProperty MaterialDetec20 { get; set; } = new(40260,0,2,ModbusDataType.Bit); + public ModbusProperty MaterialDetec01 { get; set; } = new(40241); + public ModbusProperty MaterialDetec02 { get; set; } = new(40242); + public ModbusProperty MaterialDetec03 { get; set; } = new(40243); + public ModbusProperty MaterialDetec04 { get; set; } = new(40244); + public ModbusProperty MaterialDetec05 { get; set; } = new(40245); + public ModbusProperty MaterialDetec06 { get; set; } = new(40246); + public ModbusProperty MaterialDetec07 { get; set; } = new(40247); + public ModbusProperty MaterialDetec08 { get; set; } = new(40248); + public ModbusProperty MaterialDetec09 { get; set; } = new(40249); + public ModbusProperty MaterialDetec10 { get; set; } = new(40250); + public ModbusProperty MaterialDetec11 { get; set; } = new(40251); + public ModbusProperty MaterialDetec12 { get; set; } = new(40252); + public ModbusProperty MaterialDetec13 { get; set; } = new(40253); + public ModbusProperty MaterialDetec14 { get; set; } = new(40254); + public ModbusProperty MaterialDetec15 { get; set; } = new(40255); + public ModbusProperty MaterialDetec16 { get; set; } = new(40256); + public ModbusProperty MaterialDetec17 { get; set; } = new(40257); + public ModbusProperty MaterialDetec18 { get; set; } = new(40258); + public ModbusProperty MaterialDetec19 { get; set; } = new(40259); + public ModbusProperty MaterialDetec20 { get; set; } = new(40260); #endregion 舱位状态 /// /// 备用 /// - public ModbusProperty value11 { get; set; } = new(40281, length: 20); + //public ModbusProperty value11 { get; set; } = new(40281, length: 20); /// /// 载行车设备状态 /// 0:无效值 @@ -127,7 +127,7 @@ namespace Service.Plc.Msg /// z轴扭矩百分比 /// public ModbusProperty PercentageTorqueZ { get; set; } = new(40308); - public ModbusProperty value20 { get; set; } = new(40309, length: 92); // 备用 + //public ModbusProperty value20 { get; set; } = new(40309, length: 92); // 备用 /// /// 入口雷达状态 /// 0:未触发 @@ -229,7 +229,7 @@ namespace Service.Plc.Msg /// z偏差 /// public ModbusProperty DeviationZ { get; set; } = new(40413); - public ModbusProperty value44 { get; set; } = new(40414, length: 7); // 备用 + //public ModbusProperty value44 { get; set; } = new(40414, length: 7); // 备用 diff --git a/WebStarter/appsettings.json b/WebStarter/appsettings.json index 6751166..f2a419d 100644 --- a/WebStarter/appsettings.json +++ b/WebStarter/appsettings.json @@ -2,7 +2,8 @@ "ConnectionStrings": { "ConfigId": "master", "DbType": "MySql", - "SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;" + "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", diff --git a/WebStarter/bin/Debug/net6.0/appsettings.json b/WebStarter/bin/Debug/net6.0/appsettings.json index 6751166..f2a419d 100644 --- a/WebStarter/bin/Debug/net6.0/appsettings.json +++ b/WebStarter/bin/Debug/net6.0/appsettings.json @@ -2,7 +2,8 @@ "ConnectionStrings": { "ConfigId": "master", "DbType": "MySql", - "SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;" + "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", diff --git a/WebStarter/obj/Debug/net6.0/staticwebassets.build.json b/WebStarter/obj/Debug/net6.0/staticwebassets.build.json index 4499011..e2ac291 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": "6L5ya4V2yXT6SrMz9lvVeF6F81dXoy4XMjFW1sVbQpk=", + "Hash": "eioKVWbBxP3UNRRzRoz1XiSMz4NkI2ImmvQOxazjnaQ=", "Source": "WebStarter", "BasePath": "_content/WebStarter", "Mode": "Default", @@ -10,17 +10,17 @@ { "Name": "WebStarter\\wwwroot", "Source": "WebStarter", - "ContentRoot": "D:\\vsproject\\hn_back_main\\WebStarter\\wwwroot\\", + "ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\主服务\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "Pattern": "**" } ], "Assets": [ { - "Identity": "D:\\vsproject\\hn_back_main\\WebStarter\\wwwroot\\20240523\\0.jpg", + "Identity": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\主服务\\WebStarter\\wwwroot\\20240523\\0.jpg", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\vsproject\\hn_back_main\\WebStarter\\wwwroot\\", + "ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\主服务\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240523/0.jpg", "AssetKind": "All", @@ -34,10 +34,10 @@ "OriginalItemSpec": "wwwroot\\20240523\\0.jpg" }, { - "Identity": "D:\\vsproject\\hn_back_main\\WebStarter\\wwwroot\\20240524\\0.jpg", + "Identity": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\主服务\\WebStarter\\wwwroot\\20240524\\0.jpg", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\vsproject\\hn_back_main\\WebStarter\\wwwroot\\", + "ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\主服务\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240524/0.jpg", "AssetKind": "All", @@ -51,10 +51,10 @@ "OriginalItemSpec": "wwwroot\\20240524\\0.jpg" }, { - "Identity": "D:\\vsproject\\hn_back_main\\WebStarter\\wwwroot\\20240524\\0.png", + "Identity": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\主服务\\WebStarter\\wwwroot\\20240524\\0.png", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\vsproject\\hn_back_main\\WebStarter\\wwwroot\\", + "ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\主服务\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240524/0.png", "AssetKind": "All", diff --git a/WinFormStarter/appsettings.json b/WinFormStarter/appsettings.json index 01d9b4e..ec68e90 100644 --- a/WinFormStarter/appsettings.json +++ b/WinFormStarter/appsettings.json @@ -2,7 +2,7 @@ "ConnectionStrings": { "DbType": "MySql", //数据库将支持两种模式【SqlServer,MySql】 - "SqlConnection": "server=127.0.0.1;Port=3306;Database=huanneng_dev;Uid=root;Pwd=123456;Charset=utf8;" + "SqlConnection": "server=127.0.0.1;Port=3306;Database=huanneng_dev;Uid=root;Pwd=anyixing2023!@#;Charset=utf8;" //"SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;", }, "Update": { diff --git a/WpfStarter/appsettings.json b/WpfStarter/appsettings.json index 5acd8e9..2b95f17 100644 --- a/WpfStarter/appsettings.json +++ b/WpfStarter/appsettings.json @@ -2,7 +2,8 @@ "ConnectionStrings": { "DbType": "MySql", //数据库将支持两种模式【SqlServer,MySql】 - "SqlConnection": "server=127.0.0.1;Port=3307;Database=winformdevframework;Uid=root;Pwd=w123ee;Charset=utf8;" + "SqlConnection": //"server=127.0.0.1;Port=3307;Database=winformdevframework;Uid=root;Pwd=w123ee;Charset=utf8;", + "server=127.0.0.1;Port=3306;Database=huanneng_dev;Uid=root;Pwd=anyixing2023!@#;Charset=utf8;" }, "Update": { "AutoUpdate": "false",