/********************************** BATTERY VALUE TABLE **************************************************/

/* 
 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Table Name	: TModuleValue
 * Description	: Battery Module Value and Status Table
 * createAt		: 2021.03.04
 * createBy		: JK.Woo
 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 */
drop table if exists TModuleValue;

create table TModuleValue
(
	create_date									timestamp		not null			,
	module_no									integer			not null			,
	pcb_sn										varchar(20)		null				,
	module_sn									varchar(32)		null				,
	comm_fail									BOOLEAN 		null				,
	op_status									integer 		null				,
	alarm_status								integer 		null				,
	module_voltage								float 			null				,
	module_current								float 			null				,
	module_soc									float			null				,
	module_soh									float			null				,
	cell_voltage_01								float			null				,
	cell_voltage_02								float			null				,
	cell_voltage_03								float			null				,
	cell_voltage_04								float			null				,
	cell_voltage_05								float			null				,
	cell_voltage_06								float			null				,
	cell_voltage_07								float			null				,
	cell_voltage_08								float			null				,
	cell_voltage_09								float			null				,
	cell_voltage_10								float			null				,
	cell_voltage_11								float			null				,
	cell_voltage_12								float			null				,
	cell_voltage_13								float			null				,
	cell_voltage_14								float			null				,
	cell_voltage_15								float			null				,
	cell_voltage_16								float			null				,
	cell_voltage_17								float			null				,
	cell_voltage_18								float			null				,
	cell_voltage_19								float			null				,
	cell_voltage_20								float			null				,
	cell_voltage_21								float			null				,
	cell_voltage_22								float			null				,
	cell_voltage_23								float			null				,
	cell_voltage_24								float			null				,
	cell_voltage_25								float			null				,
	cell_voltage_26								float			null				,
	cell_voltage_27								float			null				,
	cell_voltage_28								float			null				,
	cell_voltage_29								float			null				,
	cell_voltage_30								float			null				,
	cell_voltage_31								float			null				,
	cell_voltage_32								float			null				,
	cell_voltage_33								float			null				,
	cell_voltage_34								float			null				,
	cell_voltage_35								float			null				,
	cell_voltage_36								float			null				,
	temperature_01								float			null				,
	temperature_02								float			null				,
	temperature_03								float			null				,
	temperature_04								float			null				,
	temperature_05								float			null				,
	temperature_06								float			null				,
	temperature_07								float			null				,
	temperature_08								float			null				,
	temperature_09								float			null				,
	temperature_10								float			null				,
	temperature_11								float			null				,
	temperature_12								float			null				,
	temperature_13								float			null				,
	temperature_14								float			null				,
	temperature_15								float			null				,
	temperature_16								float			null				,
	warning										smallint		null				,
	fault										smallint		null				,

    primary key (create_date, module_no)
);

create index ModuleValue_data_idx1 on TModuleValue (create_date);
