PLC调试部分更改

zw
CZ 6 months ago
parent 7e328fa924
commit d061b8b069

@ -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

@ -45,69 +45,69 @@ public static class ModbusDecoder
}
foreach (var field in fields)
switch (field)
{
case ModbusProperty<bool> boolProperty:
{
SetPropertyValue(startRegisterNo, boolProperty, decodeUseBytes);
//SetPropertyValue(boolProperty.RegisterNo, boolProperty, decodeUseBytes);
break;
}
case ModbusProperty<byte> byteProperty:
{
SetPropertyValue(startRegisterNo, byteProperty, decodeUseBytes);
//SetPropertyValue(byteProperty.RegisterNo, byteProperty, decodeUseBytes);
break;
}
case ModbusProperty<sbyte> sbyteProperty:
{
//SetPropertyValue(sbyteProperty.RegisterNo, sbyteProperty, decodeUseBytes);
SetPropertyValue(startRegisterNo, sbyteProperty, decodeUseBytes);
break;
}
case ModbusProperty<short> shortProperty:
{
SetPropertyValue(startRegisterNo, shortProperty, decodeUseBytes);
//SetPropertyValue(shortProperty.RegisterNo, shortProperty, decodeUseBytes);
break;
}
case ModbusProperty<ushort> ushortProperty:
{
SetPropertyValue(startRegisterNo, ushortProperty, decodeUseBytes);
// SetPropertyValue(ushortProperty.RegisterNo, ushortProperty, decodeUseBytes);
break;
}
case ModbusProperty<int> intProperty:
{
SetPropertyValue(startRegisterNo, intProperty, decodeUseBytes);
// SetPropertyValue(intProperty.RegisterNo, intProperty, decodeUseBytes);
break;
}
case ModbusProperty<uint> uintProperty:
{
SetPropertyValue(startRegisterNo, uintProperty, decodeUseBytes);
// SetPropertyValue(uintProperty.RegisterNo, uintProperty, decodeUseBytes);
break;
}
case ModbusProperty<float> floatProperty:
switch (field)
{
SetPropertyValue(startRegisterNo, floatProperty, decodeUseBytes, true);
// SetPropertyValue(floatProperty.RegisterNo, floatProperty, decodeUseBytes);
break;
case ModbusProperty<bool> boolProperty:
{
SetPropertyValue(startRegisterNo, boolProperty, decodeUseBytes);
//SetPropertyValue(boolProperty.RegisterNo, boolProperty, decodeUseBytes);
break;
}
case ModbusProperty<byte> byteProperty:
{
SetPropertyValue(startRegisterNo, byteProperty, decodeUseBytes);
//SetPropertyValue(byteProperty.RegisterNo, byteProperty, decodeUseBytes);
break;
}
case ModbusProperty<sbyte> sbyteProperty:
{
//SetPropertyValue(sbyteProperty.RegisterNo, sbyteProperty, decodeUseBytes);
SetPropertyValue(startRegisterNo, sbyteProperty, decodeUseBytes);
break;
}
case ModbusProperty<short> shortProperty:
{
SetPropertyValue(startRegisterNo, shortProperty, decodeUseBytes);
//SetPropertyValue(shortProperty.RegisterNo, shortProperty, decodeUseBytes);
break;
}
case ModbusProperty<ushort> ushortProperty:
{
SetPropertyValue(startRegisterNo, ushortProperty, decodeUseBytes);
// SetPropertyValue(ushortProperty.RegisterNo, ushortProperty, decodeUseBytes);
break;
}
case ModbusProperty<int> intProperty:
{
SetPropertyValue(startRegisterNo, intProperty, decodeUseBytes);
// SetPropertyValue(intProperty.RegisterNo, intProperty, decodeUseBytes);
break;
}
case ModbusProperty<uint> uintProperty:
{
SetPropertyValue(startRegisterNo, uintProperty, decodeUseBytes);
// SetPropertyValue(uintProperty.RegisterNo, uintProperty, decodeUseBytes);
break;
}
case ModbusProperty<float> floatProperty:
{
SetPropertyValue(startRegisterNo, floatProperty, decodeUseBytes, true);
// SetPropertyValue(floatProperty.RegisterNo, floatProperty, decodeUseBytes);
break;
}
case ModbusProperty<double> doubleProperty:
{
SetPropertyValue(startRegisterNo, doubleProperty, decodeUseBytes);
// SetPropertyValue(doubleProperty.RegisterNo, doubleProperty, decodeUseBytes);
break;
}
case ModbusProperty<string> stringProperty:
{
SetPropertyValue(startRegisterNo, stringProperty, decodeUseBytes);
// SetPropertyValue(stringProperty.RegisterNo, stringProperty, decodeUseBytes);
break;
}
}
case ModbusProperty<double> doubleProperty:
{
SetPropertyValue(startRegisterNo, doubleProperty, decodeUseBytes);
// SetPropertyValue(doubleProperty.RegisterNo, doubleProperty, decodeUseBytes);
break;
}
case ModbusProperty<string> stringProperty:
{
SetPropertyValue(startRegisterNo, stringProperty, decodeUseBytes);
// SetPropertyValue(stringProperty.RegisterNo, stringProperty, decodeUseBytes);
break;
}
}
return t;
}

