Initial commit

This commit is contained in:
2026-08-11 16:20:44 +09:00
commit 15535f4e1a
117 changed files with 23897 additions and 0 deletions

View File

@@ -0,0 +1,262 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using BMS_D1000H.Utils.Functions;
namespace BMS_D1000H.BMSConstData
{
public class ScreenID
{
public const int MAIN_SCREEN_ID = 0;
public const int TRAY_SCREEN_ID = 1;
public const int HISTORY_SCREEN_ID = 2;
public const int PASSWORD_SCREEN_ID = 3;
public const int PARAM_SET_SCREEN_ID = 4;
public const int PARAM_SETCMD_SCREEN_ID = 5;
public const int SCREEN_SAVER_SCREEN_ID = 6;
public const int SET_MENU_SCREEN_ID = 7;
public const int NET_CONFIG_SCREEN_ID = 8;
public const int NET_CONFIG_CMD_SCREEN_ID = 9;
public const int SYSTEM_SET_SCREEN = 10;
public const int SYSTEM_SET_CMD_SCREEN = 11;
public const int CHANGE_PASSWORD_SCREEN_ID = 20;
public const int NEW_PASSWORD_SCREEN_ID = 21;
public const int CONFIRM_PASSWORD_SCREEN_ID = 22;
}
public class SystemID
{
public const int MAX_MODULE_SIZE = 10;
public const int MAX_TRAY_CELL_SIZE = 15;
public const int MAX_TRAY_TEMP_SIZE = 6;
public static readonly int FLOATING_VOLTAGE = (int)(3.55 * MAX_TRAY_CELL_SIZE * 10);
}
public class AlarmFileConst
{
public static readonly string AlarmFilePath = PathHelper.GetFullPath("alarmlist.db");
}
public class AlarmID
{
public static readonly int MAX_ALARM_COUNT = 200;
public const byte POWER_ON_RESET = 0;
public const byte EXTERNAL_RESET = 1;
public const byte SOV_WARNING = 2;
public const byte COV_WARNING = 3;
public const byte SUV_WARNING = 4;
public const byte CUV_WARNING = 5;
public const byte OCC_WARNING = 6;
public const byte OCD_WARNING = 7;
public const byte OTC_WARNING = 8;
public const byte OTD_WARNING = 9;
public const byte LTC_WARNING = 10;
public const byte LTD_WARNING = 11;
public const byte SOC_WARNING = 12;
public const byte SOV_PROTECTION = 13;
public const byte COV_PROTECTION = 14;
public const byte SUV_PROTECTION = 15;
public const byte CUV_PROTECTION = 16;
public const byte OCC_PROTECTION = 17;
public const byte OCD_PROTECTION = 18;
public const byte OTC_PROTECTION = 19;
public const byte OTD_PROTECTION = 20;
public const byte LTC_PROTECTION = 21;
public const byte LTD_PROTECTION = 22;
public const byte BMU_COMM_FAIL = 23;
public const byte BMS_COMM_FAIL = 24;
public const byte STS_STAND_BY = 25;
public const byte STS_CHARGING = 26;
public const byte STS_DISCHARGING = 27;
public const byte STS_FLOATING = 28;
public const byte HIST_DELETE = 29;
public static readonly string[] name =
{
" Power On Reset ", // 0
" External Reset ", // 1
" System Over Voltage ", // 2
" Cell Over Voltage ", // 3
" System Under Voltage", // 4
" Cell Under Voltage ", // 5
" CHG Over Current ", // 6
" DCH Over Current ", // 7
" High Temperature ", // 8
" High Temperature ", // 9
" Low Temperature ", // 10
" Low Temperature ", // 11
" Low Capacity ", // 12
" System Over Voltage ", // 13
" Cell Over Voltage ", // 14
" System Under Voltage", // 15
" Cell Under Voltage ", // 16
" CHG Over Current ", // 17
" DCH Over Current ", // 18
" High Temperature ", // 19
" High Temperature ", // 20
" Low Temperature ", // 21
" Low Temperature ", // 22
" mBMS Comm. Fail ", // 23
" rBMS Comm. Fail ", // 24
" STAND BY ", // 25
" CHARGING ", // 26
" DISCHARGING ", // 27
" FLOATING ", // 28
" HISTORY DELETE ", // 29
" UNKNOWN-1",
" UNKNOWN-2",
" UNKNOWN-3",
" UNKNOWN-4",
" UNKNOWN-5",
};
}
public class StatusStr
{
public static readonly string[] operating =
{
"STAND BY", // 0
"CHARGING", // 1
"DISCHARGING", // 2
"FLOATING", // 3
"UNKNOWN[4]", // 4
"UNKNOWN[5]", // 5
"UNKNOWN[6]", // 6
"UNKNOWN[7]", // 7
"UNKNOWN[8]", // 8
"UNKNOWN[9]", // 9
"UNKNOWN[10]", // 10
};
public static readonly string[] alarm =
{
"NORMAL", // 0
"WARNING", // 1
"TRIP", // 2
"UNKNOWN[3]", // 3
"UNKNOWN[4]", // 4
"UNKNOWN[5]", // 5
"UNKNOWN[6]", // 6
"UNKNOWN[7]", // 7
"UNKNOWN[8]", // 8
"UNKNOWN[9]", // 9
"UNKNOWN[10]", // 10
};
}
public class EventID
{
public const int EVENT_INFO = 0;
public const int EVENT_RECOVERY = 1;
public const int EVENT_WARNING = 2;
public const int EVENT_PROTECTION = 3;
public static readonly string[] event_name =
{
"INFO",
"RECOVERY",
"WARNING",
"TRIP",
"UNKNOWN-1",
"UNKNOWN-2",
"UNKNOWN-3",
};
}
public class PosID
{
public static readonly byte POS_NON = 0;
public static readonly byte POS_MODULE_1 = 1;
public static readonly byte POS_MODULE_2 = 2;
public static readonly byte POS_MODULE_3 = 3;
public static readonly byte POS_MODULE_4 = 4;
public static readonly byte POS_MODULE_5 = 5;
public static readonly byte POS_MODULE_6 = 6;
public static readonly byte POS_MODULE_7 = 7;
public static readonly byte POS_MODULE_8 = 8;
public static readonly byte POS_MODULE_9 = 9;
public static readonly byte POS_MODULE_10 = 10;
public static readonly string[] pos =
{
"-",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
};
}
public class SetSystemParameter
{
public static readonly string[] Name =
{
" Module Quantity",
};
}
public class SetParamter
{
public static readonly string[] Name =
{
" System Over Voltage",
" Cell Over Voltage",
" System Under Voltage",
" Cell Under Voltage",
" Charge Over Current",
" Discharge Over Current",
" Charge High Temperature",
" Discharge High Temperature",
" Low SOC (State of Charge)"
};
}
public class SetNetConfig
{
public static readonly string[] Name =
{
" IP Address",
" Subnet Mask",
" Gateway Address",
" Trap #1 Address",
" Trap #2 Address",
" Trap #3 Address",
" Trap #4 Address"
};
}
public class CommandFlag
{
public static readonly ushort Reset = 0x0001;
public static readonly ushort Shutdown = 0x0002;
public static readonly ushort Sound = 0x0003;
public static readonly ushort SoundHold = 0x0004;
}
public class MessageFlag
{
public static readonly byte Reset = 0x00; //Reset에 대한 메시지값
public static readonly byte Enable = 0x01; //Shutdown, Sound 에 대한 메시지값
public static readonly byte Disable = 0x00; //Shutdown, Sound 에 대한 메시지값
public static readonly byte None = 0x00; //SoundHold에 대한 메시지값
}
}

