#include "includes.h"

/*修改记录：
时间：2021-10-11
修改人：宋寒
修改内容：锦江都城酒店逻辑
*/


/*******************************************************************************
* Function Name  : BLV_BUS_DEV_C5IO_Data_Init 
* Description    : C5IO设备信息初始化函数
*******************************************************************************/
void BLV_BUS_DEV_C5IO_Data_Init_Local(void)
{
	Device_Public_Information_G BUS_Public;
	BUS_C5IO_INFO C5IO_Info;

	memset(&BUS_Public,0,sizeof(Device_Public_Information_G));
	memset(&C5IO_Info,0,sizeof(BUS_C5IO_INFO));
	
	BUS_Public.addr = 0x00;						//设备地址
	BUS_Public.type = DEV_C5IO_Type;			//设备类型
	BUS_Public.port = 0x03;						//设备发送端口
	BUS_Public.baud = 115200;					//设备发送波特率
	BUS_Public.retry_num = 0x03;		//设备数据重发次数
	BUS_Public.wait_time = 0x01F4;		//设备数据发送等待回复时间 - 100ms
	BUS_Public.polling_cf = (uint32_t)&BLV_BUS_C5IO_Cycle_Call;
	BUS_Public.processing_cf = (uint32_t)&BLV_BUS_C5IO_Data_Processing;
	
	C5IO_Info.C5IO_Version = 1;
	/*默认都为按键类型*/
	C5IO_Info.DI_Type[C5IO_DI_CH1] = BUS_C5IO_DI_Dry_Type | BUS_C5IO_DI_Level_LOW;
	C5IO_Info.DI_Type[C5IO_DI_CH2] = BUS_C5IO_DI_Dry_Type | BUS_C5IO_DI_Level_LOW;			
	C5IO_Info.DI_Type[C5IO_DI_CH3] = BUS_C5IO_DI_Dry_Type | BUS_C5IO_DI_Level_LOW;			
	C5IO_Info.DI_Type[C5IO_DI_CH4] = BUS_C5IO_DI_Dry_Type | BUS_C5IO_DI_Level_LOW;			
	C5IO_Info.DI_Type[C5IO_DI_CH5] = BUS_C5IO_DI_Dry_Type | BUS_C5IO_DI_Level_LOW;			
	C5IO_Info.DI_Type[C5IO_DI_CH6] = BUS_C5IO_DI_Key_Type | BUS_C5IO_DI_Level_LOW;		
	C5IO_Info.DI_Type[C5IO_DI_CH7] = BUS_C5IO_DI_Key_Type | BUS_C5IO_DI_Level_LOW;			//门铃
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH1] = 0x02;	//设置消抖时间为20ms	
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH2] = 0x02;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH3] = 0x02;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH4] = 0x02;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH5] = 0x02;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH6] = 0x02;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH7] = 0x02;	//设置消抖时间为20ms
//	C5IO_Info.DI_Control_Flag = 0x7F;
#if (USE_FLOOR_TYPE == 2)  //C12底板
	C5IO_Info.DI_Type[C5IO_DI_CH8] = BUS_C5IO_DI_Key_Type | BUS_C5IO_DI_Level_LOW;
	C5IO_Info.DI_Type[C5IO_DI_CH9] = BUS_C5IO_DI_Key_Type | BUS_C5IO_DI_Level_LOW;			
	C5IO_Info.DI_Type[C5IO_DI_CH10] = BUS_C5IO_DI_Key_Type | BUS_C5IO_DI_Level_LOW;			
	C5IO_Info.DI_Type[C5IO_DI_CH11] = BUS_C5IO_DI_Key_Type | BUS_C5IO_DI_Level_LOW;			
	C5IO_Info.DI_Type[C5IO_DI_CH12] = BUS_C5IO_DI_Key_Type | BUS_C5IO_DI_Level_LOW;			
	C5IO_Info.DI_Type[C5IO_DI_CH13] = BUS_C5IO_DI_Key_Type | BUS_C5IO_DI_Level_LOW;	

	C5IO_Info.DI_Detection_Time[C5IO_DI_CH8] = 0x05;	//设置消抖时间为20ms	
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH9] = 0x05;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH10] = 0x05;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH11] = 0x05;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH12] = 0x05;	//设置消抖时间为20ms
	C5IO_Info.DI_Detection_Time[C5IO_DI_CH13] = 0x05;	//设置消抖时间为20ms
//	C5IO_Info.DI_Control_Flag = 0x1FFF;
#endif
//	

	
	Add_BUS_Device_To_List2(&BUS_Public,(uint8_t *)&C5IO_Info,sizeof(BUS_C5IO_INFO));
}


/*******************************************************************************
* Function Name  : BLV_BUS_Device_Init 
* Description    : BUS设备初始化
*******************************************************************************/
void BLV_BUS_Device_Init(void)
{
	/*添加BUS设备链表*/
	memset((void *)&BUS485_Info,0,sizeof(BLV_BUS_Manage_G));
	SRAM_Write_DW(SRAM_Device_List_Start_Addr,SRAM_BUS_Device_List_Addr);
	
	
	BLV_BUS_DEV_C5MUSIC_Data_Init();
	BUS485_Info.device_num += 1;
	
	BLV_BUS_DEV_C5IO_Data_Init_Local();
	BUS485_Info.device_num += 1;
	
	BUS485_Info.Last_list_addr = SRAM_Device_List_Start_Addr;
	BUS485_Info.port_mode = Port_Normal_Mode;

	/*BLV_BUS端口初始化*/
	USART_INIT(USART_3,115200);
}

/*******************************************************************************
* Function Name  : BLV_PollPort_Init 
* Description    : 轮询设备初始化
*******************************************************************************/
void BLV_PollPort_Init(void)
{
	memset(&Poll485_Info,0,sizeof(BLV_POLL_Manage_G));
	
	/*添加设备到设备链表*/
	Poll485_Info.Last_list_addr = SRAM_Read_DW(SRAM_BUS_Device_List_Addr);	//轮询设备起始地址
	SRAM_Write_DW(Poll485_Info.Last_list_addr,SRAM_POLL_Device_List_Addr);
	Dbg_Println(DBG_BIT_SYS_STATUS_bit,"BLV_POLL_dev Start:%08X \r\n",Poll485_Info.Last_list_addr);
	
	/*添加设备 - 温控器*/
	BLWOut_RS485_Temp_Data_Init(0x01);
	Poll485_Info.device_num += 1;
	
	/*添加设备 - 插卡取电*/
	BLV_RS485_Card_Data_Init(0x01);
	Poll485_Info.device_num += 1;
	
	/*添加设备 - 红外转发*/
//	RS485_IrSend_Data_Init(0x01);
//	Poll485_Info.device_num += 1;
	
	/*添加设备 - PWM调光*/
//	BLW_RS485_PWM_Data_Init(0x01);
//	Poll485_Info.device_num += 1;

	/*添加设备 - A9继电器*/
	BLW_RS485_A9RELAY_Data_Init(0x01);   //
	Poll485_Info.device_num += 1;

	Dbg_Println(DBG_BIT_SYS_STATUS_bit,"BLV_POLL_dev END:%08X \r\n",SRAM_Read_DW(SRAM_BUS_Device_List_Addr));
	
	/*端口初始化*/
	Poll485_Info.port_mode = Port_Normal_Mode;
	Poll485_Info.baud = 9600;

#if (USE_CORE_TYPE == 1)   //使用C1F核心板

	Poll485_Info.BaudRateCfg = &UART0_BaudRateCfg;
	USART_INIT(USART_0,Poll485_Info.baud);     //C1F的轮询口是串口0
	
#elif (USE_CORE_TYPE == 2)   //使用C1核心板

	Poll485_Info.BaudRateCfg = &UART1_BaudRateCfg;
	USART_INIT(USART_1,Poll485_Info.baud);    //C1的轮询口是串口1
	
#endif  //USE_CORE_TYPE == CORE_TYPE_C1F
}

/*******************************************************************************
* Function Name  : BLV_Active_Device_Init 
* Description    : 主动设备初始化
*******************************************************************************/
void BLV_Active_Device_Init(void)
{
	/*主动设备初始化*/
	memset((void *)&Act485_Info,0,sizeof(BLV_ACTIVE_Manage_G));
	Act485_Info.Last_list_addr = SRAM_Read_DW(SRAM_POLL_Device_List_Addr);	//主动设备起始地址
	SRAM_Write_DW(Act485_Info.Last_list_addr,SRAM_ACTIVE_Device_List_Addr);	//初始化主动设备信息起始地址
	
	Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Active Device Start List:%08X\r\n" , Act485_Info.Last_list_addr);
	
	/*添加设备 - 设置公共属性*/

//	BLV_RS485_C7T_Data_Init(0x00,0x10);		//这一个初始化添加了2个设备
//	Act485_Info.device_num += 2;

	
//	BLV_485_Dev_Touch_Switch_Init(0x01);
//	Act485_Info.device_num += 1;
//	
//	BLV_485_Dev_Touch_Switch_Init(0x02);
//	Act485_Info.device_num += 1;
//	
//	BLV_485_Dev_Touch_Switch_Init(0x03);
//	Act485_Info.device_num += 1;
//	
//	BLV_485_Dev_Touch_Switch_Init(0x04);
//	Act485_Info.device_num += 1;

//	BLV_485_Dev_Touch_Switch_Init(0x04);
//	Act485_Info.device_num += 1;
	
//	BLV_485_Dev_Touch_Switch_Init(0x05);
//	Act485_Info.device_num += 1;

//	BLW_RS485_RF_GatewayHost_Init(0x01);
//	Act485_Info.device_num += 1;
					
//	BLW_RS485_WeixinLockFun_Init(0x01);      
//	Act485_Info.device_num += 1;
	
	/*添加设备 - 小宝*/
	BLV_485_Dev_XiaoBao_Init(0x00);
	Act485_Info.device_num += 1;
	
	/*增加测试接口*/
	BLV_PC_DEVICE_TEST_Init();
	Act485_Info.device_num += 1;
	
	Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Active Device End List:%08X\r\n" , SRAM_Read_DW(SRAM_ACTIVE_Device_List_Addr));
	
	Act485_Info.Act_Start = B_IDLE;
	Act485_Info.baud = 9600;
	Act485_Info.port_mode = Port_Normal_Mode;
	Act485_Info.BaudRateCfg = &UART2_BaudRateCfg;
	/*初始化主动端口*/
	USART_INIT(USART_2,9600);
}

/*******************************************************************************
* Function Name  : BLV_DEVICE_Action_Scan 
* Description    : 设备扫描函数 10ms扫描一个
* Input          : 
*******************************************************************************/
void BLV_DEVICE_Action_Scan(void)
{
	static uint32_t dev_action_processing_tick = 0,server_processing_tick = 0;
	static uint32_t action_processing_addr = SRAM_Device_List_Start_Addr;
	
	/*遍历所有设备，查看状态是否有变化*/
	if( SysTick_1ms - dev_action_processing_tick > 4)		//5ms处理一个设备
	{
		dev_action_processing_tick = SysTick_1ms;
		uint32_t endaddr = SRAM_Read_DW(SRAM_ACTIVE_Device_List_Addr);
		if((endaddr < SRAM_Device_List_Start_Addr) || (endaddr > SRAM_Device_List_End_Addr))	endaddr = SRAM_Device_List_End_Addr;
		
		//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"action_processing_addr :%08X --\r\n",action_processing_addr);
		
		if(Device_Data_Check(action_processing_addr) == 0)		//设备信息校验成功
		{
			BLV_DEVICE_Action_Processing(action_processing_addr);
		}

		action_processing_addr += SRAM_Device_List_Size;
		if(action_processing_addr >= endaddr)	action_processing_addr = SRAM_Device_List_Start_Addr;
		
		
	}
	
	/*服务信息处理 20ms处理一次*/
	if( SysTick_1ms - server_processing_tick > 20 )
	{
		server_processing_tick = SysTick_1ms;
		
		Project_Service_Processing();
	}

}

/*******************************************************************************
* Function Name  : BLV_DEVICE_Action_Processing 
* Description    : 设备处理函数
* Input          : 
	dev_addr	:设备地址
*******************************************************************************/
void BLV_DEVICE_Action_Processing(uint32_t dev_addr)
{
	uint8_t pro_type = 0,pro_devaddr = 0;
	
	pro_type = SRAM_Read_Byte(dev_addr + Dev_Type);			//需要处理的设备类型
	pro_devaddr = SRAM_Read_Byte(dev_addr + Dev_Addr);		//需要处理的设备地址
	
	switch(pro_type)
	{
		case DEV_C5IO_Type:
			if(pro_devaddr == 0x00)
			{
				//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"DEV_C5IO_Type --\r\n");
				BUS_C5IO_Scan_DI_Signal(dev_addr);
			}
			break;
		case DEV_C5MUSIC_Type:
			if(pro_devaddr == 0x01)
			{
				//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"DEV_C5MUSIC_Type --\r\n");
				BUS_C5MUSIC_Scan_Signal(dev_addr);
			}
			break;
		case DEV_TEMPTYPE:
			if(pro_devaddr == 0x00)
			{
				//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"DEV_TEMPTYPE --\r\n");
				BUS_TEMP_Scan_Signal(dev_addr);
			}
			else 
				if(pro_devaddr == 0x01)
			{
				BUS_TEMP1_Scan_Signal(dev_addr);
			}
			break;
		case DEV_CARDTYPE:
			if(pro_devaddr == 0x01)
			{
				//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"DEV_CARDTYPE --\r\n");
				Device_Card_Scan_Signal(dev_addr);
			}
			break;
		case DEV_XiaoBao_Type:
			Device_XiaoBao_Scan_Signal(dev_addr);
			break;
		case DEV_SWI_TYPE:
			//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"DEV_SWI_TYPE --\r\n");
			Device_Switch_Scan_Signal(dev_addr);
			break;

	}
}

/*******************************************************************************
* Function Name  : Get_SYS_Take_Electricity_Status 
* Description    : 获取系统取电状态
* Return         : 
	0xF0：授权到期
	0x01：取电
	0x00：未取电
*******************************************************************************/
uint8_t Get_SYS_Take_Electricity_Status(void)
{
	uint8_t rev = 0xF0;
	if(Get_Authorize_Lock_Status() == 0x01)		return rev;			/*授权到期*/
	
	rev = SRAM_Read_Byte(SRAM_Service_Take_Electricity_State);
	
	return rev;
}

