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; } }