/********************************** 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									smallint		not null			,
	model_name									varchar(32)		null				,
	module_sn									varchar(32)		null				,
	fw_ver										varchar(10)		null				,  -- "V2.4.1.4"
	comm_fail									BOOLEAN 		null				,
	op_status									smallint 		null				,
	alarm_status								smallint 		null				,
	warning										smallint		null				,
	fault										smallint		null				,
	module_voltage								NUMERIC 		null				,
	module_current								NUMERIC 		null				,
	module_soc									NUMERIC			null				,
	module_soh									NUMERIC			null				,
	module_cyclecount							NUMERIC			null				,
	cv_diff										NUMERIC			null				,
	cell_voltage_01								NUMERIC			null				,
	cell_voltage_02								NUMERIC			null				,
	cell_voltage_03								NUMERIC			null				,
	cell_voltage_04								NUMERIC			null				,
	cell_voltage_05								NUMERIC			null				,
	cell_voltage_06								NUMERIC			null				,
	cell_voltage_07								NUMERIC			null				,
	cell_voltage_08								NUMERIC			null				,
	cell_voltage_09								NUMERIC			null				,
	cell_voltage_10								NUMERIC			null				,
	cell_voltage_11								NUMERIC			null				,
	cell_voltage_12								NUMERIC			null				,
	cell_voltage_13								NUMERIC			null				,
	cell_voltage_14								NUMERIC			null				,
	cell_voltage_15								NUMERIC			null				,
	cell_voltage_16								NUMERIC			null				,
	cell_voltage_17								NUMERIC			null				,
	cell_voltage_18								NUMERIC			null				,
	cell_voltage_19								NUMERIC			null				,
	cell_voltage_20								NUMERIC			null				,
	cell_voltage_21								NUMERIC			null				,
	cell_voltage_22								NUMERIC			null				,
	cell_voltage_23								NUMERIC			null				,
	cell_voltage_24								NUMERIC			null				,
	cell_voltage_25								NUMERIC			null				,
	cell_voltage_26								NUMERIC			null				,
	cell_voltage_27								NUMERIC			null				,
	cell_voltage_28								NUMERIC			null				,
	cell_voltage_29								NUMERIC			null				,
	cell_voltage_30								NUMERIC			null				,
	cell_voltage_31								NUMERIC			null				,
	cell_voltage_32								NUMERIC			null				,
	cell_voltage_33								NUMERIC			null				,
	cell_voltage_34								NUMERIC			null				,
	cell_voltage_35								NUMERIC			null				,
	cell_voltage_36								NUMERIC			null				,
	cell_voltage_37								NUMERIC			null				,
	cell_voltage_38								NUMERIC			null				,
	cell_voltage_39								NUMERIC			null				,
	tp_diff										NUMERIC			null				,
	temperature_01								NUMERIC			null				,
	temperature_02								NUMERIC			null				,
	temperature_03								NUMERIC			null				,
	temperature_04								NUMERIC			null				,
	temperature_05								NUMERIC			null				,
	temperature_06								NUMERIC			null				,
	temperature_07								NUMERIC			null				,
	temperature_08								NUMERIC			null				,
	ext1_temp									NUMERIC			null				,
	ext2_temp									NUMERIC			null				,
	chg_option									smallint		null				,

    primary key (create_date, module_no)
);

create index ModuleValue_data_idx1 on TModuleValue (create_date);