void Device_XiaoBao_Scan_Signal(uint32_t devaddr)
{
	uint8_t val_check = 0;
	uint16_t dev_datalen = 0x00;
	RS485_XIAOBAO_INFO Rs485_xiaobao_Info;       //开关局部变量
	/*拷贝设备私有信息*/
	SRAM_DMA_Read_Buff((uint8_t *)&Rs485_xiaobao_Info,sizeof(RS485_XIAOBAO_INFO),devaddr+Dev_Privately);
	
	if(Rs485_xiaobao_Info.Ctrl_Buf[0])  //有控制数据
	{
		
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"XiaoBao Ctrl Device:%d", Rs485_xiaobao_Info.Ctrl_Buf[0]);
		
		for(uint8_t i = 0; i< Rs485_xiaobao_Info.Ctrl_Buf[0] ; i++)   //根据设备数量控制循环
		{
			switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+1])  //设备类型
			{
				case XIAOBAO_SCENE_TYPE:     //场景
				{
					uint32_t deal_addr = 0;
					deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
					switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+2])   //继电器地址
					{
						case XIAOBAO_SCENE_RECEPTION:           //会客模式（白）
							
							BUS_C5IO_Group_Control_Relay(deal_addr, Project_Receive1_Mode_Control, Project_Receive1_Mode_State);    //继电器控制
							/*铃声*/
							deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
							BUS_C5MUSIC_Warning_Dir(deal_addr,0x03,BLV_C5MUSIC_Single_Play);
							
						break;
						case XIAOBAO_SCENE_SLEEP:               //睡眠模式（黑）
							
							BUS_C5IO_Group_Control_Relay(deal_addr, Project_Neight_Mode_Control, Project_Neight_Mode_State);    //继电器控制
						
//							deal_addr = Find_Device_List_Information(DEV_C12DIMMING_Type,0x00);	
//							BUS_C12Dimming_Control_Light(deal_addr, 0xFFF, 0, 1, 0);
							/*铃声*/
							deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
							BUS_C5MUSIC_Warning_Dir(deal_addr,0x07,BLV_C5MUSIC_Single_Play);
						
						break;
						case XIAOBAO_SCENE_GENERAL_CONTROL:     //总控

						break;
						case XIAOBAO_SCENE_LEISURE:            //休闲（灰）

						break;
						case XIAOBAO_SCENE_BUSINESS:           //商务

						break;
						case XIAOBAO_SCENE_READ:               //阅读

						break;
						case XIAOBAO_SCENE_WELCOME:           //欢迎模式

						break;
						case XIAOBAO_SCENE_ROMANTIC:           //浪漫模式

						break;
						case XIAOBAO_SCENE_WATCHING:           //观影模式

						break;
						case XIAOBAO_SCENE_WARM:               //温馨
							
							BUS_C5IO_Group_Control_Relay(deal_addr, Project_Warm_Mode_Control, Project_Warm_Mode_State);    //继电器控制
							/*铃声*/
							deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
							BUS_C5MUSIC_Warning_Dir(deal_addr,0x08,BLV_C5MUSIC_Single_Play);
						
						break;
						case XIAOBAO_SCENE_ATMOSPHERE:         //氛围模式

						break;
						case XIAOBAO_SCENE_BRIGHT:             //明亮模式

						break;
						case XIAOBAO_SCENE_PARLOUR_BRIGHT:     //客厅明亮

						break;
						case XIAOBAO_SCENE_ALL_LIGHTS:           //所有灯

						break;
						case XIAOBAO_SCENE_SOFT:                 //柔和模式

						break;
						case XIAOBAO_SCENE_WAKE_UP:             //起夜模式

						break;
						case XIAOBAO_SCENE_GET_UP:              //起床模式

						break;
						case XIAOBAO_SCENE_BATHROOM:             //卫浴模式

						break;
						case XIAOBAO_SCENE_TOILET:              //如厕

						break;
						case XIAOBAO_SCENE_WASH_UP:             //洗漱

						break;
						case XIAOBAO_SCENE_TV:                 //电视

						break;
						case XIAOBAO_SCENE_MEETING:             //会议

						break;
						default: break;
					}
				}   
				break;
				case XIAOBAO_RELAY_TYPE:     //继电器
				{
					uint32_t deal_addr = 0;
					deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
					switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+2])   //继电器地址
					{
						case XIAOBAO_RELAY_BATHROOM_LIGHT:       //卫浴灯
							
						break;
						case XIAOBAO_RELAY_SHOWERSROOM_LIGHT:    //浴室灯
							
						break;
						case XIAOBAO_RELAY_MIRROR_LIGHT:          //镜前灯
							BUS_C5IO_Group_Control_Relay(deal_addr, Project_LightScence_CH2_Control, Project_LightScence_CH2_State);    //继电器控制
						break;
						case XIAOBAO_RELAY_EXHAUST_FAN:           //排气扇
							BUS_C5IO_Group_Control_Relay(deal_addr, Project_LightScence_CH4_Control, Project_LightScence_CH4_State);    //继电器控制
						break;
						case XIAOBAO_RELAY_CORRIDOR_LIGHT:        //廊灯
							BUS_C5IO_Group_Control_Relay(deal_addr, Project_LightScence_CH1_Control, Project_LightScence_CH1_State);    //继电器控制
//							BUS_C5IO_Control_Relay(deal_addr, CORRIDOR_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3]);			//廊灯
						break;
						case XIAOBAO_RELAY_BAR_LIGHT:             //吧台灯
							
						break;
						case XIAOBAO_RELAY_TV_LIGHT:              //电视灯
							
						break;
						case XIAOBAO_RELAY_LEFT_BEDSIDE_LIGHT:    //左床头灯，左阅读灯
//							BUS_C5IO_Control_Relay(deal_addr, LEFT_READ_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3]);			//左阅读灯
						break;
						case XIAOBAO_RELAY_RIGHT_BEDSIDE_LIGHT:   //右床头灯，右阅读灯
//							BUS_C5IO_Control_Relay(deal_addr, RIGHT_READ_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3]);			//右阅读灯
						break;
						case XIAOBAO_RELAY_DESK_LIGHT:             //书桌灯
							
						break;
						case XIAOBAO_RELAY_PARLOUR_LIGHT:          //客厅灯
							
						break;
						case XIAOBAO_RELAY_PENDANT_LIGHT:          //吊灯
							
						break;
						case XIAOBAO_RELAY_MASTER_LIGHT:           //主灯
							
						break;
						case XIAOBAO_RELAY_TOP_LIGHT:              //顶灯
							
						break;
						case XIAOBAO_RELAY_DOWNLIGHT:              //筒灯
							
						break;
						case XIAOBAO_RELAY_AISLE_LIGHT:            //过道灯
							
						break;
						case XIAOBAO_RELAY_SPOTLIGHT:              //射灯
							
						break;
						case XIAOBAO_RELAY_BACKGROUND_LIGHT:       //背景灯
							
						break;
						case XIAOBAO_RELAY_NIGHT_LIGHT:           //夜灯
							BUS_C5IO_Group_Control_Relay(deal_addr, Project_LightScence_CH5_Control, Project_LightScence_CH5_State);    //继电器	
//							BUS_C5IO_Control_Relay(deal_addr, NIGHT_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3]);			//夜灯
						break;
						case XIAOBAO_RELAY_SHOWERS_LIGHT:         //沐浴灯
							
						break;
						case XIAOBAO_RELAY_WASH_UP_LIGHT:        //洗漱灯
							
						break;
						case XIAOBAO_RELAY_BALCONY_LIGHT:        //阳台灯
							
						break;
						case XIAOBAO_RELAY_LEISURE_LIGHT:        //休闲灯
							
						break;
						case XIAOBAO_RELAY_READ_LIGHT:            //阅读灯
							
						break;
						case XIAOBAO_RELAY_WALL_LIGHT:            //壁灯
							
						break;
						case XIAOBAO_RELAY_WARDROBE_LIGHT:        //衣柜灯
							
						break;
						case XIAOBAO_RELAY_ROOM_LIGHT:            //房灯
//							BUS_C5IO_Control_Relay(deal_addr, ROOM_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3]);			//房灯
						break;
						case XIAOBAO_RELAY_VENTILATOR:            //换气扇
							
						break;
						case XIAOBAO_RELAY_BACKLIGHT:             //背光
							
						break;
						case XIAOBAO_RELAY_APERTURE:              //光圈
							
						break;
						case XIAOBAO_RELAY_BEDSIDE_LIGHT:          //床头灯
							
						break;
						case XIAOBAO_RELAY_ATMOSPHERE_LIGHT:       //氛围灯
							
						break;
						case XIAOBAO_RELAY_PORCH_LIGHT:             //玄关灯
							
						break;
						case XIAOBAO_RELAY_LEFT_WALL_LIGHT:          //左壁灯
//							BUS_C5IO_Control_Relay(deal_addr, LEFT_WALL_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3]);			//左壁灯
						break;
						case XIAOBAO_RELAY_RIGHT_WALL_LIGHT:          //右壁灯
//							BUS_C5IO_Control_Relay(deal_addr, RIGHT_WALL_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3]);			//右壁灯
						break;
						case XIAOBAO_RELAY_TOILET_LIGHT:             //卫生间灯
							
						break;
						default: break;
					}
					
				}
				break;
				case XIAOBAO_SERVICE_TYPE:     //服务
				{
					uint32_t deal_addr = 0;
					switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+2])
					{
						case XIAOBAO_SERVICE_CLEAR:              //清理
							if(SRAM_Read_Byte(SRAM_Global_SOS_Status_Flag) == 0x01) 	break;		//当前处于SOS，清理勿扰按键无效
							
							if(Rs485_xiaobao_Info.Ctrl_Buf[i*4+3] == 0x02)		//关闭清理
							{
								/*主要控制C5IO_DO_CH2状态*/
								deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
								BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH2,0x02);
								SRAM_Write_Byte(0x00,SRAM_Global_Clear_Start);
								
								deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
								BUS_C5MUSIC_Warning_Dir(deal_addr,0x16,BLV_C5MUSIC_Forestall);	//按键提示音
								
								Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0003,0x02);		//清理服务信息上报 - 服务信息 回路地址0x03
							}else {			//开启清理
								/*主要控制C5IO_DO_CH2 状态*/
								deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
								BUS_C5IO_Control_Do(deal_addr, C5IO_DO_CH2, 0x01);
								BUS_C5IO_Control_Do(deal_addr, C5IO_DO_CH3, 0x02);
								SRAM_Write_Byte(0x01,SRAM_Global_Clear_Start);
								SRAM_Write_Byte(0x00,SRAM_Global_Do_Not_Disturb_Start);
								
								/*铃声*/
								deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
								BUS_C5MUSIC_Warning_Dir(deal_addr,0x06,BLV_C5MUSIC_Forestall);	//按键提示音
								
								Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0002,0x02);		//勿扰服务信息上报 - 服务信息 回路地址0x02
								Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0003,0x01);		//清理服务信息上报 - 服务信息 回路地址0x03
							}
						break;
						case XIAOBAO_SERVICE_DO_NOT_DISTURB:      //勿扰
							
							if(SRAM_Read_Byte(SRAM_Global_SOS_Status_Flag) == 0x01) 	break;		//当前处于SOS，清理勿扰按键无效
							
							if(Rs485_xiaobao_Info.Ctrl_Buf[i*4+3] == 0x02)	//关闭勿扰
							{
								/*主要控制C5IO_DO_CH3状态*/
								deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
								BUS_C5IO_Control_Do(deal_addr, C5IO_DO_CH3,0x02);
								SRAM_Write_Byte(0x00,SRAM_Global_Do_Not_Disturb_Start);
								
								deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
								BUS_C5MUSIC_Warning_Dir(deal_addr,0x17,BLV_C5MUSIC_Forestall);		//按键提示音
								
								Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0002,0x0002);		//勿扰服务信息上报 - 服务信息 回路地址0x02
							}
							else 	//开启勿扰
							{
								/*主要控制C5IO_DO_CH3状态*/
								deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
								BUS_C5IO_Control_Do(deal_addr, C5IO_DO_CH2, 0x02);
								BUS_C5IO_Control_Do(deal_addr, C5IO_DO_CH3, 0x01);
								SRAM_Write_Byte(0x00,SRAM_Global_Clear_Start);
								SRAM_Write_Byte(0x01,SRAM_Global_Do_Not_Disturb_Start);
								/*铃声*/
								deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
								BUS_C5MUSIC_Warning_Dir(deal_addr,0x09,BLV_C5MUSIC_Forestall);		//按键提示音
								
								Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0002,0x0001);		//勿扰服务信息上报 - 服务信息 回路地址0x02
								Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0003,0x0002);		//勿扰服务信息上报 - 服务信息 回路地址0x02
							}
									
						break;
						case XIAOBAO_SERVICE_LATER:              //稍后
							
						break;
						case XIAOBAO_SERVICE_CHECK_OIT:          //退房
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"小宝退房...");
							SRAM_Write_Byte(0x02,SRAM_Global_Check_out_Status);
							/*铃声*/
							deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
							BUS_C5MUSIC_Warning_Dir(deal_addr,0x12,BLV_C5MUSIC_Forestall);	//按键提示音
							
							/*网络上报退房信息*/
							Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0006,0x01);		//退房服务信息上报 - 服务信息 回路地址0x07
						break;
						case XIAOBAO_SERVICE_TOOTHPASTE:        //送牙膏
							
						break;
						case XIAOBAO_SERVICE_SLIPPER:           //送拖鞋
							
						break;
						case XIAOBAO_SERVICE_CONDITIONER:       //护发素
							
						break;
						case XIAOBAO_SERVICE_SHAMPOO:           //洗发水
							
						break;
						case XIAOBAO_SERVICE_SHOWER_GEL:          //沐浴露
							
						break;
						case XIAOBAO_SERVICE_LOTION:              //润肤乳
							
						break;
						case XIAOBAO_SERVICE_SOAP:               //香皂
							
						break;
						case XIAOBAO_SERVICE_BATH_CAP:          //浴帽
							
						break;
						case XIAOBAO_SERVICE_COMB:              //送一把梳子
							
						break;
						case XIAOBAO_SERVICE_COTTON_STICK:       //送棉棒
							
						break;
						case XIAOBAO_SERVICE_HAIR_DRIER:       //吹风机
							
						break;
						case XIAOBAO_SERVICE_kETTLE:           //热水壶
							
						break;
						case XIAOBAO_SERVICE_KLEENEX:           //面巾纸
							
						break;
						case XIAOBAO_SERVICE_PEN:               //笔
							
						break;
						case XIAOBAO_SERVICE_CHARGER:           //充电器数据线
							
						break;
						case XIAOBAO_SERVICE_CALL_WAITER:       //呼叫服务员
							
						break;
						case XIAOBAO_SERVICE_TOOTHBRUSH:       //牙刷
							
						break;
						case XIAOBAO_SERVICE_WATER:           //送瓶水
							
						break;
						default: break;
					}
				}
					
				break;
				case XIAOBAO_CURTAINS_TYPE:     //窗帘
				{
//					uint32_t deal_addr = 0;
//					deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
					switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+2])   //窗帘地址
					{
						case XIAOBAO_CURTAINS_PARLOUR_CURTAINS:        //厅窗帘
							switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+3])
							{
								case 0x01:    //打开
									//开窗帘
									Project_Curtain_Control(0x01,0x01);

								break;
								case 0x02:    //关闭
									//关窗帘
								
									Project_Curtain_Control(0x01,0x02);
								break;
								case 0x06:    //停止
									//窗帘停止
									Project_Curtain_Control(0x01,0x00);
								break;
								default: break;
							}
							
						break;
						case XIAOBAO_CURTAINS_PARLOUR_WINDOW_SCREENING:   //厅窗纱
							
						break;
						case XIAOBAO_CURTAINS_BEDROOM_CURTAINS:        //卧窗帘
							
						break;
						case XIAOBAO_CURTAINS_BEDROOM_WINDOW_SCREENING:    //卧窗纱
							
						break;
						case XIAOBAO_CURTAINS_SECOND_BEDROOM_CURTAINS:     //次卧窗帘
							
						break;
						case XIAOBAO_CURTAINS_SECOND_BEDROOM_WINDOW_SCREENING:      //次卧窗纱
							
						break;
						case XIAOBAO_CURTAINS_ROLLER_SHUTTER:        //卷帘
							
						break;
						default: break;
					}
				}
				break;
				case XIAOBAO_TEMP_TYPE:     	//空调
					switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+2])   //空调地址
					{
						case XIAOBAO_TEMP_PARLOUR:        //客厅空调
						{
							uint32_t deal_addr = 0;
							deal_addr = Find_Device_List_Information(DEV_TEMPTYPE,0x01);
							uint8_t temperature = 0;   		//温度
							uint8_t speed = 0;               //风速
							uint8_t mode = 0;             //模式
							uint8_t onoff = 0;            //开关机
							if(Rs485_xiaobao_Info.Ctrl_Buf[i*4+3] >= 16 && Rs485_xiaobao_Info.Ctrl_Buf[i*4+3] <= 30)  //温度值
							{
								temperature = Rs485_xiaobao_Info.Ctrl_Buf[i*4+3];
							}
							else
							{
								RS485_TEM_INFO Rs485Temp;
								SRAM_DMA_Read_Buff((uint8_t *)&Rs485Temp,sizeof(RS485_TEM_INFO),deal_addr + Dev_Privately);
								
								switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+3])
								{
									case 0x0F:     //温度调低
										if(Rs485Temp.set_t > 16)
										{
											temperature = Rs485Temp.set_t - 1;
										}
									break;
									case 0x21:     //温度调高
										if(Rs485Temp.set_t < 32)
										{
											temperature = Rs485Temp.set_t + 1;
										}
									break;
									case 0x0E:     //风速调小
										switch(Rs485Temp.fan)
										{
											case 0:     //停止
												speed = 1;         //置为低速
											break;
											case 1:     //低速
												
											break;
											case 2:     //中速
												speed = 1;         //置为低速
											break;
											case 3:     //高速
												speed = 2;         //置为中速
											break;
											case 4:     //自动
												speed = 1;         //置为低速
											break;
											default: break;
										}
									break;
									case 0x22:     //风速调大
										switch(Rs485Temp.fan)
										{
											case 0:     //停止
												speed = 1;         //置为低速
											break;
											case 1:     //低速
												speed = 2;         //置为中速
											break;
											case 2:     //中速
												speed = 3;         //置为高速
											break;
											case 3:     //高速
												
											break;
											case 4:     //自动
												speed = 2;         //置为中速
											break;
											default: break;
										}
									break;
									default: break;
								}
							}
							switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+4] & 0x03)  //阀门
							{
								case 1:   //开阀
									
								break;
								case 2:   //关阀
									
								break;
								default: break;
							}
							switch((Rs485_xiaobao_Info.Ctrl_Buf[i*4+4] & 0x0C)>>2)  //风速
							{
								case 0:   //自动
									//speed = 0;
								break;
								case 1:   //低速
									speed = 1;
								break;
								case 2:   //中速
									speed = 2;
								break;
								case 3:   //高速
									speed = 3;
								break;
								default: break;
							}
							switch((Rs485_xiaobao_Info.Ctrl_Buf[i*4+4] & 0x30)>>4)  //模式
							{
								case 0:   //自动
									mode = 0;
								break;
								case 1:   //制冷
									mode = 1;
								break;
								case 2:   //制热
									mode = 2;
								break;
								case 3:   //送风
									mode = 3;
								break;
								default: break;
							}
							switch((Rs485_xiaobao_Info.Ctrl_Buf[i*4+4] & 0xC0)>>6)  //开关机
							{
								case 1:   //开机
									onoff = 1;
								break;
								case 2:   //关机
									onoff = 2;
								break;
								default: break;
							}
							if(Rs485_xiaobao_Info.Ctrl_Buf[i*4+3] == 0 && Rs485_xiaobao_Info.Ctrl_Buf[i*4+4] == 0)   //自动风速
							{
								speed = 0;    
							}
							
							Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"XiaoBao Ctrl Temp:%d, %d, %d, %d", onoff, mode, speed, temperature);
							
							if(onoff)
							{
								BLW_TEMP_Control_State(deal_addr, 0x00, onoff);   //开关机
							}
							if(temperature)
							{
								BLW_TEMP_Control_State(deal_addr, 0x02, temperature);   //温度
							}
							BLW_TEMP_Control_State(deal_addr, 0x01, mode);     //模式