View File

@@ -0,0 +1,239 @@
using System;
using System.Runtime.InteropServices;
using BMS_D1000H.BMSConstData;
namespace BMS_D1000H.DataStructs
{
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceDataSystem
{
[MarshalAs(UnmanagedType.I2, SizeConst = 2)]
public short MainCommState;
public short BatVoltage;
public short Current;
public short AverageCurrent;
public short RelativeStateOfCharge;
public short RemainingCapacity;
public short StateOfHealth;
public short CycleCount;
public short FullChargeCapacity;
public short DesignCapacity;
public short ModuleQuantity;
public short HistoryDelete;
public short MaxTemp;
public short MinTemp;
public short AvgTemp;
public short MaxCell;
public short MinCell;
public short AvgCell;
public short Warning;
public short Protection;
public short TrayCommState;
public short AlarmStatus;
public short OpStatus;
public short FetStatus;
public short UnixTimeStampMSB;
public short UnixTimeStampLSB;
public DeviceParam param;
public DeviceNetConfig netconfig;
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceDataTray
{
[MarshalAs(UnmanagedType.I2, SizeConst = 2)]
public short BatVoltage;
public short Current;
public short AverageCurrent;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SystemID.MAX_TRAY_CELL_SIZE)]
public short[] CellVoltage;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SystemID.MAX_TRAY_TEMP_SIZE)]
public short[] CellTemperature;
[MarshalAs(UnmanagedType.I2, SizeConst = 2)]
public short RelativeStateOfCharge;
public short RemainingCapacity;
public short StateOfHealth;
public short CycleCount;
public short FullChargeCapacity;
public short DesignCapacity;
public short MaxCellVoltage;
public short MinCellVoltage;
public short AvgCellVoltage;
public short DiffCellVoltage;
public short MaxCellNo;
public short MinCellNo;
public short MaxTemp;
public short MinTemp;
public short AvgTemp;
public short MaxTempNo;
public short MinTempNo;
public short Warning;
public short Protection;
public short AlarmStatus;
public short OpStatus;
public short FetStatus;
public short CellBalanceData;
public short CellBalanceAvg;
public short CellBalanceFlag;
public short Commfail;
public short cov_warning_cell;
public short cov_protection_cell;
public short cuv_warning_cell;
public short cuv_protection_cell;
public short otd_warning_temp;
public short otd_protection_temp;
public short otc_warning_temp;
public short otc_protection_temp;
public short ltd_warning_temp;
public short ltd_protection_temp;
public short ltc_warning_temp;
public short ltc_protection_temp;
public short UnixTimeStampMSB;
public short UnixTimeStampLSB;
public DeviceParam param;
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceParam
{
public DeviceParamVoltage voltage;
public DeviceParamCurrent current;
public DeviceParamTemperature temperature;
public DeviceParamSoc soc;
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceParamVoltage
{
[MarshalAs(UnmanagedType.I2, SizeConst = 2)]
public short CUV_Warning; // 0060 : Low cell voltage warning data
public short CUV_Threshold; // 0061 : Low cell voltage protection data
public short CUV_Recovery; // 0062 : Low cell voltage recovery data
public short SUV_Warning; // 0063 : Low voltage warning data
public short SUV_Threshold; // 0064 : Low voltage protection data
public short SUV_Recovery; // 0065 : Low voltage recovery data
public short COV_Warning; // 0066 : Over cell voltage warning data
public short COV_Threshold; // 0067 : Over cell voltage protection data
public short COV_Recovery; // 0068 : Over cell voltage recovery data
public short SOV_Warning; // 0069 : Over voltage warning data
public short SOV_Threshold; // 0070 : Over voltage protection data
public short SOV_Recovery; // 0071 : Over voltage recovery data
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceParamCurrent
{
[MarshalAs(UnmanagedType.I2, SizeConst = 2)]
public short OC_Chg_Threshold; // 0072 : Charge over current threshold
public short OC_Chg_Warning; // 0073 : Charge over current warning
public short OC_Chg_Recovery; // 0074 : Charge Over current recovery
public short OC_Chg_Time; // 0075 : Charge Over current time
public short OC_Dsg_Threshold; // 0076 : Discharge over current threshold
public short OC_Dsg_Warning; // 0077 : Discharge over current warning
public short OC_Dsg_Recovery; // 0078 : Discharge Over current recovery
public short OC_Dsg_Time; // 0079 : Discharge Over current time
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceParamTemperature
{
[MarshalAs(UnmanagedType.I2, SizeConst = 2)]
public short OT_Chg_Threshold; // 0080 : Charge high temperature threshold
public short OT_Chg_Warning; // 0081 : Charge high temperature warning
public short OT_Chg_Recovery; // 0082 : Charge high temperature recovery
public short OT_Chg_Time; // 0083 : Charge high temperature time
public short OT_Dsg_Threshold; // 0084 : Discharge high temperature threshold
public short OT_Dsg_Warning; // 0085 : Discharge high temperature warning
public short OT_Dsg_Recovery; // 0086 : Discharge high temperature recovery
public short OT_Dsg_Time; // 0087 : Discharge high temperature time
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceParamSoc
{
[MarshalAs(UnmanagedType.I2, SizeConst = 2)]
public short Low_SOC_Warning; // 0088 : Low SOC Warning
public short Low_SOC_Recovery; // 0089 : Low SOC Recovery
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceNetConfig
{
public ClassAddr ip_addr;
public ClassAddr subnet_mask;
public ClassAddr gateway_addr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public ClassAddr[] trap;
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct ClassAddr
{
[MarshalAs(UnmanagedType.I2, SizeConst = 4)]
public short[] addr;
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct DeviceParamSet
{
[MarshalAs(UnmanagedType.I2, SizeConst = 2)]
public short Set_Commad;
public short Set_Result;
public short Device_Addr;
public short Reg_Addr;
public short Reg_Size;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
public byte[] Reg_data;
}
// 파일에 읽기및 쓰기할 구조체를 정의 합니다. [StructLayout(LayoutKind.Sequential)] Attribute 반드시 정의 합니다.
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct TAlarm
{
public DateTime aTime;
public int aParam;
public byte aFlag;
public byte aNameNo;
public byte aPos;
public byte ctno;
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct TAlarmList
{
public int front;
public int rear;
public int position;
public int count;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 200)]
public TAlarm[] aData;
}
}