添加项目文件。

This commit is contained in:
2025-02-28 22:23:13 +08:00
parent d4ad2fe2de
commit 547a1b3bf6
416 changed files with 72830 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
public class BitHelper
{
/// <summary>
/// 获取字的高字节
/// </summary>
public static byte GetHByteUint16(ushort data)
{
return (byte)(data >> 8);//高位
}
/// <summary>
/// 获取字的低字节
/// </summary>
public static byte GetLByteUint16(ushort data)
{
return (byte)(data & 0xff);//低位
}
/// <summary>
/// 根据Int类型的值返回用1或0(对应True或Flase)填充的数组
/// <remarks>从右侧开始向左索引(0~31)</remarks>
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static IEnumerable<bool> GetBitList(int value)
{
var list = new List<bool>(32);
for (var i = 0; i <= 31; i++)
{
var val = 1 << i;
list.Add((value & val) == val);
}
return list;
}
/// <summary>
/// 返回Int数据中某一位是否为1
/// </summary>
/// <param name="value"></param>
/// <param name="index">32位数据的从右向左的偏移位索引(0~31)</param>
/// <returns>true表示该位为1false表示该位为0</returns>
public static bool GetBitValue(int value, ushort index)
{
if (index > 31) throw new ArgumentOutOfRangeException("index"); //索引出错
var val = 1 << index;
return (value & val) == val;
}
/// <summary>
/// 设定Int数据中某一位的值
/// </summary>
/// <param name="value">位设定前的值</param>
/// <param name="index">32位数据的从右向左的偏移位索引(0~31)</param>
/// <param name="bitValue">true设该位为1,false设为0</param>
/// <returns>返回位设定后的值</returns>
public static int SetBitValue(int value, ushort index, bool bitValue)
{
if (index > 31) throw new ArgumentOutOfRangeException("index"); //索引出错
var val = 1 << index;
return bitValue ? (value | val) : (value & ~val);
}
}
}

View File