//							if(speed >= 0)
							{
								BLW_TEMP_Control_State(deal_addr, 0x03, speed);     //风速
							}
							
						}
						break;
						case XIAOBAO_TEMP_BEDROOM:           //卧室空调
							
						break;
						case XIAOBAO_TEMP_SECOND_BEDROOM:        //次卧空调
							
						break;
						default: break;
					}
					
				break;
				case XIAOBAO_DIMMING_TYPE:     //调光
				{
					switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+2])   //调光地址
					{
						case XIAOBAO_DIMMING_BATHROOM_LIGHT:     //卫浴灯
							
						break;
						case XIAOBAO_DIMMING_SHOWERSROOM_LIGHT:     //浴室灯
							
						break;
						case XIAOBAO_DIMMING_MIRROR_LIGHT:         //镜前灯
							
						break;
						case XIAOBAO_DIMMING_CORRIDOR_LIGHT:       //廊灯
							
						break;
						case XIAOBAO_DIMMING_BAR_LIGHT:           //吧台灯
							
						break;
						case XIAOBAO_DIMMING_TV_LIGHT:             //电视灯
							
						break;
						case XIAOBAO_DIMMING_LEFT_BEDSIDE_LIGHT:     //左床头灯，左阅读灯
							
						break;
						case XIAOBAO_DIMMING_RIGHT_BEDSIDE_LIGHT:    //右床头灯，右阅读灯
							
						break;
						case XIAOBAO_DIMMING_DESK_LIGHT:            //书桌灯
							
						break;
						case XIAOBAO_DIMMING_PARLOUR_LIGHT:         //客厅灯
							
						break;
						case XIAOBAO_DIMMING_LEISURE_LIGHT:        //休闲灯
							
						break;
						case XIAOBAO_DIMMING_LEISURE_LIGHT2:       //休闲灯2
							
						break;
						case XIAOBAO_DIMMING_MASTER_LIGHT:        //主灯
							
						break;
						case XIAOBAO_DIMMING_TOP_LIGHT:           //顶灯
							
						break;
						case XIAOBAO_DIMMING_DOWNLIGHT:          //筒灯
							
						break;
						case XIAOBAO_DIMMING_AISLE_LIGHT:        //过道灯
							
						break;
						case XIAOBAO_DIMMING_SPOTLIGHT:          //射灯
							
						break;
						case XIAOBAO_DIMMING_BACKGROUND_LIGHT:       //背景灯
							
						break;
						case XIAOBAO_DIMMING_NIGHT_LIGHT:           //夜灯
							
						break;
						case XIAOBAO_DIMMING_SHOWERS_LIGHT:         //沐浴灯
							
						break;
						case XIAOBAO_DIMMING_WASH_UP_LIGHT:        //洗漱灯
							
						break;
						case XIAOBAO_DIMMING_BALCONY_LIGHT:        //阳台灯
							
						break;
						case XIAOBAO_DIMMING_LEISURE_LIGHT3:        //休闲灯3
							
						break;
						case XIAOBAO_DIMMING_READ_LIGHT:            //阅读灯
						{
//							deal_addr = Find_Device_List_Information(DEV_C12DIMMING_Type, 0x00);	
//							Device_XiaoBao_Control_CHx_Dimming(deal_addr, DIMMING_READ_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3], Rs485_xiaobao_Info.Ctrl_Buf[i*4+4]);
						}	
						break;
						case XIAOBAO_DIMMING_WALL_LIGHT:            //壁灯
							
						break;
						case XIAOBAO_DIMMING_WARDROBE_LIGHT:       //衣柜灯
							
						break;
						case XIAOBAO_DIMMING_ROOM_LIGHT:           //房灯
							
						break;
						case XIAOBAO_DIMMING_VENTILATOR_LIGHT:     //换气扇
							
						break;
						case XIAOBAO_DIMMING_BACKLIGHT:          //背光
							
						break;
						case XIAOBAO_DIMMING_APERTURE:           //光圈
							
						break;
						case XIAOBAO_DIMMING_BEDSIDE_LIGHT:      //床头灯
						{
//							deal_addr = Find_Device_List_Information(DEV_C12DIMMING_Type, 0x00);	
//							Device_XiaoBao_Control_CHx_Dimming(deal_addr, DIMMING_BEDSIDE_LIGHT_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3], Rs485_xiaobao_Info.Ctrl_Buf[i*4+4]);
							
						}
						break;
						default: break;
					}
				}
				break;
				case XIAOBAO_LIGHT_BELT_TYPE:   //灯带
				{
					switch(Rs485_xiaobao_Info.Ctrl_Buf[i*4+2])
					{
						case XIAOBAO_LIGHT_BELT_BEDSIDE:         //床头灯带
							
						break;
						case XIAOBAO_LIGHT_BELT_TV:             //电视灯带
							
						break;
						case XIAOBAO_LIGHT_BELT_WINDOW:         //窗灯带
							
						break;
						case XIAOBAO_LIGHT_BELT_PARLOUR_R:         //厅灯带红
						{
//							deal_addr = Find_Device_List_Information(DEV_RGB_LIGHT_BELT_Type, 0x01);	
//							Device_XiaoBao_Control_CHx_Dimming(deal_addr, LIGHT_BELT_PARLOUR_R_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3], Rs485_xiaobao_Info.Ctrl_Buf[i*4+4]);
						}	
						break;
						case XIAOBAO_LIGHT_BELT_PARLOUR_G:         //厅灯带绿
						{
//							deal_addr = Find_Device_List_Information(DEV_RGB_LIGHT_BELT_Type, 0x01);	
//							Device_XiaoBao_Control_CHx_Dimming(deal_addr, LIGHT_BELT_PARLOUR_G_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3], Rs485_xiaobao_Info.Ctrl_Buf[i*4+4]);
						}		
						break;
						case XIAOBAO_LIGHT_BELT_PARLOUR_B:         //厅灯带蓝
						{
//							deal_addr = Find_Device_List_Information(DEV_RGB_LIGHT_BELT_Type, 0x01);	
//							Device_XiaoBao_Control_CHx_Dimming(deal_addr, LIGHT_BELT_PARLOUR_B_NUM, Rs485_xiaobao_Info.Ctrl_Buf[i*4+3], Rs485_xiaobao_Info.Ctrl_Buf[i*4+4]);
						}			
						break;
						case XIAOBAO_LIGHT_BELT_BEDROOM_R:         //卧灯带红
							
						break;
						case XIAOBAO_LIGHT_BELT_BEDROOM_G:         //卧灯带绿
							
						break;
						case XIAOBAO_LIGHT_BELT_BEDROOM_B:         //卧灯带蓝
							
						break;
						case XIAOBAO_LIGHT_BELT_TOILET_R:         //卫灯带红
							
						break;
						case XIAOBAO_LIGHT_BELT_TOILET_G:         //卫灯带绿
							
						break;
						case XIAOBAO_LIGHT_BELT_TOILET_B:         //卫灯带蓝
							
						break;
						default: break;
					}
				}
				break;
				case XIAOBAO_MUSIC_TYPE:     //背景音乐
					
				break;
				default: break;
			}
		}
		Rs485_xiaobao_Info.Ctrl_Buf[0] = 0;     //控制设备数清零
		
		/*将数据保存，重新计算校验值 注意：一般数据有变动时，才重新计算校验值*/
		SRAM_DMA_Write_Buff((uint8_t *)&Rs485_xiaobao_Info,sizeof(RS485_XIAOBAO_INFO),devaddr+Dev_Privately);
		
		SRAM_Write_Byte(0x00,devaddr+Dev_Check);				//校验值清零
		dev_datalen = sizeof(RS485_XIAOBAO_INFO) + Dev_Privately;
		val_check = Dev_CheckSum(devaddr,dev_datalen);
		
		SRAM_Write_Byte(val_check,devaddr+Dev_Check);		//校验值重新写入
	}
}

void Device_Switch_Scan_Signal(uint32_t devaddr)
{
	uint8_t temp = 0,temp1 = 0,temp2 = 0,temp4 = 0;
	uint8_t val_check = 0;
	uint16_t dev_datalen = 0x00;
	uint32_t deal_addr = 0,temp3 = 0;
	RS485_SWI_INFO Rs485SwiInfo;       //开关局部变量
	/*拷贝设备私有信息*/
	SRAM_DMA_Read_Buff((uint8_t *)&Rs485SwiInfo,sizeof(RS485_SWI_INFO),devaddr+Dev_Privately);
	
	temp = SRAM_Read_Byte(devaddr + Dev_Addr);
	switch(temp)
	{
		case 0x00:   //开关0  -  C43开关 一共16个输入输出  前5个按键为C43温控器按键，第6到16为开关按键
			if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] == KeyPress)		//按键6 - 窗纱开
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:6",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						temp4 = SRAM_Read_Byte(SRAM_Global_Window_Gauze_Start);
						if(temp4 == 0x11)		//开动作中
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"窗纱停");
							Project_Curtain_Control(0x02,0x00);
						}else {
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"窗纱开");
							Project_Curtain_Control(0x02,0x01);
						}
						

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH7] == KeyPress)				//按键7 - 床头灯
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH7] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:7",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH8_Control) != Project_LightScence_CH8_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH8_Control,Project_LightScence_CH8_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH8_Control,BLV_Project_Light_Off_State);
						}
						
						
						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束

							#if	Project_NightMode_Enable
							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);							
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH8] == KeyPress)		//按键8 - 静音
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH8] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:8",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)	//当前不是在起夜模式下
					{
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						
						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}
						
						deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);
						
						/*铃声*/	
						if(SRAM_Read_Byte(SRAM_Global_Quiet_Mode_Status) == 0x00)
						{
							if(SRAM_Read_Byte(SRAM_Global_Mode_Start) == 0x05)
							{
								BUS_C5MUSIC_Set_Quiet_Mode2(deal_addr,1);	//开启静音
							}else {		//助眠模式下，不开启反馈音
								
								//开启静音模式
								Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"开启静音模式\r\n");
								BUS_C5MUSIC_Warning_Dir(deal_addr,0x10,BLV_C5MUSIC_Forestall);	//开启静音模式
								
								SRAM_Write_Byte(0x01,SRAM_Global_Quiet_Mode_Flag);			//静音按键标志位
								SRAM_Write_DW(SysTick_1ms,SRAM_Global_Quiet_Mode_Tick);		//记录静音按键时间搓
							}
						}else
						{
							if(SRAM_Read_Byte(SRAM_Global_Mode_Start) == 0x05)
							{
								BUS_C5MUSIC_Set_Quiet_Mode2(deal_addr,0);	//开启静音
							}else{
								
								Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"关闭静音模式\r\n");
								BUS_C5MUSIC_Set_Quiet_Mode2(deal_addr,0);
								
								BUS_C5MUSIC_Warning_Dir(deal_addr,0x0F,BLV_C5MUSIC_Forestall);	//关闭静音模式
							}
						}
						
						
					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH9] == KeyPress)		//按键9 - 窗纱关
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH9] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:9",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						temp4 = SRAM_Read_Byte(SRAM_Global_Window_Gauze_Start);
						if(temp4 == 0x12)		//开动作中
						{
							Project_Curtain_Control(0x02,0x00);    //窗纱停
						}else {
							Project_Curtain_Control(0x02,0x02);    //窗纱关
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH10] == KeyPress)				//按键10 - 廊灯
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH10] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:10",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH1_Control) != Project_LightScence_CH1_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH1_Control,Project_LightScence_CH1_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH1_Control,BLV_Project_Light_Off_State);
						}
						
						
						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束

							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}
			else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH11] == KeyPress)				//按键11 - 总控
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH11] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:11",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if(0x00 == (temp3 & Project_LightScence_CH11_Control))  //为0 Project_LightScence_CH11_State
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH11_Control,Project_LightScence_CH11_State);  //打开场景
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH11_Control,BLV_Project_Light_Off_State);    //关闭场景    
						}
						
						
						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束

							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}	
			else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH12] == KeyPress)		//按键12 - 温馨模式
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH12] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS_SWITCH_CH12 KeyPress");
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)	//当前不是在睡眠模式下
					{
						Project_LightMode_Control(Project_Warm_Mode,0x01);  //打开温馨模式
						
						if(temp2 == 0x02)	//起夜模式结束
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);	//退出起夜模式
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}
						
					}else				//当前处于睡眠模式，进入起夜模式
					{
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);
						
						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}
			else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH13] == KeyPress)		//按键13 - 阅读模式
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH13] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS_SWITCH_CH13 KeyPress");
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)	//当前不是在睡眠模式下
					{
						Project_LightMode_Control(Project_Reading_Mode,0x01);  //打开阅读模式
						
						if(temp2 == 0x02)	//起夜模式结束
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);	//退出起夜模式
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}
						
					}else				//当前处于睡眠模式，进入起夜模式
					{
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);
						
						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH14] == KeyPress)		//按键14 - 睡眠模式
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH14] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:14",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						Project_LightMode_Control(Project_Neight_Mode,0x01);
//						Project_Curtain_Control(0x01,0x02);
						Project_Curtain_Control(0x02,0x02);

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH15] == KeyPress)		//按键15 - 明亮模式1
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH15] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:15",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						Project_LightMode_Control(Project_Bright_Mode,0x01);
//						Project_Curtain_Control(0x01,0x02);
//						Project_Curtain_Control(0x02,0x02);

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH16] == KeyPress)		//按键16 - 会客模式1
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH16] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:16",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						Project_LightMode_Control(Project_Reception_Mode,0x01);
//						Project_Curtain_Control(0x01,0x02);
//						Project_Curtain_Control(0x02,0x02);

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}
			break;
		case 0x01:		//开关1 - 6键控制逻辑 
			if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH1] == KeyPress)				//按键1 - 廊灯
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH1] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:1",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH1_Control) != Project_LightScence_CH1_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH1_Control,Project_LightScence_CH1_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH1_Control,BLV_Project_Light_Off_State);
						}
						
						
						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束

							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH2] == KeyPress)		//按键2 - 镜前灯
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH2] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:2",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH2_Control) != Project_LightScence_CH2_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH2_Control,Project_LightScence_CH2_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH2_Control,BLV_Project_Light_Off_State);
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH3] == KeyPress)		//按键3 - 清理
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH3] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:3",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						temp4 = SRAM_Read_Byte(SRAM_Service_Clear_LastState);
						if(temp4 == 0x01)
						{
							SRAM_Write_Byte(0x00,SRAM_Service_Clear_State);
						}else
						{
							SRAM_Write_Byte(0x01,SRAM_Service_Clear_State);
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH4] == KeyPress)		//按键4 - 卫生间灯
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH4] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:4",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH3_Control) != Project_LightScence_CH3_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH3_Control,Project_LightScence_CH3_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH3_Control,BLV_Project_Light_Off_State);
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH5] == KeyPress)		//按键5 - 排气扇1
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH5] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:5",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH4_Control) != Project_LightScence_CH4_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH4_Control,Project_LightScence_CH4_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH4_Control,BLV_Project_Light_Off_State);
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] == KeyPress)				//按键6 - 勿扰
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:6",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{

						temp4 = SRAM_Read_Byte(SRAM_Service_Do_Not_Disturb_LastState);
						if(temp4 == 0x01)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"关闭勿扰");
							SRAM_Write_Byte(0x00,SRAM_Service_Do_Not_Disturb_State);
						}else
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"打开勿扰");
							SRAM_Write_Byte(0x01,SRAM_Service_Do_Not_Disturb_State);
						}
						
						
						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束

							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}
			break;
		case 0x02:		//开关2 - 3键控制逻辑
      if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH2] == KeyPress)		//按键2 - 卫浴灯
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH2] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:2",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH5_Control) != Project_LightScence_CH5_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH5_Control,Project_LightScence_CH5_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH5_Control,BLV_Project_Light_Off_State);
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}
			else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH4] == KeyPress)		//按键4 - 镜前灯2
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH4] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:4",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH6_Control) != Project_LightScence_CH6_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH6_Control,Project_LightScence_CH6_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH6_Control,BLV_Project_Light_Off_State);
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] == KeyPress)		//按键5 - 排气扇2
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:6",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH7_Control) != Project_LightScence_CH7_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH7_Control,Project_LightScence_CH7_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH7_Control,BLV_Project_Light_Off_State);
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}
			break;
		case 0x03:		//开关3 - 4键控制逻辑
			if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH1] == KeyPress)		//按键1 - 窗帘开
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH1] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:1",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						temp4 = SRAM_Read_Byte(SRAM_Global_Curtain_Start);
						if(temp4 == 0x11)		//开动作中
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"窗帘停");
							Project_Curtain_Control(0x01,0x00);
						}else {
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"窗帘开");
							Project_Curtain_Control(0x01,0x01);
						}
						

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH3] == KeyPress)		//按键3 - 顶灯
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH3] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:3",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if((temp3 & Project_LightScence_CH9_Control) != Project_LightScence_CH9_State)
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH9_Control,Project_LightScence_CH9_State);
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH9_Control,BLV_Project_Light_Off_State);
						}

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else	if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH4] == KeyPress)		//按键4 - 窗帘关
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH4] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:4",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						temp4 = SRAM_Read_Byte(SRAM_Global_Curtain_Start);
						if(temp4 == 0x12)		//开动作中
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"窗帘停");
							Project_Curtain_Control(0x01,0x00);
						}else {
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"窗帘关");
							Project_Curtain_Control(0x01,0x02);
						}
						

						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] == KeyPress)				//按键6 - 总控2
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS Switch%d KeyPress:6",temp);
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)		//当前不是在起夜模式下，正常控制
					{
						
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						temp3 = Get_BUS_C5IO_Realy_Status(deal_addr);
						if(0x00 == (temp3 & Project_LightScence_CH12_Control))  //为0 Project_LightScence_CH11_State
						{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH12_Control,Project_LightScence_CH12_State);  //打开场景
						}else{
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH12_Control,BLV_Project_Light_Off_State);    //关闭场景    
						}
						
						
						if(temp2 == 0x02)	//起夜模式结束 - 关闭夜灯
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);				//起夜模式结束

							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}

					}else { 				//起夜模式中 - 开夜灯
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);

						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}	
			break;
		case 0x04:		//开关4 - 4键控制逻辑
			if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH1] == KeyPress)		//按键1 - 阅读模式
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH1] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS_SWITCH_CH1 KeyPress");
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)	//当前不是在睡眠模式下
					{
						Project_LightMode_Control(Project_Reading_Mode,0x01);  //打开阅读模式
						
						if(temp2 == 0x02)	//起夜模式结束
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);	//退出起夜模式
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}
						
					}else				//当前处于睡眠模式，进入起夜模式
					{
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);
						
						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else	if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH3] == KeyPress)		//按键3 - 会客模式2
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH3] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS_SWITCH_CH13 KeyPress");
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)	//当前不是在睡眠模式下
					{
						Project_LightMode_Control(Project_Reception2_Mode,0x01);  //打开会客模式2
						
						if(temp2 == 0x02)	//起夜模式结束
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);	//退出起夜模式
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}
						
					}else				//当前处于睡眠模式，进入起夜模式
					{
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);
						
						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else	if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH4] == KeyPress)		//按键4 - 明亮模式2
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH4] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS_SWITCH_CH4 KeyPress");
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)	//当前不是在睡眠模式下
					{
						Project_LightMode_Control(Project_Bright2_Mode,0x01);  //打开明亮模式2
						
						if(temp2 == 0x02)	//起夜模式结束
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);	//退出起夜模式
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}
						
					}else				//当前处于睡眠模式，进入起夜模式
					{
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);
						
						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}else if(Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] == KeyPress)		//按键6 - 观影模式
			{
				temp1++;
				Rs485SwiInfo.DevReadBuf[RS_SWITCH_CH6] = KeyNoAction;
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"RS_SWITCH_CH6 KeyPress");
				
				if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
				{
					temp2 = SRAM_Read_Byte(SRAM_Global_NightMode_Start);
					if(temp2 != 0x01)	//当前不是在睡眠模式下
					{
						Project_LightMode_Control(Project_Viewing_Mode,0x01);  //打开阅读模式
						
						if(temp2 == 0x02)	//起夜模式结束
						{
							SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);	//退出起夜模式
							
							#if	Project_NightMode_Enable
							BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,BLV_Project_Light_Off_State);
							#endif
						}
						
					}else				//当前处于睡眠模式，进入起夜模式
					{
						SRAM_Write_Byte(0x02,SRAM_Global_NightMode_Start);
						
						#if	Project_NightMode_Enable
						deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
						//BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH8,0x01);			//开启夜灯
						BUS_C5IO_Group_Control_Relay(deal_addr,Project_Scene_NightLight_Control,Project_Scene_NightLight_State);
						#endif
					}
				}
				
			}
			break;
	}
	
	
	if(temp1 != 0x00)
	{
		/*将数据保存，重新计算校验值 注意：一般数据有变动时，才重新计算校验值*/
		SRAM_DMA_Write_Buff((uint8_t *)&Rs485SwiInfo,sizeof(RS485_SWI_INFO),devaddr+Dev_Privately);
		
		SRAM_Write_Byte(0x00,devaddr+Dev_Check);				//校验值清零
		dev_datalen = sizeof(RS485_SWI_INFO) + Dev_Privately;
		val_check = Dev_CheckSum(devaddr,dev_datalen);
		
		SRAM_Write_Byte(val_check,devaddr+Dev_Check);		//校验值重新写入
	}
}