@ -6,7 +6,7 @@ public class ModbusProperty<T> : IModbusProperty
/// </summary>
/// <param name="registerNo">寄存器编号</param>
/// <param name="start">根据类型Register为第几个寄存器</param>
/// <param name="length">根据类型Register 为 几个寄存器</param>
/// <param name="length">根据类型Register 为 几个寄存器(2byte)</param>
/// <param name="type">Register/Bit</param>
/// <param name="scale">精度</param>
/// <param name="round">保留几位小数</param>

@ -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<HostToPlc>(bytes01, PlcMgr.HostToPlcData);
ModbusDecoder.Decode<HostToPlc>(bytes01, PlcMgr.HostToPlcData);
}
var bytes02 = master.BatchReadHolderRegister(201, 222);

@ -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;
}
/// <summary>
/// 查看拍照状态
/// </summary>

@ -71,7 +71,7 @@ namespace Service.Plc.Msg
/// 对时时钟:年
/// </summary>
public ModbusProperty<ushort> Years { get; set; } = new(40016);
public ModbusProperty<string> Standby3 { get; set; } = new(40017, length: 4); // 备用3
//public ModbusProperty<string> Standby3 { get; set; } = new(40017, length: 4); // 备用36
//public ModbusProperty<string> ChargingStatus { get; set; } = new(40021, length: 40); // 仓位充电状态
/// <summary>
/// 仓位充电状态
@ -340,7 +340,7 @@ namespace Service.Plc.Msg
/// 电池包锁止异常,暂停命令 0无命令1000暂停使能
/// </summary>
public ModbusProperty<ushort> StopCommand { get; set; } = new(40105);
public ModbusProperty<string> Standby4 { get; set; } = new(40106, length: 5); // 备用4
//public ModbusProperty<string> Standby4 { get; set; } = new(40106, length: 5); // 备用4
/// <summary>
/// 任务类型
/// <para>0.无任务</para>

@ -4,15 +4,10 @@ namespace Service.Plc.Msg
{
public class PlcFault
{
public ModbusProperty<ushort> ErrorCode01 { get; set; } = new(40701); // 错误码
public ModbusProperty<ushort> ErrorCode02 { get; set; } = new(40702); // 错误码
public ModbusProperty<ushort> ErrorCode03 { get; set; } = new(40703); // 错误码
public ModbusProperty<ushort> ErrorCode04 { get; set; } = new(40704); // 错误码
public ModbusProperty<ushort> ErrorCode05 { get; set; } = new(40705); // 错误码
public ModbusProperty<ushort> ErrorCode06 { get; set; } = new(40706); // 错误码
public ModbusProperty<ushort> ErrorCode07 { get; set; } = new(40707); // 错误码
public ModbusProperty<ushort> ErrorCode08 { get; set; } = new(40708); // 错误码
public ModbusProperty<ushort> ErrorCode09 { get; set; } = new(40709); // 错误码
public ModbusProperty<ushort> ErrorCode10 { get; set; } = new(40710); // 错误码
public ModbusProperty<int> ErrorCode01 { get; set; } = new(40701,length :2); // 错误码
public ModbusProperty<int> ErrorCode03 { get; set; } = new(40703,length :2); // 错误码
public ModbusProperty<int> ErrorCode05 { get; set; } = new(40705,length :2); // 错误码
public ModbusProperty<int> ErrorCode07 { get; set; } = new(40707,length :2); // 错误码
public ModbusProperty<int> ErrorCode09 { get; set; } = new(40709, length: 2); // 错误码
}
}