@@ -0,0 +1,278 @@
using OrpaonEMS.App.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
public class BmsLoadData
{
public static List<BMSRoCell> GetRoData()
{
List<BMSRoCell> bMSRoCells = new List<BMSRoCell>()
{
new BMSRoCell(name:"电池簇电压",offset:0,ratio:0.1,index:0,lengh:1,address:"1",focus:true ,unit:"V"),
new BMSRoCell(name:"电池簇电流值",offset:-1600,ratio:0.1,index:2,lengh:1,address:"2",focus:true ,unit:"A"),
new BMSRoCell(name:"电池簇总SOC",offset:0,ratio:0.1,index:4,lengh:1,address:"3",focus:true ,unit:"%"),
new BMSRoCell(name:"电池簇总SOH",offset:0,ratio:1,index:6,lengh:1,address:"4",focus:true ,unit:"%"),
new BMSRoCell(name:"电池簇总SOE",offset:0,ratio:0.1,index:8,lengh:1,address:"5",focus:true ,unit:"%"),
new BMSRoCell(name:"电池簇绝缘电阻R+",offset:0,ratio:1,index:10,lengh:1,address:"6",focus:true ,unit:"kΩ"),
new BMSRoCell(name:"电池簇绝缘电阻R-",offset:0,ratio:1,index:12,lengh:1,address:"7",focus:true ,unit:"kΩ"),
new BMSRoCell(name:"电池簇电池状态",offset:0,ratio:1,index:14,lengh:1,address:"8",focus:true ,unit:""),
new BMSRoCell(name:"DI检测状态",offset:0,ratio:1,index:16,lengh:1,address:"9",focus:true ,unit:""),
new BMSRoCell(name:"DO输出状态",offset:0,ratio:1,index:18,lengh:1,address:"10",focus:true ,unit:""),
new BMSRoCell(name:"实际温度采集点数",offset:0,ratio:1,index:20,lengh:1,address:"11",focus:true ,unit:""),
new BMSRoCell(name:"电池最高温度",offset:-40,ratio:0.1,index:22,lengh:1,address:"12",focus:true ,unit:"℃"),
new BMSRoCell(name:"电池最高温度所在模块号",offset:0,ratio:1,index:24,lengh:1,address:"13",focus:true ,unit:""),
new BMSRoCell(name:"电池最高温度模块内序号",offset:0,ratio:1,index:26,lengh:1,address:"14",focus:true ,unit:""),
new BMSRoCell(name:"电池最低温度",offset:-40,ratio:0.1,index:28,lengh:1,address:"15",focus:true ,unit:"℃"),
new BMSRoCell(name:"电池最低温度所在模块号",offset:0,ratio:1,index:30,lengh:1,address:"16",focus:true ,unit:""),
new BMSRoCell(name:"电池最低温度模块内序号",offset:0,ratio:1,index:32,lengh:1,address:"17",focus:true ,unit:""),
new BMSRoCell(name:"电池平均温度",offset:-40,ratio:0.1,index:34,lengh:1,address:"18",focus:true ,unit:"℃"),
new BMSRoCell(name:"电池组电池总节数",offset:0,ratio:1,index:36,lengh:1,address:"19",focus:true ,unit:"节"),
new BMSRoCell(name:"单体平均电压",offset:0,ratio:0.001,index:38,lengh:1,address:"20",focus:true ,unit:"V"),
new BMSRoCell(name:"最高单体电压",offset:0,ratio:0.001,index:40,lengh:1,address:"21",focus:true ,unit:"V"),
new BMSRoCell(name:"最高单体电压所在模块号",offset:0,ratio:1,index:42,lengh:1,address:"22",focus:true ,unit:"号"),
new BMSRoCell(name:"最高单体电压模块内序号",offset:0,ratio:1,index:44,lengh:1,address:"23",focus:true ,unit:"号"),
new BMSRoCell(name:"最低单体电压",offset:0,ratio:0.001,index:46,lengh:1,address:"24",focus:true ,unit:"V"),
new BMSRoCell(name:"最低单体电压所在模块号",offset:0,ratio:1,index:48,lengh:1,address:"25",focus:true ,unit:"号"),
new BMSRoCell(name:"最低单体电压模块内序号",offset:0,ratio:1,index:50,lengh:1,address:"26",focus:true ,unit:"号"),
new BMSRoCell(name:"单体平均SOC",offset:0,ratio:0.1,index:52,lengh:1,address:"27",focus:true ,unit:"%"),
new BMSRoCell(name:"最高单体SOC",offset:0,ratio:0.1,index:54,lengh:1,address:"28",focus:true ,unit:"%"),
new BMSRoCell(name:"最高单体SOC所在模块号",offset:0,ratio:1,index:56,lengh:1,address:"29",focus:true ,unit:"号"),
new BMSRoCell(name:"最高单体SOC模块内序号",offset:0,ratio:1,index:58,lengh:1,address:"30",focus:true ,unit:"号"),
new BMSRoCell(name:"最低单体SOC",offset:0,ratio:0.1,index:60,lengh:1,address:"31",focus:true ,unit:"%"),
new BMSRoCell(name:"最低单体SOC所在模块号",offset:0,ratio:1,index:62,lengh:1,address:"32",focus:true ,unit:""),
new BMSRoCell(name:"最低单体SOC模块内序号",offset:0,ratio:1,index:64,lengh:1,address:"33",focus:true ,unit:""),
new BMSRoCell(name:"单体平均SOH",offset:0,ratio:0.1,index:66,lengh:1,address:"34",focus:true ,unit:"%"),
new BMSRoCell(name:"最高单体SOH",offset:0,ratio:0.1,index:68,lengh:1,address:"35",focus:true ,unit:"%"),
new BMSRoCell(name:"最高单体SOH所在模块号",offset:0,ratio:1,index:70,lengh:1,address:"36",focus:true ,unit:"号"),
new BMSRoCell(name:"最高单体SOH模块内序号",offset:0,ratio:1,index:72,lengh:1,address:"37",focus:true ,unit:"号"),
new BMSRoCell(name:"最低单体SOH",offset:0,ratio:0.1,index:74,lengh:1,address:"38",focus:true ,unit:"%"),
new BMSRoCell(name:"最低单体SOH所在模块号",offset:0,ratio:1,index:76,lengh:1,address:"39",focus:true ,unit:"号"),
new BMSRoCell(name:"最低单体SOH模块内序号",offset:0,ratio:1,index:78,lengh:1,address:"40",focus:true ,unit:"号"),
new BMSRoCell(name:"单体平均内阻",offset:0,ratio:1,index:80,lengh:1,address:"41",focus:true ,unit:"毫欧"),
new BMSRoCell(name:"最高单体内阻",offset:0,ratio:1,index:82,lengh:1,address:"42",focus:true ,unit:"毫欧"),
new BMSRoCell(name:"最高单体内阻所在模块号",offset:0,ratio:1,index:84,lengh:1,address:"43",focus:true ,unit:"号"),
new BMSRoCell(name:"最高单体内阻模块内序号",offset:0,ratio:1,index:86,lengh:1,address:"44",focus:true ,unit:"号"),
new BMSRoCell(name:"最低单体内阻",offset:0,ratio:1,index:88,lengh:1,address:"45",focus:true ,unit:""),
new BMSRoCell(name:"最低单体内阻所在模块号",offset:0,ratio:1,index:90,lengh:1,address:"46",focus:true ,unit:"号"),
new BMSRoCell(name:"最低单体内阻模块内序号",offset:0,ratio:1,index:92,lengh:1,address:"47",focus:true ,unit:"号"),
new BMSRoCell(name:"电池箱最高温度",offset:-40,ratio:0.1,index:94,lengh:1,address:"48",focus:true ,unit:"℃"),
new BMSRoCell(name:"电池箱最高温度所在模块号",offset:0,ratio:1,index:96,lengh:1,address:"49",focus:true ,unit:"号"),
new BMSRoCell(name:"电池箱最高温度模块内序号",offset:0,ratio:1,index:98,lengh:1,address:"50",focus:true ,unit:"号"),
new BMSRoCell(name:"电池箱最低温度",offset:-40,ratio:0.1,index:100,lengh:1,address:"51",focus:true ,unit:"℃"),
new BMSRoCell(name:"电池箱最低温度所在模块号",offset:0,ratio:1,index:102,lengh:1,address:"52",focus:true ,unit:"号"),
new BMSRoCell(name:"电池箱最低温度模块内序号",offset:0,ratio:1,index:104,lengh:1,address:"53",focus:true ,unit:"号"),
new BMSRoCell(name:"电池箱箱平均温度",offset:-40,ratio:0.1,index:106,lengh:1,address:"54",focus:true ,unit:"℃"),
new BMSRoCell(name:"电池模组最高电压值",offset:0,ratio:0.1,index:108,lengh:1,address:"55",focus:true ,unit:"V"),
new BMSRoCell(name:"电池模组最高电压序号",offset:0,ratio:1,index:110,lengh:1,address:"56",focus:true ,unit:"号"),
new BMSRoCell(name:"电池模组最低电压值",offset:0,ratio:0.1,index:112,lengh:1,address:"57",focus:true ,unit:"V"),
new BMSRoCell(name:"电池模组最低电压序号",offset:0,ratio:1,index:114,lengh:1,address:"58",focus:true ,unit:"号"),
new BMSRoCell(name:"累计充电电量",offset:0,ratio:0.1,index:116,lengh:2,address:"59",focus:true ,unit:"KWh"),
new BMSRoCell(name:"累计放电电量",offset:0,ratio:0.1,index:120,lengh:2,address:"61",focus:true ,unit:"KWh"),
new BMSRoCell(name:"单次充电电量",offset:0,ratio:0.1,index:124,lengh:1,address:"63",focus:true ,unit:"KWh"),
new BMSRoCell(name:"单次放电电量",offset:0,ratio:0.1,index:126,lengh:1,address:"64",focus:true ,unit:"KWh"),
new BMSRoCell(name:"累计充电次数",offset:0,ratio:1,index:128,lengh:1,address:"65",focus:true ,unit:"次"),
new BMSRoCell(name:"累计放电次数",offset:0,ratio:1,index:130,lengh:1,address:"66",focus:true ,unit:"次"),
new BMSRoCell(name:"电池组负载电压",offset:0,ratio:0.1,index:132,lengh:1,address:"67",focus:true ,unit:"V"),
new BMSRoCell(name:"电池组总电压-备用1",offset:0,ratio:0.1,index:134,lengh:1,address:"68",focus:true ,unit:"V"),
new BMSRoCell(name:"电池组电流值-备用1",offset:-1600,ratio:0.1,index:136,lengh:1,address:"69",focus:true ,unit:"A"),
new BMSRoCell(name:"电池组电流值-备用2",offset:-1600,ratio:0.1,index:138,lengh:1,address:"70",focus:true ,unit:"A"),
new BMSRoCell(name:"系统运行心跳",offset:0,ratio:1,index:140,lengh:1,address:"71",focus:true ,unit:""),
new BMSRoCell(name:"绝缘采集状态",offset:0,ratio:1,index:142,lengh:1,address:"72",focus:true ,unit:""),
new BMSRoCell(name:"系统告警状态",offset:0,ratio:1,index:144,lengh:1,address:"73",focus:true ,unit:""),
new BMSRoCell(name:"系统告警状态-故障码",offset:0,ratio:1,index:146,lengh:1,address:"74",focus:true ,unit:""),
new BMSRoCell(name:"系统告警状态-禁充/禁放解",offset:0,ratio:1,index:148,lengh:1,address:"75",focus:true ,unit:""),
new BMSRoCell(name:"系统告警状态-禁充/禁放解除时间",offset:0,ratio:1,index:150,lengh:1,address:"76",focus:true ,unit:"分钟"),
new BMSRoCell(name:"历史总故障个数",offset:0,ratio:1,index:152,lengh:1,address:"77",focus:true ,unit:"个"),
new BMSRoCell(name:"历史总故障-当前故障序号",offset:0,ratio:1,index:154,lengh:1,address:"78",focus:true ,unit:""),
new BMSRoCell(name:"历史总故障-故障码",offset:0,ratio:1,index:156,lengh:1,address:"79",focus:true ,unit:""),
new BMSRoCell(name:"故障信息1-电池簇总压",offset:0,ratio:0.1,index:158,lengh:1,address:"80",focus:true ,unit:"V"),
new BMSRoCell(name:"故障信息2-电池簇电流",offset:-1600,ratio:0.1,index:160,lengh:1,address:"81",focus:true ,unit:"A"),
new BMSRoCell(name:"故障信息3-电池簇SOC",offset:0,ratio:0.1,index:162,lengh:1,address:"82",focus:true ,unit:"%"),
new BMSRoCell(name:"故障信息4-绝缘电值",offset:0,ratio:1,index:164,lengh:1,address:"83",focus:true ,unit:"kΩ"),
new BMSRoCell(name:"故障信息5-最大电压",offset:0,ratio:0.001,index:166,lengh:1,address:"84",focus:true ,unit:"V"),
new BMSRoCell(name:"故障信息6-最大电压节号",offset:0,ratio:1,index:168,lengh:1,address:"85",focus:true ,unit:"号"),
new BMSRoCell(name:"故障信息7-最小电压",offset:0,ratio:0.001,index:170,lengh:1,address:"86",focus:true ,unit:"V"),
new BMSRoCell(name:"故障信息8-最小电压节号",offset:0,ratio:1,index:172,lengh:1,address:"87",focus:true ,unit:"号"),
new BMSRoCell(name:"故障信息9-最大温度",offset:-40,ratio:0.1,index:174,lengh:1,address:"88",focus:true ,unit:"℃"),
new BMSRoCell(name:"故障信息10-最大温度节号",offset:0,ratio:1,index:176,lengh:1,address:"89",focus:true ,unit:"号"),
new BMSRoCell(name:"故障信息11-最小温度",offset:-40,ratio:0.1,index:178,lengh:1,address:"90",focus:true ,unit:"℃"),
new BMSRoCell(name:"故障信息12-最小温度节号",offset:0,ratio:1,index:180,lengh:1,address:"91",focus:true ,unit:"号"),
new BMSRoCell(name:"故障信息13-DO状态",offset:0,ratio:1,index:182,lengh:1,address:"92",focus:true ,unit:""),
new BMSRoCell(name:"故障信息14-DI状态",offset:0,ratio:1,index:184,lengh:1,address:"93",focus:true ,unit:""),
new BMSRoCell(name:"故障信息15-年月",offset:0,ratio:1,index:186,lengh:1,address:"94",focus:true ,unit:""),
new BMSRoCell(name:"故障信息16-日时",offset:0,ratio:1,index:188,lengh:1,address:"95",focus:true ,unit:""),
new BMSRoCell(name:"故障信息17-分秒",offset:0,ratio:1,index:190,lengh:1,address:"96",focus:true ,unit:""),
new BMSRoCell(name:"最大允许充电电流",offset:0,ratio:0.1,index:298,lengh:1,address:"150",focus:true ,unit:"A"),
new BMSRoCell(name:"最大允许放电电流",offset:0,ratio:0.1,index:300,lengh:1,address:"151",focus:true ,unit:"A"),
new BMSRoCell(name:"最大允许充电功率",offset:0,ratio:0.1,index:302,lengh:1,address:"152",focus:true ,unit:"KW"),
new BMSRoCell(name:"最大允许放电功率",offset:0,ratio:0.1,index:304,lengh:1,address:"153",focus:true ,unit:"KW"),
new BMSRoCell(name:"最大单体电压节号",offset:0,ratio:1,index:306,lengh:1,address:"154",focus:true ,unit:""),
new BMSRoCell(name:"最小单体电压节号",offset:0,ratio:1,index:308,lengh:1,address:"155",focus:true ,unit:""),
new BMSRoCell(name:"最大单体温度节号",offset:0,ratio:1,index:310,lengh:1,address:"156",focus:true ,unit:""),
new BMSRoCell(name:"最小单体温度节号",offset:0,ratio:1,index:312,lengh:1,address:"157",focus:true ,unit:""),
new BMSRoCell(name:"最大SOC节号",offset:0,ratio:1,index:314,lengh:1,address:"158",focus:true ,unit:""),
new BMSRoCell(name:"最小SOC节号",offset:0,ratio:1,index:316,lengh:1,address:"159",focus:true ,unit:""),
new BMSRoCell(name:"最大SOH节号",offset:0,ratio:1,index:318,lengh:1,address:"160",focus:true ,unit:""),
new BMSRoCell(name:"最小SOH节号",offset:0,ratio:1,index:320,lengh:1,address:"161",focus:true ,unit:""),
new BMSRoCell(name:"最大电池内阻节号",offset:0,ratio:1,index:322,lengh:1,address:"162",focus:true ,unit:""),
new BMSRoCell(name:"最小电池内阻节号",offset:0,ratio:1,index:324,lengh:1,address:"163",focus:true ,unit:""),
new BMSRoCell(name:"单日累计充电电量-高字节",offset:0,ratio:0.1,index:326,lengh:1,address:"164",focus:true ,unit:"KWh"),
new BMSRoCell(name:"单日累计充电电量-低字节",offset:0,ratio:0.1,index:328,lengh:1,address:"165",focus:true ,unit:"KWh"),
new BMSRoCell(name:"单日累计放电电量-高字节",offset:0,ratio:0.1,index:330,lengh:1,address:"166",focus:true ,unit:"KWh"),
new BMSRoCell(name:"单日累计放电电量-低字节",offset:0,ratio:0.1,index:332,lengh:1,address:"167",focus:true ,unit:"KWh"),
new BMSRoCell(name:"主控采集NTC温度1",offset:-40,ratio:1,index:334,lengh:1,address:"168",focus:true ,unit:"℃"),
new BMSRoCell(name:"主控采集NTC温度2",offset:-40,ratio:1,index:336,lengh:1,address:"169",focus:true ,unit:"℃"),
new BMSRoCell(name:"主控采集NTC温度3",offset:-40,ratio:1,index:338,lengh:1,address:"170",focus:true ,unit:"℃"),
new BMSRoCell(name:"主控采集NTC温度4",offset:-40,ratio:1,index:340,lengh:1,address:"171",focus:true ,unit:"℃"),
new BMSRoCell(name:"通讯协议版本号主版本",offset:0,ratio:1,index:398,lengh:1,address:"200",focus:true ,unit:""),
new BMSRoCell(name:"通讯协议版本号子版本",offset:0,ratio:1,index:400,lengh:1,address:"201",focus:true ,unit:""),
new BMSRoCell(name:"项目年份",offset:0,ratio:1,index:402,lengh:1,address:"202",focus:true ,unit:""),
new BMSRoCell(name:"项目编号",offset:0,ratio:1,index:404,lengh:1,address:"203",focus:true ,unit:""),
new BMSRoCell(name:"项目软件主版本",offset:0,ratio:1,index:406,lengh:1,address:"204",focus:true ,unit:""),
new BMSRoCell(name:"项目软件子版本",offset:0,ratio:1,index:408,lengh:1,address:"205",focus:true ,unit:""),
new BMSRoCell(name:"项目软件测试版本",offset:0,ratio:1,index:410,lengh:1,address:"206",focus:true ,unit:""),
new BMSRoCell(name:"从控站址分配结果",offset:0,ratio:1,index:412,lengh:1,address:"207",focus:true ,unit:""),
};
return bMSRoCells;
}
public static ObservableCollection<BmsRwCell> GetRWData()
{
ObservableCollection<BmsRwCell> bMSRoCells = new ObservableCollection<BmsRwCell>()
{
new BmsRwCell(name:"组端过压1级报警阈值",offset:0,ratio:0.1,index:0,lengh:1,address:"1",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端过压2级报警阈值",offset:0,ratio:0.1,index:2,lengh:1,address:"2",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端过压3级报警阈值",offset:0,ratio:0.1,index:4,lengh:1,address:"3",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端过压报警回差值",offset:0,ratio:0.1,index:6,lengh:1,address:"4",focus:true ,unit:"V",valueRange:new ValueRange(0,25),WR:"读/写"),
new BmsRwCell(name:"组端欠压1级报警阈值",offset:0,ratio:0.1,index:8,lengh:1,address:"5",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端欠压2级报警阈值",offset:0,ratio:0.1,index:10,lengh:1,address:"6",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端欠压3级报警阈值",offset:0,ratio:0.1,index:12,lengh:1,address:"7",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端欠压报警回差值",offset:0,ratio:0.1,index:14,lengh:1,address:"8",focus:true ,unit:"V",valueRange:new ValueRange(0,25),WR:"读/写"),
new BmsRwCell(name:"组端放电过流1级报警阈值",offset:0,ratio:0.1,index:16,lengh:1,address:"9",focus:true ,unit:"A",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端放电过流2级报警阈值",offset:0,ratio:0.1,index:18,lengh:1,address:"10",focus:true ,unit:"A",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端放电过流3级报警阈值",offset:0,ratio:0.1,index:20,lengh:1,address:"11",focus:true ,unit:"A",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端放电过流报警回差值",offset:0,ratio:0.1,index:22,lengh:1,address:"12",focus:true ,unit:"A",valueRange:new ValueRange(0,25),WR:"读/写"),
new BmsRwCell(name:"组端充电过流1级报警阈值",offset:0,ratio:0.1,index:24,lengh:1,address:"13",focus:true ,unit:"A",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端充电过流2级报警阈值",offset:0,ratio:0.1,index:26,lengh:1,address:"14",focus:true ,unit:"A",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端充电过流3级报警阈值",offset:0,ratio:0.1,index:28,lengh:1,address:"15",focus:true ,unit:"A",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"组端充电过流报警回差值",offset:0,ratio:0.1,index:30,lengh:1,address:"16",focus:true ,unit:"A",valueRange:new ValueRange(0,25),WR:"读/写"),
new BmsRwCell(name:"组端绝缘1级报警阈值",offset:0,ratio:1,index:32,lengh:1,address:"17",focus:true ,unit:"K",valueRange:new ValueRange(0,60000),WR:"读/写"),
new BmsRwCell(name:"组端绝缘2级报警阈值",offset:0,ratio:1,index:34,lengh:1,address:"18",focus:true ,unit:"K",valueRange:new ValueRange(0,60000),WR:"读/写"),
new BmsRwCell(name:"组端绝缘3级报警阈值",offset:0,ratio:1,index:36,lengh:1,address:"19",focus:true ,unit:"K",valueRange:new ValueRange(0,60000),WR:"读/写"),
new BmsRwCell(name:"组端绝缘报警回差值",offset:0,ratio:1,index:38,lengh:1,address:"20",focus:true ,unit:"K",valueRange:new ValueRange(0,255),WR:"读/写"),
new BmsRwCell(name:"单体充电过温1级报警阈值",offset:-40,ratio:0.1,index:40,lengh:1,address:"21",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"单体充电过温2级报警阈值",offset:-40,ratio:0.1,index:42,lengh:1,address:"22",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"单体充电过温3级报警阈值",offset:-40,ratio:0.1,index:44,lengh:1,address:"23",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"电池充电过温报警回差值",offset:0,ratio:0.1,index:46,lengh:1,address:"24",focus:true ,unit:"℃",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"单体充电欠温1级报警阈值",offset:-40,ratio:0.1,index:48,lengh:1,address:"25",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"单体充电欠温2级报警阈值",offset:-40,ratio:0.1,index:50,lengh:1,address:"26",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"单体充电欠温3级报警阈值",offset:-40,ratio:0.1,index:52,lengh:1,address:"27",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"电池充电欠温报警回差值",offset:0,ratio:0.1,index:54,lengh:1,address:"28",focus:true ,unit:"℃",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"单体电压过压1级报警阈值",offset:0,ratio:0.001,index:56,lengh:1,address:"29",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压过压2级报警阈值",offset:0,ratio:0.001,index:58,lengh:1,address:"30",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压过压3级报警阈值",offset:0,ratio:0.001,index:60,lengh:1,address:"31",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压过压报警回差值",offset:0,ratio:0.001,index:62,lengh:1,address:"32",focus:true ,unit:"V",valueRange:new ValueRange(0,0.25),WR:"读/写"),
new BmsRwCell(name:"单体电压欠压1级报警阈值",offset:0,ratio:0.001,index:64,lengh:1,address:"33",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压欠压2级报警阈值",offset:0,ratio:0.001,index:66,lengh:1,address:"34",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压欠压3级报警阈值",offset:0,ratio:0.001,index:68,lengh:1,address:"35",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压欠压报警回差值",offset:0,ratio:0.001,index:70,lengh:1,address:"36",focus:true ,unit:"V",valueRange:new ValueRange(0,0.25),WR:"读/写"),
new BmsRwCell(name:"单体电压差压1级报警阈值",offset:0,ratio:0.001,index:72,lengh:1,address:"37",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压差压2级报警阈值",offset:0,ratio:0.001,index:74,lengh:1,address:"38",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压差压3级报警阈值",offset:0,ratio:0.001,index:76,lengh:1,address:"39",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"单体电压差压报警回差值",offset:0,ratio:0.001,index:78,lengh:1,address:"40",focus:true ,unit:"V",valueRange:new ValueRange(0,0.25),WR:"读/写"),
new BmsRwCell(name:"单体温度温差1级报警阈值",offset:0,ratio:0.1,index:80,lengh:1,address:"41",focus:true ,unit:"℃",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"单体温度温差2级报警阈值",offset:0,ratio:0.1,index:82,lengh:1,address:"42",focus:true ,unit:"℃",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"单体温度温差3级报警阈值",offset:0,ratio:0.1,index:84,lengh:1,address:"43",focus:true ,unit:"℃",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"单体温度温差报警回差值",offset:0,ratio:0.1,index:86,lengh:1,address:"44",focus:true ,unit:"℃",valueRange:new ValueRange(0,10),WR:"读/写"),
new BmsRwCell(name:"SOC过低1级报警阈值",offset:0,ratio:0.01,index:88,lengh:1,address:"45",focus:true ,unit:"",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"SOC过低2级报警阈值",offset:0,ratio:0.01,index:90,lengh:1,address:"46",focus:true ,unit:"",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"SOC过低3级报警阈值",offset:0,ratio:0.01,index:92,lengh:1,address:"47",focus:true ,unit:"",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"SOC过低报警回差值",offset:0,ratio:0.01,index:94,lengh:1,address:"48",focus:true ,unit:"",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"动力插箱温度过高1级报警阈值",offset:-40,ratio:0.1,index:96,lengh:1,address:"49",focus:true ,unit:"",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"动力插箱温度过高2级报警阈值",offset:-40,ratio:0.1,index:98,lengh:1,address:"50",focus:true ,unit:"",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"动力插箱温度过高3级报警阈值",offset:-40,ratio:0.1,index:100,lengh:1,address:"51",focus:true ,unit:"",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"动力插箱温度过高报警回差值",offset:0,ratio:0.1,index:102,lengh:1,address:"52",focus:true ,unit:"",valueRange:new ValueRange(0,25),WR:"读/写"),
new BmsRwCell(name:"电池模组过压1级报警阈值",offset:0,ratio:0.1,index:104,lengh:1,address:"53",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"电池模组过压2级报警阈值",offset:0,ratio:0.1,index:106,lengh:1,address:"54",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"电池模组过压3级报警阈值",offset:0,ratio:0.1,index:108,lengh:1,address:"55",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"电池模组过压报警回差值",offset:0,ratio:0.1,index:110,lengh:1,address:"56",focus:true ,unit:"V",valueRange:new ValueRange(0,25),WR:"读/写"),
new BmsRwCell(name:"电池模组欠压1级报警阈值",offset:0,ratio:0.1,index:112,lengh:1,address:"57",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"电池模组欠压2级报警阈值",offset:0,ratio:0.1,index:114,lengh:1,address:"58",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"电池模组欠压3级报警阈值",offset:0,ratio:0.1,index:116,lengh:1,address:"59",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"电池模组欠压报警回差值",offset:0,ratio:0.1,index:118,lengh:1,address:"60",focus:true ,unit:"V",valueRange:new ValueRange(0,25),WR:"读/写"),
new BmsRwCell(name:"单体放电过温1级报警阈值",offset:-40,ratio:0.1,index:120,lengh:1,address:"61",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"单体放电过温2级报警阈值",offset:-40,ratio:0.1,index:122,lengh:1,address:"62",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"单体放电过温3级报警阈值",offset:-40,ratio:0.1,index:124,lengh:1,address:"63",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"电池放电过温报警回差值",offset:0,ratio:0.1,index:126,lengh:1,address:"64",focus:true ,unit:"℃",valueRange:new ValueRange(0,120),WR:"读/写"),
new BmsRwCell(name:"单体放电欠温1级报警阈值",offset:-40,ratio:0.1,index:128,lengh:1,address:"65",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"单体放电欠温2级报警阈值",offset:-40,ratio:0.1,index:130,lengh:1,address:"66",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"单体放电欠温3级报警阈值",offset:-40,ratio:0.1,index:132,lengh:1,address:"67",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"电池放电欠温报警回差值",offset:0,ratio:0.1,index:134,lengh:1,address:"68",focus:true ,unit:"℃",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"SOC过高1级报警阈值",offset:0,ratio:0.01,index:136,lengh:1,address:"69",focus:true ,unit:"",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"SOC过高2级报警阈值",offset:0,ratio:0.01,index:138,lengh:1,address:"70",focus:true ,unit:"",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"SOC过高3级报警阈值",offset:0,ratio:0.01,index:140,lengh:1,address:"71",focus:true ,unit:"",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"SOC过高报警回差值",offset:0,ratio:0.01,index:142,lengh:1,address:"72",focus:true ,unit:"",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"温升快1级报警阈值",offset:0,ratio:1,index:144,lengh:1,address:"73",focus:true ,unit:"℃/min",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"温升快2级报警阈值",offset:0,ratio:1,index:146,lengh:1,address:"74",focus:true ,unit:"℃/min",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"温升快3级报警阈值",offset:0,ratio:1,index:148,lengh:1,address:"75",focus:true ,unit:"℃/min",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"温升快报警回差值",offset:0,ratio:1,index:150,lengh:1,address:"76",focus:true ,unit:"℃/min",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"从控内温差大1级报警阈值",offset:-40,ratio:1,index:152,lengh:1,address:"77",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"从控内温差大2级报警阈值",offset:-40,ratio:1,index:154,lengh:1,address:"78",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"从控内温差大3级报警阈值",offset:-40,ratio:1,index:156,lengh:1,address:"79",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"从控内温差大报警回差值",offset:0,ratio:1,index:158,lengh:1,address:"80",focus:true ,unit:"℃",valueRange:new ValueRange(0,100),WR:"读/写"),
new BmsRwCell(name:"从控内压差大1级报警阈值",offset:0,ratio:0.001,index:160,lengh:1,address:"81",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"从控内压差大2级报警阈值",offset:0,ratio:0.001,index:162,lengh:1,address:"82",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"从控内压差大3级报警阈值",offset:0,ratio:0.001,index:164,lengh:1,address:"83",focus:true ,unit:"V",valueRange:new ValueRange(0,4.5),WR:"读/写"),
new BmsRwCell(name:"从控内压差大报警回差值",offset:0,ratio:0.001,index:166,lengh:1,address:"84",focus:true ,unit:"V",valueRange:new ValueRange(0,0.25),WR:"读/写"),
new BmsRwCell(name:"从控总压压差大1级报警阈值",offset:0,ratio:0.1,index:168,lengh:1,address:"85",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"从控总压压差大2级报警阈值",offset:0,ratio:0.1,index:170,lengh:1,address:"86",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"从控总压压差大3级报警阈值",offset:0,ratio:0.1,index:172,lengh:1,address:"87",focus:true ,unit:"V",valueRange:new ValueRange(0,1000),WR:"读/写"),
new BmsRwCell(name:"从控总压压差大报警回差值",offset:0,ratio:0.1,index:174,lengh:1,address:"88",focus:true ,unit:"V",valueRange:new ValueRange(0,25),WR:"读/写"),
new BmsRwCell(name:"风扇启动温度",offset:-40,ratio:0.1,index:202,lengh:1,address:"102",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"风扇关闭温度",offset:-40,ratio:0.1,index:204,lengh:1,address:"103",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读/写"),
new BmsRwCell(name:"绝缘采集控制",offset:0,ratio:1,index:210,lengh:1,address:"106",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"可调风扇控制-占空比",offset:0,ratio:1,index:212,lengh:1,address:"107",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"复归指令",offset:0,ratio:1,index:214,lengh:1,address:"108",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"跳机指令",offset:0,ratio:1,index:216,lengh:1,address:"109",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"显控检测故障",offset:0,ratio:1,index:218,lengh:1,address:"110",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"累计充电电量(高字节)",offset:0,ratio:1,index:222,lengh:1,address:"112",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"累计充电电量(低字节)",offset:0,ratio:1,index:224,lengh:1,address:"113",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"累计放电电量(高字节)",offset:0,ratio:1,index:226,lengh:1,address:"114",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"累计放电电量(低字节)",offset:0,ratio:1,index:228,lengh:1,address:"115",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"BMS请求设定TMS模式",offset:0,ratio:1,index:442,lengh:1,address:"222",focus:true ,unit:"",valueRange:new ValueRange(0,3),WR:"写"),
new BmsRwCell(name:"BMS请求设定TMS溫度",offset:-40,ratio:1,index:444,lengh:1,address:"223",focus:true ,unit:"℃",valueRange:new ValueRange(0,65535),WR:"读/写"),
new BmsRwCell(name:"TMS工作模式",offset:0,ratio:1,index:446,lengh:1,address:"224",focus:true ,unit:"",valueRange:new ValueRange(0,3),WR:"读"),
new BmsRwCell(name:"出水温度",offset:-40,ratio:1,index:448,lengh:1,address:"225",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读"),
new BmsRwCell(name:"回水温度",offset:-40,ratio:1,index:450,lengh:1,address:"226",focus:true ,unit:"℃",valueRange:new ValueRange(-40,120),WR:"读"),
new BmsRwCell(name:"进水压力",offset:0,ratio:1,index:452,lengh:1,address:"227",focus:true ,unit:"Bar",valueRange:new ValueRange(0,25),WR:"读"),
new BmsRwCell(name:"出水压力",offset:0,ratio:1,index:454,lengh:1,address:"228",focus:true ,unit:"Bar",valueRange:new ValueRange(0,25),WR:"读"),
new BmsRwCell(name:"液冷故障码及等级",offset:0,ratio:1,index:456,lengh:1,address:"229",focus:true ,unit:"",valueRange:new ValueRange(0,65535),WR:"读"),
new BmsRwCell(name:"消防压力",offset:0,ratio:1,index:458,lengh:1,address:"230",focus:true ,unit:"Kpa",valueRange:new ValueRange(0,65535),WR:"读"),
new BmsRwCell(name:"消防烟感触发",offset:0,ratio:1,index:460,lengh:1,address:"231",focus:true ,unit:"",valueRange:new ValueRange(0,1),WR:"读"),
new BmsRwCell(name:"消防温感触发",offset:0,ratio:1,index:462,lengh:1,address:"232",focus:true ,unit:"",valueRange:new ValueRange(0,1),WR:"读"),
new BmsRwCell(name:"消防设备工作模式",offset:0,ratio:1,index:464,lengh:1,address:"233",focus:true ,unit:"",valueRange:new ValueRange(1,2),WR:"读"),
new BmsRwCell(name:"消防主电源状态",offset:0,ratio:1,index:466,lengh:1,address:"234",focus:true ,unit:"",valueRange:new ValueRange(0,1),WR:"读"),
new BmsRwCell(name:"消防副电源状态",offset:0,ratio:1,index:468,lengh:1,address:"235",focus:true ,unit:"",valueRange:new ValueRange(0,1),WR:"读"),
new BmsRwCell(name:"消防电磁阀状态",offset:0,ratio:1,index:470,lengh:1,address:"236",focus:true ,unit:"",valueRange:new ValueRange(0,1),WR:"读"),
new BmsRwCell(name:"消防喷射倒计时",offset:0,ratio:1,index:472,lengh:1,address:"237",focus:true ,unit:"",valueRange:new ValueRange(0,60),WR:"读"),
new BmsRwCell(name:"消防压力传感器状态检测",offset:0,ratio:1,index:474,lengh:1,address:"238",focus:true ,unit:"",valueRange:new ValueRange(0,1),WR:"读"),
};
return bMSRoCells;
}
}
}

View File

@@ -0,0 +1,172 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
/// <summary>
/// 字节帮助类
/// </summary>
public class ByteHelper
{
/// <summary>
/// 字节数组转为16进制字符串
/// </summary>
/// <param name="bytes">字节数组</param>
/// <returns>16进制字符串</returns>
public static string ToHexString(byte[] bytes)
{
string hexString = string.Empty;
for (int i = 0; i < bytes.Length; i++)
{
hexString += ByteToHexStr(bytes[i]);
}
return hexString;
}
/// <summary>
/// 字节转为16进制字符串一个字节转为两个字符[0-F][0-F]
/// </summary>
/// <param name="inByte">字节</param>
/// <returns>字符串</returns>
public static string ByteToHexStr(byte inByte)
{
string result = string.Empty;
try
{
char[] hexDict = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
char[] charParts = new char[2];
charParts[0] = hexDict[(inByte >> 4) & 0x0F]; //放在byte左半部分的重新移回右边并匹配十六进制字符;
charParts[1] = hexDict[inByte & 0x0F]; //放在byte右半部分的直接匹配十六进制字符;
result = new string(charParts);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
return result;
}
/// <summary>
/// 十六进制字符串转为字节数组
/// </summary>
/// <param name="hexStr">十六进制字符串</param>
/// <returns>字节数组</returns>
public static byte[] HexStrToBytes(string hexStr)
{
/* 说明1byte=8bit中文char=2byte(此处不考虑)英文char=1byte
1个“个位”的十六进制数占4bit所以2个英文char转为十六进制数后占一个byte */
byte[] bytes = new byte[hexStr.Length / 2 + (((hexStr.Length % 2) > 0) ? 1 : 0)];
for (int i = 0; i < bytes.Length; i++)
{
char leftPart = hexStr[i * 2];
char rightPart;
if ((i * 2 + 1) < hexStr.Length)
rightPart = hexStr[i * 2 + 1];
else
rightPart = '0';
int a = ByteToHexValue((byte)leftPart);
int b = ByteToHexValue((byte)rightPart);
//由于16进制数的'个位'数只占4bit所以左部分左移4位加上右部分共占8位即一个byte;
bytes[i] = (byte)((a << 4) + b);
}
return bytes;
}
/// <summary>
/// 转换字节实际为英文char为16进制数据0-15
/// </summary>
/// <param name="b">字节</param>
/// <returns>字节</returns>
public static byte ByteToHexValue(byte b)
{
byte value = 0;
if (b >= '0' && b <= '9')
{
//原值在ASCII中介于'0'-'9'之间的减去0x30即ASCII中'0'的十六进制表示十进制为48得到数值0-9。
value = (byte)(b - 0x30);
}
if (b >= 'A' && b <= 'F')
{
//原值在ASCII中介于'A'-'F'之间的减去0x37十进制为55A的ASCII十进制为65所以可得到数值10-15。
value = (byte)(b - 0x37);
}
if (b >= 'a' && b <= 'f')
{
//原值在ASCII中介于'a'-'f'之间的减去0x57十进制为87a的ASCII十进制为97所以可得到数值10-15。
value = (byte)(b - 0x57);
}
return value;
}
/// <summary>
/// 区块字符串数据转为区块字节数据不足则补位16字节
/// </summary>
/// <param name="blockData">区块字符串数据</param>
/// <returns>List<byte></returns>
public static List<byte> GetBlockBytes(string blockData)
{
List<byte> blockBytes = new List<byte>();
blockBytes.AddRange(HexStrToBytes(blockData));
if (blockBytes.Count < 16)
{
for (int i = blockBytes.Count; i < 16; i++)
{
blockBytes.Add(0x00);
}
}
return blockBytes;
}
/// <summary>
/// 字节转二进制字符串8个字符
/// </summary>
/// <param name="value">单个字节</param>
/// <returns>二进制字符串8个字符</returns>
public static string ByteToBinaryStr(byte value)
{
return Convert.ToString(value, 2).PadLeft(8, '0');
}
/// <summary>
/// 字节转字符数组长度为8形如01010101
/// </summary>
/// <param name="value">单个字节</param>
/// <returns>字符数组长度为8</returns>
public static char[] ByteToCharArray(byte value)
{
return ByteToBinaryStr(value).ToCharArray();
}
/// <summary>
/// 获取算数累加校验和超过1字节的进位忽略
/// https://blog.csdn.net/qq_30725967/article/details/88364985
/// </summary>
/// <param name="buffer">字节数组</param>
/// <returns>1字节的校验和</returns>
public static byte GetChecksumCalculateAdd(byte[] buffer)//取低八位
{
int cks = 0;
foreach (byte item in buffer)
{
cks = (cks + item) % 0xffff;
}
//byte bt = (byte)((cks & 0xff00) >> 8);//取校验和高8位
byte bt = (byte)(cks & 0xff);//取校验和低8位
return bt;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
public class ComboBoxModel
{
private String key;
/// <summary>
/// Key值
/// </summary>
public String Key
{
get { return key; }
set { key = value; }
}
private String text;
/// <summary>
/// Text值
/// </summary>
public String Text
{
get { return text; }
set { text = value; }
}
}
}

View File

@@ -0,0 +1,237 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
/// <summary>
/// 处理数据类型转换,数制转换、编码转换相关的类
/// </summary>
public sealed class ConvertHelper
{
#region
/// <summary>
/// 指定字符串的固定长度,如果字符串小于固定长度,
/// 则在字符串的前面补足零可设置的固定长度最大为9位
/// </summary>
/// <param name="text">原始字符串</param>
/// <param name="limitedLength">字符串的固定长度</param>
public static string RepairZero(string text, int limitedLength)
{
//补足0的字符串
string temp = "";
//补足0
for (int i = 0; i < limitedLength - text.Length; i++)
{
temp += "0";
}
//连接text
temp += text;
//返回补足0的字符串
return temp;
}
#endregion
#region
/// <summary>
/// 实现各进制数间的转换。
/// </summary>
/// <param name="value">要转换的值,即原值</param>
/// <param name="from">原值的进制,只能是2,8,10,16四个值。</param>
/// <param name="to">要转换到的目标进制只能是2,8,10,16四个值。</param>
/// <returns>转换失败返回“0”</returns>
/// <example>
/// ConvertBase("15",10,16); 表示将十进制数15转换为16进制的数。
/// </example>
public static string ConvertBase(string value, int from, int to)
{
try
{
int intValue = Convert.ToInt32(value, from); //先转成10进制
string result = Convert.ToString(intValue, to); //再转成目标进制
if (to == 2)
{
result = result.PadLeft(8, '0');
}
return result;
}
catch (Exception ex)
{
Console.WriteLine(ex);
return "0";
}
}
#endregion
#region 使string转换成byte[]
/// <summary>
/// 使用指定字符集将string转换成byte[]
/// </summary>
/// <param name="text">要转换的字符串</param>
/// <param name="encoding">字符编码</param>
public static byte[] StringToBytes(string text, Encoding encoding)
{
return encoding.GetBytes(text);
}
#endregion
#region byte[]string
/// <summary>
/// 使用指定字符集将byte[]转换成string
/// </summary>
/// <param name="bytes">要转换的字节数组</param>
/// <param name="encoding">字符编码</param>
public static string BytesToString(byte[] bytes, Encoding encoding)
{
return encoding.GetString(bytes);
}
/// <summary>
/// 从字节数组生成字符串;
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
public string GetBufferStr(byte[] buffer)
{
//byte SEP = 0xB3 /*分隔符|*/;
string result = "";
for (int i = 0; i < buffer.Length; i++)
{
switch (buffer[i])
{
//case SEP:
// result += "|";
// break;
default:
string str = (char)buffer[i] + "";
if (!string.IsNullOrEmpty(str))
{
result += str;
}
break;
}
}
return result;
}
#endregion
#region byte[]int
/// <summary>
/// 将byte[]转换成int
/// </summary>
/// <param name="data">需要转换成整数的byte数组</param>
public static int BytesToInt32(byte[] data)
{
//如果传入的字节数组长度小于4,则返回0
if (data.Length < 4)
{
return 0;
}
//定义要返回的整数
int num = 0;
//如果传入的字节数组长度大于4,需要进行处理
if (data.Length >= 4)
{
//创建一个临时缓冲区
byte[] tempBuffer = new byte[4];
//将传入的字节数组的前4个字节复制到临时缓冲区
Buffer.BlockCopy(data, 0, tempBuffer, 0, 4);
//将临时缓冲区的值转换成整数并赋给num
num = BitConverter.ToInt32(tempBuffer, 0);
}
//返回整数
return num;
}
#endregion
#region struct和byte[]
public static byte[] StructToBytes(object structObj)
{
int size = Marshal.SizeOf(structObj);
IntPtr buffer = Marshal.AllocHGlobal(size);
try
{
Marshal.StructureToPtr(structObj, buffer, false);
byte[] bytes = new byte[size];
Marshal.Copy(buffer, bytes, 0, size);
return bytes;
}
finally
{
Marshal.FreeHGlobal(buffer);
}
}
public static T BytesToStruct<T>(byte[] data)
{
IntPtr buffer = Marshal.AllocHGlobal(data.Length);
try
{
Marshal.Copy(data, 0, buffer, data.Length);
return Marshal.PtrToStructure<T>(buffer);
}
finally
{
Marshal.FreeHGlobal(buffer);
}
}
#endregion
/// <summary>
/// 通用类型转换
/// http://www.dzwebs.net/4343.html
/// </summary>
/// <param name="value">值</param>
/// <param name="type">类型</param>
/// <returns>object</returns>
public static object ChangeType(object value, Type type)
{
if (value == null && type.IsGenericType) return Activator.CreateInstance(type);
if (value == null) return null;
if (type == value.GetType()) return value;
if (type.IsEnum)
{
if (value is string)
return Enum.Parse(type, value as string);
else
return Enum.ToObject(type, value);
}
if (!type.IsInterface && type.IsGenericType)
{
Type innerType = type.GetGenericArguments()[0];
object innerValue = ChangeType(value, innerType);
return Activator.CreateInstance(type, new object[] { innerValue });
}
if (value is string && type == typeof(Guid)) return new Guid(value as string);
if (value is string && type == typeof(Version)) return new Version(value as string);
//自定义类转换会在这句返回;
if (!(value is IConvertible)) return value;
return Convert.ChangeType(value, type);
}
}
}

View File

@@ -0,0 +1,143 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
public static class EnumExtension
{
#region
public static Attribute GetEnumAttribute(this Enum value, Type attribute)
{
var enumType = value.GetType();
var name = Enum.GetName(enumType, value);
if (name != null)
{
// 获取枚举字段。
var fieldInfo = enumType.GetField(name);
if (fieldInfo != null)
{
// 获取描述的属性。
var attr = Attribute.GetCustomAttribute(fieldInfo,
attribute, false);
return attr;
}
}
return null;
}
public static T GetEnumAttribute<T>(this Enum value)
{
var enumType = value.GetType();
var name = Enum.GetName(enumType, value);
if (name != null)
{
// 获取枚举字段。
var fieldInfo = enumType.GetField(name);
if (fieldInfo != null)
{
// 获取描述的属性。
var attr = Attribute.GetCustomAttribute(fieldInfo, typeof(T), false);
return (T)(object)attr;
}
}
return default(T);
}
/// <summary>
/// 获取枚举描述内容;
/// </summary>
/// <param name="value"></param>
/// <param name="defaultval"></param>
/// <returns></returns>
public static string GetEnumDescription(this Enum value, string defaultval = "")
{
var attr = GetEnumAttribute(value, typeof(DescriptionAttribute));
return (attr as DescriptionAttribute)?.Description ?? defaultval;
}
#endregion
#region
/// <summary>
/// 通过枚举对象获取枚举列表
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value"></param>
/// <returns></returns>
public static List<T> GetEnumList<T>(this T value)
{
var list = new List<T>();
if (value is Enum)
{
var valData = Convert.ToInt32((T)Enum.Parse(typeof(T), value.ToString()));
var tps = Enum.GetValues(typeof(T));
list.AddRange(from object tp in tps where ((int)Convert.ToInt32((T)Enum.Parse(typeof(T), tp.ToString())) & valData) == valData select (T)tp);
}
return list;
}
/* 参考https://www.codenong.com/17123548/ */
/// <summary>
/// 通过枚举类型获取枚举列表;
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value"></param>
/// <returns></returns>
public static List<T> GetEnumList<T>() where T : Enum
{
List<T> list = Enum.GetValues(typeof(T)).OfType<T>().ToList();
return list;
}
/* 参考https://www.codenong.com/105372/ */
/// <summary>
/// Gets all items for an enum value.(通过枚举对象获取所有枚举)
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value">The value.</param>
/// <returns></returns>
public static IEnumerable<T> GetAllItems<T>(this Enum value)
{
foreach (object item in Enum.GetValues(typeof(T)))
{
yield return (T)item;
}
}
/// <summary>
/// Gets all items for an enum type.(通过枚举类型获取所有枚举)
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static IEnumerable<T> GetAllItems<T>() where T : struct
{
foreach (object item in Enum.GetValues(typeof(T)))
{
yield return (T)item;
}
}
#endregion
/// <summary>
/// 将枚举转换为值
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value"></param>
/// <returns></returns>
public static T ToValue<T>(this Enum value) where T : struct
{
return (T)(object)value;
}
}
}

View File

@@ -0,0 +1,152 @@
using OrpaonEMS.App.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
/// <summary>
/// 报警加载的静态方法
/// </summary>
public class LoadAlarm
{
/// <summary>
/// 获取报警信息
/// </summary>
/// <returns></returns>
public static List<AlarmCell> GetAlarms(Channel<AlarmChannelData> channel)
{
return new List<AlarmCell>()
{
new AlarmCell(channel,"组端过压1级报警","1",1,0),
new AlarmCell(channel,"组端过压2级报警","2",2,1),
new AlarmCell(channel,"组端过压3级报警","3",3,2),
new AlarmCell(channel,"组端欠压1级报警","4",1,3),
new AlarmCell(channel,"组端欠压2级报警","5",2,4),
new AlarmCell(channel,"组端欠压3级报警","6",3,5),
new AlarmCell(channel,"组端放电过流1级报警","7",1,6),
new AlarmCell(channel,"组端放电过流2级报警","8",2,7),
new AlarmCell(channel,"组端放电过流3级报警","9",3,8),
new AlarmCell(channel,"组端充电过流1级报警","10",1,9),
new AlarmCell(channel,"组端充电过流2级报警","11",2,10),
new AlarmCell(channel,"组端充电过流3级报警","12",3,11),
new AlarmCell(channel,"组端绝缘1级报警","13",1,12),
new AlarmCell(channel,"组端绝缘2级报警","14",2,13),
new AlarmCell(channel,"组端绝缘3级报警","15",3,14),
new AlarmCell(channel,"单体电池充电过温1级报警","16",1,15),
new AlarmCell(channel,"单体电池充电过温2级报警","17",2,16),
new AlarmCell(channel,"单体电池充电过温3级报警","18",3,17),
new AlarmCell(channel,"单体电池充电欠温1级报警","19",1,18),
new AlarmCell(channel,"单体电池充电欠温2级报警","20",2,19),
new AlarmCell(channel,"单体电池充电欠温3级报警","21",3,20),
new AlarmCell(channel,"单体电压过压1级报警","22",1,21),
new AlarmCell(channel,"单体电压过压2级报警","23",2,22),
new AlarmCell(channel,"单体电压过压3级报警","24",3,23),
new AlarmCell(channel,"单体电压欠压1级报警","25",1,24),
new AlarmCell(channel,"单体电压欠压2级报警","26",2,25),
new AlarmCell(channel,"单体电压欠压3级报警","27",3,26),
new AlarmCell(channel,"单体压差过高1级报警","28",1,27),
new AlarmCell(channel,"单体压差过高2级报警","29",2,28),
new AlarmCell(channel,"单体压差过高3级报警","30",3,29),
new AlarmCell(channel,"单体温差过高1级报警","31",1,30),
new AlarmCell(channel,"单体温差过高2级报警","32",2,31),
new AlarmCell(channel,"单体温差过高3级报警","33",3,32),
new AlarmCell(channel,"SOC过低1级告警","34",1,33),
new AlarmCell(channel,"SOC过低2级告警","35",2,34),
new AlarmCell(channel,"SOC过低3级告警","36",3,35),
new AlarmCell(channel,"动力插箱温度过高1级报警","37",1,36),
new AlarmCell(channel,"动力插箱温度过高2级报警","38",2,37),
new AlarmCell(channel,"动力插箱温度过高3级报警","39",3,38),
new AlarmCell(channel,"电池模组过压1级报警","40",1,39),
new AlarmCell(channel,"电池模组过压2级报警","41",2,40),
new AlarmCell(channel,"电池模组过压3级报警","42",3,41),
new AlarmCell(channel,"电池模组欠压1级报警","43",1,42),
new AlarmCell(channel,"电池模组欠压2级报警","44",2,43),
new AlarmCell(channel,"电池模组欠压3级报警","45",3,44),
new AlarmCell(channel,"DI1故障","46",3,45),
new AlarmCell(channel,"DI2故障","47",3,46),
new AlarmCell(channel,"DI3故障","48",3,47),
new AlarmCell(channel,"DI4故障","49",3,48),
new AlarmCell(channel,"DI5故障","50",3,49),
new AlarmCell(channel,"DI6故障","51",3,50),
new AlarmCell(channel,"DI7故障","52",3,51),
new AlarmCell(channel,"DI8故障","53",3,52),
new AlarmCell(channel,"内网通讯失联","54",3,53),
new AlarmCell(channel,"单体电压采集异常","55",3,54),
new AlarmCell(channel,"单体温度采集故障三级告警","56",3,55),
new AlarmCell(channel,"显控检测故障","57",3,56),
new AlarmCell(channel,"簇间压差大","58",3,57),
new AlarmCell(channel,"簇间跳机故障","59",3,58),
new AlarmCell(channel,"电池极限故障","60",3,59),
new AlarmCell(channel,"项目软件版本参数不一致","61",3,60),
new AlarmCell(channel,"与PCS通讯故障","62",3,61),
new AlarmCell(channel,"PC强控调试模式","63",3,62),
new AlarmCell(channel,"CAN霍尔传感器故障","64",3,63),
new AlarmCell(channel,"CAN霍尔传感器通讯故障","65",3,64),
new AlarmCell(channel,"硬件自检异常","66",3,65),
new AlarmCell(channel,"单体电压线束故障","67",3,66),
new AlarmCell(channel,"均衡故障","68",1,67),
new AlarmCell(channel,"EMS通讯故障","69",1,68),
new AlarmCell(channel,"与三级BMS通讯故障","70",2,69),
new AlarmCell(channel,"单体电池放电过温1级报警","71",1,70),
new AlarmCell(channel,"单体电池放电过温2级报警","72",2,71),
new AlarmCell(channel,"单体电池放电过温3级报警","73",3,72),
new AlarmCell(channel,"单体电池放电欠温1级报警","74",1,73),
new AlarmCell(channel,"单体电池放电欠温2级报警","75",2,74),
new AlarmCell(channel,"单体电池放电欠温3级报警","76",3,75),
new AlarmCell(channel,"SOC过高1级告警","77",1,76),
new AlarmCell(channel,"SOC过高2级告警","78",2,77),
new AlarmCell(channel,"SOC过高3级告警","79",3,78),
new AlarmCell(channel,"温升快报警1级报警","80",1,79),
new AlarmCell(channel,"温升快报警2级报警","81",2,80),
new AlarmCell(channel,"温升快报警3级报警","82",3,81),
new AlarmCell(channel,"预充失败","83",3,82),
new AlarmCell(channel,"单体温度采集故障一级告警","84",1,83),
new AlarmCell(channel,"单体温度采集故障二级告警","85",2,84),
new AlarmCell(channel,"从控内温差大1级报警","86",1,85),
new AlarmCell(channel,"从控内温差大2级报警","87",2,86),
new AlarmCell(channel,"从控内温差大3级报警","88",3,87),
new AlarmCell(channel,"从控内压差大1级报警","89",1,88),
new AlarmCell(channel,"从控内压差大2级报警","90",2,89),
new AlarmCell(channel,"从控内压差大3级报警","91",3,90),
new AlarmCell(channel,"从控总压压差大1级报警","92",1,91),
new AlarmCell(channel,"从控总压压差大2级报警","93",2,92),
new AlarmCell(channel,"从控总压压差大3级报警","94",3,93),
new AlarmCell(channel,"DBC使能开启","95",1,94),
new AlarmCell(channel,"菊花链单环故障","96",1,95),
new AlarmCell(channel,"单体电压采集芯片故障","97",3,96),
new AlarmCell(channel,"极柱温度采集故障1级报警","98",1,97),
new AlarmCell(channel,"极柱温度采集故障2级报警","99",2,98),
new AlarmCell(channel,"极柱温度采集故障3级报警","100",3,99),
new AlarmCell(channel,"主控供电过压故障","101",3,100),
new AlarmCell(channel,"主控供电欠压故障","102",3,101),
new AlarmCell(channel,"主控程序运行故障","103",2,102),
new AlarmCell(channel,"从控程序运行故障","104",2,103),
new AlarmCell(channel,"主控EEPROM故障","105",1,104),
new AlarmCell(channel,"主控Flash故障","106",1,105),
new AlarmCell(channel,"从控EEPROM故障","107",1,106),
new AlarmCell(channel,"单体电压不刷新","108",2,107),
new AlarmCell(channel,"AFE供电故障","109",1,108),
new AlarmCell(channel,"主控12V输出电压故障","110",1,109),
new AlarmCell(channel,"主控RTC故障","111",1,110),
new AlarmCell(channel,"CAB500故障","112",3,111),
new AlarmCell(channel,"模拟量霍尔故障","113",3,112),
new AlarmCell(channel,"电池总压检测电路故障","114",2,113),
new AlarmCell(channel,"电池负载侧电压检测电路故障","115",2,114),
new AlarmCell(channel,"绝缘电路故障","116",2,115),
new AlarmCell(channel,"SOC跳变故障","117",1,116),
new AlarmCell(channel,"电池簇充放电回路连接铜排虚接","118",3,117),
new AlarmCell(channel,"单体热失控预警","119",3,118),
new AlarmCell(channel,"从控开入总告警","120",1,119),
new AlarmCell(channel,"从控开入总告警","121",3,120),
new AlarmCell(channel,"从控开入总告警","122",3,121),
};
}
}
}

View File

@@ -0,0 +1,25 @@
using OrpaonEMS.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
/// <summary>
/// 电表和开关单元
/// </summary>
public class MeterSwitchCell
{
/// <summary>
/// 开关的状态
/// </summary>
public SwitchEm SwtichState { get; set; }
/// <summary>
/// 电表的实时功率
/// </summary>
public double RtPw { get; set; }
}
}

View File

@@ -0,0 +1,115 @@
using OrpaonEMS.Model.Enums;
using System;
namespace OrpaonEMS.App.Com
{
/// <summary>
/// 特殊的峰谷时间模型
/// </summary>
public class SpecialPeakValley
{
/// <summary>
/// 放电开始时间 其他
/// </summary>
public string OtherDisChargStartTime { get; set; } = "08:00";
/// <summary>
/// 放电结束时间 其他
/// </summary>
public string OtherDisChargEndTime { get; set; } = "23:00";
/// <summary>
/// 充电开始时间 通用
/// </summary>
public string ChargStartTime { get; set; } = "23:00";
/// <summary>
/// 充电结束时间 通用
/// </summary>
public string ChargEndTime { get; set; } = "06:00";
/// <summary>
/// 放电开始时间 7-8月份
/// </summary>
public string JulyAndAugustDisChargStartTime { get; set; } = "11:00";
/// <summary>
/// 放电结束时间 7-8月份
/// </summary>
public string JulyAndAugustDisChargEndTime { get; set; } = "23:00";
/// <summary>
/// 获取特殊的充放电的信息
/// </summary>
/// <returns></returns>
public ElePVEnum GetSpecialPeakValley()
{
//特殊月份
if (DateTime.Now.Month == 7 || DateTime.Now.Month == 8)
{
if (GetIsTimeSpan(DateTime.Now.ToString("HH:mm"), JulyAndAugustDisChargStartTime, JulyAndAugustDisChargEndTime))
{
return ElePVEnum.Peak;
}
else if (GetIsTimeSpan(DateTime.Now.ToString("HH:mm"), ChargStartTime, ChargEndTime))
{
return ElePVEnum.Valley;
}
else
{
return ElePVEnum.Flat;
}
}
else//正常月份
{
if (GetIsTimeSpan(DateTime.Now.ToString("HH:mm"), OtherDisChargStartTime, OtherDisChargEndTime))
{
return ElePVEnum.Peak;
}
else if (GetIsTimeSpan(DateTime.Now.ToString("HH:mm"), ChargStartTime, ChargEndTime))
{
return ElePVEnum.Valley;
}
else
{
return ElePVEnum.Flat;
}
}
}
/// <summary>
/// 判断时间是否在 某一时间段内
/// </summary>
/// <param name="timeStr"></param>
/// <returns></returns>
public bool GetIsTimeSpan(string timeStr, string startTime, string endTime)
{
//判断当前时间是否在工作时间段内
//string _strWorkingDayAM = "08:30";//工作时间上午08:30
//string _strWorkingDayPM = "17:30";
TimeSpan dspStart = DateTime.Parse(startTime).TimeOfDay;
TimeSpan dspEnd = DateTime.Parse(endTime).TimeOfDay;
//string time1 = "2017-2-17 8:10:00";
DateTime t1 = Convert.ToDateTime(timeStr);
TimeSpan dspNow = t1.TimeOfDay;
if (dspNow > dspStart && dspNow < dspEnd)
{
return true;
}
else if (dspStart > dspEnd)//时间区间处于跨天的状态
{
if (dspNow >= dspStart || dspNow <= dspEnd)
{
return true;
}
}
return false;
}
}
}

View File

@@ -0,0 +1,183 @@
using OrpaonEMS.App.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace OrpaonEMS.App.Com
{
/// <summary>
/// 触发模型
/// </summary>
public class TrigTimeModel
{
/// <summary>
/// 周期定时器
/// </summary>
private System.Timers.Timer CycleTimer { get; set; }
/// <summary>
/// 触发时间达到阈值
/// </summary>
public event EventHandler TrigTimeOutHandler;
public TrigTimeModel(int trigThValue, int trigThSecTime)
{
TrigThValue = trigThValue;
TrigThSecTime = trigThSecTime;
//10秒触发一次
CycleTimer = new System.Timers.Timer(1000);
CycleTimer.Elapsed += CycleAction;
CycleTimer.AutoReset = true;
CycleTimer.Enabled = true;
}
/// <summary>
/// 周期调用这个方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <exception cref="NotImplementedException"></exception>
private void CycleAction(object? sender, ElapsedEventArgs e)
{
try
{
//如果Execute执行的是一个很耗时的方法会导致方法未执行完毕定时器又启动了一个线程来执行Execute方法
//CycleTimer.Stop(); //先关闭定时器
if (TrigState)//触发击中时统计时间
{
TrigRtTimeSec = (DateTime.Now - TrigStartTime).TotalSeconds;
if (TrigRtTimeSec >= TrigThSecTime)
{
CycleTimer.Stop(); //先关闭定时器,不再触发后续的事件
TrigTimeOutHandler(this, null);
}
}
else//触发消失
{
TrigRtTimeSec = 0;
}
//CycleTimer.Start(); //执行完毕后再开启器
}
catch (Exception ex)
{
CycleTimer.Start(); //执行完毕后再开启器
}
}
/// <summary>
/// 更新值
/// 大于一个值
/// </summary>
/// <returns></returns>
public bool UpdateByCompareOver(double Value)
{
if (Value >= TrigThValue)
{
TrigState = true;
}
else
{
TrigState = false;
}
return TrigState;
}
/// <summary>
/// 更新值
/// 小于一个值
/// </summary>
/// <returns></returns>
public bool UpdateByCompareLess(double Value)
{
if (Value <= TrigThValue)
{
TrigState = true;
}
else
{
TrigState = false;
}
return TrigState;
}
/// <summary>
/// 更新状态等使用
/// 为False时代表关注点被触发
/// </summary>
/// <param name="Value"></param>
/// <returns></returns>
public bool UpdateByBool(bool Value)
{
if (Value==false)//关注False。为False时代表关注点被触发
{
TrigState = true;
}
else
{
TrigState = false;
}
return TrigState;
}
/// <summary>
/// 触发成功开始的时间
/// </summary>
public DateTime TrigStartTime { get; set; }
private bool _TrigState = false;
/// <summary>
/// 触发时间
/// </summary>
public bool TrigState
{
get { return _TrigState; }
set
{
if (value != _TrigState)//状态改变
{
if (value)//触发击中
{
TrigStartTime = DateTime.Now;
CycleTimer.Start();
}
else//触发消失
{
CycleTimer.Stop();
}
_TrigState = value;
}
}
}
/// <summary>
/// 达到触发值实时时间-秒
/// </summary>
public double TrigRtTimeSec { get; set; }
/// <summary>
/// 达到触发值的值
/// </summary>
public int TrigThValue { get; set; }
/// <summary>
/// 达到触发值的值时长阈值-秒
/// </summary>
public int TrigThSecTime { get; set; }
}
}

View File

@@ -0,0 +1,234 @@
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.Com
{
/// <summary>
/// 月浦的电费账单
/// </summary>
public class YuPuEleFees : BindableBase
{
private double _TopPeakCharg;
/// <summary>
/// 尖峰充电
/// </summary>
public double TopPeakCharg
{
get { return _TopPeakCharg; }
set { _TopPeakCharg = value; RaisePropertyChanged(); }
}
private double _TopPeakDisCharg;
/// <summary>
/// 尖峰放电
/// </summary>
public double TopPeakDisCharg
{
get { return _TopPeakDisCharg; }
set { _TopPeakDisCharg = value; RaisePropertyChanged(); }
}
private double _PeakCharg;
/// <summary>
/// 峰充电
/// </summary>
public double PeakCharg
{
get { return _PeakCharg; }
set { _PeakCharg = value; RaisePropertyChanged(); }
}
private double _PeakDisCharg;
/// <summary>
/// 峰放电
/// </summary>
public double PeakDisCharg
{
get { return _PeakDisCharg; }
set { _PeakDisCharg = value; RaisePropertyChanged(); }
}
private double _ValleyCharg;
/// <summary>
/// 谷充电
/// </summary>
public double ValleyCharg
{
get { return _ValleyCharg; }
set { _ValleyCharg = value; RaisePropertyChanged(); }
}
private double _ValleyDisCharg;
/// <summary>
/// 谷放电
/// </summary>
public double ValleyDisCharg
{
get { return _ValleyDisCharg; }
set { _ValleyDisCharg = value; RaisePropertyChanged(); }
}
private double _FlatCharg;
/// <summary>
/// 平充电
/// </summary>
public double FlatCharg
{
get { return _FlatCharg; }
set { _FlatCharg = value; RaisePropertyChanged(); }
}
private double _FlatDisCharg;
/// <summary>
/// 平放电
/// </summary>
public double FlatDisCharg
{
get { return _FlatDisCharg; }
set { _FlatDisCharg = value; RaisePropertyChanged(); }
}
private double _TopPeakChargPw;
/// <summary>
/// 尖峰充电
/// </summary>
public double TopPeakChargPw
{
get { return _TopPeakChargPw; }
set { _TopPeakChargPw = value; RaisePropertyChanged(); }
}
private double _TopPeakDisChargPw;
/// <summary>
/// 尖峰放电
/// </summary>
public double TopPeakDisChargPw
{
get { return _TopPeakDisChargPw; }
set { _TopPeakDisChargPw = value; RaisePropertyChanged(); }
}
private double _PeakChargPw;
/// <summary>
/// 峰充电
/// </summary>
public double PeakChargPw
{
get { return _PeakChargPw; }
set { _PeakChargPw = value; RaisePropertyChanged(); }
}
private double _PeakDisChargPw;
/// <summary>
/// 峰放电
/// </summary>
public double PeakDisChargPw
{
get { return _PeakDisChargPw; }
set { _PeakDisChargPw = value; RaisePropertyChanged(); }
}
private double _ValleyChargPw;
/// <summary>
/// 谷充电
/// </summary>
public double ValleyChargPw
{
get { return _ValleyChargPw; }
set { _ValleyChargPw = value; RaisePropertyChanged(); }
}
private double _ValleyDisChargPw;
/// <summary>
/// 谷放电
/// </summary>
public double ValleyDisChargPw
{
get { return _ValleyDisChargPw; }
set { _ValleyDisChargPw = value; RaisePropertyChanged(); }
}
private double _FlatChargPw;
/// <summary>
/// 平充电
/// </summary>
public double FlatChargPw
{
get { return _FlatChargPw; }
set { _FlatChargPw = value; RaisePropertyChanged(); }
}
private double _FlatDisChargPw;
/// <summary>
/// 平放电
/// </summary>
public double FlatDisChargPw
{
get { return _FlatDisChargPw; }
set { _FlatDisChargPw = value; RaisePropertyChanged(); }
}
private double _ManageTotalEleFees;
/// <summary>
/// 管理大楼总电价
/// </summary>
public double ManageTotalEleFees
{
get { return _ManageTotalEleFees; }
set { _ManageTotalEleFees = value; RaisePropertyChanged(); }
}
private double _TaxSolarDisChargPw;
/// <summary>
/// 税务大楼光伏放电
/// </summary>
public double TaxSolarDisChargPw
{
get { return _TaxSolarDisChargPw; }
set { _TaxSolarDisChargPw = value; RaisePropertyChanged(); }
}
private double _ManageSolarDisChargPw;
/// <summary>
/// 管理大楼光伏放电
/// </summary>
public double ManageSolarDisChargPw
{
get { return _ManageSolarDisChargPw; }
set { _ManageSolarDisChargPw = value; RaisePropertyChanged(); }
}
private double _TaxSolarDisCharg;
/// <summary>
/// 税务大楼光伏放电 收费
/// </summary>
public double TaxSolarDisCharg
{
get { return _TaxSolarDisCharg; }
set { _TaxSolarDisCharg = value; RaisePropertyChanged(); }
}
private double _TotalEleFees;
/// <summary>
/// 总体收益
/// </summary>
public double TotalEleFees
{
get { return _TotalEleFees; }
set { _TotalEleFees = value; RaisePropertyChanged(); }
}
}
}