void Device_Card_Scan_Signal(uint32_t devaddr)
{
	uint16_t temp = 0,temp1 = 0;
	uint8_t crc_val = 0;
	uint32_t deal_addr = 0;
	RS485_CARD_INFO 	Rs485CardInfo;
	SRAM_DMA_Read_Buff((uint8_t *)&Rs485CardInfo,sizeof(RS485_CARD_INFO),devaddr+Dev_Privately);
	temp = Rs485CardInfo.Rs485CardAction;
	switch(temp)
	{
		case 0x01:         	//无卡 拔卡 
			temp1++;
			Rs485CardInfo.Rs485CardAction = 0x00; 
		
			//播放提示音
			deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);
			BUS_C5MUSIC_Set_Global_Volume(deal_addr,70);
			BUS_C5MUSIC_Warning_Dir(deal_addr,0x0D,BLV_C5MUSIC_Single_Play);	//按键提示音 - 播放离开提示词
		
			Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0001,0x02);		//取电服务信息上报 - 服务信息 回路地址0x02
			Rs485CardInfo.Rs485CardoffFlag = 0x01;
			Rs485CardInfo.Rs485CardoffTick = SysTick_1ms;
			break;
		case 0x02:   			//高频卡
		case 0x03:          	//客人
		case 0x04:         	//服务员
		case 0x05:        	//经理
		case 0x06:       	//工程
		case 0x07:  
			Rs485CardInfo.Rs485CardAction = 0x00; 
			
			SRAM_Write_Byte(0x01,SRAM_Service_Take_Electricity_State);			//取电 开
			
			Rs485CardInfo.Rs485CardoffFlag = 0x00;
		
			temp1++;
			
			break;
	}
	
	/*延时断电10s*/
	if(Rs485CardInfo.Rs485CardoffFlag == 0x01)
	{
		if(SysTick_1ms - Rs485CardInfo.Rs485CardoffTick > 10000)
		{
			temp1++;
			Rs485CardInfo.Rs485CardoffFlag = 0x00;
			Rs485CardInfo.Rs485CardoffTick = SysTick_1ms;
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"延时断电\r\n");
			
			SRAM_Write_Byte(0x02,SRAM_Service_Take_Electricity_State);			//取电 关
		}
	}
	
	if(temp1 != 0x00)
	{
		
		/*将数据保存进入SRAM中*/
		SRAM_DMA_Write_Buff((uint8_t *)&Rs485CardInfo,sizeof(RS485_CARD_INFO),devaddr+Dev_Privately);
		
		/*计算校验值*/
		SRAM_Write_Byte(0x00,devaddr+Dev_Check);
		temp = sizeof(RS485_CARD_INFO) + Dev_Privately;
		crc_val = Dev_CheckSum(devaddr,temp);
		SRAM_Write_Byte(crc_val,devaddr+Dev_Check);		//校验值重新写入
	}
}

/*
#define Project_Bright_Mode 		0x01		//明亮模式
#define Project_Reception_Mode		0x02		//会客模式
#define Project_Warm_Mode			0x03		//温馨模式
#define Project_Neight_Mode		    0x04		//睡眠模式
#define Project_Hypnotic_Mode		0x05		//助眠模式
#define Project_Romance_Mode		0x06		//浪漫模式
#define Project_Reading_Mode		0x07		//阅读模式
#define Project_Relaxation_Mode	    0x08		//休闲模式
#define Project_Viewing_Mode		0x09		//观影模式
*/

