#ifndef MODULE_EVCOMM_H_
#define MODULE_EVCOMM_H_

#include 	<stdbool.h>

int CanFd;

typedef unsigned char 		byte;

extern struct Ev_Board_Cmd
{
	int none;							// 0
	int address_assignment;				// 0x00000200
	int get_firmware_ver;				// 0x00000400
	int get_hardware_ver;				// 0x00000500
	int charging_permission;			// 0x00000600
	int present_output_power;			// 0x00000700
	int present_output_cap;				// 0x00000800
	int get_output_req;					// 0x00000900
	int get_battery_info;				// 0x00000A00
	int evse_stop_charging;				// 0x00000C00
	int get_miscellaneous_info;			// 0x00000D00

	int download_req;					// 0x00000E00
	int start_block_transfer;			// 0x00000F00
	int data_transfer;					// 0x00001000
	int download_finish;				// 0x00001100

	int isolation_status;				// 0x00001200
	int sync_rtc_info;					// 0x00001400
	int evse_precharge_info;			// 0x00001500
}Ev_Cmd;

extern struct Ev_Cmd_Dir
{
	unsigned short master_to_slave;
	unsigned short slave_to_master;
}Ev_Dir;

struct timeval _id_assign_time;

// Send msg to can-bus
void SetTargetAddr(byte *target_number, byte index);

void GetFirmwareVersion(byte gun_index, byte toId);
void SyncRtcInfo(byte gun_index, byte toId, int epoch);
void GetHardwareVersion(byte gun_index, byte toId);
void SetChargingPermission(byte gun_index, byte permissionStatus, short aOutputPw, short aOutputVol, short aOutputCur, byte toId);
void SetPresentOutputPower(short outputVol_b1, short outputCur_b1, short outputVol_b2, short outputCur_b2);
void SetPresentOutputCapacity(short aOutputPw_b1, short aOutputCur_b1, short aOutputPw_b2, short aOutputCur_b2);
void GetOutputReq(byte gun_index, byte toId);
void GetEvBatteryInfo(byte gun_index, byte toId);
void GetMiscellaneousInfo(byte gun_index, byte relayStatus, float power, float voltage, byte toId);
void SetIsolationStatus(byte gun_index, byte result, byte toId);
void SetEvsePrechargeInfo(byte gun_index, byte result, byte toId);
// �o�e�q�ΥD�ʰ���R�q���G�έ�]
void EvseStopChargingEvent(byte stopResult, byte *stopReason, byte toId);

// Receive msg From can-bus.

enum Receieve_PSU_msgf
{
	// ���ݥD��
	ADDRESS_REQ = 						0x080001FF,
	NOTIFICATION_EV_STATUS = 			0x08000300,
	NOTIFICATION_EV_STOP = 				0x08000B00,

	// ���ݦ^��
	ACK_EV_FW_VERSION = 				0x08000400,
	ACK_EV_HW_VERSION = 				0x08000500,
	ACK_GET_OUTPUT_REQ =				0x08000900,
	ACK_GET_EV_BATTERY_INFO =			0x08000A00,
	ACK_GET_MISCELLANEOUS_INFO = 		0x08000D00,
	ACK_EVSE_ISOLATION_STATUS = 		0x08001200,
	ACK_EVSE_PRECHAGE_INFO = 			0x08001500,
};

#endif /* MODULE_EVCOMM_H_ */