1319 lines
36 KiB
C#
1319 lines
36 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Runtime.InteropServices;
|
||
using System.Windows.Forms;
|
||
using static DevExpress.Utils.MVVM.Internal.ILReader;
|
||
using LFP_Manager.Function;
|
||
|
||
namespace LFP_Manager.DataStructure
|
||
{
|
||
public class CommConfig
|
||
{
|
||
public int CommType;
|
||
|
||
public string SnmpIP;
|
||
public int SnmpModelIndex;
|
||
public int ModuleQty;
|
||
public int RecvWaitTime;
|
||
|
||
public string UartPort;
|
||
public int UartBaudrate;
|
||
public int UartModelIndex;
|
||
public int UartProtocol;
|
||
|
||
public int DbLogPeriod;
|
||
|
||
public int GyroSensitive;
|
||
|
||
public int ControlLevel;
|
||
|
||
public string MasterPw;
|
||
public string EngineerPw;
|
||
public string TechnicianPw;
|
||
|
||
public CommConfig()
|
||
{
|
||
CommType = 0;
|
||
|
||
SnmpIP = "192.168.0.200";
|
||
SnmpModelIndex = 0;
|
||
ModuleQty = 1;
|
||
RecvWaitTime = 1500; // 1500ms
|
||
|
||
UartPort = "";
|
||
UartBaudrate = 9600;
|
||
UartModelIndex = 0;
|
||
UartProtocol = 0;
|
||
|
||
DbLogPeriod = 5;
|
||
|
||
GyroSensitive = 120;
|
||
|
||
ControlLevel = 0;
|
||
|
||
MasterPw = "8003";
|
||
EngineerPw = "7003";
|
||
TechnicianPw = "6003";
|
||
}
|
||
}
|
||
|
||
public class TMinMax
|
||
{
|
||
public short value;
|
||
public short num;
|
||
|
||
public TMinMax()
|
||
{
|
||
value = 0;
|
||
num = 0;
|
||
}
|
||
}
|
||
|
||
public class DeviceSystemTotalData
|
||
{
|
||
public bool CommFail;
|
||
|
||
public DeviceSystemIdent IdentData;
|
||
public DeviceValueTotalData ValueData;
|
||
public DeviceStatusTotalData StatusData;
|
||
|
||
public DeviceSystemTotalData()
|
||
{
|
||
IdentData = new DeviceSystemIdent();
|
||
ValueData = new DeviceValueTotalData();
|
||
StatusData = new DeviceStatusTotalData();
|
||
}
|
||
}
|
||
|
||
public class DeviceSystemIdent
|
||
{
|
||
public string Manufacturer;
|
||
public string DeviceModel;
|
||
//public int ModuleQuantity;
|
||
|
||
public byte[] fw_ver;
|
||
public string FwVerStr;
|
||
|
||
public int AlarmOutputMode;
|
||
|
||
public UInt32 ManufactureDate;
|
||
public string SerialNumber;
|
||
|
||
public DeviceSystemIdent()
|
||
{
|
||
Manufacturer = "";
|
||
DeviceModel = "";
|
||
//ModuleQuantity = 1;
|
||
|
||
fw_ver = new byte[4];
|
||
FwVerStr = "";
|
||
|
||
AlarmOutputMode = 0;
|
||
ManufactureDate = 0;
|
||
SerialNumber = "";
|
||
}
|
||
}
|
||
|
||
public class DateTimeStruct
|
||
{
|
||
public int year;
|
||
public int month;
|
||
public int day;
|
||
public int hour;
|
||
public int minute;
|
||
public int second;
|
||
|
||
public string DateTimeStr;
|
||
|
||
public DateTimeStruct()
|
||
{
|
||
DateTimeStr = "-";
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
year = 0;
|
||
month = 0;
|
||
day = 0;
|
||
hour = 0;
|
||
minute = 0;
|
||
second = 0;
|
||
DateTimeStr = "-";
|
||
}
|
||
}
|
||
|
||
public class DeviceSystemData
|
||
{
|
||
public bool active;
|
||
|
||
public int mNo;
|
||
public int cellQty;
|
||
public int recv_cellQty;
|
||
public int tempQty;
|
||
public int ntcQty;
|
||
public int ChargeVoltage;
|
||
public int DOD;
|
||
public int MaxChaCurrent;
|
||
public int MaxDchCurrent;
|
||
|
||
public int FloatVoltage;
|
||
public int BoostVoltage;
|
||
|
||
public int MinChargeTemp;
|
||
public int MaxChargeTemp;
|
||
|
||
public UInt32 heatbeat;
|
||
public bool CommFail;
|
||
public bool ShelfCommFail;
|
||
public DateTime LastRxTime;
|
||
public Int32 BmsDateTimeInt;
|
||
public ushort BmsDateTimeShort1;
|
||
public ushort BmsDateTimeShort2;
|
||
|
||
public DateTimeStruct BmsDateTime;
|
||
|
||
public DeviceValueData ValueData;
|
||
public DeviceAvgData AvgData;
|
||
public DeviceStatusData StatusData;
|
||
public DeviceParamData ParamData;
|
||
public DeviceCalibration CalibrationData;
|
||
public DeviceInforation Information;
|
||
public DeviceEtcStatus EtcStatus;
|
||
|
||
public DeviceMaxValue MaxValue;
|
||
public DeviceGyroValue GyroValue;
|
||
|
||
public DeviceSystemData()
|
||
{
|
||
active = false;
|
||
|
||
mNo = 0;
|
||
cellQty = csConstData.SystemInfo.MAX_MODULE_CELL_SIZE;
|
||
tempQty = csConstData.SystemInfo.MAX_MODULE_TEMP_SIZE;
|
||
ChargeVoltage = 0;
|
||
DOD = 0;
|
||
MaxChaCurrent = 0;
|
||
MaxDchCurrent = 0;
|
||
|
||
heatbeat = 0;
|
||
CommFail = false;
|
||
ShelfCommFail = false;
|
||
LastRxTime = DateTime.MinValue;
|
||
BmsDateTimeInt = 0;
|
||
|
||
BmsDateTime = new DateTimeStruct();
|
||
|
||
ValueData = new DeviceValueData();
|
||
AvgData = new DeviceAvgData();
|
||
StatusData = new DeviceStatusData();
|
||
ParamData = new DeviceParamData();
|
||
CalibrationData = new DeviceCalibration();
|
||
Information = new DeviceInforation();
|
||
EtcStatus = new DeviceEtcStatus();
|
||
|
||
MaxValue = new DeviceMaxValue();
|
||
GyroValue = new DeviceGyroValue();
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
active = false;
|
||
mNo = 0;
|
||
cellQty = csConstData.SystemInfo.MAX_MODULE_CELL_SIZE;
|
||
tempQty = csConstData.SystemInfo.MAX_MODULE_TEMP_SIZE;
|
||
ChargeVoltage = 0;
|
||
DOD = 0;
|
||
MaxChaCurrent = 0;
|
||
MaxDchCurrent = 0;
|
||
heatbeat = 0;
|
||
CommFail = false;
|
||
ShelfCommFail = false;
|
||
LastRxTime = DateTime.MinValue;
|
||
BmsDateTimeInt = 0;
|
||
BmsDateTime.Reset();
|
||
ValueData.Reset();
|
||
AvgData.Reset();
|
||
StatusData.Reset();
|
||
ParamData.Reset();
|
||
CalibrationData.Reset();
|
||
Information.Reset();
|
||
EtcStatus.Reset();
|
||
MaxValue.Reset();
|
||
GyroValue.Reset();
|
||
}
|
||
}
|
||
|
||
public class DeviceValueTotalData
|
||
{
|
||
public short TotalVoltage;
|
||
public short TotalCurrent;
|
||
public short TotalSOC;
|
||
public short TotalSOH;
|
||
public short TotalTemp;
|
||
|
||
public DeviceValueTotalData()
|
||
{
|
||
TotalVoltage = 0;
|
||
TotalCurrent = 0;
|
||
TotalSOC = 0;
|
||
TotalSOH = 0;
|
||
TotalTemp = 0;
|
||
}
|
||
}
|
||
|
||
public class DeviceValueData
|
||
{
|
||
public byte[] fw_ver;
|
||
|
||
public short voltageOfPack;
|
||
public short current;
|
||
public short cha_current;
|
||
public short dch_current;
|
||
public short averageCurrent;
|
||
public short rSOC;
|
||
|
||
public short NumOfCells;
|
||
public short NumOfTemps;
|
||
|
||
public ushort[] CellVoltage;
|
||
public short[] CellTemperature;
|
||
|
||
public short Ext1Temperature;
|
||
public short Ext2Temperature;
|
||
|
||
public short remainingCapacity;
|
||
public short stateOfHealth;
|
||
public int cycleCount;
|
||
public int fullChargeCapacity;
|
||
public int designedCapacity;
|
||
|
||
public int TimeLeft;
|
||
|
||
public int Ah_Charged;
|
||
public int Ah_Discharged;
|
||
public int NoOfDischargeCycles;
|
||
public int NoOfChargeCycles;
|
||
|
||
public int ModuleAlarms;
|
||
public int ModuleWarnings;
|
||
public int ModuleStatus;
|
||
public int ModuleVoltage_int;
|
||
public int ModBusDocVersion;
|
||
|
||
public int ParametersChanged;
|
||
public int MaxBattChargeCurr;
|
||
public int MaxBattDischargeCurr;
|
||
|
||
public int BatteryProdDateYear;
|
||
public int BatteryProdDateMonth;
|
||
public int BatteryProdDateDay;
|
||
|
||
public int BatteryModelDescription;
|
||
public int BatteryType;
|
||
|
||
public DeviceValueData()
|
||
{
|
||
fw_ver = new byte[6];
|
||
|
||
CellVoltage = new ushort[csConstData.SystemInfo.MAX_MODULE_CELL_SIZE];
|
||
CellTemperature = new short[csConstData.SystemInfo.MAX_MODULE_TEMP_SIZE];
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
voltageOfPack = 0;
|
||
current = 0;
|
||
cha_current = 0;
|
||
dch_current = 0;
|
||
averageCurrent = 0;
|
||
rSOC = 0;
|
||
NumOfCells = 0;
|
||
NumOfTemps = 0;
|
||
for (int i = 0; i < csConstData.SystemInfo.MAX_MODULE_CELL_SIZE; i++)
|
||
{
|
||
CellVoltage[i] = 0;
|
||
}
|
||
for (int i = 0; i < csConstData.SystemInfo.MAX_MODULE_TEMP_SIZE; i++)
|
||
{
|
||
CellTemperature[i] = 0;
|
||
}
|
||
Ext1Temperature = 0;
|
||
Ext2Temperature = 0;
|
||
remainingCapacity = 0;
|
||
stateOfHealth = 0;
|
||
cycleCount = 0;
|
||
fullChargeCapacity = 0;
|
||
designedCapacity = 0;
|
||
TimeLeft = 0;
|
||
Ah_Charged = 0;
|
||
Ah_Discharged = 0;
|
||
NoOfDischargeCycles = 0;
|
||
NoOfChargeCycles = 0;
|
||
ModuleAlarms = 0;
|
||
ModuleWarnings = 0;
|
||
ModuleStatus = 0;
|
||
ModuleVoltage_int = 0;
|
||
ModBusDocVersion = 0;
|
||
ParametersChanged = 0;
|
||
MaxBattChargeCurr = 0;
|
||
MaxBattDischargeCurr = 0;
|
||
BatteryProdDateYear = 0;
|
||
BatteryProdDateMonth = 0;
|
||
BatteryProdDateDay = 0;
|
||
BatteryModelDescription = 0;
|
||
BatteryType = 0;
|
||
}
|
||
}
|
||
|
||
public class DeviceAvgData
|
||
{
|
||
public int maxCellVoltage;
|
||
public int minCellVoltage;
|
||
public int avgCellVoltage;
|
||
public int diffCellVoltage;
|
||
public int maxCellNum;
|
||
public int minCellNum;
|
||
public int maxTemp;
|
||
public int minTemp;
|
||
public int avgTemp;
|
||
public int diffTemp;
|
||
public int maxTempNum;
|
||
public int minTempNum;
|
||
|
||
public DeviceAvgData()
|
||
{
|
||
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
maxCellVoltage = 0;
|
||
minCellVoltage = 0;
|
||
avgCellVoltage = 0;
|
||
diffCellVoltage = 0;
|
||
maxCellNum = 0;
|
||
minCellNum = 0;
|
||
maxTemp = 0;
|
||
minTemp = 0;
|
||
avgTemp = 0;
|
||
diffTemp = 0;
|
||
maxTempNum = 0;
|
||
minTempNum = 0;
|
||
}
|
||
}
|
||
|
||
public class DeviceStatusTotalData
|
||
{
|
||
public short batteryStatus;
|
||
public short warning;
|
||
public short protection;
|
||
public short status;
|
||
}
|
||
|
||
public class DeviceStatusData
|
||
{
|
||
public short batteryStatus;
|
||
public short batteryStatus1;
|
||
public short warning;
|
||
public short protection;
|
||
public short protection1;
|
||
public short status;
|
||
public short faultAndStatus;
|
||
public short relayStatus;
|
||
public short errorCode;
|
||
public short specialAlarm; // 1: Commfail, 2. Gyro, 3, Breaker
|
||
|
||
public short faultstatus; // Only for RS-485
|
||
|
||
public short cellBallanceStatus;
|
||
public short cellBalanceValue;
|
||
public short cellBalanceFlag;
|
||
|
||
public DeviceStatusData()
|
||
{
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
batteryStatus = 0;
|
||
batteryStatus1 = 0;
|
||
warning = 0;
|
||
protection = 0;
|
||
protection1 = 0;
|
||
status = 0;
|
||
faultAndStatus = 0;
|
||
relayStatus = 0;
|
||
errorCode = 0;
|
||
specialAlarm = 0;
|
||
faultstatus = 0;
|
||
cellBallanceStatus = 0;
|
||
cellBalanceValue = 0;
|
||
cellBalanceFlag = 0;
|
||
}
|
||
}
|
||
|
||
public class DeviceCommStatus
|
||
{
|
||
public DateTime LastRxTime;
|
||
public bool CommFail;
|
||
}
|
||
|
||
public class DeviceParamData
|
||
{
|
||
public short CellOverVoltageTrip;
|
||
public short CellOverVoltageWarning;
|
||
public short CellOverVoltageRelease;
|
||
public short CellUnderVoltageTrip;
|
||
public short CellUnderVoltageWarning;
|
||
public short CellUnderVoltageRelease;
|
||
|
||
public short SysOverVoltageTrip;
|
||
public short SysOverVoltageWarning;
|
||
public short SysOverVoltageRelease;
|
||
public short SysUnderVoltageTrip;
|
||
public short SysUnderVoltageWarning;
|
||
public short SysUnderVoltageRelease;
|
||
|
||
public short ChaHighTempTrip;
|
||
public short ChaHighTempWarning;
|
||
public short ChaHighTempRelease;
|
||
public short ChaLowTempTrip;
|
||
public short ChaLowTempWarning;
|
||
public short ChaLowTempRelease;
|
||
public short DchHighTempTrip;
|
||
public short DchHighTempWarning;
|
||
public short DchHighTempRelease;
|
||
public short DchLowTempTrip;
|
||
public short DchLowTempWarning;
|
||
public short DchLowTempRelease;
|
||
|
||
public short ChaOverCurrentTrip1;
|
||
public short ChaOverCurrentTrip2;
|
||
public short ChaOverCurrentWarning;
|
||
public short ChaOverCurrentReleaseTime;
|
||
public short ChaOverCurrentTimes;
|
||
public short ChaOverCurrentDelay1;
|
||
public short ChaOverCurrentDelay2;
|
||
|
||
public short DchOverCurrentTrip1;
|
||
public short DchOverCurrentTrip2;
|
||
public short DchOverCurrentWarning;
|
||
public short DchOverCurrentReleaseTime;
|
||
public short DchOverCurrentTimes;
|
||
public short DchOverCurrentDelay1;
|
||
public short DchOverCurrentDelay2;
|
||
|
||
public short PcbHighTempTrip;
|
||
public short PcbHighTempWarning;
|
||
public short PcbHighTempRelease;
|
||
|
||
public short EnvLowTempWarning;
|
||
public short EnvLowTempTrip;
|
||
public short EnvLowTempRelease;
|
||
public short EnvHighTempWarning;
|
||
public short EnvHighTempTrip;
|
||
public short EnvHighTempRelease;
|
||
|
||
public short ShortCircuit;
|
||
|
||
public short LowSocTrip;
|
||
public short LowSocWarning;
|
||
public short LowSocRelease;
|
||
|
||
public short CellVoltageDifferenceTrip;
|
||
public short CellVoltageDifferenceWarning;
|
||
public short CellVoltageDifferenceRelease;
|
||
public short CellVoltageDifferenceTime;
|
||
|
||
public short DefalutParamOption;
|
||
public short DefalutParamAll;
|
||
public ushort ReadParamAll;
|
||
|
||
public DeviceParamData()
|
||
{
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
CellOverVoltageTrip = 0;
|
||
CellOverVoltageWarning = 0;
|
||
CellOverVoltageRelease = 0;
|
||
CellUnderVoltageTrip = 0;
|
||
CellUnderVoltageWarning = 0;
|
||
CellUnderVoltageRelease = 0;
|
||
SysOverVoltageTrip = 0;
|
||
SysOverVoltageWarning = 0;
|
||
SysOverVoltageRelease = 0;
|
||
SysUnderVoltageTrip = 0;
|
||
SysUnderVoltageWarning = 0;
|
||
SysUnderVoltageRelease = 0;
|
||
ChaHighTempTrip = 0;
|
||
ChaHighTempWarning = 0;
|
||
ChaHighTempRelease = 0;
|
||
ChaLowTempTrip = 0;
|
||
ChaLowTempWarning = 0;
|
||
ChaLowTempRelease = 0;
|
||
DchHighTempTrip = 0;
|
||
DchHighTempWarning = 0;
|
||
DchHighTempRelease = 0;
|
||
DchLowTempTrip = 0;
|
||
DchLowTempWarning = 0;
|
||
DchLowTempRelease = 0;
|
||
ChaOverCurrentTrip1 = 0;
|
||
ChaOverCurrentTrip2 = 0;
|
||
ChaOverCurrentWarning = 0;
|
||
ChaOverCurrentReleaseTime = 0;
|
||
ChaOverCurrentTimes = 0;
|
||
ChaOverCurrentDelay1 = 0;
|
||
ChaOverCurrentDelay2 = 0;
|
||
DchOverCurrentTrip1 = 0;
|
||
DchOverCurrentTrip2 = 0;
|
||
DchOverCurrentWarning = 0;
|
||
DchOverCurrentReleaseTime = 0;
|
||
DchOverCurrentTimes = 0;
|
||
DchOverCurrentDelay1 = 0;
|
||
DchOverCurrentDelay2 = 0;
|
||
PcbHighTempTrip = 0;
|
||
PcbHighTempWarning = 0;
|
||
PcbHighTempRelease = 0;
|
||
EnvLowTempWarning = 0;
|
||
EnvLowTempTrip = 0;
|
||
EnvLowTempRelease = 0;
|
||
EnvHighTempWarning = 0;
|
||
EnvHighTempTrip = 0;
|
||
EnvHighTempRelease = 0;
|
||
ShortCircuit = 0;
|
||
LowSocTrip = 0;
|
||
LowSocWarning = 0;
|
||
LowSocRelease = 0;
|
||
CellVoltageDifferenceTrip = 0;
|
||
CellVoltageDifferenceWarning = 0;
|
||
CellVoltageDifferenceRelease = 0;
|
||
CellVoltageDifferenceTime = 0;
|
||
DefalutParamOption = 0;
|
||
DefalutParamAll = 0;
|
||
ReadParamAll = 0;
|
||
}
|
||
public DeviceParamData DeepCopy()
|
||
{
|
||
DeviceParamData newCopy = new DeviceParamData
|
||
{
|
||
CellOverVoltageTrip = CellOverVoltageTrip,
|
||
CellOverVoltageWarning = CellOverVoltageWarning,
|
||
CellOverVoltageRelease = CellOverVoltageRelease,
|
||
CellUnderVoltageTrip = CellUnderVoltageTrip,
|
||
CellUnderVoltageWarning = CellUnderVoltageWarning,
|
||
CellUnderVoltageRelease = CellUnderVoltageRelease,
|
||
|
||
SysOverVoltageTrip = SysOverVoltageTrip,
|
||
SysOverVoltageWarning = SysOverVoltageWarning,
|
||
SysOverVoltageRelease = SysOverVoltageRelease,
|
||
SysUnderVoltageTrip = SysUnderVoltageTrip,
|
||
SysUnderVoltageWarning = SysUnderVoltageWarning,
|
||
SysUnderVoltageRelease = SysUnderVoltageRelease,
|
||
|
||
ChaHighTempTrip = ChaHighTempTrip,
|
||
ChaHighTempWarning = ChaHighTempWarning,
|
||
ChaHighTempRelease = ChaHighTempRelease,
|
||
ChaLowTempTrip = ChaLowTempTrip,
|
||
ChaLowTempWarning = ChaLowTempWarning,
|
||
ChaLowTempRelease = ChaLowTempRelease,
|
||
DchHighTempTrip = DchHighTempTrip,
|
||
DchHighTempWarning = DchHighTempWarning,
|
||
DchHighTempRelease = DchHighTempRelease,
|
||
DchLowTempTrip = DchLowTempTrip,
|
||
DchLowTempWarning = DchLowTempWarning,
|
||
DchLowTempRelease = DchLowTempRelease,
|
||
|
||
ChaOverCurrentTrip1 = ChaOverCurrentTrip1,
|
||
ChaOverCurrentTrip2 = ChaOverCurrentTrip2,
|
||
ChaOverCurrentWarning = ChaOverCurrentWarning,
|
||
ChaOverCurrentReleaseTime = ChaOverCurrentReleaseTime,
|
||
ChaOverCurrentTimes = ChaOverCurrentTimes,
|
||
ChaOverCurrentDelay1 = ChaOverCurrentDelay1,
|
||
ChaOverCurrentDelay2 = ChaOverCurrentDelay2,
|
||
|
||
DchOverCurrentTrip1 = DchOverCurrentTrip1,
|
||
DchOverCurrentTrip2 = DchOverCurrentTrip2,
|
||
DchOverCurrentWarning = DchOverCurrentWarning,
|
||
DchOverCurrentReleaseTime = DchOverCurrentReleaseTime,
|
||
DchOverCurrentTimes = DchOverCurrentTimes,
|
||
DchOverCurrentDelay1 = DchOverCurrentDelay1,
|
||
DchOverCurrentDelay2 = DchOverCurrentDelay2,
|
||
|
||
PcbHighTempTrip = PcbHighTempTrip,
|
||
PcbHighTempWarning = PcbHighTempWarning,
|
||
PcbHighTempRelease = PcbHighTempRelease,
|
||
|
||
EnvLowTempWarning = EnvLowTempWarning,
|
||
EnvLowTempTrip = EnvLowTempTrip,
|
||
EnvLowTempRelease = EnvLowTempRelease,
|
||
EnvHighTempWarning = EnvHighTempWarning,
|
||
EnvHighTempTrip = EnvHighTempTrip,
|
||
EnvHighTempRelease = EnvHighTempRelease,
|
||
|
||
ShortCircuit = ShortCircuit,
|
||
|
||
LowSocTrip = LowSocTrip,
|
||
LowSocWarning = LowSocWarning,
|
||
LowSocRelease = LowSocRelease,
|
||
|
||
CellVoltageDifferenceTrip = CellVoltageDifferenceTrip,
|
||
CellVoltageDifferenceWarning = CellVoltageDifferenceWarning,
|
||
CellVoltageDifferenceRelease = CellVoltageDifferenceRelease,
|
||
CellVoltageDifferenceTime = CellVoltageDifferenceTime,
|
||
|
||
DefalutParamOption = DefalutParamOption,
|
||
DefalutParamAll = DefalutParamAll,
|
||
ReadParamAll = ReadParamAll,
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
|
||
public class DeviceCalibration
|
||
{
|
||
public ForcedBalControl ForcedBalancing;
|
||
public BatteryParameter Battery;
|
||
public SystemInfor SystemInfo;
|
||
public CapCalibration CapCalib;
|
||
public FetCalibration FetCalib;
|
||
public ChargeMode ChaMode;
|
||
public TAntiTheft AntiTheft;
|
||
public TBmsDateTime BmsDateTime;
|
||
|
||
public TBalCalib BalCalib;
|
||
|
||
public DeviceInforation InvData;
|
||
|
||
public TAntiTheftComm AntiTheftComm;
|
||
public TAntiTheftGyro AntiTheftGyro;
|
||
|
||
public DeviceCalibration()
|
||
{
|
||
ForcedBalancing = new ForcedBalControl();
|
||
Battery = new BatteryParameter();
|
||
SystemInfo = new SystemInfor();
|
||
CapCalib = new CapCalibration();
|
||
FetCalib = new FetCalibration();
|
||
ChaMode = new ChargeMode();
|
||
AntiTheft = new TAntiTheft();
|
||
BmsDateTime = new TBmsDateTime();
|
||
|
||
BalCalib = new TBalCalib();
|
||
|
||
InvData = new DeviceInforation();
|
||
|
||
AntiTheftComm = new TAntiTheftComm();
|
||
AntiTheftGyro = new TAntiTheftGyro();
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
ForcedBalancing.Reset();
|
||
Battery.Reset();
|
||
SystemInfo.Reset();
|
||
CapCalib.Reset();
|
||
FetCalib.Reset();
|
||
ChaMode.Reset();
|
||
AntiTheft.Reset();
|
||
BmsDateTime.Reset();
|
||
BalCalib.Reset();
|
||
InvData.Reset();
|
||
AntiTheftComm.Reset();
|
||
AntiTheftGyro.Reset();
|
||
}
|
||
|
||
public DeviceCalibration DeepCopy()
|
||
{
|
||
DeviceCalibration newCopy = new DeviceCalibration
|
||
{
|
||
ForcedBalancing = ForcedBalancing,
|
||
Battery = Battery,
|
||
SystemInfo = SystemInfo,
|
||
|
||
CapCalib = CapCalib.DeepCopy(),
|
||
AntiTheft = AntiTheft.DeepCopy(),
|
||
BalCalib = BalCalib.DeepCopy(),
|
||
|
||
FetCalib = FetCalib,
|
||
ChaMode = ChaMode.DeepCopy(),
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
|
||
public class TAntiTheftComm
|
||
{
|
||
public int TimeOut;
|
||
public int FuncSwitch;
|
||
public int Unlock;
|
||
|
||
public TAntiTheftComm()
|
||
{
|
||
TimeOut = 0;
|
||
FuncSwitch = 0;
|
||
Unlock = 0;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
TimeOut = 0;
|
||
FuncSwitch = 0;
|
||
Unlock = 0;
|
||
}
|
||
|
||
public TAntiTheftComm DeepCopy()
|
||
{
|
||
TAntiTheftComm newCopy = new TAntiTheftComm
|
||
{
|
||
TimeOut = TimeOut,
|
||
FuncSwitch = FuncSwitch,
|
||
Unlock = Unlock
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
public class TAntiTheftGyro
|
||
{
|
||
public int XAxis;
|
||
public int YAxis;
|
||
public int ZAxis;
|
||
public int GyroPolicySel;
|
||
public int GyroFuncSwitch;
|
||
public int GyroState;
|
||
public int Unlock;
|
||
|
||
public TAntiTheftGyro()
|
||
{
|
||
XAxis = 0;
|
||
YAxis = 0;
|
||
ZAxis = 0;
|
||
GyroPolicySel = 0;
|
||
GyroFuncSwitch = 0;
|
||
GyroState = 0;
|
||
Unlock = 0;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
XAxis = 0;
|
||
YAxis = 0;
|
||
ZAxis = 0;
|
||
GyroPolicySel = 0;
|
||
GyroFuncSwitch = 0;
|
||
GyroState = 0;
|
||
Unlock = 0;
|
||
}
|
||
|
||
public TAntiTheftGyro DeepCopy()
|
||
{
|
||
TAntiTheftGyro newCopy = new TAntiTheftGyro
|
||
{
|
||
XAxis = XAxis,
|
||
YAxis = YAxis,
|
||
ZAxis = ZAxis,
|
||
GyroPolicySel = GyroPolicySel,
|
||
GyroFuncSwitch = GyroFuncSwitch,
|
||
GyroState = GyroState,
|
||
Unlock = Unlock,
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
|
||
public class ForcedBalControl
|
||
{
|
||
public short Control;
|
||
public short CellNo;
|
||
public bool AutoB;
|
||
|
||
public ForcedBalControl()
|
||
{
|
||
Control = 0;
|
||
CellNo = 0;
|
||
AutoB = false;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
Control = 0;
|
||
CellNo = 0;
|
||
AutoB = false;
|
||
}
|
||
}
|
||
|
||
public class BatteryParameter
|
||
{
|
||
public short CellQty;
|
||
public short TempQty;
|
||
public UInt32 Capacity;
|
||
|
||
public BatteryParameter()
|
||
{
|
||
CellQty = 0;
|
||
TempQty = 0;
|
||
Capacity = 0;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
CellQty = 0;
|
||
TempQty = 0;
|
||
Capacity = 0;
|
||
}
|
||
}
|
||
|
||
public class SystemInfor
|
||
{
|
||
//public short Id;
|
||
public DateTime devTime;
|
||
public ushort LastRebootCause;
|
||
|
||
public SystemInfor()
|
||
{
|
||
//Id = 0;
|
||
devTime = DateTime.MinValue;
|
||
LastRebootCause = 0;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
//Id = 0;
|
||
devTime = DateTime.MinValue;
|
||
LastRebootCause = 0;
|
||
}
|
||
}
|
||
|
||
public class CapCalibration
|
||
{
|
||
public int DesignCapacity;
|
||
public int SocValue;
|
||
public int CycleCount;
|
||
|
||
public CapCalibration()
|
||
{
|
||
DesignCapacity = 0;
|
||
SocValue = 0;
|
||
CycleCount = 0;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
DesignCapacity = 0;
|
||
SocValue = 0;
|
||
CycleCount = 0;
|
||
}
|
||
|
||
public CapCalibration DeepCopy()
|
||
{
|
||
CapCalibration newCopy = new CapCalibration
|
||
{
|
||
DesignCapacity = DesignCapacity,
|
||
SocValue = SocValue,
|
||
CycleCount = CycleCount,
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
|
||
public class ChargeMode
|
||
{
|
||
public int Mode;
|
||
public int Value;
|
||
|
||
public ChargeMode()
|
||
{
|
||
Mode = 0;
|
||
Value = 0;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
Mode = 0;
|
||
Value = 0;
|
||
}
|
||
|
||
public ChargeMode DeepCopy()
|
||
{
|
||
ChargeMode newCopy = new ChargeMode
|
||
{
|
||
Mode = Mode,
|
||
Value = Value,
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
public class TAntiTheft
|
||
{
|
||
public int Comm;
|
||
public int GyroScope;
|
||
|
||
public TAntiTheft()
|
||
{
|
||
Comm = 0;
|
||
GyroScope = 0;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
Comm = 0;
|
||
GyroScope = 0;
|
||
}
|
||
|
||
public TAntiTheft DeepCopy()
|
||
{
|
||
TAntiTheft newCopy = new TAntiTheft
|
||
{
|
||
Comm = Comm,
|
||
GyroScope = GyroScope,
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
public class TBmsDateTime
|
||
{
|
||
public string Str;
|
||
public int lValue;
|
||
public short[] sValue;
|
||
|
||
public TBmsDateTime()
|
||
{
|
||
Str = "";
|
||
lValue = 0;
|
||
sValue = new short[2];
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
Str = "";
|
||
lValue = 0;
|
||
sValue = new short[2];
|
||
}
|
||
|
||
public TBmsDateTime DeepCopy()
|
||
{
|
||
TBmsDateTime newCopy = new TBmsDateTime
|
||
{
|
||
Str = Str,
|
||
lValue = lValue,
|
||
};
|
||
for (int i = 0; i < 2; i++)
|
||
{
|
||
newCopy.sValue[i] = sValue[i];
|
||
}
|
||
return newCopy;
|
||
}
|
||
}
|
||
public class TBalCalib
|
||
{
|
||
public int Volt;
|
||
public int Diff;
|
||
|
||
public TBalCalib()
|
||
{
|
||
Volt = 0;
|
||
Diff = 0;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
Volt = 0;
|
||
Diff = 0;
|
||
}
|
||
|
||
public TBalCalib DeepCopy()
|
||
{
|
||
TBalCalib newCopy = new TBalCalib
|
||
{
|
||
Volt = Volt,
|
||
Diff = Diff,
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
|
||
|
||
public class FetCalibration
|
||
{
|
||
public short FetStatus;
|
||
public short DchFetOff; // 6010
|
||
public short ChaFetOff; // 6011
|
||
public short LmtChaFetOff; // 6012
|
||
public short PreChaFetOn; // 6013
|
||
public short HeaterFetOn; // 6014
|
||
public short ChaFetOn; // 6015
|
||
|
||
public FetCalibration()
|
||
{
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
FetStatus = 0;
|
||
DchFetOff = 0;
|
||
ChaFetOff = 0;
|
||
LmtChaFetOff = 0;
|
||
PreChaFetOn = 0;
|
||
HeaterFetOn = 0;
|
||
ChaFetOn = 0;
|
||
}
|
||
|
||
public FetCalibration DeepCopy()
|
||
{
|
||
FetCalibration newCopy = new FetCalibration
|
||
{
|
||
FetStatus = FetStatus,
|
||
DchFetOff = DchFetOff,
|
||
ChaFetOff = ChaFetOff,
|
||
LmtChaFetOff = LmtChaFetOff,
|
||
PreChaFetOn = PreChaFetOn,
|
||
HeaterFetOn = HeaterFetOn,
|
||
ChaFetOn = ChaFetOn,
|
||
};
|
||
return newCopy;
|
||
}
|
||
}
|
||
|
||
public class DeviceInforation
|
||
{
|
||
//public string ManuDate_Str;
|
||
public byte[] ManuDate_Byte;
|
||
|
||
public byte[] Model_Byte;
|
||
public byte[] FwVer_Byte;
|
||
//public string Model_Str;
|
||
//public string FwVer_Str;
|
||
public byte[] BMS_SN;
|
||
//public string BMS_SN_Str;
|
||
public byte[] Module_SN;
|
||
public byte[] Vendor_Byte;
|
||
|
||
public string VendorName;
|
||
public string ProductCode;
|
||
public string MajorMinorRev;
|
||
public string ModelName;
|
||
public string HwSerialNumber;
|
||
public string HwProductRev;
|
||
public string ManufacturingDate;
|
||
public string SwProductRev;
|
||
|
||
public DeviceInforation()
|
||
{
|
||
ManuDate_Byte = new byte[10];
|
||
|
||
Model_Byte = new byte[24];
|
||
FwVer_Byte = new byte[6];
|
||
//Model_Str = " ";
|
||
//FwVer_Str = " ";
|
||
BMS_SN = new byte[32];
|
||
//BMS_SN_Str = " ";
|
||
Module_SN = new byte[32];
|
||
Vendor_Byte = new byte[10];
|
||
|
||
VendorName = "-";
|
||
ProductCode = "-";
|
||
MajorMinorRev = "-";
|
||
ModelName = "-";
|
||
HwSerialNumber = "-";
|
||
HwProductRev = "-";
|
||
ManufacturingDate = "-";
|
||
SwProductRev = "-";
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
Array.Clear(ManuDate_Byte, 0, ManuDate_Byte.Length);
|
||
Array.Clear(Model_Byte, 0, Model_Byte.Length);
|
||
Array.Clear(FwVer_Byte, 0, FwVer_Byte.Length);
|
||
Array.Clear(BMS_SN, 0, BMS_SN.Length);
|
||
Array.Clear(Module_SN, 0, Module_SN.Length);
|
||
Array.Clear(Vendor_Byte, 0, Vendor_Byte.Length);
|
||
VendorName = "-";
|
||
ProductCode = "-";
|
||
MajorMinorRev = "-";
|
||
ModelName = "-";
|
||
HwSerialNumber = "-";
|
||
HwProductRev = "-";
|
||
ManufacturingDate = "-";
|
||
SwProductRev = "-";
|
||
}
|
||
}
|
||
|
||
public class DeviceEtcStatus
|
||
{
|
||
public short SwitchHW;
|
||
public short SwitchWarning;
|
||
public short SwitchProtect;
|
||
public ushort LogDurationIdle; // min
|
||
public ushort LogDurationActive; // min
|
||
public UInt32 DataAndTime;
|
||
public ushort ChgOCPModel; /* 充电限流
|
||
0:不限流保护
|
||
1:始终限流充电
|
||
2:预充保护
|
||
4:充电过流后限流
|
||
8:预充+充电过流后限流 */
|
||
public short ChgLmtVoltage; // mv
|
||
public short SOC_StopFloat; // % 暂停浮充Soc
|
||
public short SOC_RecvFloat; // % 恢复浮充电压
|
||
public short DurationFloat; // sec
|
||
public short DurationIdle; // sec
|
||
public short VoltageStopFloat; // 0.1V
|
||
public short VoltageRecvFloat; // 0.1V
|
||
public short FloatMode; /* 0000: 持续浮充
|
||
0001:检测电压
|
||
0002:定时浮充
|
||
0003:检测SOC */
|
||
public short BalanceVoltage; // mV 均衡启动电压
|
||
public short BalanceDeltaV; // mV 均衡启动压差
|
||
public short WarnLowCapacity; // 低容量告警
|
||
public short HistroyDelete; // 删除数据记录
|
||
|
||
public DeviceEtcStatus()
|
||
{
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
SwitchHW = 0;
|
||
SwitchWarning = 0;
|
||
SwitchProtect = 0;
|
||
LogDurationIdle = 0;
|
||
LogDurationActive = 0;
|
||
DataAndTime = 0;
|
||
ChgOCPModel = 0;
|
||
ChgLmtVoltage = 0;
|
||
SOC_StopFloat = 0;
|
||
SOC_RecvFloat = 0;
|
||
DurationFloat = 0;
|
||
DurationIdle = 0;
|
||
VoltageStopFloat = 0;
|
||
VoltageRecvFloat = 0;
|
||
FloatMode = 0;
|
||
BalanceVoltage = 0;
|
||
BalanceDeltaV = 0;
|
||
WarnLowCapacity = 0;
|
||
HistroyDelete = 0;
|
||
}
|
||
}
|
||
|
||
public class DeviceMaxValue
|
||
{
|
||
public short MaxChgCurrent;
|
||
public short MaxChgTemperature;
|
||
public short MinChgTemperature;
|
||
public short FloatChgVolt;
|
||
public short BoostChgVolt;
|
||
|
||
public DeviceMaxValue()
|
||
{
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
MaxChgCurrent = 0;
|
||
MaxChgTemperature = 0;
|
||
MinChgTemperature = 0;
|
||
FloatChgVolt = 0;
|
||
BoostChgVolt = 0;
|
||
}
|
||
}
|
||
public class DeviceGyroValue
|
||
{
|
||
public short X_axis;
|
||
public short Y_axis;
|
||
public short Z_axis;
|
||
public short Gyro_policy_sel;
|
||
public short Gyro_func_sw;
|
||
public short Gyro_state;
|
||
|
||
public DeviceGyroValue()
|
||
{
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
X_axis = 0;
|
||
Y_axis = 0;
|
||
Z_axis = 0;
|
||
Gyro_policy_sel = 0;
|
||
Gyro_func_sw = 0;
|
||
Gyro_state = 0;
|
||
}
|
||
}
|
||
|
||
public class TUartTRxData
|
||
{
|
||
public int type;
|
||
public int length;
|
||
public byte[] data;
|
||
|
||
public TUartTRxData()
|
||
{
|
||
type = 0;
|
||
length = 0;
|
||
data = new byte[256];
|
||
}
|
||
public TUartTRxData DeepCopy()
|
||
{
|
||
TUartTRxData newCopy = new TUartTRxData
|
||
{
|
||
type = type,
|
||
length = length,
|
||
data = data
|
||
};
|
||
for (int i = 0; i < data.Length; i++)
|
||
{
|
||
newCopy.data[i] = data[i];
|
||
}
|
||
|
||
return newCopy;
|
||
}
|
||
}
|
||
|
||
public class TUartTxBuff
|
||
{
|
||
public int InPos;
|
||
public int OutPos;
|
||
public TUartTRxData[] Buf;
|
||
public TUartTxBuff()
|
||
{
|
||
InPos = 0;
|
||
OutPos = 0;
|
||
Buf = new TUartTRxData[50];
|
||
for (int i = 0; i < 50; i++)
|
||
{
|
||
Buf[i] = new TUartTRxData();
|
||
}
|
||
}
|
||
|
||
public bool CheckBuff()
|
||
{
|
||
if (InPos != OutPos) { return true; }
|
||
else { return false; }
|
||
}
|
||
public void PutBuff(TUartTRxData UartTxData)
|
||
{
|
||
if (UartTxData != null)
|
||
{
|
||
Buf[InPos++] = UartTxData.DeepCopy();
|
||
InPos %= 50;
|
||
}
|
||
}
|
||
public TUartTRxData GetBuff()
|
||
{
|
||
TUartTRxData result = null;
|
||
|
||
if (InPos != OutPos)
|
||
{
|
||
result = Buf[OutPos++].DeepCopy();
|
||
OutPos %= 50;
|
||
}
|
||
return result;
|
||
}
|
||
}
|
||
}
|