void BUS_C5IO_Scan_DI_Signal(uint32_t dev_addr)
{
	
	uint8_t crc_val = 0,temp1 = 0,temp2 = 0;
	uint16_t temp = 0;
	uint32_t deal_addr = 0,temp3 = 0;
	BUS_C5IO_INFO C5IO_Info;
	RS485_A9RELAY_INFO Rs485A9RELAY;     //

	uint8_t BrightSceneFlag1;   //明亮场景状态1
	uint8_t BrightSceneFlag2;   //明亮场景状态2
	uint8_t ReceiveSceneFlag1;  //接待场景状态1
	uint8_t ReceiveSceneFlag2;  //接待场景状态2
	uint8_t WarmSceneFlag;     //温馨场景状态
	uint8_t NeightSceneFlag;   //睡眠场景状态
	uint8_t ReadSceneFlag;     //阅读场景状态
	uint8_t ViewSceneFlag;     //观影场景状态
	
	uint32_t dev_A9RELAY_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);  
			
	if(0x00 == dev_A9RELAY_addr)
	{
		return;
	}
	
	SRAM_DMA_Read_Buff((uint8_t *)&Rs485A9RELAY,sizeof(RS485_A9RELAY_INFO),dev_A9RELAY_addr+Dev_Privately);

	SRAM_DMA_Read_Buff((uint8_t *)&C5IO_Info,sizeof(BUS_C5IO_INFO),dev_addr+Dev_Privately);
	
	for(uint8_t i = 0;i<C5IO_DI_CH_MAX;i++)
	{
		switch((C5IO_Info.DI_Type[i] & 0x0F))
		{
			case BUS_C5IO_DI_Key_Type:
				if(C5IO_Info.DI_Start[i] == 0x01)
				{
					temp1++;
					C5IO_Info.DI_Start[i] = 0;			//门铃按键按下
					
					/*测试状态下 - 检测到开关状态变化打开或关闭对应继电器，同时上报PC*/
					if(g_pc_test.test_flag == 0x01)
					{
						BUS_C5IO_Control_Relay(dev_addr,i,0x03);		//控制对应继电器
						BLV_PC_Testing_Data_Reported(0x01,DEV_C5IO_Type,0x00,SRAM_LOG_Device_C5IO_DI_Status,2);
					}
					
					if(i == C5IO_DI_CH7)
					{
						if(Get_SYS_Take_Electricity_Status() == 0x01)		//插卡才能操作
						{
							if(SRAM_Read_Byte(SRAM_Global_Do_Not_Disturb_Start) == 0x00)			//当前处于勿扰模式
							{
								deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);
								BUS_C5MUSIC_Doorbell_Dir(deal_addr,0x05);
							}else{
								Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"当前处于勿扰模式\r\n");
							}
						}
					}
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"---C5IO Key%d strat:%02X \r\n",i,0x01);
				}
				
				break;
			case BUS_C5IO_DI_Pir_Type:
				if(C5IO_Info.DI_Start[i] != C5IO_Info.DI_LastStart[i])
				{
					temp1++;
					C5IO_Info.DI_LastStart[i] = C5IO_Info.DI_Start[i];			
					//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"---C5IO Pir%d strat:%02X \r\n",i,C5IO_Info.DI_LastStart[i]);
				}
				break;
			case BUS_C5IO_DI_Dry_Type:

				if(C5IO_Info.DI_Start[i] != C5IO_Info.DI_LastStart[i])
				{
					temp1++;
					C5IO_Info.DI_LastStart[i] = C5IO_Info.DI_Start[i];			
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"输入状态变化，输入回路:%d\r\n", i);
					/*干接点插卡*/
					if((i == C5IO_DI_CH1) && (C5IO_Info.DI_LastStart[i] == 0x01))			//开启（插卡）
					{
						Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"干接点插卡\r\n");
						SRAM_Write_Byte(0x00,SRAM_Global_Room_Rent_Flag);
		
						SRAM_Write_Byte(0x01,SRAM_Global_Power_on_Status);			//记录取电标志位
						SRAM_Write_Byte(0x01,SRAM_Service_Take_Electricity_State);			//取电 开
					}
					else if((i == C5IO_DI_CH1) && (C5IO_Info.DI_LastStart[i] == 0x00))   //关闭
					{
						Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"干接点拔卡\r\n");

						SRAM_Write_Byte(0x02,SRAM_Global_Power_on_Status);			//记录取电标志位
						
						SRAM_Write_DW(SysTick_1ms, SRAM_Global_Power_off_Tick);  	//记录拔卡时间
						
						deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);
						BUS_C5MUSIC_Set_Global_Volume(deal_addr,70);
						BUS_C5MUSIC_Warning_Dir(deal_addr,0x0D,BLV_C5MUSIC_Single_Play);	//按键提示音 - 播放离开提示词
					}
					/*门磁*/
					if((i == C5IO_DI_CH2) && (C5IO_Info.DI_LastStart[i] == 0x01))			//开启
					{
						/* - 5s后关闭廊灯*/
						SRAM_Write_Byte(0x02,SRAM_Global_Door_Status_Flag);
						SRAM_Write_DW(SysTick_1ms,SRAM_Global_Door_Status_Tick);
						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_Door_Status_Tick----");
						
						Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x000D,0x02);		//门磁上报服务器 - 关状态
					}else if((i == C5IO_DI_CH2) && (C5IO_Info.DI_LastStart[i] == 0x00))		//关闭
					{
						/*打开廊灯 - 三分钟后关闭*/
						SRAM_Write_Byte(0x01,SRAM_Global_Door_Status_Flag);
						SRAM_Write_DW(SysTick_1ms,SRAM_Global_Door_Status_Tick);
						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_Door_Status_Tick----");
						
						/*开启继电器5 - 对应廊灯*/
						C5IO_Info.Relay_Control[C5IO_Relay_CH2] = BUS_C5IO_OUT_HIGH;
						C5IO_Info.Relay_Control_Flag |= 0x01<<C5IO_Relay_CH2;
						
						Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x000D,0x01);		//门磁上报服务器 - 开状态
					}
					
					/*SOS*/
					if((i == C5IO_DI_CH3) && (C5IO_Info.DI_LastStart[i] == 0x01))			//开启
					{
						deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);
						//BUS_C5MUSIC_Set_Playback_Mode(deal_addr,BLV_C5MUSIC_Single_Cycle);	
						BUS_C5MUSIC_Warning_Dir(deal_addr,0x14,BLV_C5MUSIC_Single_Play);			//提示音 - 单曲循环
						
						SRAM_Write_Byte(0x01,SRAM_Global_SOS_Status_Flag);
						SRAM_Write_Byte(0x00,SRAM_Global_SOS_LEDStatus_Flag);
						SRAM_Write_DW(SysTick_1ms,SRAM_Global_SOS_Status_Tick);
						
						Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0008,0x01);		//SOS上报服务器 - 开状态
						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SOS OPEN----");
					}else if((i == C5IO_DI_CH3) && (C5IO_Info.DI_LastStart[i] == 0x00))		//关闭
					{
						temp1++;
						//关闭DO
						C5IO_Info.DO_Control[C5IO_DO_CH2] = BUS_C5IO_OUT_LOW;
						C5IO_Info.DO_Control_Flag |= 0x01<<C5IO_DO_CH2;
						C5IO_Info.DO_Control[C5IO_DO_CH3] = BUS_C5IO_OUT_LOW;
						C5IO_Info.DO_Control_Flag |= 0x01<<C5IO_DO_CH3;
								
						deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);
						//BUS_C5MUSIC_Set_Playback_Mode(deal_addr,BLV_C5MUSIC_Full_Loop);	
						BUS_C5MUSIC_Warning_Dir(deal_addr,0x15,BLV_C5MUSIC_Single_Play);			//提示音 - 单曲循环
						
						SRAM_Write_Byte(0x00,SRAM_Global_SOS_Status_Flag);
						
						Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0008,0x02);		//SOS上报服务器 - 关状态
						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SOS Close----");
					}
					
					/*红外感应1*/
					if((i == C5IO_DI_CH4) && (C5IO_Info.DI_LastStart[i] == 0x01))			//开启
					{
						/* - 5s后关闭廊灯*/
//						SRAM_Write_Byte(0x02,SRAM_Global_Door_Status_Flag);
//						SRAM_Write_DW(SysTick_1ms,SRAM_Global_Door_Status_Tick);
//						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_Door_Status_Tick----");
						
						/*打开第5路继电器*/
						C5IO_Info.Relay_Control[C5IO_Relay_CH5] = BUS_C5IO_OUT_HIGH;
						C5IO_Info.Relay_Control_Flag |= 0x01<<C5IO_Relay_CH5;		
						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----红外感应1检测到人----");
						
//						Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x000D,0x02);		//门磁上报服务器 - 关状态
					}else if((i == C5IO_DI_CH4) && (C5IO_Info.DI_LastStart[i] == 0x00))		//关闭
					{
						/*延时标志置位 时间置位*/
						SRAM_Write_Byte(0x02,SRAM_Global_NodePir1_Status_Flag);
						SRAM_Write_DW(SysTick_1ms,SRAM_Global_NodePir1_Status_Tick);  //保存时间
						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----红外感应1未检测到人----");

//						Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x000D,0x01);		//门磁上报服务器 - 开状态
					}
				
					/*红外感应2*/
					if((i == C5IO_DI_CH5) && (C5IO_Info.DI_LastStart[i] == 0x01))			//开启
					{
						/* - 5s后关闭廊灯*/
//						SRAM_Write_Byte(0x02,SRAM_Global_Door_Status_Flag);
//						SRAM_Write_DW(SysTick_1ms,SRAM_Global_Door_Status_Tick);
//						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_Door_Status_Tick----");
						
						/*打开第12路继电器*/
						C5IO_Info.Relay_Control[C5IO_Relay_CH12] = BUS_C5IO_OUT_HIGH;
						C5IO_Info.Relay_Control_Flag |= 0x01<<C5IO_Relay_CH12;		
						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----红外感应2检测到人----");
						
//						Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x000D,0x02);		//门磁上报服务器 - 关状态
					}else if((i == C5IO_DI_CH5) && (C5IO_Info.DI_LastStart[i] == 0x00))		//关闭
					{
						/*延时标志置位 时间置位*/
						SRAM_Write_Byte(0x02,SRAM_Global_NodePir2_Status_Flag);
						SRAM_Write_DW(SysTick_1ms,SRAM_Global_NodePir2_Status_Tick);  //保存时间
						Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----红外感应2未检测到人----");

//						Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x000D,0x01);		//门磁上报服务器 - 开状态
					}
					
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"---C5IO Dry%d strat:%02X \r\n",i,C5IO_Info.DI_LastStart[i]);
				}
				break;
		}
	}
	
	/*延时断电10s*/
	temp2 = SRAM_Read_Byte(SRAM_Global_Power_on_Status);
	if(temp2 == 0x02)
	{
		temp3 = SRAM_Read_DW(SRAM_Global_Power_off_Tick);
		if(SysTick_1ms - temp3 > 10000)
		{
			temp1++;
			SRAM_Write_Byte(0x00,SRAM_Global_Power_on_Status);			//清除拔卡标志位
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"干接点 断电\r\n");
			
			SRAM_Write_Byte(0x02,SRAM_Service_Take_Electricity_State);			//取电 关
		}
	}
	
	/*延时关闭廊灯*/
	temp2 = SRAM_Read_Byte(SRAM_Global_Door_Status_Flag);
	if(temp2 == 0x01)
	{
		temp3 = SRAM_Read_DW(SRAM_Global_Door_Status_Tick);
		if(SysTick_1ms - temp3 > 180000)
		{
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_Door_Status_Tick----");
			SRAM_Write_Byte(0x00,SRAM_Global_Door_Status_Flag);
			temp1++;
			//关闭继电器5 - 廊灯
			C5IO_Info.Relay_Control[C5IO_Relay_CH2] = BUS_C5IO_OUT_LOW;
			C5IO_Info.Relay_Control_Flag |= 0x01<<C5IO_Relay_CH2;
		}
	}else if(temp2 == 0x02)
	{
		
		temp3 = SRAM_Read_DW(SRAM_Global_Door_Status_Tick);
		
		if(SysTick_1ms - temp3 > 5000)
		{
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_Door_Status_Tick----");
			SRAM_Write_Byte(0x00,SRAM_Global_Door_Status_Flag);
			temp1++;
			//关闭继电器5 - 廊灯
			C5IO_Info.Relay_Control[C5IO_Relay_CH2] = BUS_C5IO_OUT_LOW;
			C5IO_Info.Relay_Control_Flag |= 0x01<<C5IO_Relay_CH2;
		}
	}

	/*延时5分钟关闭第5路继电器*/
	temp2 = SRAM_Read_Byte(SRAM_Global_NodePir1_Status_Flag);
	if(temp2 == 0x02)
	{
		temp3 = SRAM_Read_DW(SRAM_Global_NodePir1_Status_Tick);
		
		if(SysTick_1ms - temp3 > 300000)    
		{
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_NodePir1_Status_Tick----");
			SRAM_Write_Byte(0x00,SRAM_Global_NodePir1_Status_Flag);
			temp1++;
			//关闭继电器5
			C5IO_Info.Relay_Control[C5IO_Relay_CH5] = BUS_C5IO_OUT_LOW;
			C5IO_Info.Relay_Control_Flag |= 0x01<<C5IO_Relay_CH5;

		}
	}	
	
	/*延时5分钟关闭第12路继电器*/
	temp2 = SRAM_Read_Byte(SRAM_Global_NodePir2_Status_Flag);
	if(temp2 == 0x02)
	{
		temp3 = SRAM_Read_DW(SRAM_Global_NodePir2_Status_Tick);
		
		if(SysTick_1ms - temp3 > 300000)    
		{
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_NodePir1_Status_Tick----");
			SRAM_Write_Byte(0x00,SRAM_Global_NodePir2_Status_Flag);
			temp1++;
			//关闭继电器5
			C5IO_Info.Relay_Control[C5IO_Relay_CH12] = BUS_C5IO_OUT_LOW;
			C5IO_Info.Relay_Control_Flag |= 0x01<<C5IO_Relay_CH12;

		}
	}	
	
	/*SOS状态 , 清理，勿扰反馈灯同时闪烁*/
	temp2 = SRAM_Read_Byte(SRAM_Global_SOS_Status_Flag);
	if(temp2 == 0x01)
	{
		temp3 = SRAM_Read_DW(SRAM_Global_SOS_Status_Tick);
		if(SysTick_1ms - temp3 > 500)
		{
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"----SRAM_Global_SOS_Status_Tick----");
			SRAM_Write_DW(SysTick_1ms,SRAM_Global_SOS_Status_Tick);
			if(SRAM_Read_Byte(SRAM_Global_SOS_LEDStatus_Flag) == 0x00)
			{
				SRAM_Write_Byte(0x01,SRAM_Global_SOS_LEDStatus_Flag);
				temp1++;
				//打开DO
				C5IO_Info.DO_Control[C5IO_DO_CH2] = BUS_C5IO_OUT_HIGH;
				C5IO_Info.DO_Control_Flag |= 0x01<<C5IO_DO_CH2;
				C5IO_Info.DO_Control[C5IO_DO_CH3] = BUS_C5IO_OUT_HIGH;
				C5IO_Info.DO_Control_Flag |= 0x01<<C5IO_DO_CH3;
				
				Project_Service_Feedback(Project_Service_Do_Not_Disturb,0x01);
				Project_Service_Feedback(Project_Service_Clear,0x01);
			}else {
				SRAM_Write_Byte(0x00,SRAM_Global_SOS_LEDStatus_Flag);
				temp1++;
				//关闭DO
				C5IO_Info.DO_Control[C5IO_DO_CH2] = BUS_C5IO_OUT_LOW;
				C5IO_Info.DO_Control_Flag |= 0x01<<C5IO_DO_CH2;
				C5IO_Info.DO_Control[C5IO_DO_CH3] = BUS_C5IO_OUT_LOW;
				C5IO_Info.DO_Control_Flag |= 0x01<<C5IO_DO_CH3;
				
				Project_Service_Feedback(Project_Service_Do_Not_Disturb,0x00);  
				Project_Service_Feedback(Project_Service_Clear,0x00);
			}
			
		}
	}
	
	if(	(
		(C5IO_Info.Relay_Level_Actual_Start != C5IO_Info.Last_Relay_Level_Start) || (C5IO_Info.DO_Level_Actual_Start != C5IO_Info.Last_DO_Level_Start)
//	||	   (0x01 == PWM_State_Change_Get(dev_PWM_addr))  //调光状态有变化
	   ) 
		&& (Get_SYS_Take_Electricity_Status() == 0x01)
		)
	{
		if(
			((C5IO_Info.Relay_Level_Actual_Start & Project_Bright1_Mode_Control) == Project_Bright1_Mode_State)   //继电器判断
//			&&(100 == Rs485PWM.DevSendBuf[PWM_OUT_CH1]) && (100 == Rs485PWM.DevSendBuf[PWM_OUT_CH2])  
//		  &&(100 == Rs485PWM.DevSendBuf[PWM_OUT_CH3]) && (100 == Rs485PWM.DevSendBuf[PWM_OUT_CH4])      //调光判断
			)
		{
			BrightSceneFlag1 = 0x01;   //明亮场景为开
		}
		else
		{
			BrightSceneFlag1 = 0x02;   //明亮场景为关
		}
		if(
			((C5IO_Info.Relay_Level_Actual_Start & Project_Bright2_Mode_Control) == Project_Bright2_Mode_State)   //继电器判断
//			&&(100 == Rs485PWM.DevSendBuf[PWM_OUT_CH1]) && (100 == Rs485PWM.DevSendBuf[PWM_OUT_CH2])  
//		  &&(100 == Rs485PWM.DevSendBuf[PWM_OUT_CH3]) && (100 == Rs485PWM.DevSendBuf[PWM_OUT_CH4])      //调光判断
			)
		{
			BrightSceneFlag2 = 0x01;   //明亮场景为开
		}
		else
		{
			BrightSceneFlag2 = 0x02;   //明亮场景为关
		}
		
		if(
			((C5IO_Info.Relay_Level_Actual_Start & Project_Receive1_Mode_Control) == Project_Receive1_Mode_State)   //继电器判断
//			&&(100 == Rs485PWM.DevSendBuf[PWM_OUT_CH1]) && (100 == Rs485PWM.DevSendBuf[PWM_OUT_CH2])  
//		  &&(100 == Rs485PWM.DevSendBuf[PWM_OUT_CH3]) && (100 == Rs485PWM.DevSendBuf[PWM_OUT_CH4])      //调光判断
			)
		{
			ReceiveSceneFlag1 = 0x01;   //会客场景为开
		}
		else
		{
			ReceiveSceneFlag1 = 0x02;   //会客场景为关
		}
		
		if(
			((C5IO_Info.Relay_Level_Actual_Start & Project_Receive2_Mode_Control) == Project_Receive2_Mode_State)   //继电器判断
//			&&(100 == Rs485PWM.DevSendBuf[PWM_OUT_CH1]) && (100 == Rs485PWM.DevSendBuf[PWM_OUT_CH2])  
//		  &&(100 == Rs485PWM.DevSendBuf[PWM_OUT_CH3]) && (100 == Rs485PWM.DevSendBuf[PWM_OUT_CH4])      //调光判断
			)
		{
			ReceiveSceneFlag2 = 0x01;   //会客场景为开
		}
		else
		{
			ReceiveSceneFlag2 = 0x02;   //会客场景为关
		}
		
		if(
			((C5IO_Info.Relay_Level_Actual_Start & Project_Warm_Mode_Control) == Project_Warm_Mode_State)     //继电器判断
//			 &&(40 == Rs485PWM.DevSendBuf[PWM_OUT_CH1]) && (40 == Rs485PWM.DevSendBuf[PWM_OUT_CH2])  
//		   &&(40 == Rs485PWM.DevSendBuf[PWM_OUT_CH3]) && (0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH4])      //调光判断			
			)
		{
			WarmSceneFlag = 0x01;    //温馨场景为开
		}
		else
		{
			WarmSceneFlag = 0x02;    //温馨场景为关
		}
		
		if(
			((C5IO_Info.Relay_Level_Actual_Start & Project_Neight_Mode_Control) == Project_Neight_Mode_State)   //继电器判断
//			 &&(0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH1]) && (0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH2])  
//		   &&(0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH3]) && (0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH4])       //调光判断	
			)
		{
			NeightSceneFlag = 0x01;    //睡眠场景为开
		}
		else
		{
			NeightSceneFlag = 0x02;    //睡眠场景为关
		}		
		
		if(
			((C5IO_Info.Relay_Level_Actual_Start & Project_Reading_Mode_Control) == Project_Reading_Mode_State)   //继电器判断
//			 &&(60 == Rs485PWM.DevSendBuf[PWM_OUT_CH1]) && (60 == Rs485PWM.DevSendBuf[PWM_OUT_CH2]) //调光判断     //调光判断			
			)
		{
			ReadSceneFlag = 0x01;    //阅读场景为开
		}
		else
		{
			ReadSceneFlag = 0x02;    //阅读场景为关
		}

		if(
			((C5IO_Info.Relay_Level_Actual_Start & Project_Viewing_Mode_Control) == Project_Viewing_Mode_State)   //继电器判断
//			 &&(0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH1]) && (0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH2])  
//		   &&(0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH3]) && (0x00 == Rs485PWM.DevSendBuf[PWM_OUT_CH4]) //调光判断     //调光判断			
			)
		{
			ViewSceneFlag = 0x01;    //观影场景为开
		}
		else
		{
			ViewSceneFlag = 0x02;    //观影场景为关
		}		
		
		/*根据继电器实际状态，控制反馈灯*/
		
		temp2 = SRAM_Read_Byte(SRAM_Global_Mode_Start);
		if(
				(0x01 == BrightSceneFlag1) &&      //场景状态为开
			 (temp2 != Project_Bright_Mode))		//明亮模式
		{
			temp1++;
			
			SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);
			SRAM_Write_Byte(Project_Bright_Mode,SRAM_Global_Mode_Start);
			SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
			SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);					//退出起夜模式
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"明亮模式\r\n");
			
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_Bright_Mode);
		}

		if(
				(0x01 == BrightSceneFlag2) &&      //场景状态为开
			 (temp2 != Project_Bright2_Mode))		//明亮模式2
		{
			temp1++;
			
			SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);
			SRAM_Write_Byte(Project_Bright2_Mode,SRAM_Global_Mode_Start);
			SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
			SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);					//退出起夜模式
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"明亮模式\r\n");
			
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_Bright2_Mode);
		}
		
		if(
				(0x01 == ReceiveSceneFlag1) &&      //场景状态为开
			 (temp2 != Project_Reception_Mode))		//会客模式1
		{
			temp1++;
			
			SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);
			SRAM_Write_Byte(Project_Reception_Mode,SRAM_Global_Mode_Start);
			SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
			SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);					//退出起夜模式
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"会客模式1\r\n");
			
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_Reception_Mode);
		}

		if(
				(0x01 == ReceiveSceneFlag2) &&      //场景状态为开
			 (temp2 != Project_Reception2_Mode))		//会客模式2
		{
			temp1++;
			
			SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);
			SRAM_Write_Byte(Project_Reception2_Mode,SRAM_Global_Mode_Start);
			SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
			SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);					//退出起夜模式
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"会客模式2\r\n");
			
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_Reception2_Mode);
		}		
		
		if(
			(0x01 == WarmSceneFlag) &&
			(temp2 != Project_Warm_Mode)
		  )		//温馨模式
		{
			temp1++;
			SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);

			SRAM_Write_Byte(Project_Warm_Mode,SRAM_Global_Mode_Start);
			SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"温馨模式\r\n");
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_Warm_Mode);   
		}

		if(
				(0x01 == ReadSceneFlag)
			&&
			(temp2 != Project_Reading_Mode))		//阅读模式
		{
			temp1++;
			SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);

			SRAM_Write_Byte(Project_Reading_Mode,SRAM_Global_Mode_Start);
			SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"阅读模式\r\n");
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_Reading_Mode);
		}

		if(
				(0x01 == ViewSceneFlag)
				&&      
			(temp2 != Project_Viewing_Mode)
			)		//观影模式
		{
			temp1++;
			SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);

			SRAM_Write_Byte(Project_Viewing_Mode,SRAM_Global_Mode_Start);
			SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"观影模式\r\n");
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_Viewing_Mode);
		}		
		
		if(
			(0x01 == NeightSceneFlag)
			&&
			(temp2 != Project_Neight_Mode)
			)	//睡眠模式
		{
			temp1++;
			
			SRAM_Write_Byte(Project_Neight_Mode,SRAM_Global_Mode_Start);
			
			#if Project_NightMode_Enable
			SRAM_Write_Byte(0x01,SRAM_Global_NightMode_Start);					//进入起夜模式
			#endif
		
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"睡眠模式\r\n");
			
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_Neight_Mode);
		}
		
		if( (0x02 == BrightSceneFlag1)
			&&(0x02 == BrightSceneFlag2)
		&&(0x02 == ReceiveSceneFlag1)
		&&(0x02 == ReceiveSceneFlag2)
		&& (0x02 == WarmSceneFlag)
		&& (0x02 == NeightSceneFlag)
		&& (0x02 == ReadSceneFlag)
		&& (0x02 == ViewSceneFlag)		
		&& (temp2 != Project_NO_Schema)
		)		//不是在起夜模式
		{
			temp1++;
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"无模式\r\n");
			SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);
			
			SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) == 0x05)	//如果之前是助眠模式，需关闭助眠音乐
			{
				deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);
				BUS_C5MUSIC_Stop_Playback(deal_addr);
			}
			
			SRAM_Write_Byte(Project_NO_Schema,SRAM_Global_Mode_Start);
			
			if(SRAM_Read_Byte(SRAM_Global_Card_Status) == 0x01)		//第一次卡插入，如果进入睡眠模式，不进行动作
			{
				SRAM_Write_Byte(0x00,SRAM_Global_Card_Status);
				#if Project_NightMode_Enable
				SRAM_Write_Byte(0x00,SRAM_Global_NightMode_Start);					//进入起夜模式
				#endif
			}
			
			/*控制指示灯*/
			Project_LightMode_Feedback(Project_NO_Schema);
		}
		

		
		/*确认退房中，反馈灯开始闪烁*/
		// temp2 = SRAM_Read_Byte(SRAM_Global_Check_out_Status);
		// if(temp2 == 0x01)
		// {
		// 	temp3 = SRAM_Read_DW(SRAM_Global_Check_out_LED_Tick);
		// 	if(SysTick_1ms - temp3 > 300)
		// 	{
		// 		SRAM_Write_DW(SysTick_1ms,SRAM_Global_Check_out_LED_Tick);
		// 		if(SRAM_Read_Byte(SRAM_Global_Check_out_LED_Status) == 0x00)
		// 		{
		// 			SRAM_Write_Byte(0x01,SRAM_Global_Check_out_LED_Status);
		// 			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
		// 			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x01);	//退房 指示灯开
		// 		}else {
		// 			SRAM_Write_Byte(0x00,SRAM_Global_Check_out_LED_Status);
		// 			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
		// 			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//退房 指示灯关
		// 		}
		// 	}
		// 	/*确认时间超时，关闭反馈灯*/
		// 	temp3 = SRAM_Read_DW(SRAM_Global_Check_out_Tick);
		// 	if(SysTick_1ms - temp3 > 10000)
		// 	{
		// 		SRAM_Write_Byte(0x00,SRAM_Global_Check_out_Status);
		// 		deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
		// 		BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//退房 指示灯关
		// 	}
		// }
		
		/*关闭睡眠反馈灯*/
		temp2 = SRAM_Read_Byte(SRAM_Global_Off_Sleeplight_Flag);
		if(temp2 == 0x01)
		{
			temp3 = SRAM_Read_DW(SRAM_Global_Off_Sleeplight_Tick);
			if(SysTick_1ms - temp3 > 5000)
			{
				Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"关闭睡眠反馈灯\r\n");
				temp3 = SysTick_1ms;
				SRAM_Write_DW(temp3,SRAM_Global_Off_Sleeplight_Tick);		//记录时间搓
				SRAM_Write_Byte(0x00,SRAM_Global_Off_Sleeplight_Flag);		//清楚标志位
				
				/*关闭所有按键反馈灯*/
				Project_Feedback_All_OFF();
			}
		}
		
