#ifndef _BLV_NOR_DEV_LVINPUTFUN_
#define _BLV_NOR_DEV_LVINPUTFUN_

#include "stdint.h"
#include "BLV_All_Dev_Init.h"


#define  LVINPUTNUMMAX  			20         //弱电输入个数限制
#define  C1_LVINPUTNUMMAX         	0x07    //C1为7路                                    


typedef struct{
	uint64_t LVinputCH01:2;			//1
	uint64_t LVinputCH02:2;			//2
	uint64_t LVinputCH03:2;			//3
	uint64_t LVinputCH04:2;			//4
	uint64_t LVinputCH05:2;  		//5
	uint64_t LVinputCH06:2;    		//6
	uint64_t LVinputCH07:2;   		//7
	uint64_t LVinputCH08:2;      	//8
	uint64_t LVinputCH09:2;     	//9
	uint64_t LVinputCH10:2;      	//10        
	uint64_t LVinputCH11:2;    		//11
	uint64_t LVinputCH12:2;    		//12
	uint64_t LVinputCH13:2;     	//13      
	uint64_t LVinputCH14:2;      	//14      
	uint64_t LVinputCH15:2;     	//15   
	
	uint64_t LVinputCH16:2;   		//16      //以下服务都用于客需服务
	uint64_t LVinputCH17:2;   		//17      	
	uint64_t LVinputCH18:2;   		//18      
	uint64_t LVinputCH19:2;   		//19      	
	uint64_t LVinputCH20:2;   		//20      
	uint64_t LVinputCH21:2;   		//21      
	uint64_t LVinputCH22:2;   		//22      
	uint64_t LVinputCH23:2;   		//23      	
	uint64_t LVinputCH24:2;   		//24      
	uint64_t LVinputCH25:2;   		//25      	
	uint64_t LVinputCH26:2;   		//26      
	uint64_t LVinputCH27:2;   		//27      	
	uint64_t LVinputCH28:2;   		//28      
	uint64_t LVinputCH29:2;   		//29      	
	uint64_t LVinputCH30:2;   		//30      
	uint64_t LVinputCH31:2;   		//31      	
	uint64_t LVinputCH32:2;   		//32      
	
}__attribute__ ((__packed__))DEV_LVINPUTDATA_TYPE;  //服务信息数据类型

#define INCH6_DI_CH_MAX		0x06

typedef struct 
{
	BLV_COMM_RECORD_G comm_record;						//通讯记录
	
	uint8_t DevReadBuf[LVINPUTNUMMAX];   				//每两位存按键的状态 用于输入检测，读完便清空   
	uint8_t DevReadBufLast[LVINPUTNUMMAX];   			//每两位存按键的状态 用于接收输入检测比较

	uint32_t      DevC5IOAddr;         					//C5IO的设备地址

	uint8_t LVinputValidNum;   							//弱电输入有效回路数
	uint8_t DevSendCnt;         						//发送计数
	uint8_t DevOffline;         						//离线在线  1，设备离线   0，设备在线
	uint8_t DevOfflineLast;								//设备离线标志 1，设备离线   0，设备在线         占2位
	uint8_t DevSn;            							//设备Sn号
	uint8_t Dev_Init_Flag;								//设备初始化标志位	2025-09-26
	
/*6路 弱电输入 变量声明开始*/	
	uint8_t Send_Type;

	uint8_t DI_Type[INCH6_DI_CH_MAX];					//DI输入类型 0~3:检测类型 4~7:检测电平
	uint8_t DI_Start[INCH6_DI_CH_MAX];					//DI动作状态
	uint8_t DI_Report_En[INCH6_DI_CH_MAX];				//DI主动上报使能
	uint8_t DI_LastStart[INCH6_DI_CH_MAX];
	uint8_t DI_Detection_Time[INCH6_DI_CH_MAX];			//DI消抖时间	
	
	uint16_t Version;       							//IO程序版本
	uint16_t control_flag;       						//控制标志位
	uint16_t DI_set_flag;								//DI设置标志位
	uint16_t Last_DI_set_flag;	
	uint16_t DI_Level_Actual_Start;	
	uint32_t DI_Actual_State;
	uint32_t DI_Perfect_State;
	
/*6路 弱电输入 变量声明结束*/	
//	Dev_Name_Struct Devname[DEVNAMENUMMAX]; //如果该类设备同时具备输入与输出，那么输入输出别名共用    

	//弱电输入别名   仅支持30个回路别名
	uint32_t inquire_tick;								//询问时间戳
	uint32_t HoldTick[LVINPUTNUMMAX];       			//2024-06-13
}__attribute__ ((__packed__))NOR_LVINPUT_INFO;			//服务信息的结构体参数


void BLV_Nor_Dev_LVinput_Init(uint8_t devaddr, uint16_t LoopMax);





#endif


