diff --git a/Service/Cloud/Common/CloudConst.cs b/Service/Cloud/Common/CloudConst.cs index b573cdb..8b6bd80 100644 --- a/Service/Cloud/Common/CloudConst.cs +++ b/Service/Cloud/Common/CloudConst.cs @@ -60,6 +60,26 @@ public class CloudConst public static readonly string chargeDevDataInfo = "chargeDevDataInfo"; public static readonly string chargeDevDataInfoRes = "chargeDevDataInfoRes"; public static readonly string batDataInfo = "batDataInfo"; + public static readonly string batDataInfoRes = "batDataInfoRes"; + public static readonly string batteryTotalRes = "batteryTotalRes"; + public static readonly string meterDayEnergyValRes = "meterDayEnergyValRes"; + public static readonly string meterEnergyKwhRes = "meterEnergyKwhRes"; + public static readonly string powerTotalRes = "powerTotalRes"; + public static readonly string staChargingTotalRes = "staChargingTotalRes"; + public static readonly string staDayEnergyValRes = "staDayEnergyValRes"; + public static readonly string staDayOpeEnergyValRes = "staDayOpeEnergyValRes"; + public static readonly string staHourAmountValRes = "staHourAmountValRes"; + public static readonly string staHourEnergyValRes = "staHourEnergyValRes"; + public static readonly string batteryTotal = "batteryTotal"; + public static readonly string chargingTotalDis = "chargingTotalDis"; + public static readonly string meterDayEnergyVal = "meterDayEnergyVal"; + public static readonly string staHourEnergyVal = "staHourEnergyVal"; + public static readonly string staHourAmountVal = "staHourAmountVal"; + public static readonly string staDayEnergyVal = "staDayEnergyVal"; + public static readonly string staChargingTotal = "staChargingTotal"; + public static readonly string meterEnergyKwh = "meterEnergyKwh"; + public static readonly string powerTotal = "powerTotal"; + public static readonly string staDayOpeEnergyVal = "staDayOpeEnergyVal"; /// /// 站外 diff --git a/Service/Cloud/Msg/Cloud/Resp/BatDataInfoRes.cs b/Service/Cloud/Msg/Cloud/Resp/BatDataInfoRes.cs index 21d63eb..03f63a1 100644 --- a/Service/Cloud/Msg/Cloud/Resp/BatDataInfoRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/BatDataInfoRes.cs @@ -1,6 +1,8 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; -public class BatDataInfoRes +namespace Service.Cloud.Msg.Cloud.Resp; + +public class BatDataInfoRes : ICmd { /// /// 应答结果 @@ -8,4 +10,9 @@ public class BatDataInfoRes /// /// public byte re { get; set; } + + public string GetCmd() + { + return CloudConst.batDataInfoRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/BatteryTotalRes.cs b/Service/Cloud/Msg/Cloud/Resp/BatteryTotalRes.cs index 8e35133..b8082d6 100644 --- a/Service/Cloud/Msg/Cloud/Resp/BatteryTotalRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/BatteryTotalRes.cs @@ -1,6 +1,8 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; -public class BatteryTotalRes +namespace Service.Cloud.Msg.Cloud.Resp; + +public class BatteryTotalRes : ICmd { /// /// 应答结果 @@ -8,4 +10,8 @@ public class BatteryTotalRes /// /// public byte re { get; set; } + public string GetCmd() + { + return CloudConst.batteryTotalRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/ChargeDevDataInfoRes.cs b/Service/Cloud/Msg/Cloud/Resp/ChargeDevDataInfoRes.cs index b216dfb..f38f803 100644 --- a/Service/Cloud/Msg/Cloud/Resp/ChargeDevDataInfoRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/ChargeDevDataInfoRes.cs @@ -10,7 +10,7 @@ namespace Service.Cloud.Msg.Cloud.Resp /// /// 4.2.10.2 云平台应答充电机的遥测数据上报 /// - public class ChargeDevDataInfoRes + public class ChargeDevDataInfoRes : ICmd { /// /// 应答结果0成功1失败 diff --git a/Service/Cloud/Msg/Cloud/Resp/ChargingTotalDisRes.cs b/Service/Cloud/Msg/Cloud/Resp/ChargingTotalDisRes.cs index a60cdbe..8d1ad38 100644 --- a/Service/Cloud/Msg/Cloud/Resp/ChargingTotalDisRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/ChargingTotalDisRes.cs @@ -1,12 +1,19 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Cloud.Resp; /// /// 5.2.4 后台服务器应答换电站充电电池电量分布统计信息 /// -public class ChargingTotalDisRes +public class ChargingTotalDisRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + + public string GetCmd() + { + return CloudConst.chargeDevDataInfoRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/EqmStateEndLogInfoRes.cs b/Service/Cloud/Msg/Cloud/Resp/EqmStateEndLogInfoRes.cs index 94bf692..e591c6a 100644 --- a/Service/Cloud/Msg/Cloud/Resp/EqmStateEndLogInfoRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/EqmStateEndLogInfoRes.cs @@ -1,6 +1,8 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; -public class EqmStateEndLogInfoRes +namespace Service.Cloud.Msg.Cloud.Resp; + +public class EqmStateEndLogInfoRes : ICmd { /// /// 接收结果 0:成功 1:失败 @@ -11,4 +13,8 @@ public class EqmStateEndLogInfoRes /// public string rs {get;set;} // + public string GetCmd() + { + return CloudConst.eqmStateEndLogInfoRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/MeterDayEnergyValRes.cs b/Service/Cloud/Msg/Cloud/Resp/MeterDayEnergyValRes.cs index 50cbb69..a4d20f9 100644 --- a/Service/Cloud/Msg/Cloud/Resp/MeterDayEnergyValRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/MeterDayEnergyValRes.cs @@ -1,9 +1,16 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; -public class MeterDayEnergyValRes +namespace Service.Cloud.Msg.Cloud.Resp; + +public class MeterDayEnergyValRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + + public string GetCmd() + { + return CloudConst.meterDayEnergyValRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/MeterEnergyKwhRes.cs b/Service/Cloud/Msg/Cloud/Resp/MeterEnergyKwhRes.cs index 517647b..dcaf009 100644 --- a/Service/Cloud/Msg/Cloud/Resp/MeterEnergyKwhRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/MeterEnergyKwhRes.cs @@ -1,12 +1,19 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Cloud.Resp; /// /// 0 后台服务器返回电能表小时能耗值信息 /// -public class MeterEnergyKwhRes +public class MeterEnergyKwhRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + + public string GetCmd() + { + return CloudConst.meterEnergyKwhRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/PowerTotalRes.cs b/Service/Cloud/Msg/Cloud/Resp/PowerTotalRes.cs index edaf24a..cc8ba56 100644 --- a/Service/Cloud/Msg/Cloud/Resp/PowerTotalRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/PowerTotalRes.cs @@ -1,12 +1,19 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Cloud.Resp; /// /// 5.2.6 后台服务器应答电能表累计值信息 /// -public class PowerTotalRes +public class PowerTotalRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + + public string GetCmd() + { + return CloudConst.powerTotalRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/StaChargingTotalRes.cs b/Service/Cloud/Msg/Cloud/Resp/StaChargingTotalRes.cs index d4c7e11..162180a 100644 --- a/Service/Cloud/Msg/Cloud/Resp/StaChargingTotalRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/StaChargingTotalRes.cs @@ -1,12 +1,19 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Cloud.Resp; /// /// 后台服务器应答电能表变化值信息 /// -public class StaChargingTotalRes +public class StaChargingTotalRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + + public string GetCmd() + { + return CloudConst.staChargingTotalRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/StaDayEnergyValRes.cs b/Service/Cloud/Msg/Cloud/Resp/StaDayEnergyValRes.cs index cb2157f..d6ef56d 100644 --- a/Service/Cloud/Msg/Cloud/Resp/StaDayEnergyValRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/StaDayEnergyValRes.cs @@ -1,9 +1,16 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; -public class StaDayEnergyValRes +namespace Service.Cloud.Msg.Cloud.Resp; + +public class StaDayEnergyValRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + + public string GetCmd() + { + return CloudConst.staDayEnergyValRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/StaDayOpeEnergyValRes.cs b/Service/Cloud/Msg/Cloud/Resp/StaDayOpeEnergyValRes.cs index d98422c..bcb88a2 100644 --- a/Service/Cloud/Msg/Cloud/Resp/StaDayOpeEnergyValRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/StaDayOpeEnergyValRes.cs @@ -1,12 +1,18 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Cloud.Resp; /// /// 5.2.18 后台服务器换电站日运行统计结果信息 /// -public class StaDayOpeEnergyValRes +public class StaDayOpeEnergyValRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + public string GetCmd() + { + return CloudConst.staDayOpeEnergyValRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/StaHourAmountValRes.cs b/Service/Cloud/Msg/Cloud/Resp/StaHourAmountValRes.cs index deb6c32..a2e3368 100644 --- a/Service/Cloud/Msg/Cloud/Resp/StaHourAmountValRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/StaHourAmountValRes.cs @@ -1,12 +1,18 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Cloud.Resp; /// /// 5.2.20 后台应答服务器换电站分时用电统计信息 /// -public class StaHourAmountValRes +public class StaHourAmountValRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + public string GetCmd() + { + return CloudConst.staHourAmountValRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Cloud/Resp/StaHourEnergyValRes.cs b/Service/Cloud/Msg/Cloud/Resp/StaHourEnergyValRes.cs index 5584c17..e368609 100644 --- a/Service/Cloud/Msg/Cloud/Resp/StaHourEnergyValRes.cs +++ b/Service/Cloud/Msg/Cloud/Resp/StaHourEnergyValRes.cs @@ -1,12 +1,18 @@ -namespace Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Cloud.Resp; /// /// 4 后台服务器换电站分时用电统计信息 /// -public class StaHourEnergyValRes +public class StaHourEnergyValRes : ICmd { /// /// 接收结果 0:成功 1:失败 /// public byte re {get;set;} + public string GetCmd() + { + return CloudConst.staHourEnergyValRes; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/BatDataInfo.cs b/Service/Cloud/Msg/Host/Req/BatDataInfo.cs index 0a91b8f..8045e04 100644 --- a/Service/Cloud/Msg/Host/Req/BatDataInfo.cs +++ b/Service/Cloud/Msg/Host/Req/BatDataInfo.cs @@ -27,4 +27,93 @@ namespace Service.Cloud.Msg.Host.Req return CloudConst.batDataInfo; } } + + public class SingleBatInfo + { + /// + /// 电池序列号 + /// + public string bn { get; set; } + + /// + /// 充电架 ID 按电池架的编号 A1,A2… + /// + public string sd { get; set; } + + /// + /// 所在充电机序号 从 1 开始递增 + /// + public int cno { get; set; } + + /// + /// 是否在充电 0:未知 1:正在充电 2:未电池 + /// + public int hc { get; set; } + + /// + /// 电接头连接状态 0:未知 1:已经连接 2:未连接 + /// + public int el { get; set; } + + /// + /// 剩余能量 单位 0.1 kwh + /// + public float soe { get; set; } + + /// + /// 当前 SOC 0-100 单位 0.1 ,没有充电填 0 + /// + public float soc { get; set; } + + /// + /// 当前 SOH 0-100 单位 0.1 ,没有充电填 0 + /// + public float soh { get; set; } + + /// + /// 最低单体电压 单位 0.01V + /// + public float lsv { get; set; } + + /// + /// 最高单体电压 单位 0.01V + /// + public float hsv { get; set; } + + /// + /// 最低单体温度 单位 0.1℃ + /// + public float lst { get; set; } + + /// + /// 最高单体温度 单位 0.1℃ + /// + public float hst { get; set; } + + /// + /// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ” + /// + public DateTime bt { get; set; } + + public List sgl_info = new List(); + } + + public class SglInfo + { + /// + /// 单体电池号 从 1 开始递增 + /// + public int sl { get; set; } + + /// + /// 单体电压 每一节电芯的单体电压 单位 0.1V ,如果没有该节电芯的数据,填65535.0 无效值 + /// + public float sv { get; set; } + + /// + /// 单体温度 每一节电芯的单体温度 单位 0.1℃ ,如果没有该节电芯的数据,填65535.0 无效值 + /// + public float st { get; set; } + + } } diff --git a/Service/Cloud/Msg/Host/Req/BatteryTotal.cs b/Service/Cloud/Msg/Host/Req/BatteryTotal.cs index bc9d007..333d2bc 100644 --- a/Service/Cloud/Msg/Host/Req/BatteryTotal.cs +++ b/Service/Cloud/Msg/Host/Req/BatteryTotal.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.1 换电站上报电池状态分布统计信息 /// -public class BatteryTotal +public class BatteryTotal : ICmd { /// /// 换电站编码 换电站唯一码,区域码+类型码+流水号 @@ -41,5 +43,8 @@ public class BatteryTotal /// 更新时间 格式” yyyy-MM-dd HH:mm:ss” /// public DateTime ut { get; set; } - + public string GetCmd() + { + return CloudConst.batteryTotal; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/ChargingTotalDis.cs b/Service/Cloud/Msg/Host/Req/ChargingTotalDis.cs index 4250f10..3489701 100644 --- a/Service/Cloud/Msg/Host/Req/ChargingTotalDis.cs +++ b/Service/Cloud/Msg/Host/Req/ChargingTotalDis.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.3 换电站充电电池电量分布统计信息 /// -public class ChargingTotalDis +public class ChargingTotalDis : ICmd { /// /// 换电站编码 换电站唯一码,区域码+ 类型码+流水号 @@ -29,4 +31,8 @@ public class ChargingTotalDis /// 低电量电池数量 0%--80%(同型号) /// public int lc { get; set; } + public string GetCmd() + { + return CloudConst.chargingTotalDis; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/EqmStateEndLogInfo.cs b/Service/Cloud/Msg/Host/Req/EqmStateEndLogInfo.cs index d8ab784..2ab5721 100644 --- a/Service/Cloud/Msg/Host/Req/EqmStateEndLogInfo.cs +++ b/Service/Cloud/Msg/Host/Req/EqmStateEndLogInfo.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// /// -public class EqmStateEndLogInfo +public class EqmStateEndLogInfo : ICmd { /// /// 设备编号 无辅助设备(场站码+00000) @@ -33,4 +35,8 @@ public class EqmStateEndLogInfo /// 采集模式 1: 自动;2:人工录入 /// public int cm {get;set;} // + public string GetCmd() + { + return CloudConst.eqmStateEndLogInfo; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/MeterDayEnergyVal.cs b/Service/Cloud/Msg/Host/Req/MeterDayEnergyVal.cs index fbec0de..c613cad 100644 --- a/Service/Cloud/Msg/Host/Req/MeterDayEnergyVal.cs +++ b/Service/Cloud/Msg/Host/Req/MeterDayEnergyVal.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.11 电能表每天能耗值信息 /// -public class MeterDayEnergyVal +public class MeterDayEnergyVal : ICmd { /// /// 换电站编码 @@ -33,4 +35,8 @@ public class MeterDayEnergyVal /// 结束时间 精确到天。格式” yyyy-MM-dd ” /// public DateTime et { get; set; } + public string GetCmd() + { + return CloudConst.meterDayEnergyVal; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs b/Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs index 0d7a658..1698500 100644 --- a/Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs +++ b/Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.9 电能表小时能耗值信息 /// -public class MeterEnergyKwh +public class MeterEnergyKwh : ICmd { /// /// 换电站编码 @@ -33,4 +35,8 @@ public class MeterEnergyKwh /// 结束时间 格式” yyyy-MM-dd HH:mm:ss ” /// public DateTime et { get; set; } + public string GetCmd() + { + return CloudConst.meterEnergyKwh; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/PowerTotal.cs b/Service/Cloud/Msg/Host/Req/PowerTotal.cs index 80d6ed0..16620ea 100644 --- a/Service/Cloud/Msg/Host/Req/PowerTotal.cs +++ b/Service/Cloud/Msg/Host/Req/PowerTotal.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.5 电能表累计值信息 /// -public class PowerTotal +public class PowerTotal : ICmd { /// /// 换电站编码 @@ -25,4 +27,8 @@ public class PowerTotal /// 累积值 单位:kWh,保留两位 小数 /// public float mk { get; set; } + public string GetCmd() + { + return CloudConst.powerTotal; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/RealTimeFaultInfo.cs b/Service/Cloud/Msg/Host/Req/RealTimeFaultInfo.cs index 51ade31..ab221ad 100644 --- a/Service/Cloud/Msg/Host/Req/RealTimeFaultInfo.cs +++ b/Service/Cloud/Msg/Host/Req/RealTimeFaultInfo.cs @@ -1,4 +1,4 @@ -using Service.Cloud.Common; + using Service.Cloud.Common; using System; using System.Collections.Generic; using System.Linq; diff --git a/Service/Cloud/Msg/Host/Req/SingleBatInfo.cs b/Service/Cloud/Msg/Host/Req/SingleBatInfo.cs index 602eed3..d370259 100644 --- a/Service/Cloud/Msg/Host/Req/SingleBatInfo.cs +++ b/Service/Cloud/Msg/Host/Req/SingleBatInfo.cs @@ -1,84 +1,91 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; public class SingleBatInfo { /// - /// 电池序列号 - /// - public string bn { get; set; } - - /// - /// 充电架 ID 按电池架的编号 A1,A2… - /// - public string sd { get; set; } - - /// - /// 所在充电机序号 从 1 开始递增 - /// - public int cno { get; set; } - - /// - /// 是否在充电 0:未知 1:正在充电 2:未电池 - /// - public int hc { get; set; } - - /// - /// 电接头连接状态 0:未知 1:已经连接 2:未连接 - /// - public int el { get; set; } - - /// - /// 剩余能量 单位 0.1 kwh - /// - public float soe { get; set; } - - /// - /// 当前 SOC 0-100 单位 0.1 ,没有充电填 0 - /// - public float soc { get; set; } - - /// - /// 当前 SOH 0-100 单位 0.1 ,没有充电填 0 - /// - public float soh { get; set; } - - /// - /// 最低单体电压 单位 0.01V - /// - public float lsv { get; set; } - - /// - /// 最高单体电压 单位 0.01V - /// - public float hsv { get; set; } - - /// - /// 最低单体温度 单位 0.1℃ - /// - public float lst { get; set; } - - /// - /// 最高单体温度 单位 0.1℃ - /// - public float hst { get; set; } - - /// - /// 单体电池号 从 1 开始递增 - /// - public int sl { get; set; } - - /// - /// 单体电压 每一节电芯的单体电压 单位 0.1V ,如果没有该节电芯的数据,填65535.0 无效值 - /// - public float sv { get; set; } - - /// - /// 单体温度 每一节电芯的单体温度 单位 0.1℃ ,如果没有该节电芯的数据,填65535.0 无效值 - /// - public float st { get; set; } - - /// - /// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ” - /// - public DateTime bt { get; set; } -} + /// 电池序列号 + /// + public string bn { get; set; } + + /// + /// 充电架 ID 按电池架的编号 A1,A2… + /// + public string sd { get; set; } + + /// + /// 所在充电机序号 从 1 开始递增 + /// + public int cno { get; set; } + + /// + /// 是否在充电 0:未知 1:正在充电 2:未电池 + /// + public int hc { get; set; } + + /// + /// 电接头连接状态 0:未知 1:已经连接 2:未连接 + /// + public int el { get; set; } + + /// + /// 剩余能量 单位 0.1 kwh + /// + public float soe { get; set; } + + /// + /// 当前 SOC 0-100 单位 0.1 ,没有充电填 0 + /// + public float soc { get; set; } + + /// + /// 当前 SOH 0-100 单位 0.1 ,没有充电填 0 + /// + public float soh { get; set; } + + /// + /// 最低单体电压 单位 0.01V + /// + public float lsv { get; set; } + + /// + /// 最高单体电压 单位 0.01V + /// + public float hsv { get; set; } + + /// + /// 最低单体温度 单位 0.1℃ + /// + public float lst { get; set; } + + /// + /// 最高单体温度 单位 0.1℃ + /// + public float hst { get; set; } + + /// + /// 单体电池号 从 1 开始递增 + /// + public int sl { get; set; } + + /// + /// 单体电压 每一节电芯的单体电压 单位 0.1V ,如果没有该节电芯的数据,填65535.0 无效值 + /// + public float sv { get; set; } + + /// + /// 单体温度 每一节电芯的单体温度 单位 0.1℃ ,如果没有该节电芯的数据,填65535.0 无效值 + /// + public float st { get; set; } + + /// + /// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ” + /// + public DateTime bt { get; set; } + + public string GetCmd() + { + return CloudConst.batDataInfo; + } +} \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/StaChargingTotal.cs b/Service/Cloud/Msg/Host/Req/StaChargingTotal.cs index fd9bc3d..b8cc7f8 100644 --- a/Service/Cloud/Msg/Host/Req/StaChargingTotal.cs +++ b/Service/Cloud/Msg/Host/Req/StaChargingTotal.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.7 换电站电能表变化值信息 /// -public class StaChargingTotal +public class StaChargingTotal : ICmd { /// /// 换电站编码 @@ -33,4 +35,8 @@ public class StaChargingTotal /// 结束时间 格式” yyyy-MM-dd HH:mm:ss ” /// public DateTime et { get; set; } + public string GetCmd() + { + return CloudConst.staChargingTotal; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs b/Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs index 91f7cac..907856f 100644 --- a/Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs +++ b/Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.15 换电站每天用电统计信息 /// -public class StaDayEnergyVal +public class StaDayEnergyVal : ICmd { /// /// 换电站编码 @@ -33,4 +35,8 @@ public class StaDayEnergyVal /// 结束时间 精确到天。格式”yyyy-MM-dd”(如2020-11-21) /// public DateTime et { get; set; } + public string GetCmd() + { + return CloudConst.staDayEnergyVal; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/StaDayOpeEnergyVal.cs b/Service/Cloud/Msg/Host/Req/StaDayOpeEnergyVal.cs similarity index 91% rename from Service/Cloud/Msg/Host/StaDayOpeEnergyVal.cs rename to Service/Cloud/Msg/Host/Req/StaDayOpeEnergyVal.cs index de4f446..b70b779 100644 --- a/Service/Cloud/Msg/Host/StaDayOpeEnergyVal.cs +++ b/Service/Cloud/Msg/Host/Req/StaDayOpeEnergyVal.cs @@ -1,4 +1,6 @@ -namespace Service.Cloud.Msg.Host; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host; /// /// 5.2.17 换电站日运行统计结果信息 @@ -61,4 +63,10 @@ public class StaDayOpeEnergyVal /// 换电日期 精确到 日。格式 ” yyyy-MM-dd”(如2020-11-20) /// public DateTime dt { get; set; } + + + public string GetCmd() + { + return CloudConst.staDayOpeEnergyVal; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/StaHourAmountVal.cs b/Service/Cloud/Msg/Host/Req/StaHourAmountVal.cs index c61c66e..39ac0bb 100644 --- a/Service/Cloud/Msg/Host/Req/StaHourAmountVal.cs +++ b/Service/Cloud/Msg/Host/Req/StaHourAmountVal.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.19 换电站分时用电计费信息 /// -public class StaHourAmountVal +public class StaHourAmountVal : ICmd { /// /// 换电站编码 @@ -33,4 +35,8 @@ public class StaHourAmountVal /// 结束时间 精确到小时。格式 ”yyyy-MM-dd HH:mm:ss”(如 2020-11-20 19:00:00) /// public DateTime et { get; set; } + public string GetCmd() + { + return CloudConst.staHourAmountVal; + } } \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/StaHourEnergyVal.cs b/Service/Cloud/Msg/Host/Req/StaHourEnergyVal.cs index d30be33..b3ccfb9 100644 --- a/Service/Cloud/Msg/Host/Req/StaHourEnergyVal.cs +++ b/Service/Cloud/Msg/Host/Req/StaHourEnergyVal.cs @@ -1,9 +1,11 @@ -namespace Service.Cloud.Msg.Host.Req; +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req; /// /// 5.2.13 换电站分时用电统计信息 /// -public class StaHourEnergyVal +public class StaHourEnergyVal : ICmd { /// /// 换电站编码 @@ -33,4 +35,8 @@ public class StaHourEnergyVal /// 结束时间 精确到小时。格式”yyyy-MM-ddHH:mm:ss ”(如2020/11/20 18:00:00) /// public DateTime et { get; set; } + public string GetCmd() + { + return CloudConst.staHourEnergyVal; + } } \ No newline at end of file diff --git a/Service/MyTask/PlcHeartTask.cs b/Service/MyTask/PlcHeartTask.cs index 27b64f0..54b926f 100644 --- a/Service/MyTask/PlcHeartTask.cs +++ b/Service/MyTask/PlcHeartTask.cs @@ -30,8 +30,10 @@ public class PlcHeartTask: ITask public void Handle() { + Log.Info("Plc start write heart"); if (PlcMgr.PlcClient != null) { + Log.Info("Plc write connect and satrt set value"); heart = !heart; HostToPlc writeHostToPlc = new HostToPlc(); writeHostToPlc.ProtocolVersion1.Value = 2; @@ -73,7 +75,11 @@ public class PlcHeartTask: ITask bool writeCharge7 = PlcMgr.PlcClient.WriteValue(writeHostToPlc.ChargingStatus07); bool writeCharge8 = PlcMgr.PlcClient.WriteValue(writeHostToPlc.ChargingStatus08); - + Log.Info("Plc write finish"); + } + else + { + Log.Info("Plc write not connect"); } } diff --git a/Service/Plc/Client/PlcClient.cs b/Service/Plc/Client/PlcClient.cs index c57faa2..daf28dc 100644 --- a/Service/Plc/Client/PlcClient.cs +++ b/Service/Plc/Client/PlcClient.cs @@ -15,10 +15,9 @@ namespace Service.Plc.Client; [Scope] public class PlcClient : ModbusTcpMaster { - private static readonly ILog Log = LogManager.GetLogger(typeof(PlcClient)); - private long TaskNo=0; + private long TaskNo = 0; public BinInfoRepository BinInfoRepository { get; set; } public EquipAlarmDefineRepository EquipAlarmDefineRepository { get; set; } public EquipAlarmRecordRepository EquipAlarmRecordRepository { get; set; } @@ -40,8 +39,7 @@ public class PlcClient : ModbusTcpMaster //读取当前任务 public long ReadTaskNo() { - - return Interlocked.Read( ref TaskNo); + return Interlocked.Read(ref TaskNo); } public PlcClient() @@ -52,65 +50,140 @@ public class PlcClient : ModbusTcpMaster Duration = 1000; AutoReConnect = true; ByteSeq = EndingConst.ByteSeq.BA; - WordSeq= EndingConst.WordSeq.CD; + WordSeq = EndingConst.WordSeq.CD; } private void BatchRead(ModbusTcpMaster master) { - var bytes01 = master.BatchReadHolderRegister(1, 115); - if (bytes01 != null) + try { - PlcMgr.DataValidityTime = DateTime.Now; + Log.Info("Plc read satrt"); + if (master != null) + { + var bytes01 = master.BatchReadHolderRegister(1, 115); + if (bytes01 != null) + { + PlcMgr.DataValidityTime = DateTime.Now; - ModbusDecoder.Decode(bytes01, PlcMgr.HostToPlcData, EndingConst.ByteSeq.AB, - EndingConst.WordSeq.DC); - } + ModbusDecoder.Decode(bytes01, PlcMgr.HostToPlcData, EndingConst.ByteSeq.AB, + EndingConst.WordSeq.DC); + } - var bytes02 = master.BatchReadHolderRegister(201, 222); - if (bytes02 != null) - { - PlcMgr.DataValidityTime = DateTime.Now; - ModbusDecoder.Decode(bytes02, PlcMgr.PlcToHostData, EndingConst.ByteSeq.AB, - EndingConst.WordSeq.DC); - - UpdateBinInfoCache(PlcMgr.PlcToHostData.MaterialDetec01.Value, "1"); - UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec02.Value, "2"); - UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec03.Value, "3"); - UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec04.Value, "4"); - UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec05.Value, "5"); - UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec06.Value, "6"); - UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec07.Value, "7"); - UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec08.Value, "8"); + var bytes02 = master.BatchReadHolderRegister(201, 222); + if (bytes02 != null) + { + PlcMgr.DataValidityTime = DateTime.Now; + ModbusDecoder.Decode(bytes02, PlcMgr.PlcToHostData, EndingConst.ByteSeq.AB, + EndingConst.WordSeq.DC); + + UpdateBinInfoCache(PlcMgr.PlcToHostData.MaterialDetec01.Value, "1"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec02.Value, "2"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec03.Value, "3"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec04.Value, "4"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec05.Value, "5"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec06.Value, "6"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec07.Value, "7"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec08.Value, "8"); + } - } + var bytes03 = master.BatchReadHolderRegister(701, 32); + if (bytes03 != null) + { + PlcMgr.LastPlcFaultData = PlcMgr.PlcFaultData; + PlcMgr.DataValidityTime = DateTime.Now; + ModbusDecoder.Decode(bytes03, PlcMgr.PlcFaultData, EndingConst.ByteSeq.AB, + EndingConst.WordSeq.CD); + List alarm = new List() + { + PlcMgr.PlcFaultData.ErrorCode01.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode02.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode03.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode04.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode05.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode06.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode07.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode08.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode09.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode10.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode11.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode12.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode13.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode14.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode15.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode16.Value.ToString(), + }; + SaveAlarmInfo(alarm); + } + + Log.Info("Plc read finish"); + } + else if(PlcMgr.PlcClient!=null) + { + Log.Info("Plc use plcClient read"); + + var bytes01 = PlcMgr.PlcClient.BatchReadHolderRegister(1, 115); + if (bytes01 != null) + { + PlcMgr.DataValidityTime = DateTime.Now; + + ModbusDecoder.Decode(bytes01, PlcMgr.HostToPlcData, EndingConst.ByteSeq.AB, + EndingConst.WordSeq.DC); + } - var bytes03 = master.BatchReadHolderRegister(701, 32); - if (bytes03 != null) + var bytes02 = PlcMgr.PlcClient.BatchReadHolderRegister(201, 222); + if (bytes02 != null) + { + PlcMgr.DataValidityTime = DateTime.Now; + ModbusDecoder.Decode(bytes02, PlcMgr.PlcToHostData, EndingConst.ByteSeq.AB, + EndingConst.WordSeq.DC); + + UpdateBinInfoCache(PlcMgr.PlcToHostData.MaterialDetec01.Value, "1"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec02.Value, "2"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec03.Value, "3"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec04.Value, "4"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec05.Value, "5"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec06.Value, "6"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec07.Value, "7"); + UpdateBinInfo(PlcMgr.PlcToHostData.MaterialDetec08.Value, "8"); + } + + var bytes03 = PlcMgr.PlcClient.BatchReadHolderRegister(701, 32); + if (bytes03 != null) + { + PlcMgr.LastPlcFaultData = PlcMgr.PlcFaultData; + PlcMgr.DataValidityTime = DateTime.Now; + ModbusDecoder.Decode(bytes03, PlcMgr.PlcFaultData, EndingConst.ByteSeq.AB, + EndingConst.WordSeq.CD); + List alarm = new List() + { + PlcMgr.PlcFaultData.ErrorCode01.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode02.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode03.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode04.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode05.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode06.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode07.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode08.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode09.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode10.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode11.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode12.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode13.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode14.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode15.Value.ToString(), + PlcMgr.PlcFaultData.ErrorCode16.Value.ToString(), + }; + SaveAlarmInfo(alarm); + } + + Log.Info("Plc read finish"); + } + + } + catch (Exception e) { - PlcMgr.LastPlcFaultData = PlcMgr.PlcFaultData; - PlcMgr.DataValidityTime = DateTime.Now; - ModbusDecoder.Decode(bytes03, PlcMgr.PlcFaultData, EndingConst.ByteSeq.AB, - EndingConst.WordSeq.CD); - List alarm = new List() - { - PlcMgr.PlcFaultData.ErrorCode01.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode02.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode03.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode04.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode05.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode06.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode07.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode08.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode09.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode10.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode11.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode12.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode13.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode14.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode15.Value.ToString(), - PlcMgr.PlcFaultData.ErrorCode16.Value.ToString(), - }; - SaveAlarmInfo(alarm); + Log.Info($"Plc read error:{e}"); + throw; } } @@ -161,8 +234,8 @@ public class PlcClient : ModbusTcpMaster { #region 有报警比较两边差异,新出现的报警就添加,消失的报警就处理并记录 - var lstEquipAlarmRecord=EquipAlarmRecordRepository.QueryListByClause(i => i.EquipTypeCode == 3); - var sqllstAlarm=lstEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList(); + var lstEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipTypeCode == 3); + var sqllstAlarm = lstEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList(); // 找出实时报警中存在但数据库中不存在的元素 List uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList(); @@ -171,10 +244,13 @@ public class PlcClient : ModbusTcpMaster List uniqueToList2 = sqllstAlarm.Except(lstAlarm).ToList(); if (uniqueToList1.Count > 0) - {//这里要添加新的报警数据 + { + //这里要添加新的报警数据 foreach (var errorCode in uniqueToList1) { - EquipAlarmDefine? alarmDefine = EquipAlarmDefineRepository.SelectByEquipCodeAndErrorCode((int)EquipmentType.Plc, plc, errorCode); + EquipAlarmDefine? alarmDefine = + EquipAlarmDefineRepository.SelectByEquipCodeAndErrorCode((int)EquipmentType.Plc, plc, + errorCode); if (alarmDefine != null) { EquipAlarmRecord record = new EquipAlarmRecord() @@ -185,7 +261,7 @@ public class PlcClient : ModbusTcpMaster ErrorLevel = alarmDefine.ErrorLevel, ErrorMsg = alarmDefine.ErrorMsg, ProcessMethod = alarmDefine.ProcessMethod, - StartTime= DateTime.Now + StartTime = DateTime.Now }; EquipAlarmRecordRepository.Insert(record); } @@ -193,7 +269,8 @@ public class PlcClient : ModbusTcpMaster } if (uniqueToList2.Count > 0) - {//这些是要清除实时报警,并且处理记录的。 + { + //这些是要清除实时报警,并且处理记录的。 // 使用LINQ找出ErrorCode在uniqueToList2中的EquipAlarmRecord对象 List filteredObjectList = lstEquipAlarmRecord .Where(obj => uniqueToList2.Contains(obj.ErrorCode)) @@ -208,10 +285,11 @@ public class PlcClient : ModbusTcpMaster EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg; EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod; EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime; - EquipAlarmProcessRecord.ProcessTime=DateTime.Now; + EquipAlarmProcessRecord.ProcessTime = DateTime.Now; EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord); } + EquipAlarmRecordRepository.Delete(filteredObjectList); } @@ -221,7 +299,7 @@ public class PlcClient : ModbusTcpMaster { #region 没报警把已处理记录更新并删除实时报警 - var lstEquipAlarmRecord=EquipAlarmRecordRepository.QueryListByClause(i=>i.EquipTypeCode==3); + var lstEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipTypeCode == 3); if (lstEquipAlarmRecord.Count > 0) { foreach (var VARIABLE in lstEquipAlarmRecord) @@ -234,16 +312,15 @@ public class PlcClient : ModbusTcpMaster EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg; EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod; EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime; - EquipAlarmProcessRecord.ProcessTime=DateTime.Now; + EquipAlarmProcessRecord.ProcessTime = DateTime.Now; EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord); } } + EquipAlarmRecordRepository.Delete(lstEquipAlarmRecord); #endregion - - } } @@ -252,7 +329,8 @@ public class PlcClient : ModbusTcpMaster if (exists == 0) BinInfoRepository.Update( it => - new BinInfo(){ + new BinInfo() + { Exists = 0, BatteryNo = "-1", Soc = (decimal)-1, @@ -264,7 +342,6 @@ public class PlcClient : ModbusTcpMaster BinInfoRepository.Update(it => it.Exists == 1, it => it.No == binNo); - } private void UpdateBinInfoCache(int exists, string binNo) @@ -272,15 +349,14 @@ public class PlcClient : ModbusTcpMaster if (exists == 0) BinInfoRepository.Update( it => - new BinInfo(){ + new BinInfo() + { Exists = 0, - }, it => it.No == binNo); else BinInfoRepository.Update(it => it.Exists == 1, it => it.No == binNo); - } -} +} \ No newline at end of file diff --git a/Service/Service.csproj b/Service/Service.csproj index 71c9246..5ce8eff 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -56,6 +56,7 @@ +