//		/*关闭音量+指示灯*/
//		temp2 = SRAM_Read_Byte(SRAM_Global_Volume_Plus_Start);
//		if(temp2 == 0x01)
//		{
//			temp3 = SRAM_Read_DW(SRAM_Global_Volume_Plus_Tick);
//			if(SysTick_1ms - temp3 > 1000)
//			{
//				temp3 = SysTick_1ms;
//				SRAM_Write_DW(temp3,SRAM_Global_Volume_Plus_Tick);		//记录时间搓
//				SRAM_Write_Byte(0x00,SRAM_Global_Volume_Plus_Start);		//清楚标志位
//				
//				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);
//				BLW_Touch_Switch_Feedback(deal_addr,0,0x00);
//				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x07);
//				BLW_Touch_Switch_Feedback(deal_addr,2,0x00);
//			}
//		}
//		
//		/*关闭音量-指示灯*/
//		temp2 = SRAM_Read_Byte(SRAM_Global_Volume_Subtraction_Start);
//		if(temp2 == 0x01)
//		{
//			temp3 = SRAM_Read_DW(SRAM_Global_Volume_Subtraction_Tick);
//			if(SysTick_1ms - temp3 > 1000)
//			{
//				temp3 = SysTick_1ms;
//				SRAM_Write_DW(temp3,SRAM_Global_Volume_Subtraction_Tick);		//记录时间搓
//				SRAM_Write_Byte(0x00,SRAM_Global_Volume_Subtraction_Start);		//清楚标志位
//				
//				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);
//				BLW_Touch_Switch_Feedback(deal_addr,2,0x00);
//				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x07);
//				BLW_Touch_Switch_Feedback(deal_addr,0,0x00);
//			}
//		}

		/*场景反馈灯控制 - 廊灯*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH1_Control) == Project_LightScence_CH1_State)		
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x01);
			}
		}else {
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);
			
		}
		
		/*场景反馈灯控制 - 排气扇*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH2_Control) == Project_LightScence_CH2_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH2,0x01);
			}
		}else 
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH2,0x00);
		}
		
		/*场景反馈灯控制 - 卫生间灯*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH3_Control) == Project_LightScence_CH3_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x01);
			}
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);
		}

		/*场景反馈灯控制 - 排气扇1*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH4_Control) == Project_LightScence_CH4_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH5,0x01);
			}
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH5,0x00);
		}
		
		/*场景反馈灯控制 - 卫浴灯*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH5_Control) == Project_LightScence_CH5_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x02);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH2,0x01);
			}
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x02);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH2,0x00);
		}
		/*场景反馈灯控制 - 镜前灯2*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH6_Control) == Project_LightScence_CH6_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x02);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x01);
			}
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x02);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);
		}
		/*场景反馈灯控制 - 排气扇2*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH7_Control) == Project_LightScence_CH7_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x02);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x01);
			}
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x02);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);
		}		
		/*场景反馈灯控制 - 顶灯*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH9_Control) == Project_LightScence_CH9_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x03);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x01);
			}
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x03);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);
		}			
		
		/*场景反馈灯控制 - 床头灯*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH8_Control) == Project_LightScence_CH8_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH7,0x01);
			}
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH7,0x00);
		}
		
		/*场景反馈灯控制 - 廊灯*/
		if((C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH1_Control) == Project_LightScence_CH1_State)	
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH10,0x01);
			}
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH10,0x00);
		}
		
		/*场景反馈灯控制 - 总控1*/
		if(C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH11_Control)   //不为0
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);         //就开
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH11,0x01);
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);      
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH11,0x00);
		}
		
		/*场景反馈灯控制 - 总控2*/
		if(C5IO_Info.Relay_Level_Actual_Start & Project_LightScence_CH12_Control)   //不为0
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x03);         //就开
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x01);
		}else
		{
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x03);      
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);
		}
		
		if(SRAM_Read_Byte(SRAM_Global_SOS_Status_Flag) == 0x00)				//不在SOS状态时，可控制
		{
			if((C5IO_Info.DO_Level_Actual_Start & 0x06) == 0x04)		//勿扰
			{
				if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
				{
					Project_Service_Feedback(Project_Service_Do_Not_Disturb,0x01);
					Project_Service_Feedback(Project_Service_Clear,0x00);
				}
				
			}else if((C5IO_Info.DO_Level_Actual_Start & 0x06) == 0x00)
			{
				Project_Service_Feedback(Project_Service_Do_Not_Disturb,0x00);
				Project_Service_Feedback(Project_Service_Clear,0x00);
			}
		}
		

	
	}

	/*继电器变化*/
	if(C5IO_Info.Relay_Level_Actual_Start != C5IO_Info.Last_Relay_Level_Start)
	{
		C5IO_Info.Last_Relay_Level_Start = C5IO_Info.Relay_Level_Actual_Start;
		temp1++;
		/*测试输出状态下 - 检测到继电器状态变化上报PC*/
		if(g_pc_test.test_flag == 0x02)		
		{
			BLV_PC_Testing_Data_Reported(0x02,DEV_C5IO_Type,0x00,SRAM_LOG_Device_C5IO_Relay_Status,4);
		}
		
	}
	
	/*DO变化*/
	if(C5IO_Info.DO_Level_Actual_Start != C5IO_Info.Last_DO_Level_Start)
	{
		C5IO_Info.Last_DO_Level_Start = C5IO_Info.DO_Level_Actual_Start;
		temp1++;
		/*测试输出状态下 - 检测到继电器状态变化上报PC*/
		if(g_pc_test.test_flag == 0x02)		
		{
			BLV_PC_Testing_Data_Reported(0x02,DEV_C5IO_Type,0x00,SRAM_LOG_Device_C5IO_Relay_Status,4);
		}
	}
	
	if(SRAM_Read_Byte(SRAM_Global_SOS_Status_Flag) == 0x00)				//不在SOS状态时，可控制
	{
		if((C5IO_Info.DO_Level_Actual_Start & 0x06) == 0x02)			//清理
		{
			if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)
			{
				Project_Service_Feedback(Project_Service_Do_Not_Disturb,0x00);
				Project_Service_Feedback(Project_Service_Clear,0x01);
			}
		}else if((C5IO_Info.DO_Level_Actual_Start & 0x06) == 0x00)
		{
			Project_Service_Feedback(Project_Service_Do_Not_Disturb,0x00);
			Project_Service_Feedback(Project_Service_Clear,0x00);
		}
	}
	
	/*窗帘控制 - 反馈灯输出*/
	temp2 = SRAM_Read_Byte(SRAM_Global_Curtain_Start);
	if( ((C5IO_Info.Relay_Level_Actual_Start & 0x00030000) == 0x00010000) && (temp2 != 0x11) )		//窗帘开
	{
		deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x03);
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH1, 0x01);
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH4, 0x00);
		
		
		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"窗帘状态上报服务器 - 开状态\r\n");
		temp2 = 0x11;	//动作
		SRAM_Write_Byte(temp2,SRAM_Global_Curtain_Start);
		
		Udp_Addtion_Roomstate(Dev_NodeCurtain,0x01,0x00,0x01);		//窗帘状态上报服务器 - 开状态
	}else if( ((C5IO_Info.Relay_Level_Actual_Start & 0x00030000) == 0x00020000) && (temp2 != 0x12) )	//窗帘关
	{
		deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x03);
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH1, 0x00);		
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH4, 0x01);
		
		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"窗帘状态上报服务器 - 关状态\r\n");
		temp2 = 0x12;	//动作
		SRAM_Write_Byte(temp2,SRAM_Global_Curtain_Start);
		
		Udp_Addtion_Roomstate(Dev_NodeCurtain,0x01,0x00,0x02);		//窗帘状态上报服务器 - 关状态
	}else if(((C5IO_Info.Relay_Level_Actual_Start & 0x00030000) == 0x00000000) && ((temp2 & 0xF0) != 0x00) )	//窗帘停
	{
		deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x03);
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH1, 0x00);		
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH4, 0x00);
		
		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"窗帘状态上报服务器 - 停状态\r\n");
		temp2 &= 0x0F;	//动作已停止
		SRAM_Write_Byte(temp2,SRAM_Global_Curtain_Start);
		
		Udp_Addtion_Roomstate(Dev_NodeCurtain,0x01,0x00,0x06);		//窗帘状态上报服务器 - 停状态
	}
	
	/*窗纱控制 - 反馈灯输出*/
	temp2 = SRAM_Read_Byte(SRAM_Global_Window_Gauze_Start);
	if( ((C5IO_Info.Relay_Level_Actual_Start & 0x000C0000) == 0x00040000) && (temp2 != 0x11) )		//窗纱开
	{
		deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH6, 0x01);		
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH9, 0x00);
		
		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"窗纱状态上报服务器 - 开状态\r\n");
		temp2 = 0x11;	//动作
		SRAM_Write_Byte(temp2,SRAM_Global_Window_Gauze_Start);
		
		Udp_Addtion_Roomstate(Dev_NodeCurtain,0x02,0x00,0x01);		//窗帘状态上报服务器 - 开状态
	}else if( ((C5IO_Info.Relay_Level_Actual_Start & 0x000C0000) == 0x00080000) && (temp2 != 0x12) )	//窗纱关
	{
		deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH6, 0x00);		
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH9, 0x01);
		
		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"窗纱状态上报服务器 - 关状态\r\n");
		temp2 = 0x12;	//动作
		SRAM_Write_Byte(temp2,SRAM_Global_Window_Gauze_Start);
		
		Udp_Addtion_Roomstate(Dev_NodeCurtain,0x02,0x00,0x02);		//窗帘状态上报服务器 - 关状态
	}else if(((C5IO_Info.Relay_Level_Actual_Start & 0x000C0000) == 0x00000000) && ((temp2 & 0xF0) != 0x00) )	//窗纱停
	{
		deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH6, 0x00);		
		BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH9, 0x00);
		
		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"窗纱状态上报服务器 - 停状态\r\n");
		temp2 &= 0x0F;	//动作已停止
		SRAM_Write_Byte(temp2,SRAM_Global_Window_Gauze_Start);
		
		Udp_Addtion_Roomstate(Dev_NodeCurtain,0x02,0x00,0x06);		//窗帘状态上报服务器 - 停状态
	}

	
	if(temp1 != 0x00)
	{
		SRAM_DMA_Write_Buff((uint8_t *)&C5IO_Info,sizeof(BUS_C5IO_INFO),dev_addr+Dev_Privately);
		/*计算校验值*/
		SRAM_Write_Byte(0x00,dev_addr+Dev_Check);
		temp = sizeof(BUS_C5IO_INFO) + Dev_Privately;
		crc_val = Dev_CheckSum(dev_addr,temp);
		SRAM_Write_Byte(crc_val,dev_addr+Dev_Check);		//校验值重新写入
	}
}

void BUS_C5MUSIC_Scan_Signal(uint32_t devaddr)
{
	uint16_t temp = 0;
	uint8_t crc_val = 0,temp2 = 0,temp3 = 0;
	uint32_t temp1 = 0;
	BUS_C5MUSIC_INFO C5Music_Info;
	SRAM_DMA_Read_Buff((uint8_t *)&C5Music_Info,sizeof(BUS_C5MUSIC_INFO),devaddr+Dev_Privately);
	
	/*查看助眠音乐是否播放完成*/
	if(((C5Music_Info.now_playback_dir == BLV_C5MUSIC_Helpsleep1_Dir) 
		|| (C5Music_Info.now_playback_dir == BLV_C5MUSIC_Helpsleep2_Dir) 
		|| (C5Music_Info.now_playback_dir == BLV_C5MUSIC_Helpsleep3_Dir)) && (SRAM_Read_Byte(SRAM_Global_Mode_Start) == 0x05))	//助眠模式下
	{
		if( SysTick_1s - C5Music_Info.helpsleep_tick > 60)
		{
			if((C5Music_Info.now_playback_status == BLV_C5MUSIC_Halted) && (C5Music_Info.now_playback_status_num == 0x00))
			{
				/*助眠音乐播放完毕，进入睡眠模式*/
				temp2 = 0x04;
				SRAM_Write_Byte(temp2,SRAM_Global_Mode_Start);
				#if Project_NightMode_Enable
				SRAM_Write_Byte(0x01,SRAM_Global_NightMode_Start);					//进入起夜模式
				#endif

				Project_LightMode_Control(Project_Neight_Mode,0x00);
			}
		}
	}
	
	if(C5Music_Info.now_mute_status == 0x00)
	{
		if(C5Music_Info.quiet_mode != 0x01)		
		{
			temp3++;
			C5Music_Info.quiet_mode = 0x01;		//当前处于静音模式
		}
		
		if(SRAM_Read_Byte(SRAM_Global_Mode_Start) != 0x04)		
		{	

			if(C5Music_Info.quite_flag != 0x01)		//静音模式下，开启反馈灯
			{
				temp3++;
				Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"静音模式下，开启反馈灯\r\n");
				C5Music_Info.quite_flag = 0x01;
				SRAM_Write_Byte(0x01,SRAM_Global_Quiet_Mode_Status);

				Project_QuietMode_Feedback(0x01);
			}
		}else {			//睡眠模式下，关闭反馈灯
			temp3++;
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"睡眠模式下，关闭反馈灯 \r\n");
			C5Music_Info.quite_flag = 0x02;

			Project_QuietMode_Feedback(0x00);
		}
	}else{
		if(C5Music_Info.quiet_mode != 0x00)		
		{
			temp3++;
			C5Music_Info.quiet_mode = 0x00;		//当前不处于静音模式
		}

		//不在静音模式下，关闭反馈灯
		if(C5Music_Info.quite_flag != 0x00)
		{
			temp3++;
			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"不在静音模式下，关闭反馈灯 \r\n");
			C5Music_Info.quite_flag = 0x00;
			SRAM_Write_Byte(0x00,SRAM_Global_Quiet_Mode_Status);

			Project_QuietMode_Feedback(0x00);
		}
	}
	/*静音控制标志位处理*/
	temp2 = SRAM_Read_Byte(SRAM_Global_Quiet_Mode_Flag);
	if(temp2 == 0x01)
	{
		temp1 = SRAM_Read_DW(SRAM_Global_Quiet_Mode_Tick);
		if(SysTick_1ms - temp1 > 1800)
		{
			if(C5Music_Info.now_playback_status == BLV_C5MUSIC_Halted)		//静音提示音播放完毕
			{
				SRAM_Write_Byte(0x00,SRAM_Global_Quiet_Mode_Flag);
				Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"now_playback_status ：%d 设置音量为0  -- \r\n",C5Music_Info.now_playback_status);
				BUS_C5MUSIC_Set_Quiet_Mode(devaddr);
			}
		}
		
		
	}
	
	
//	/*写日志*/
//	if(sd_log_flag == 0x01)
//	{
//		sd_log_flag = 0x00;
//		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"sd_log_flag \r\n");
//		C5Music_Info.file_start_addr = SRAM_Get_SD_LOG_READ_Start_Address();
//		C5Music_Info.file_end_addr = SRAM_Get_SD_LOG_READ_End_Address();
//		
//		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"file_start_addr:%08X file_end_addr:%08X \r\n",C5Music_Info.file_start_addr,C5Music_Info.file_end_addr);
//		if(C5Music_Info.file_start_addr > C5Music_Info.file_end_addr)
//		{
//			temp1 = SRAM_LOG_End_Address - C5Music_Info.file_start_addr;
//			temp1 += C5Music_Info.file_end_addr - SRAM_LOG_DATA_Address;
//			C5Music_Info.file_block_num = temp1/512;
//			if(temp1%512 != 0)
//			{
//				C5Music_Info.file_block_num++;
//			}
//			C5Music_Info.file_size = temp1;
//		}else if(C5Music_Info.file_start_addr < C5Music_Info.file_end_addr)
//		{
//			temp1 = C5Music_Info.file_end_addr - C5Music_Info.file_start_addr;
//			C5Music_Info.file_block_num = temp1/512;
//			if(temp1%512 != 0)
//			{
//				C5Music_Info.file_block_num++;
//			}
//			C5Music_Info.file_size = temp1;
//		}
//		
//		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"file_block_num:%d file_size:%d\r\n",C5Music_Info.file_block_num,C5Music_Info.file_size);
//		C5Music_Info.file_block = 0x00;
//		if(C5Music_Info.file_block_num != 0)
//		{
//			C5Music_Info.control_flag |= C5MUSIC_Write_FILEHEAD_Flag;
//		}else {
//			Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"sd log not data \r\n");
//		}
//	}
	
	if(temp3 != 0x00)
	{
		SRAM_DMA_Write_Buff((uint8_t *)&C5Music_Info,sizeof(BUS_C5MUSIC_INFO),devaddr+Dev_Privately);
		/*计算校验值*/
		SRAM_Write_Byte(0x00,devaddr+Dev_Check);
		temp = sizeof(BUS_C5MUSIC_INFO) + Dev_Privately;
		crc_val = Dev_CheckSum(devaddr,temp);
		SRAM_Write_Byte(crc_val,devaddr+Dev_Check);		//校验值重新写入
	}
}