@ -65,38 +65,38 @@ namespace Service.Plc.Msg
/// <summary>
/// 备用
/// </summary>
public ModbusProperty<string> value09 { get; set; } = new(40211, length: 30);
//public ModbusProperty<1> value09 { get; set; } = new(40211, length: 30);
#region 舱位状态 bit0:有料检测 Bit1有料检测开关故障
public ModbusProperty<byte> MaterialDetec01 { get; set; } = new(40241,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec02 { get; set; } = new(40242,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec03 { get; set; } = new(40243,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec04 { get; set; } = new(40244,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec05 { get; set; } = new(40245,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec06 { get; set; } = new(40246,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec07 { get; set; } = new(40247,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec08 { get; set; } = new(40248,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec09 { get; set; } = new(40249,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec10 { get; set; } = new(40250,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec11 { get; set; } = new(40251,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec12 { get; set; } = new(40252,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec13 { get; set; } = new(40253,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec14 { get; set; } = new(40254,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec15 { get; set; } = new(40255,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec16 { get; set; } = new(40256,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec17 { get; set; } = new(40257,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec18 { get; set; } = new(40258,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec19 { get; set; } = new(40259,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec20 { get; set; } = new(40260,0,2,ModbusDataType.Bit);
public ModbusProperty<byte> MaterialDetec01 { get; set; } = new(40241);
public ModbusProperty<byte> MaterialDetec02 { get; set; } = new(40242);
public ModbusProperty<byte> MaterialDetec03 { get; set; } = new(40243);
public ModbusProperty<byte> MaterialDetec04 { get; set; } = new(40244);
public ModbusProperty<byte> MaterialDetec05 { get; set; } = new(40245);
public ModbusProperty<byte> MaterialDetec06 { get; set; } = new(40246);
public ModbusProperty<byte> MaterialDetec07 { get; set; } = new(40247);
public ModbusProperty<byte> MaterialDetec08 { get; set; } = new(40248);
public ModbusProperty<byte> MaterialDetec09 { get; set; } = new(40249);
public ModbusProperty<byte> MaterialDetec10 { get; set; } = new(40250);
public ModbusProperty<byte> MaterialDetec11 { get; set; } = new(40251);
public ModbusProperty<byte> MaterialDetec12 { get; set; } = new(40252);
public ModbusProperty<byte> MaterialDetec13 { get; set; } = new(40253);
public ModbusProperty<byte> MaterialDetec14 { get; set; } = new(40254);
public ModbusProperty<byte> MaterialDetec15 { get; set; } = new(40255);
public ModbusProperty<byte> MaterialDetec16 { get; set; } = new(40256);
public ModbusProperty<byte> MaterialDetec17 { get; set; } = new(40257);
public ModbusProperty<byte> MaterialDetec18 { get; set; } = new(40258);
public ModbusProperty<byte> MaterialDetec19 { get; set; } = new(40259);
public ModbusProperty<byte> MaterialDetec20 { get; set; } = new(40260);
#endregion 舱位状态
/// <summary>
/// 备用
/// </summary>
public ModbusProperty<string> value11 { get; set; } = new(40281, length: 20);
//public ModbusProperty<string> value11 { get; set; } = new(40281, length: 20);
/// <summary>
/// 载行车设备状态
/// <para>0无效值</para>
@ -127,7 +127,7 @@ namespace Service.Plc.Msg
/// z轴扭矩百分比
/// </summary>
public ModbusProperty<short> PercentageTorqueZ { get; set; } = new(40308);
public ModbusProperty<string> value20 { get; set; } = new(40309, length: 92); // 备用
//public ModbusProperty<string> value20 { get; set; } = new(40309, length: 92); // 备用
/// <summary>
/// 入口雷达状态
/// 0未触发
@ -229,7 +229,7 @@ namespace Service.Plc.Msg
/// z偏差
/// </summary>
public ModbusProperty<short> DeviationZ { get; set; } = new(40413);
public ModbusProperty<string> value44 { get; set; } = new(40414, length: 7); // 备用
//public ModbusProperty<string> value44 { get; set; } = new(40414, length: 7); // 备用

@ -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",

@ -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",

@ -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",

@ -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": {

@ -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",

Loading…
Cancel
Save