#ifndef _MODBUS_MONITOR_H_
#define _MODBUS_MONITOR_H_
#include "Modbus.h"
#include <stdio.h>
#include <string.h>
#include "measure.h"


typedef struct
{
	unsigned short Ia;   					//只读		 //当前A相电流 					0x0001 R A
    unsigned short Ib;      							 //当前B相电流 					0x0002 R A
    unsigned short Ic;   								 //当前C相电流 					0x0003 R A	
    unsigned short RunStatus;   					 	 //当前运行状态 				0x0004 R V
    unsigned short FaultStatus;           				 //FaultLED状态       		    0x0005
	
	unsigned short TripLevel;    			//读写		 //当前脱扣等级 				0x0006 R V
    unsigned short RatedCurrentLevel;   				 //当前额定电流等级		 	    0x0007 R V
	unsigned short PhaseProtectOn_Off;    				 //不平衡保护开关状态   		0x0008
	unsigned short JamProtectOn_Off;      				 //阻塞保护开关状态     		0x0009
	unsigned short StallProtectOn_Off;     			   	//堵转保护开关状态     			0x00010
    unsigned short ResetOn_Off;            	//只写		//接地保护开关状态     			0x00011
	
	unsigned short GrandProtectOn_Off;    				 //接地保护开关状态     		0x00012
	
	unsigned short Reset_Key;    						 //重置按键开关     			0x00013
	unsigned short Stop_Key;    						 //停止按键开关     			0x00014
}MODBUS_MONITOR_DATA_TPDF;    //监控数据 


typedef struct
{
    unsigned short TripLevel;    				//当前脱扣等级 				
    unsigned short RatedCurrentLevel;   	 //当前额定电流等级		  
	unsigned short PhaseProtectOn_Off;     //不平衡保护开关状态   
	unsigned short JamProtectOn_Off;       //阻塞保护开关状态     
	unsigned short StallProtectOn_Off;     //堵转保护开关状态     
    unsigned short ResetOn_Off;            //接地保护开关状态     
	unsigned short GrandProtectOn_Off;     //接地保护开关状态   

}MODBUS_WRITE_DATA_TPDF;    //监控数据 



#define MARCO_IAP 0			//Remote upgrade switch marco
#define MARCO_FREERTOS 0	//Freertos switch marco









typedef struct
{
		unsigned char SlaveAddr;
}MODBUS_SET;


typedef struct
{
		unsigned char SuperSlaveAddr;
}MODBUS_SUPER_SET;


#if MARCO_FREERTOS
		extern QueueHandle_t	MODBUS_ReceiveQueue;	
		extern QueueHandle_t	MODBUS_TransmitQueue;	
#endif

unsigned char ReadModbusSet(MODBUS_SET* TempPtr);
unsigned char SetModbusSet(MODBUS_SET* TempPtr,unsigned char TempParameterIndex);
void MODBUS_RTU_TaskFunction(void const * argument);
void CopySorceDataToModbus(UART_DATA_TPDF* TempStructPtr);
void MODBUS_ReadMonitorData(void);
void MODBUS_WriteMonitorData(void);
extern UART_DATA_TPDF  Modbus_ReceiveBuffer;
extern UART_DATA_TPDF  Modbus_SendBuffer;

#endif