void BUS_TEMP_Scan_Signal(uint32_t devaddr)
{
	uint16_t temp = 0,temp4 = 0;
	uint8_t crc_val = 0,temp1 = 0;
	uint32_t deal_addr = 0,temp2 = 0,temp3 = 0;
	RS485_TEMP_INFO Rs485Temp;
	SRAM_DMA_Read_Buff((uint8_t *)&Rs485Temp,sizeof(RS485_TEMP_INFO),devaddr+Dev_Privately);
	

	if((Rs485Temp.TemState.on_off != Rs485Temp.TemStateLast.on_off ) 	\
		|| (Rs485Temp.TemState.mode != Rs485Temp.TemStateLast.mode)  	\
		||(Rs485Temp.TemState.fan != Rs485Temp.TemStateLast.fan) 		\
		|| (Rs485Temp.TemState.valve != Rs485Temp.TemStateLast.valve) 	\
		||(Rs485Temp.TemState.set_t != Rs485Temp.TemStateLast.set_t)	\
		||(Rs485Temp.TemState.indoor_t != Rs485Temp.TemStateLast.indoor_t))
	{
		temp1++;
		
		Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"C7T BUS_TEMP_Scan_Signal ");
		Rs485Temp.TemStateLast.on_off = Rs485Temp.TemState.on_off;
		Rs485Temp.TemStateLast.mode = Rs485Temp.TemState.mode;
		Rs485Temp.TemStateLast.fan = Rs485Temp.TemState.fan;
		Rs485Temp.TemStateLast.valve = Rs485Temp.TemState.valve;
		Rs485Temp.TemStateLast.set_t = Rs485Temp.TemState.set_t;
		Rs485Temp.TemStateLast.indoor_t = Rs485Temp.TemState.indoor_t;
		
		if(Rs485Temp.TemState.on_off == TEMP_STATE_ON)
		{
			if(Rs485Temp.TemState.set_t == 0x00)	temp = 32;
			else temp = Rs485Temp.TemState.set_t;
			if(Rs485Temp.TemState.indoor_t == 0x00)	temp4 = 32;
			else temp4 = Rs485Temp.TemState.indoor_t;
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"---C7T空调开机---\r\n");
			switch(Rs485Temp.TemState.fan)
			{
				case 0x00:
					Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"自动 ");
					if(Rs485Temp.TemState.mode == TEMP_COLD)	//制冷
					{
						if(temp >= temp4 + 3)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"关闭风扇 ");
							
							deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);
							
//							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);
						}else if(temp == temp4 + 1)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"低速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x01);
//							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x01);
						}else if(temp == temp4 - 1)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"中速 ");
							deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);
//							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x01);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);
						}else if(temp == temp4 -3)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"高速 ");
							deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);							
//							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x01);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);
						}
					}else if(Rs485Temp.TemState.mode == 0x02)	//制热
					{
						if(temp >= temp4 + 3)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"高速 ");
							deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);
//							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x01);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);
						}else if(temp == temp4 + 1)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"中速 ");
							deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);							
//							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x01);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);
						}else if(temp == temp4 - 1)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"低速 ");
							deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x01);							
//							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x01);
						}else if(temp == temp4 -3)
						{
							Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"关闭风扇 ");
							deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);
							BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);							
//							deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);	
//							BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);
						}
					}
					break;
				case 0x03:
					Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"高速 ");
					deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x01);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);				
//					deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x01);	
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);	
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);	
					break;
				case 0x02:
					Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"中速 ");
					deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x01);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);				
//					deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x01);	
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);	
					break;
				case 0x01:
					Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"低速 ");
					deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x01);				
//					deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);	
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x01);	
					break;
			}

			switch(Rs485Temp.TemState.valve)
			{
				case TEMP_VALVE_OPEN:
					Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"阀开 ");
					deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH2, 0x01);				
//					deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH13,0x01);
					break;
				case TEMP_VALVE_CLOSE:
					Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"阀关 ");
					deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
					BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH2, 0x02);					
//					deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//					BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH13,0x02);
					break;
			}
			
			if(Rs485Temp.on_offFlag == 0x01)
			{
				Rs485Temp.on_offFlag = 0x00;
				if(Get_SYS_Take_Electricity_Status() == 0x01)
				{
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"空调开机 - 铃声 \r\n");
					deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
					/*铃声*/	
					BUS_C5MUSIC_Warning_Dir(deal_addr,0x0B,BLV_C5MUSIC_Forestall);	//按键提示音
				}
			}
		}else if(Rs485Temp.TemState.on_off == TEMP_STATE_OFF)
		{
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"C7T空调关机\r\n");
			deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH2, 0x02);	
			BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH3, 0x02);	
			BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH4, 0x02);	
			BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH5, 0x02);	
			
//			deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
//			BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH13,0x02);	
//			BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH14,0x02);	
//			BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH15,0x02);
//			BUS_C5IO_Control_Relay(deal_addr,C5IO_Relay_CH16,0x02);
			
			if(Rs485Temp.on_offFlag == 0x01)
			{
				Rs485Temp.on_offFlag = 0x00;
				if(Get_SYS_Take_Electricity_Status() == 0x01)
				{
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"空调关机 - 铃声\r\n");
					deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
					/*铃声*/	
					BUS_C5MUSIC_Warning_Dir(deal_addr,0x0C,BLV_C5MUSIC_Forestall);	//按键提示音
				}
			}
		}
		temp4 = TEMSTATECONVER(Rs485Temp.TemState);
		Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"上报空调状态：%02X\r\n",temp4);
		Udp_Addtion_Roomstate(DEV_RS485_TEMPCTRL1,0x00,0x0000,temp4);
	}
	
	if(Get_SYS_Take_Electricity_Status() == 0x00)	//没插卡才能操作
	{
		temp2 = SRAM_Read_DW(SRAM_Register_Start_ADDRESS + Register_RoomRent_OFFSET);
		if(temp2 ==  0x02)	//当前处于出租状态，控制空调开机
		{
			if(SRAM_Read_Byte(SRAM_Global_Room_Rent_Flag) == 0x01)		//空调开机
			{
				temp1++;
				Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"出租 - 空调开机\r\n");
				SRAM_Write_Byte(0x02,SRAM_Global_Room_Rent_Flag);
				SRAM_Write_DW(SysTick_1ms,SRAM_Global_Room_Rent_Tick);
				Rs485Temp.TemStateCtrl.on_off = TEMP_STATE_ON;	//开机
				Rs485Temp.TemStateCtrl.mode = TEMP_COLD;	//制冷
				Rs485Temp.TemStateCtrl.set_t = 0x1A;	//26°
				Rs485Temp.TemStateCtrl.fan = 0x03;	//高风速
			}else if(SRAM_Read_Byte(SRAM_Global_Room_Rent_Flag) == 0x02)
			{
				temp3 = SRAM_Read_DW(SRAM_Global_Room_Rent_Tick);
				if(SysTick_1ms - temp3 > 1800000)		/*20分钟后关闭空调*/
				{
					temp1++;
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"出租 - 空调关机\r\n");
					SRAM_Write_Byte(0x00,SRAM_Global_Room_Rent_Flag);
					SRAM_Write_DW(SysTick_1ms,SRAM_Global_Room_Rent_Tick);
					
					Rs485Temp.TemStateCtrl.on_off = TEMP_STATE_OFF;	//开机
				}
			}
		}
	}

	if(temp1 != 0x00)
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"BUS_TEMP_Scan_Signal 11");
		/*将数据保存进入SRAM中*/
		SRAM_DMA_Write_Buff((uint8_t *)&Rs485Temp,sizeof(RS485_TEMP_INFO),devaddr+Dev_Privately);
		
		/*计算校验值*/
		SRAM_Write_Byte(0x00,devaddr+Dev_Check);
		temp = sizeof(RS485_TEMP_INFO) + Dev_Privately;
		crc_val = Dev_CheckSum(devaddr,temp);
		SRAM_Write_Byte(crc_val,devaddr+Dev_Check);		//校验值重新写入
	}

}


void BUS_TEMP1_Scan_Signal(uint32_t devaddr)
{
	uint16_t temp = 0;
	uint8_t crc_val = 0,temp1 = 0;
	uint32_t deal_addr = 0,temp2 = 0,temp3 = 0;
	RS485_TEM_INFO Rs485Temp;
	SRAM_DMA_Read_Buff((uint8_t *)&Rs485Temp,sizeof(RS485_TEM_INFO),devaddr+Dev_Privately);
	

	if(Rs485Temp.TemState != Rs485Temp.TemStateLast)
	{
		temp1++;
		Rs485Temp.TemStateLast = Rs485Temp.TemState;
		if(Rs485Temp.on_off == TEMP_ON)
		{
//			if(Rs485Temp.fan != Rs485Temp.last_fan)
			{
				Rs485Temp.last_fan = Rs485Temp.fan;
				switch(Rs485Temp.fan)
				{
					case 0x00:
						//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"自动 ");
						
						if(Rs485Temp.mode == 0x01)	//制冷
						{
							if(Rs485Temp.set_t >= Rs485Temp.indoor_t + 3)
							{
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);
								//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"关闭风扇 ");

							}else if(Rs485Temp.set_t == Rs485Temp.indoor_t + 1)
							{
								//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"低速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x01);
							}else if(Rs485Temp.set_t == Rs485Temp.indoor_t - 1)
							{
								//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"中速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);
							}else if(Rs485Temp.set_t == Rs485Temp.indoor_t -3)
							{
								//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"高速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);
							}
						}else if(Rs485Temp.mode == 0x02)	//制热
						{
							if(Rs485Temp.set_t >= Rs485Temp.indoor_t + 3)
							{
								//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"高速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);
							}else if(Rs485Temp.set_t == Rs485Temp.indoor_t + 1)
							{
								//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"中速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);
							}else if(Rs485Temp.set_t == Rs485Temp.indoor_t - 1)
							{
								//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"低速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x01);
							}else if(Rs485Temp.set_t == Rs485Temp.indoor_t -3)
							{
								//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"关闭风扇 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);
							}
						}
						
						
						break;
					case 0x03:
						//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"高速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);
						break;
					case 0x02:
						//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"中速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);
						break;
					case 0x01:
						//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"低速 ");
								deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
								BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x01);	
						break;
				}
			}
			
			if(Rs485Temp.valve != Rs485Temp.last_valve)
			{
				Rs485Temp.last_valve = Rs485Temp.valve;
				switch(Rs485Temp.valve)
				{
					case TEMP_VALVE_OPEN:
						//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"阀开 ");
						deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
						BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH6, 0x01);
					
						break;
					case TEMP_VALVE_CLOSE:
						//Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"阀关 ");
						deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
						BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH6, 0x02);
						break;
				}
			}
			
			if(Rs485Temp.on_offFlag == 0x01)
			{
				Rs485Temp.on_offFlag = 0x00;
				if(SRAM_Read_Byte(SRAM_Global_Power_on_Status) == 0x01)		//插卡才能操作
				{
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"空调开机 - 铃声 \r\n");
					deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
					/*铃声*/	
					BUS_C5MUSIC_Warning_Dir(deal_addr,0x0B,BLV_C5MUSIC_Forestall);	//按键提示音
				}
			}
		}else if(Rs485Temp.on_off == TEMP_OFF)
		{
			deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH6, 0x02);			
			BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH7, 0x02);
			BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH8, 0x02);
			BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH9, 0x02);	
			
			if(Rs485Temp.on_offFlag == 0x01)
			{
				Rs485Temp.on_offFlag = 0x00;
				if(SRAM_Read_Byte(SRAM_Global_Power_on_Status) == 0x01)		//插卡才能操作
				{
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"空调关机 - 铃声\r\n");
					deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
					/*铃声*/	
					BUS_C5MUSIC_Warning_Dir(deal_addr,0x0C,BLV_C5MUSIC_Forestall);	//按键提示音
				}
			}
		}
	}
	
	if(Get_SYS_Take_Electricity_Status() == 0x00)	//没插卡才能操作
	{
		temp2 = SRAM_Read_DW(SRAM_Register_Start_ADDRESS + Register_RoomRent_OFFSET);
		if(temp2 ==  0x02)	//当前处于出租状态，控制空调开机
		{
			if(SRAM_Read_Byte(SRAM_Global_Room_Rent_Flag) == 0x01)		//空调开机
			{
				temp1++;
				Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"出租 - 空调开机\r\n");
				SRAM_Write_Byte(0x02,SRAM_Global_Room_Rent_Flag);
				SRAM_Write_DW(SysTick_1ms,SRAM_Global_Room_Rent_Tick);
				Rs485Temp.info[0] = 0x01;	//开机
				Rs485Temp.info[1] = 0x01;	//制冷
				Rs485Temp.info[2] = 0x1A;	//26°
				Rs485Temp.info[3] = 0x03;	//高风速
			}else if(SRAM_Read_Byte(SRAM_Global_Room_Rent_Flag) == 0x02)
			{
				temp3 = SRAM_Read_DW(SRAM_Global_Room_Rent_Tick);
				if(SysTick_1ms - temp3 > 1800000)		/*20分钟后关闭空调*/
				{
					temp1++;
					Dbg_Print(DBG_BIT_LOGIC_STATUS_bit,"出租 - 空调关机\r\n");
					SRAM_Write_Byte(0x00,SRAM_Global_Room_Rent_Flag);
					SRAM_Write_DW(SysTick_1ms,SRAM_Global_Room_Rent_Tick);
					Rs485Temp.info[0] = 0x02;	//关机
				}
				
			}
		}
	}
	
	if(temp1 != 0x00)
	{
		/*将数据保存进入SRAM中*/
		SRAM_DMA_Write_Buff((uint8_t *)&Rs485Temp,sizeof(RS485_TEM_INFO),devaddr+Dev_Privately);
		
		/*计算校验值*/
		SRAM_Write_Byte(0x00,devaddr+Dev_Check);
		temp = sizeof(RS485_TEM_INFO) + Dev_Privately;
		crc_val = Dev_CheckSum(devaddr,temp);
		SRAM_Write_Byte(crc_val,devaddr+Dev_Check);		//校验值重新写入
	}
}
/*******************************************************************************
* Function Name  : Project_Service_Processing
* Description    : 项目服务信息处理
*******************************************************************************/
void Project_Service_Processing(void)
{
	uint8_t state_temp1 = 0,state_temp2 = 0;
	uint32_t deal_addr = 0;
	
	
	/*服务信息 - 取电*/
	state_temp1 = SRAM_Read_Byte(SRAM_Service_Take_Electricity_State);
	state_temp2 = SRAM_Read_Byte(SRAM_Service_Take_Electricity_LastState);
	if(state_temp1 != state_temp2)
	{
		switch(state_temp1)
		{
			case 0x01:		//取电动作
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"取电动作");
				
				if(Get_Authorize_Lock_Status() == 0x01)		break ;			/*授权到期*/
				
				deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH0_Control,Project_LightScence_CH0_State);
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH1,0x01);			//打开房态
				
				//开窗帘
				Project_Curtain_Control(0x01,0x01);
				//开窗纱
				Project_Curtain_Control(0x02,0x01);
			
				deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
				BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH1, 0x01);
	
			
				deal_addr = Find_Device_List_Information(DEV_TEMPTYPE,0x00);
				BLW_C7T_TEMP_Control_State(deal_addr,0x00,0x01);
				BLW_C7T_TEMP_Control_State(deal_addr,0x01,0x01);
				BLW_C7T_TEMP_Control_State(deal_addr,0x02,0x1A);
				BLW_C7T_TEMP_Control_State(deal_addr,0x03,0x02);
				
//				deal_addr = Find_Device_List_Information(DEV_TEMPTYPE,0x01);
				
				
				SRAM_Write_Byte(0x00,SRAM_Global_Room_Rent_Flag);		//
				SRAM_Write_Byte(0x01,SRAM_Global_Card_Status);			//记录插卡标志位
				
				
				deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Set_Global_Volume(deal_addr,70);
				BUS_C5MUSIC_Greet_Dir(deal_addr,0x01,BLV_C5MUSIC_Single_Play);	//欢迎词
				
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0001,0x01);		//取电服务信息上报 - 服务信息 回路地址0x02
				break;
			case 0x02:		//断电动作
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"断电动作");
				deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Group_Control_Relay(deal_addr,Project_LightScence_CH0_Control,BLV_Project_Light_Off_State);

				/*关闭勿扰及房态反馈灯*/
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH1,0x02);		//房态
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH3,0x02);		//勿扰

				//开窗帘
				Project_Curtain_Control(0x01,0x02);
				//开窗纱
				Project_Curtain_Control(0x02,0x02);
				
				deal_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
				BLW_A9RELAY_Control_State(deal_addr, A9RELAY_OUT_CH1, 0x02);
				
			
				deal_addr = Find_Device_List_Information(DEV_TEMPTYPE,0x00);
				BLW_C7T_TEMP_Control_State(deal_addr,0x00,0x02);
			
				SRAM_Write_Byte(0x00,SRAM_Global_Do_Not_Disturb_Start);	
				
				/*关闭按键反馈灯*/
				Project_Feedback_All_OFF();
				
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0001,0x02);		//取电服务信息上报 - 服务信息 回路地址0x02
				break;
		}
		SRAM_Write_Byte(state_temp1,SRAM_Service_Take_Electricity_LastState);
	}

	/*服务信息 - 清理*/
	state_temp1 = SRAM_Read_Byte(SRAM_Service_Clear_State);
	state_temp2 = SRAM_Read_Byte(SRAM_Service_Clear_LastState);
	if(state_temp1 != state_temp2)
	{
		switch(state_temp1)
		{
			case 0x00:		//关
				Dbg_Println(DBG_BIT_NET_STATUS_bit,"清理服务关闭\r\n",deal_addr);
				/*主要控制C5IO_DO_CH2状态*/
				deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH2,0x02);
				SRAM_Write_Byte(0x00,SRAM_Global_Clear_Start);
				
				deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(deal_addr,0x16,BLV_C5MUSIC_Forestall);	//按键提示音
				
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0003,0x02);		//清理服务信息上报 - 服务信息 回路地址0x03
				break;
			case 0x01:		//开
				Dbg_Println(DBG_BIT_NET_STATUS_bit,"清理服务开启\r\n",deal_addr);
				deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH2,0x01);
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH3,0x02);
				SRAM_Write_Byte(0x01,SRAM_Global_Clear_Start);
				SRAM_Write_Byte(0x00,SRAM_Global_Do_Not_Disturb_Start);
				
				SRAM_Write_Byte(0x00,SRAM_Service_Do_Not_Disturb_State);		//清理服务打开，应关闭勿扰
				SRAM_Write_Byte(0x00,SRAM_Service_Do_Not_Disturb_LastState);
				/*铃声*/
				deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(deal_addr,0x06,BLV_C5MUSIC_Forestall);	//按键提示音
				
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0002,0x02);		//勿扰服务信息上报 - 服务信息 回路地址0x02
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0003,0x01);		//清理服务信息上报 - 服务信息 回路地址0x03
				break;
		}
		SRAM_Write_Byte(state_temp1,SRAM_Service_Clear_LastState);
	}
	
	/*服务信息 - 退房*/
	state_temp1 = SRAM_Read_Byte(SRAM_Service_Check_Out_State);
	state_temp2 = SRAM_Read_Byte(SRAM_Service_Check_Out_LastState);
	if(state_temp1 != state_temp2)
	{
		switch(state_temp1)
		{
			case 0x00:		//关
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"当前已开启退房，取消退房...");
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);
				
				SRAM_Write_Byte(0x00,SRAM_Global_Check_out_Status);
				/*铃声*/
				deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	//关闭
				BUS_C5MUSIC_Warning_Dir(deal_addr,0x13,BLV_C5MUSIC_Forestall);	//按键提示音
				
				/*网络上报退房信息*/
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0006,0x02);		//退房服务信息上报 - 服务信息 回路地址0x07
				break;
			case 0x01:		//开
				Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"退房确认中，确认退房...");
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x01);
				
				SRAM_Write_Byte(0x02,SRAM_Global_Check_out_Status);
				/*铃声*/
				deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(deal_addr,0x12,BLV_C5MUSIC_Forestall);	//按键提示音
				
				/*网络上报退房信息*/
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0006,0x01);		//退房服务信息上报 - 服务信息 回路地址0x07
				break;
		}
		SRAM_Write_Byte(state_temp1,SRAM_Service_Check_Out_LastState);
	}

	if(Get_SYS_Take_Electricity_Status() != 0x01)	return ;		/*取电才能操作一下内容*/

	/*服务信息 - 勿扰*/
	state_temp1 = SRAM_Read_Byte(SRAM_Service_Do_Not_Disturb_State);
	state_temp2 = SRAM_Read_Byte(SRAM_Service_Do_Not_Disturb_LastState);
	if(state_temp1 != state_temp2)
	{
		switch(state_temp1)
		{
			case 0x00:		//关
				Dbg_Println(DBG_BIT_NET_STATUS_bit,"勿扰服务关闭\r\n",deal_addr);
				/*主要控制C5IO_DO_CH3状态*/
				deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH3,0x02);
				SRAM_Write_Byte(0x00,SRAM_Global_Do_Not_Disturb_Start);
				
				deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(deal_addr,0x17,BLV_C5MUSIC_Forestall);		//按键提示音
				
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0002,0x02);		//勿扰服务信息上报 - 服务信息 回路地址0x02
				break;
			case 0x01:		//开
				Dbg_Println(DBG_BIT_NET_STATUS_bit,"勿扰服务开启\r\n",deal_addr);
				/*主要控制C5IO_DO_CH3状态*/
				deal_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH2,0x02);
				BUS_C5IO_Control_Do(deal_addr,C5IO_DO_CH3,0x01);
				SRAM_Write_Byte(0x00,SRAM_Global_Clear_Start);
				SRAM_Write_Byte(0x01,SRAM_Global_Do_Not_Disturb_Start);

				SRAM_Write_Byte(0x00,SRAM_Service_Clear_State);					//勿扰模式打开，应关闭清理服务
				SRAM_Write_Byte(0x00,SRAM_Service_Clear_LastState);
				/*铃声*/
				deal_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(deal_addr,0x09,BLV_C5MUSIC_Forestall);		//按键提示音
				
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0002,0x01);		//勿扰服务信息上报 - 服务信息 回路地址0x02
				Udp_Addtion_Roomstate(Dev_Host_Service,0x00,0x0003,0x02);		//清理服务信息上报 - 服务信息 回路地址0x03
				break;
		}
		SRAM_Write_Byte(state_temp1,SRAM_Service_Do_Not_Disturb_LastState);
	}

	/*服务信息 - 等待*/
	state_temp1 = SRAM_Read_Byte(SRAM_Service_Await_State);
	state_temp2 = SRAM_Read_Byte(SRAM_Service_Await_LastState);
	if(state_temp1 != state_temp2)
	{
		switch(state_temp1)
		{
			case 0x00:		//关
				
				break;
			case 0x01:		//开
				
				break;
		}
		SRAM_Write_Byte(state_temp1,SRAM_Service_Await_LastState);
	}
	

}

/*******************************************************************************
* Function Name  : Project_Temp_Control 
* Description    : 项目温控器状态控制函数
* Input          : 
	Temp_num	: 温控器序号

* Return         :
*******************************************************************************/
void Project_Temp_Control(uint8_t Temp_num,uint16_t state)
{
//	uint16_t temp = state;
//	uint32_t deal_addr = 0;
	switch(Temp_num)
	{
		case 0x01:
			// deal_addr = Find_Device_List_Information(DEV_TEMPTYPE,0x00);		//Temp 设备类型为0x07,设备地址默认为0x01;
			// if((deal_addr < SRAM_Device_List_Start_Addr) || (deal_addr > SRAM_Device_List_End_Addr))
			// {
			// 	Dbg_Println(DBG_BIT_NET_STATUS_bit,"Udp_Internal_Dev_Control Devaddr Fail%08X --------\r\n",deal_addr);
			// 	break;
			// }
			// BLW_C7T_TEMP_Group_Control_State(deal_addr,temp);
			break;
		case 0x02:

			break;
	}
}

/*******************************************************************************
* Function Name  : Project_Curtain_Control 
* Description    : 项目窗帘状态控制函数
* Input          : 
	Curtain_num	: 窗帘序号
	status		：控制状态 
		0x00：窗帘停
		0x01：窗帘开
		0x02：窗帘关
* Return         :
*******************************************************************************/
void Project_Curtain_Control(uint8_t Curtain_num,uint8_t state)
{
	uint32_t dev_addr = 0;
	switch(Curtain_num)
	{
		case 0x01:
			if(state == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Relay_Inching(dev_addr,C5IO_Relay_CH17,0x01,BLV_Curtains_Control_Time);
				BUS_C5IO_Control_Relay(dev_addr,C5IO_Relay_CH18,0x02);
			}else if(state == 0x02)
			{
				dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Relay(dev_addr,C5IO_Relay_CH17,0x02);
				BUS_C5IO_Control_Relay_Inching(dev_addr,C5IO_Relay_CH18,0x01,BLV_Curtains_Control_Time);
			}else if(state == 0x00)
			{
				dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Relay(dev_addr,C5IO_Relay_CH17,0x02);
				BUS_C5IO_Control_Relay(dev_addr,C5IO_Relay_CH18,0x02);
			}
			break;
		case 0x02:
			if(state == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Relay_Inching(dev_addr,C5IO_Relay_CH19,0x01,BLV_Curtains_Control_Time);
				BUS_C5IO_Control_Relay(dev_addr,C5IO_Relay_CH20,0x02);
			}else if(state == 0x02)
			{
				dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Relay(dev_addr,C5IO_Relay_CH19,0x02);
				BUS_C5IO_Control_Relay_Inching(dev_addr,C5IO_Relay_CH20,0x01,BLV_Curtains_Control_Time);
			}else if(state == 0x00)
			{
				dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
				BUS_C5IO_Control_Relay(dev_addr,C5IO_Relay_CH19,0x02);
				BUS_C5IO_Control_Relay(dev_addr,C5IO_Relay_CH20,0x02);
			}
			break;
	}
}

/*******************************************************************************
* Function Name  : Project_LightMode_Control 
* Description    : 项目模式控制函数
* Input          : 
	mode_num	: 模式序号
	sound		：声音标志位，是否播放提示音
* Return         :
*******************************************************************************/
void Project_LightMode_Control(uint8_t mode_num,uint8_t sound)
{
	uint32_t dev_addr = 0;
	switch(mode_num)
	{
		case Project_NO_Schema:		//无模式
			
			break;
		case Project_Bright_Mode:		//明亮模式
			dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
			BUS_C5IO_Group_Control_Relay(dev_addr,Project_Bright1_Mode_Control,Project_Bright1_Mode_State);//控制继电器
		
			dev_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(dev_addr, A9RELAY_OUT_CH1, 0x01);
		
		
			/*铃声*/
			if(sound == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(dev_addr,0x05,BLV_C5MUSIC_Single_Play);
			}
			
			break;
		case Project_Bright2_Mode:  //明亮模式2
			dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
			BUS_C5IO_Group_Control_Relay(dev_addr,Project_Bright2_Mode_Control,Project_Bright2_Mode_State);//控制继电器		

			dev_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(dev_addr, A9RELAY_OUT_CH1, 0x01);
		
			/*铃声*/
			if(sound == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(dev_addr,0x05,BLV_C5MUSIC_Single_Play);				
			}
			break;
		case Project_Reception_Mode:	//会客模式
			dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
			BUS_C5IO_Group_Control_Relay(dev_addr,Project_Receive1_Mode_Control,Project_Receive1_Mode_State);//控制继电器	
		
			dev_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(dev_addr, A9RELAY_OUT_CH1, 0x01);
		
			/*铃声*/
			if(sound == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(dev_addr,0x03,BLV_C5MUSIC_Single_Play);				
			}
			break;
		case Project_Reception2_Mode:	//会客模式2
			dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
			BUS_C5IO_Group_Control_Relay(dev_addr,Project_Receive2_Mode_Control,Project_Receive2_Mode_State);//控制继电器		

			dev_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(dev_addr, A9RELAY_OUT_CH1, 0x01);
		
			/*铃声*/
			if(sound == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(dev_addr,0x03,BLV_C5MUSIC_Single_Play);				
			}
			break;		
		case Project_Warm_Mode:		//温馨模式
			dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
			BUS_C5IO_Group_Control_Relay(dev_addr,Project_Warm_Mode_Control,Project_Warm_Mode_State);
		
			dev_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(dev_addr, A9RELAY_OUT_CH1, 0x02);
		
			/*铃声*/
			if(sound == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(dev_addr,0x08,BLV_C5MUSIC_Single_Play);
			}
			
			break;
		case Project_Neight_Mode:		//睡眠模式
			dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
			BUS_C5IO_Group_Control_Relay(dev_addr,Project_Neight_Mode_Control,Project_Neight_Mode_State);
		
			dev_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(dev_addr, A9RELAY_OUT_CH1, 0x02);

			/*铃声*/
			if(sound == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(dev_addr,0x07,BLV_C5MUSIC_Single_Play);
			}
			break;
//		case Project_Hypnotic_Mode:	//助眠模式
//			
//			break;
//		case Project_Romance_Mode:		//浪漫模式
//			
//			break;
		case Project_Reading_Mode:		//阅读模式
			dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
			BUS_C5IO_Group_Control_Relay(dev_addr,Project_Reading_Mode_Control, Project_Reading_Mode_State);
		
			dev_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(dev_addr, A9RELAY_OUT_CH1, 0x01);

		
			/*铃声*/
			if(sound == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(dev_addr,0x0A,BLV_C5MUSIC_Single_Play);
			}
			break;
//		case Project_Relaxation_Mode:	//休闲模式
//			break;
		case Project_Viewing_Mode:		//观影模式    
			dev_addr = Find_Device_List_Information(DEV_C5IO_Type,0x00);
			BUS_C5IO_Group_Control_Relay(dev_addr,Project_Viewing_Mode_Control, Project_Viewing_Mode_State);

			dev_addr = Find_Device_List_Information(DEV_A9RELAYTYPE,0x01);
			BLW_A9RELAY_Control_State(dev_addr, A9RELAY_OUT_CH1, 0x02);		
		
			/*铃声*/
			if(sound == 0x01)
			{
				dev_addr = Find_Device_List_Information(DEV_C5MUSIC_Type,0x01);	
				BUS_C5MUSIC_Warning_Dir(dev_addr,0x02,BLV_C5MUSIC_Single_Play);
			}			
			break;
	}
}

/*******************************************************************************
* Function Name  : Project_LightMode_Feedback 
* Description    : 项目模式反馈灯控制函数
* Input          : 
	mode_num	: 模式序号
* Return         :
*******************************************************************************/
void Project_LightMode_Feedback(uint8_t mode_num)
{
	uint32_t temp = 0,deal_addr = 0;
	switch(mode_num)
	{
		case Project_NO_Schema:		//无模式
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"无模式反馈灯控制");
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//观影模式
			
			break;
		case Project_Bright_Mode:		//明亮模式1
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x01); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//观影模式
			break;
		case Project_Bright2_Mode:		//明亮模式2
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x01);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//观影模式
			break;		
		case Project_Reception_Mode:	//会客模式1
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"会客模式反馈灯控制");
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x01); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//观影模式
			break;
		case Project_Reception2_Mode:	//会客模式2
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"会客模式反馈灯控制");
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x01);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//观影模式
			break;
		case Project_Warm_Mode:		//温馨模式
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"温馨模式反馈灯控制");
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x01); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//观影模式
			break;
		case Project_Neight_Mode:		//睡眠模式
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"睡眠模式反馈灯控制");
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x01); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//观影模式
			
			/*记录一个时间搓*/
			temp = SysTick_1ms;
			SRAM_Write_DW(temp,SRAM_Global_Off_Sleeplight_Tick);		//记录时间搓
			SRAM_Write_Byte(0x01,SRAM_Global_Off_Sleeplight_Flag);		//保存标志位
			break;
		case Project_Hypnotic_Mode:		//助眠模式
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"助眠模式反馈灯控制");

			break;
		case Project_Romance_Mode:		//浪漫模式
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"浪漫模式反馈灯控制");

			break;
		case Project_Reading_Mode:		//阅读模式
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"阅读模式反馈灯控制");
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x01); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x01);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//观影模式
			break;
		case Project_Relaxation_Mode:	//休闲模式
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"休闲模式反馈灯控制");

			break;
		case Project_Viewing_Mode:		//观影模式
			Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"观影模式反馈灯控制");
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);   
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); //温馨模式		
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); //阅读模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); //睡眠模式
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); //明亮模式1
			BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); //会客模式1
		
			deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);   		
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	//阅读模式
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//会客模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);	//明亮模式2
			BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x01);	//观影模式		
			break;
	}
}

/*******************************************************************************
* Function Name  : Project_Service_Feedback 
* Description    : 项目服务反馈灯控制函数
* Input          : 
	mode_num	: 模式序号
* Return         :
*******************************************************************************/
void Project_Service_Feedback(uint8_t service,uint8_t on_off)
{
	uint32_t deal_addr = 0;
	switch(service)
	{
		case Project_Service_Do_Not_Disturb:
			if(on_off == 0x01)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x01);	//勿扰
			}else if(on_off == 0x00)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	//勿扰
			}
			break;
		case Project_Service_Clear:
			if(on_off == 0x01)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x01);	//清理
			}else if(on_off == 0x00)
			{
				deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
				BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	//清理
			}
			break;
	}
}

/*******************************************************************************
* Function Name  : Project_Feedback_All_OFF 
* Description    : 项目反馈灯全关
*******************************************************************************/
void Project_Feedback_All_OFF(void)
{
	uint32_t deal_addr;
	
	deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH6,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH7,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH8,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH9,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH10,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH11,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH12,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH13,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH14,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH15,0x00); 		
	BLW_C7T_Switch_Feedback(deal_addr, RS_SWITCH_CH16,0x00); 		
	
	deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x01);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH2,0x00);	
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH5,0x00);	
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);
	deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x02);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH2,0x00);	  
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);
	deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x03);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);	
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	  
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);
	deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x04);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH1,0x00);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH3,0x00);	  
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH4,0x00);
	BLW_Touch_Switch_Feedback(deal_addr,RS_SWITCH_CH6,0x00);	
}

/*******************************************************************************
* Function Name  : Project_QuietMode_Feedback 
* Description    : 项目静音模式反馈灯控制函数
* Input          : 
	state	: 状态
		0x00：关闭
		0x01：开启
* Return         :
*******************************************************************************/
void Project_QuietMode_Feedback(uint8_t state)
{
	uint32_t deal_addr = 0;
	deal_addr = Find_Device_List_Information(DEV_SWI_TYPE,0x00);
	BLW_C7T_Switch_Feedback(deal_addr,RS_SWITCH_CH8,state);
}



