/*----------------------------------------------------------------------
* Copyright	: Video Surveillance(China) Co. Ltd
* Description  : This file describes the database table struct in VS
*				system. The structure may change with table definition.
* Created On   : 3/13/07
* Maintained by:
* Modification :
*
-----------------------------------------------------------------------*/
#ifndef __VS_TABLE_STRUCTS_HEADER__
#define __VS_TABLE_STRUCTS_HEADER__

/*---------------------------Includes----------------------------*/
#include "ssi.h"
#include "device_info.h"

/*---------------------------Defines----------------------------*/

#define VS_FTP_USER_NAME_LEN	   128
#define VS_FTP_PASSWD_LEN		  128
#define VS_DEV_ID_LEN			  32
#define VS_USER_ID_LEN			 32
#define VS_USERGRP_ID_LEN			 32
#define VS_USER_NAME_LEN		   32
#define VS_DEV_NAME_LEN			64
#define VS_DEV_VENDOR_LEN		  64
#define VS_DEV_MACADDR_LEN		 20
#define VS_DEV_LOC_ID_LEN		  64
#define VS_STORAGE_VOL_LEN		 32
#define VS_FILE_PATHNAME_LEN		   64
#define VS_FILE_PATH_LEN		   96
#define VS_DEV_DOMAINNAME_LEN	  64
#define VS_DEV_URL_LEN			 64
#define VS_DEV_SCHEDULE_LEN		2016
#define VS_EVENT_IPLIST_LEN		256
#define VS_PRESET_DESC_LEN		 128
#define VS_TRACK_DESC_LEN		  128
#define VS_TRACK_SEQ_LEN		   256
#define VS_MOUNT_DESC_LEN		  64
#define VS_MOUNT_OPTION_LEN		32
#define VS_LOGIN_NAME_LEN		  16
#define VS_LOGIN_PASSWD_LEN		16
#define VS_IP_ADDR_LEN			 16
#define VS_BOOKMARK_DESC_LEN  128
#define VS_DOMAINID_LEN			5

#define VS_WWW_DOMAINNAME_LEN		64
#define VS_DEV_SERIALNO_LEN		32
#define VS_DEVGROUP_ID_LEN		32
#define VS_FW_ID_LEN 				 18
#define VS_MAX_FW_NUM 			 32
#define VS_DEV_VEST_RIGHT_LEN		64
#define VS_EVENTALARM_DESCRIPTION_LEN	128

#define VS_SYS_EVNETALARM_TEXT_LEN			 256
#define VS_IPADDR_LEN			 	 16
#define VS_LOG_DESC_LEN		 	 256

#define	VS_CFG_FILTER_LEN		64
#define	VS_SD_CARD_NAME_LEN	32

#define VS_STRING_LENG_16	16
#define VS_STRING_LENG_32	32
#define VS_STRING_LENG_64 64

#define VS_PATROL_CFGSTRING_LEN 1024
//#define VS_DEV_DECODER_SCHEME_LEN 1024
#define VS_DEV_DECODER_CONFIG_LEN 10000

/*设备配置表*/
#define VS_TAB_DEV_BASE_INFO		"DevBaseInfo"
#define VS_TAB_DEV_RELATION			"DevRelation"
#define VS_TAB_MASTER_BASE_INFO	"MasterBaseInfo"
#define VS_TAB_DEV_CAMERA			"CameraSetting"
#define VS_TAB_DEV_ALARM_INPUT		"AlarmInput"
#define VS_TAB_DEV_ALARM_OUTPUT	"AlarmOutput"
#define VS_TAB_DEV_LOCATION			"LocationInfo"
#define VS_TAB_DEV_GPSHIS_PREFIX	"HisGpsInfo_"		//GPS历史信息表前缀

/*通用配置表*/
#define VS_TAB_VSSSVR_PROFILE		"VssSvrProfile"
#define VS_TAB_RECORD_SCHEME		"RecordScheme"
#define VS_TAB_STORAGE_PATH		"StoragePath"
#define VS_TAB_STORAGE_POLICY		"StoragePolicy"
#define VS_TAB_ALMUP_RECORD_POLICY	"AlarmUpRecordPolicy"
#define VS_TAB_DEVGRPINFO			"DevGroupInfo"

//客户端告警联动配置
#define VS_TAB_CLI_ALM_ACT 	"CliAlmAct"

//告警联动配置表
#define VS_TAB_ALM_ACT_RELATION 	"AlmActRelation"
#define VS_TAB_ALM_FW_LIST			"SysAlmFwList"


/*设备划归表*/
#define  VS_TAB_DEVRELATEDUSER		"DevRelatedUser"


//摄像头注册信息表
#define  VS_TAB_CAMERA_REGISTERED_INFO	 "CameraRegisteredInfo"

//活动客户端列表
#define VS_TAB_ALIVE_WATCHER		"AliveWatcher"

//日志记录表
#define VS_TAB_SUR_LOG				"SurveillanceLog"
#define VS_TAB_PLAYBACK_LOG		"PlaybackLog"
#define VS_TAB_LOGIN_LOG			"LoginLog"

#define VS_TAB_DEV_EVENT			"DevEventLog"
#define VS_TAB_DEV_ALARM			"DevAlarmLog"
#define VS_TAB_SYS_EVENT			"SysEventLog"
#define VS_TAB_SYS_ALARM			"SysAlarmLog"
#define VS_TAB_OPERATION_LOG		"OperationLog"


/* Preset position and track sequence */
#define VS_TAB_PRESET_POS		 	"PresetPos"
#define VS_TAB_TRACK_SEQ		   	"TrackSequence"

/*  video bookmark for client */
#define VS_TAB_USER_DISP_MODE 		"UserDispModeTab"
#define VS_TAB_USER_BOOKMARK		"BookmarkTab"
#define VS_TAB_USER_PATROLCFG		"PatrolCfgTab"


//解码器播放方案
#define VS_TAB_DECODER_SCHEME		"DecoderSchemeTab"

/*---------------------------Struts----------------------------*/

/*
 * Surveillance server information
 */
#define VS_VSSSVR_SURSVRID		"VssSvrId"
#define VS_VSSSVR_SURNAME	 	"SvrName"
#define VS_VSSSVR_VISITOPTION		"VisiteOption"
#define VS_VSSSVR_SVRIP	 		"SvrIp"
#define VS_VSSSVR_SVRPORT   		"SvrPort"
#define VS_VSSSVR_WWWDOMAINNAME	"WWWDomainName"
#define VS_VSSSVR_WWWPORT			"WWWSvrPort"
#define VS_VSSSVR_DOMAINID		"DomainId"
#define VS_VSSSVR_ADSVRPORT		"AdSvrPort"
#define VS_VSSSVR_ADWWWSVRPORT	"AdWWWSvrPort"

typedef struct TabVssSvrInfo_s
{
	U32 nVssSvrId;
	S8  szName[VS_DEV_NAME_LEN];
	U32	nVisitOption;	//0: IP;	1: WWW Domain Name
	U32 nVssSvrIp;
	U32 nPort;
	S8	szWWWDomainName[VS_WWW_DOMAINNAME_LEN];
	U32 nWWWSvrPort;
	S8	szDomainId[VS_DOMAINID_LEN+1];
	U32 nAdSvrPort;
	U32 nAdWWWSvrPort;
}TabVssSvrInfo_t;

#define VS_STORAGE_PATH_NO			"PathNo"
#define	VS_STORAGE_PATH_NAME			"PathName"
#define VS_STORAGE_PATH_PATH			"Path"
#define VS_STORAGE_PATH_OPTION		"MountOption"

typedef struct TabStoragePath_s
{
	U32 nPathNo;
	S8  szPathName[VS_FILE_PATHNAME_LEN];
	S8  szPath[VS_FILE_PATH_LEN - VS_MOUNT_OPTION_LEN];
	S8  szMountOption[VS_MOUNT_OPTION_LEN];
}TabStoragePath_t;


#define VS_RECORD_SCHEME_NO			"RecordSchemeNo"
#define	VS_RECORD_SCHEME_NAME			"RecordSchemeName"
#define VS_RECORD_SCHEME_SCHEDULE	"Schedule"
#define VS_RECORD_SCHEME_ALARMSTREAMOPTION	"AlwaysStreamForAlarm"


typedef struct TabRecordScheme_s
{
	U32 nSchemeNo;
	S8  szSchemeName[VS_DEV_NAME_LEN];
	U8  nSchedule[VS_DEV_SCHEDULE_LEN+4];   /* each element: VS_REC_TYPE_XXX. hack to db string '\0' */
	U32 nAlwaysStreamForAlarm;
}TabRecordScheme_t;



#define VS_STORAGE_POLICY_NO						"StoragePolicyNo"
#define VS_STORAGE_POLICY_NAME					"StoragePolicyName"
#define VS_STORAGE_POLICY_FRAMESTOREOPTION 		"FrameStoreOption"
#define VS_STORAGE_POLICY_PRESERVINGDAYS		"PreservingDays"
#define VS_STORAGE_POLICY_OPTIONWHENSPACEFULL	"OptionWhenSpaceFull"
#define VS_STORAGE_POLICY_SPALCELEFTALARM		"SpaceLeftAlarm"
#define VS_STORAGE_POLICY_CACHEDTIME	   		"CachedTime"
#define VS_STORAGE_POLICY_AFTERWARDTIME			"AfterwardTime"
#define VS_STORAGE_POLICY_SLICESIZE				"SliceSize"
#define VS_STORAGE_POLICY_STREAMRECORDOPTION	"StreamRecordOption"
#define VS_STORAGE_POLICY_PRIPATH			"PriStoragePath"
#define VS_STORAGE_POLICY_SECPATH			"SecStoragePath"
#define VS_STORAGE_POLICY_VSSSVRID			"VssSvrId"


#define VS_DEVCAMERA_MAXBITRATE_MIN	 512000	 // in bps
#define VS_DEVCAMERA_MAXBITRATE_MAX	4000000

typedef enum
{
	STREAM_HIGER_QUALITY,
	STREAM_LOWER_SPACE,
}VS_STREAM_OPTION;

#define VS_SLICESIZE_MIN	5		//最小切片时长
#define VS_SLICESIZE_MAX	60		//最大切片市场
#define VS_DEVCAMERA_CACHEDTIME_MAX	10	   // in seconds 告警最大预录时间
#define VS_DEVCAMERA_AFTERWARDTIME_MAX 3600	// in seconds 告警最大录像持续时间
#define VS_DEVCAMERA_AFTERWARDTIME_MIN 5	// in seconds 告警最大录像持续时间


enum
{
	FRAME_STORE_ALL = 0,
	FRAME_STORE_I_ONLY,
	FRAME_STORE_MAX,
};

enum
{
	DELETE_RECORD_BY_CFG_DAYS,	//按存储策略配置的天数来删除
	DELETE_RECORD_WHEN_SPACEFULL,	//当存储满时才删除
};

typedef struct TabStoragePolicy_s
{
	U32 nPolicyNo;
	S8  szPolicyName[VS_DEV_NAME_LEN];
	
	U32 nFrameStoreOption;					// FRAME_STORE_ALL / FRAME_STORE_I_ONLY
	U32 nPreservingDays;
	U32 nOptionWhenSpaceFull;				//借用本字段来配置:按计划删除/满则删除
	U32 nSpaceLeftAlarm;
	U32 nCachedTime;

	U32 nAfterwardTime;

	U32 nSliceSize;	
	U32 nStreamRecordOption;	//VS_STREAM_OPTION

	S8  szPriStoragePath[VS_FILE_PATH_LEN];
	S8  szSecStoragePath[VS_FILE_PATH_LEN];

	U32 nVssSvrId;
}TabStoragePolicy_t;


#define VS_ALMUP_RECORD_POLICY_NO			"PolicyNo"
#define VS_ALMUP_RECORD_POLICY_NAME			"PolicyName"	
#define VS_ALMUP_RECORD_POLICY_PRESERVINGDAYS	"PreservingDays"

typedef struct TabAlmupRecordPolicy_s
{
	U32 nPolicyNo;
	S8	szPolicyName[VS_DEV_NAME_LEN];
	U32 nPreservingDays;
}TabAlmupRecordPolicy_t;

//设备组配置表
#define VS_DEVGROUP_ID		"DevGroupID"
#define VS_DEVGROUP_NAME	"DevGroupName"
#define VS_DEVGROUP_DOMAINID	"DomainId"

typedef struct TabDevGroupInfo_s
{
	S8	szDevGroupID[VS_DEVGROUP_ID_LEN];
	S8	szDevGroupName[VS_DEV_NAME_LEN];
	S8	szDomainId[VS_DOMAINID_LEN+1];
}TabDevGroupInfo_t;


/*
 * Device base info table(including master and slave device)
 */
#define VS_DEVBASE_DEVID		  "DevId"
#define VS_DEVBASE_DEVNAME		"DevName"
#define VS_DEVBASE_TYPE		   "Type"
#define VS_DEVBASE_VERSION		"Version"
#define VS_DEVBASE_VENDOR   "Vendor"
#define VS_DEVBASE_DOMAINID		 "DomainId"
#define VS_DEVBASE_VSSSVRID	   "VssSvrId"

typedef struct TabDevBaseInfo_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	S8  szDevName[VS_DEV_NAME_LEN];
	U32 nType;								/* device type, VS_DEV_TYPE_XXX */
	U32 nVersion;
	U32 nVendor;							/* vendor define, VS_DEV_VENDOR_XXX */
	S8  szDomainId[VS_DOMAINID_LEN+1];
	S32 nVssSvrId;							/* media server ID */
}TabDevBaseInfo_t;


/*
 * slave and master device relation
 */
#define VS_DEVREL_SLAVEID	 "SlaveDevId"
#define VS_DEVREL_MASTERID	"MasterDevId"
#define VS_DEVREL_TYPE			"SlaveType"
#define VS_DEVREL_IONUMBER	"IONumber"

typedef struct TabDevRelation_s
{
	S8  szSlaveDev[VS_DEV_ID_LEN];
	S8  szMasterDev[VS_DEV_ID_LEN];
	U32 nSlaveType;
	U32 nIONum;
}TabDevRelation_t;

//主设备基本信息
#define VS_MASTERDEV_ID			"DevId"
#define VS_MASTERDEV_SERIALNO		"DevSerialNo"
#define VS_MASTERDEV_GROUPID		"DevGroupID"
#define VS_MASTERDEV_IPADDR		"IpAddr"
#define VS_MASTERDEV_COMMPORT		"CommPort"
#define VS_MASTERDEV_LOGINNAME	"LoginName"
#define VS_MASTERDEV_LOGINPWD		"LoginPassword"
#define VS_MASTERDEV_STATUS		"Status"

typedef struct TabMasterBaseInfo_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	S8	szDevSerialNo[VS_DEV_SERIALNO_LEN];
	S8	szDevGroupID[VS_DEVGROUP_ID_LEN];
	U32 nIpAddr;
	U32	nCommPort;
	S8	szLoginName[VS_LOGIN_NAME_LEN];
	S8	szLoginPassword[VS_LOGIN_PASSWD_LEN];

#define STATUS_OFFLINE		0
#define STATUS_HBLOST		1
#define STATUS_ACTIVE		2

	U32	nState;	//状态，由VMS判断并写入，非配置。0:  offline	1: heartbeet lost	2: active
}TabMasterBaseInfo_t;

/*
 *  setting related Camera,
 */
#define VS_DEVCAMERA_DEVID				"DevId"
#define VS_DEVCAMERA_PLATRECORDOPTION   	"PlatRecordOption"
#define VS_DEVCAMERA_RECORDSCHEMENO		"RecordSchemeNo"
#define VS_DEVCAMERA_STORAGEPOLICYNO 	"StoragePolicyNo"
#define VS_DEVCAMERA_ALMUPPOLICYNO 	"AlarmUpRecordPolicyNo"
#define VS_DEVCAMERA_HEADTRANSPRO		"HeadTransPro"	//new
#define VS_DEVCAMERA_PLATTRANSPRO		"PlatTransPro"	//new
#define VS_DEVCAMERA_BHEARDMULTICAST		"bHeadMulticast"
#define VS_DEVCAMERA_BPLATMULTICAST		"bPlatMulticast"
#define VS_DEVCAMERA_HEADMULTICASTIP		"HeadMulticastIp"
#define VS_DEVCAMERA_PLATMULTICASTIP		"PlatMulticastIp"
#define VS_DEVCAMERA_RECORDSTATUS		"RecordStatus"
#define VS_DEVCAMERA_VISITSTREAMOPTION	"VisitStreamOption"

#define PLAT_NO_RECORD			0		//不使用平台录像
#define PLAT_SCHEME_RECORD	1		//平台录像(根据录制策略按计划/告警录像)

#define VS_VISITSTREAM_NO_FIRBID		0	//不禁止任何码流
#define VS_VISITSTREAM_FIRBID_0		1	//禁止第0路(CIF)
#define VS_VISITSTREAM_FIRBID_1		2	//禁止第1路(D1)
#define VS_VISITSTREAM_FIRBID_BOTH	3	//禁止第0路、第1路

#define VS_PROTOCOL_UDP	0
#define VS_PROTOCOL_TCP	1

typedef struct TabDevCamera_s
{
	S8  szDevId[VS_DEV_ID_LEN];

	U32 nPlatRecordOption;

	U32 nRecordSchemeNo;	//当nPlatRecordOption=PLAT_SCHEME_RECORD时有效
	U32 nStoragePolicyNo;	//当nPlatRecordOption=PLAT_SCHEME_RECORD时有效

	U32 nAlarmUpRecordPolicyNo;//IPC告警上传录像删除策略

	U32 nHeadTransPro;	//前端流传输协议	VS_PROTOCOL_UDP, VS_PROTOCOL_TCP
	U32 nPlatTransPro;//Client流传输协议	VS_PROTOCOL_UDP, VS_PROTOCOL_TCP
	
	U32	bHeadMulticast;
	U32 bPlatMulticast;
	U32	nHeadMulticastIp;
	U32	nPlatMulticastIp;
	U32 nRecordStatus;
	U32 nVisitStreamOption;
}TabDevCamera_t;


//Alarm Input device
#define VS_DEVALMIN_DEVID		  "DevId"
#define VS_DEVALMIN_TYPE		   "Type"
#define VS_DEVALMIN_VIDEO_CHANNEL  "VideoChannel"
#define VS_DEVALMIN_ALARM_LEVEL	"AlarmLevel"

typedef struct TabDevAlmin_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 nType;							  /* VS_ALARM_IN_XXX */
	U32 nVideoChannel;
	U32 nAlarmLevel;						/* VS_ALARM_LEVEL_XXX */
}TabDevAlmin_t;


//Alarm ouptput device
#define VS_DEVALMOUT_DEVID		  "DevId"
#define VS_DEVALMOUT_TYPE		   "Type"

typedef struct TabDevAlmout_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 nType;							  /* VS_ALARM_OUT_XXX */
}TabDevAlmout_t;

// Device Location table
#define VS_DEVLOC_DEVID		  "DevId"
#define VS_DEVLOC_LANDMARK	   "LandMark"
#define VS_DEVLOC_STREET		 "Street"
#define VS_DEVLOC_NUMBER		 "Number"
#define VS_DEVLOC_DISTRICT	   "District"
#define VS_DEVLOC_CITY		   "City"
#define VS_DEVLOC_PROVINCE	   "Province"
#define VS_DEVLOC_COUNTRY		"Country"
#define VS_DEVLOC_LONGITUDE	  "Longitude"
#define VS_DEVLOC_LATITUDE	   "Latitude"

#define VS_DEVLOC_PHONENUM3G                "PhoneNum3G" 
#define VS_DEVLOC_LOCTYPE                   "LocType"             
#define VS_DEVLOC_CARRIERNAME               "CarrierName"         
#define VS_DEVLOC_CARRIERGENDER             "CarrierGender"       
#define VS_DEVLOC_CARRIERJOBTITLE           "CarrierJobTitle"     
#define VS_DEVLOC_CARRIERNUMBER             "CarrierNumber"       
#define VS_DEVLOC_CARRIERPHONE              "CarrierPhone"        
#define VS_DEVLOC_CARNUMBER                 "CarNumber"           
#define VS_DEVLOC_CARTYPE                   "CarType"             
#define VS_DEVLOC_CARFACTORYPLATEMODEL      "CarFactoryPlateModel"
#define VS_DEVLOC_CARCOLOR                  "CarColor"     


#define VS_LOCATION_FIX 		0//0：位于固定位置
#define VS_LOCATION_BY_HUMAN	1//1：由人员携带
#define VS_LOCATION_BY_CAR	2//2：由车辆携带
#define VS_LOCATION_BY_OTHER	3//3：其他

#define VS_GENDOR_UNCONFIGURED	0	//性别未配置
#define VS_GENDOR_MAN				1	//男
#define VS_GENDOR_WOMAN			2	//女

#define VS_CARTYPE_UNCONFIGURED	0//0：未定义
#define VS_CARTYPE_CAR				1//1：轿车
#define VS_CARTYPE_TRACTOR		2//2：牵引车
#define VS_CARTYPE_TRUCK			3//3：货车
#define VS_CARTYPE_PASSENGER		4//4：客车


typedef struct TabDevLoc_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	S8  szLandmark[VS_STRING_LENG_32];
	S8  szStreet[VS_STRING_LENG_32];
	S8  szNum[VS_STRING_LENG_32];
	S8  szDistrict[VS_STRING_LENG_32];
	S8  szCity[VS_STRING_LENG_32];
	S8  szProvince[VS_STRING_LENG_32];
	S8  szCountry[VS_STRING_LENG_32];
	S8  szLongitude[VS_STRING_LENG_32];
	S8  szLatitude[VS_STRING_LENG_32];

	S8 PhoneNum3G[VS_STRING_LENG_32];
	U32 LocType;
	S8 CarrierName[VS_STRING_LENG_64];
	U32 CarrierGender;
	S8 CarrierJobTitle	[VS_STRING_LENG_32];
	S8 CarrierNumber[VS_STRING_LENG_32];
	S8 CarrierPhone[VS_STRING_LENG_32];
	S8 CarNumber[VS_STRING_LENG_32];
	U32 CarType;
	S8 CarFactoryPlateModel[VS_STRING_LENG_64];
	S8 CarColor[VS_STRING_LENG_32];	
}TabDevLoc_t;

#define VS_DEV_HISGPSINFO_DEVID			"DevId"      
#define VS_DEV_HISGPSINFO_GPSDATATIME	"GpsDataTime"
#define VS_DEV_HISGPSINFO_LONGITUDE		"Longitude"  
#define VS_DEV_HISGPSINFO_LATITUDE		"Latitude"   
#define VS_DEV_HISGPSINFO_ALTITUDE		"Altitude"   
#define VS_DEV_HISGPSINFO_BACCURATE		"bAccurate"  
#define VS_DEV_HISGPSINFO_DIRECTION		"Direction"  
#define VS_DEV_HISGPSINFO_SPEED			"Speed"      

typedef struct TabHistoryGpsInfo_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 GpsDataTime;
	S8  Longitude[VS_STRING_LENG_16];
	S8  Latitude[VS_STRING_LENG_16];
	S32 Altitude;
	S32 bAccurate;
	S32 Direction;
	S32 Speed;
}TabHistoryGpsInfo_t;

//客户端告警前端联动配置
#define VS_CLI_ALMACT_DEVID				"DevId"
#define VS_CLI_ALMACT_ALMACTTYPE	 		"AlmActType"
#define VS_CLI_ALMACT_ALMTYPE 		"AlmType"

#define VS_CLI_ALMACT_TYPE_BLINCKICON	1	//节点图标闪烁
#define VS_CLI_ALMACT_TYPE_PLAYVOICE	2	//声音告警
#define VS_CLI_ALMACT_TYPE_POPVIDEO	3	//弹出告警视频

typedef struct TabCliAlmAct_s
{
	S8  szDevId[VS_DEV_ID_LEN];	   // alarm input devId or camera id
	U32 nAlmActType;				// VS_CLI_ALMACT_TYPE_XXX 见上面定义
	S8 szAlmType[VS_STRING_LENG_64];	// VS_ALARM_TYPE_XXX 取值组合，以逗号分开，由客户端配置和分析
} TabCliAlmAct_t;


//告警前端联动配置
#define VS_ALMACTRELATION_DEVID				"DevId"
#define VS_ALMACTRELATION_TYPE	 			"Type"
#define VS_ALMACTRELATION_ALMOUTDEVID 		"AlmOutDevId"
#define VS_ALMACTRELATION_ALMACTTYPE 		"AlmActType"
#define VS_ALMACTRELATION_PARAM1 			"Param1"
#define VS_ALMACTRELATION_PARAM2 			"Param2"

typedef struct TabAlmActionRelation_s
{
	S8  szDevId[VS_DEV_ID_LEN];	   // alarm input devId or camera id
	U32 nType;					 		// VS_ALARM_TYPE_XXX ，仅包括和业务相关的告警
	S8  szAlmOutDevId[VS_DEV_ID_LEN]; // alarm output devId or PTZ id

#define VS_ALARM_ACT_IO	   1
#define VS_ALARM_ACT_PREPOS   2
#define VS_ALARM_ACT_TRACK	3
	U32 nAlmActType;					//VS_ALARM_ACT_XXX

	U32 nParam1;						// io输出时，设置为持续时间（s）,
										// Ptz 预置点操作时，设置为预置点位置；
										// 巡航时，设置为轨迹号。*/
	U32 nParam2;
} TabAlmActionRelation_t;


//告警平台前转配置
#define VS_ALMFWLIST_DEVID				"DevId"
#define VS_ALMFWLIST_TYPE					"Type"
#define VS_ALMFWLIST_CLIENTID 			"ClientId"
#define VS_ALMFWLIST_ALMFWTYPE	 		"AlmFwType"
#define VS_ALMFWLIST_ENTRYNUM	 			"EntryNum"
#define VS_ALMFWLIST_ALMFWLIST 			"AlmFwList"
#define VS_ALMFWLIST_ALMMSG	 			"AlmMsg"

typedef struct TabSysAlmFwList_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 nType; 							// VS_ALARM_TYPE_XXX ，仅包括和业务相关的告警

#define VS_ALARM_FWTYPE_SMS	   1
#define VS_ALARM_FWTYPE_EMAIL	 2
#define VS_ALARM_FWTYPE_VOICE	 4
#define VS_ALARM_FWTYPE_GSMTERM   8
	U32 nAlmFwType; 					//短消息 1, 邮件 2,  声讯 4, 可以组合多选。

	U32 nEntryNum; 						//接收个数
	S8  szAlmFwList[VS_FW_ID_LEN*VS_MAX_FW_NUM];//接警用户ID
}TabSysAlmFwList_t;


//摄像头注册信息
#define VS_CAMERAREGINFO_DEVID			"DevId"
#define VS_CAMERAREGINFO_BDOUBLESTREAM	"bDoubleStream"
#define VS_CAMERAREGINFO_BWITHPTZ		"bWithPTZ"
#define VS_CAMERAREGINFO_BWITHAUDIOIN	"bWithAudioIn"
#define VS_CAMERAREGINFO_BWITHAUDIOOUT	"bWithAudioOut"

typedef struct TabCameraRegInfo_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 bDoubleStream;
	U32 bWithPTZ;
	U32	bWithAudioIn;
	U32	bWithAudioOut;
}TabCameraRegInfo_s;


//设备划归配置表
#define VS_DEVRELATEDUSER_DEVORGRPID	"DevOrGrpId"
#define VS_DEVRELATEDUSER_USERORGRPID	"UserOrGrpId"
#define VS_DEVRELATEDUSER_ISGRPID		"IsDevGrpID"
#define VS_DEVRELATEDUSER_ISUSERGRPID	"IsUserGrpId"
#define VS_DEVRELATEDUSER_PRIORITY		"Priority"
#define VS_DEVRELATEDUSER_RIGHTS			"Rights"
#define VS_DEVRELATEDUSER_DEVDOMAIN		"DevDomainId"

typedef struct TabDevRelatedUser_s
{
	S8 szDevOrGrpId[VS_DEV_ID_LEN];
	S8 szUserOrGrpId[VS_USER_ID_LEN];
	U32 bIsDevGrpId;
	U32 bIsUserGrpId;
	U32 nPriority;
	S8	szRightBits[VS_DEV_VEST_RIGHT_LEN];
	S8	szDevDomain[VS_DOMAINID_LEN+1];
}TabDevRelatedUser_t;


//云台预置点preset position info
#define VS_PRESETPOS_DEVID  "DevId"
#define VS_PRESETPOS_NO	 "PresetNo"
#define VS_PRESETPOS_DESC   "PresetDesc"

typedef struct TabPresetPos_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 nPresetNo;
	S8  szPresetDesc[VS_PRESET_DESC_LEN];
}TabPresetPos_t;


//云台轨迹track info
#define VS_TRACKSEQ_DEVID   "DevId"
#define VS_TRACKSEQ_NO	  "TrackNo"
#define VS_TRACKSEQ_DESC	"TrackDesc"
#define VS_TRACKSEQ_SEQ	 "TrackSeq"
typedef struct TabTrackSeq_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 nTrackNo;
	S8  szTrackDesc[VS_TRACK_DESC_LEN];
	S8  szTrackSeq[VS_TRACK_SEQ_LEN];
}TabTrackSeq_t;


//活动Watcher列表
#define VS_ALIVEWATCHER_VSSID		"VssSvrId"
#define VS_ALIVEWATCHER_IPADDR	"IpAddr"
#define VS_ALIVEWATCHER_PORT		"Port"
typedef struct TabAliveWatcher_s
{
	U32 nSurSvrId;
	U32 nIpAddr;
	U32 nPort;
}TabAliveWatcher_t;


//实时监控日志
#define VS_SURLOG_VSS_ID			  "VssSvrId"
#define VS_SURLOG_VSS_STARTTIME	   "VssStartTime"
#define VS_SURLOG_SEQ				 "SdrSeq"
#define VS_SURLOG_STARTTIME		   "SdrStartTime"
#define VS_SURLOG_STOPTIME			"SdrStopTime"
#define VS_SURLOG_STOPREASON		  "StopReason"
#define VS_SURLOG_USERID			  "UserId"
#define VS_SURLOG_DEVID			   "DevId"
#define VS_SURLOG_CLIENTIP			"ClientIp"
#define VS_SURLOG_CLIENTPORT		  "ClientPort"
#define VS_SURLOG_MEDIAIP			 "MediaIp"
#define VS_SURLOG_MEDIAPORT		   "MediaPort"
#define VS_SURLOG_RTPFLAG			 "RtpFlag"
#define VS_SURLOG_PATROLID			"PatrolId"
#define VS_SURLOG_BUNICAST			"bUnicast"
#define VS_SURLOG_CONNID			  "ConnId"
#define VS_SURLOG_MCASTIP			 "McastIp"
#define VS_SURLOG_MCASTPORT		   "McastPort"
#define VS_SURLOG_MSGTYPE			 "MsgType"
#define VS_SURLOG_ERRCODE			 "ErrCode"


#define VS_SUR_STOP_NORMAL			  1
#define VS_SUR_STOP_HBLOST_MDS		  2
#define VS_SUR_STOP_SS_RESTART		  3
#define VS_SUR_STOP_CLIENT_RESTART	  4
#define VS_SUR_STOP_HBLOST_CLIENT	   5
#define VS_SUR_STOP_SYNC_CLIENT		 6
#define VS_SUR_STOP_SHELL_COMMAND	   7
#define VS_SUR_STOP_DYN_REMOVE		  8
#define VS_SUR_STOP_LONG_SDR			9
#define VS_SUR_STOP_PATROL_OLD_CONN	 10
#define VS_SUR_STOP_SS_STOP			 11
#define VS_SUR_STOP_SUBSVR_HB_LOST	  12
#define VS_SUR_STOP_OCCUPY_BY_HIGERUSER 13
#define VS_SUR_STOP_INVITE_FAILED 14
#define VS_SUR_STOP_MANUAL 15 //手动停止
#define VS_SUR_STOP_CLI_REINVITE 16 //客户端重新请求

#define VS_SUR_UNICAST_CONN			 1
#define VS_SUR_MULTICAST_CONN		   2

typedef struct TabSurLog_s
{
	U32 nSurSvrId;
	U32 nSurStartTime;
	U32 nSdrSeq;
	U32 nSdrStartTime;
	U32 nSdrStopTime;
	U32 nStopReason;
	S8  szUserName[VS_USER_NAME_LEN];
	S8  szDeviceId[VS_DEV_ID_LEN];
	U32 nClientIp;
	U32 nClientPort;
	U32 nMediaListenIp;
	U32 nMediaListenPort;
	U32 nRtpFlag;
	U32 nPatrolId;
	U32 nUnicast;
	U32 nConnId;
	U32 nMcastIp;
	U32 nMcastPort;
	U32 nMsgType;
	U32 nErrCode;
}TabSurLog_t;

//回放日志
#define VS_PLAYBACKLOG_VSS_ID			  "VssSvrId"
#define VS_PLAYBACKLOG_VSS_STARTTIME	   "VssStartTime"
#define VS_PLAYBACKLOG_SEQ				 "SdrSeq"
#define VS_PLAYBACKLOG_STARTTIME		   "SdrStartTime"
#define VS_PLAYBACKLOG_STOPTIME			"SdrStopTime"
#define VS_PLAYBACKLOG_USERID			  "UserId"
#define VS_PLAYBACKLOG_DEVID			   "DevId"
#define VS_PLAYBACKLOG_CLIENTIP			"ClientIp"
#define VS_PLAYBACKLOG_CLIENTPORT		  "ClientPort"
#define VS_PLAYBACKLOG_OPTYPE			  "OpType"
#define VS_PLAYBACKLOG_ENTRYTIME		   "EntryTime"
#define VS_PLAYBACKLOG_CONTENTSTART		"ContentStartTime"
#define VS_PLAYBACKLOG_CONTENTSTOP		 "ContentStopTime"

typedef struct TabPlaybackLog_s
{
	U32 nStmSvrId;
	U32 nStmStartTime;
	U32 nSdrSeq;
	U32 nSdrStartTime;
	U32 nSdrStopTime;
	S8  szUserId[VS_USER_ID_LEN];
	S8  szDeviceId[VS_DEV_ID_LEN];
	U32 nClientIp;
	U32 nClientPort;
	U32 nOpType;
	U32 nPbEntryTime;
	U32 nPbContentStart;
	U32 nPbContentStop;
}TabPlaybackLog_t;

//登录认证日志
#define VS_LOGINLOG_VMS_ID			  "VmsSvrId"
#define VS_LOGINLOG_VMS_STARTTIME	   "VmsStartTime"
#define VS_LOGINLOG_SEQ				 "SdrSeq"
#define VS_LOGINLOG_LOGINTIME		   "LoginTime"
#define VS_LOGINLOG_LOGINSTATUS		 "LoginStatus"
#define VS_LOGINLOG_LOGOUTTIME		  "LogoutTime"
#define VS_LOGINLOG_LOGOUTSTATUS		"LogoutStatus"
#define VS_LOGINLOG_USERID			  "UserId"
#define VS_LOGINLOG_CLIENTIP			"ClientIp"
#define VS_LOGINLOG_CLIENTTYPE		  "ClientType"
 
typedef struct TabLoginLog_s
{
	U32 nVmsSvrId;
	U32 nVmsStartTime;
	U32 nSdrSeq;
	U32 nLoginTime; 
	U32 nLoginStatus;
	U32 nLogoutTime;
	U32 nLogoutStatus;
	S8  szUserId[VS_USER_ID_LEN];
	U32 nClientIp;
	U32 nClientType;
}TabLoginLog_t;



//设备事件
#define VS_DEVEVENT_DEVID	 "DevId"
#define VS_DEVEVENT_TIMESTAMP "Timestamp"
#define VS_DEVEVENT_TYPE	  "Type"
#define VS_DEVEVENT_DESCRIPTION	"Description"


typedef	enum
{
	VS_EVENT_TYPE_NONE =	EVENT_TYPE_NONE,
	VS_EVENT_TYPE_USB_PLUGIN =	EVENT_TYPE_USB_PLUGIN,		//U盘插入
	VS_EVENT_TYPE_USB_UNPLUG =	EVENT_TYPE_USB_UNPLUG,		//U盘拔出
	VS_EVENT_TYPE_SD1_PLUGIN =	EVENT_TYPE_SD1_PLUGIN,		//SD1插入
	VS_EVENT_TYPE_SD1_UNPLUG =	EVENT_TYPE_SD1_UNPLUG,		//SD1拔出
	VS_EVENT_TYPE_SD2_PLUGIN =	EVENT_TYPE_SD2_PLUGIN,		//SD2插入
	VS_EVENT_TYPE_SD2_UNPLUG =	EVENT_TYPE_SD2_UNPLUG,		//SD2拔出
	VS_EVENT_TYPE_RECORD_START =	EVENT_TYPE_RECORD_START,	//录像开始
	VS_EVENT_TYPE_RECORD_FINISHED =	EVENT_TYPE_RECORD_FINISHED,	//录像结束
	VS_EVENT_TYPE_RECORD_FILE_REMOVED =	EVENT_TYPE_RECORD_FILE_REMOVED,	//录像文件删除
	VS_EVENT_TYPE_RECORD_DIR_REMOVED =	EVENT_TYPE_RECORD_DIR_REMOVED,	//录像目录删除
	VS_EVENT_TYPE_START_UPDATE_FIRMWARE = EVENT_TYPE_START_UPDATE_FIRMWARE, //固件更新需要较长时间
	VS_EVENT_TYPE_UPDATE_FIRMWARE_OK = EVENT_TYPE_UPDATE_FIRMWARE_OK,
	VS_EVENT_TYPE_UPDATE_FIRMWARE_FAILED = EVENT_TYPE_UPDATE_FIRMWARE_FAILED,
	VS_EVENT_TYPE_UPDATE_CONFIG_OK = EVENT_TYPE_UPDATE_CONFIG_OK, //配置更新不需要时间
	VS_EVENT_TYPE_UPDATE_CONFIG_FAILED = EVENT_TYPE_UPDATE_CONFIG_FAILED,
	VS_EVENT_TYPE_START_REBOOT = EVENT_TYPE_START_REBOOT,
	VS_EVENT_TYPE_GPS_INFO = EVENT_TYPE_GPS_INFO,

	VS_EVENT_TYPE_OTHER,
}EventType;


typedef struct TabDevEventInfo_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 Timestamp;
	U32 nType;	//EventType
	S8	szDescription[VS_EVENTALARM_DESCRIPTION_LEN];
}TabDevEventInfo_t;


//设备告警
#define VS_DEVALARM_DEVID			"DevId"
#define VS_DEVALARM_TIMESTAMP	"Timestamp"
#define VS_DEVALARM_TYPE			"Type"
#define VS_DEVALARM_ISRAISE		"IsRaise"
#define VS_DEVALARM_LEVEL			"AlarmLevel"
#define VS_DEVALARM_DESCRIPTION	"Description"



typedef enum
{
//IO告警输入
	VS_ALARM_TYPE_NONE			= VS_ALARM_IN_NONE			,
	VS_ALARM_TYPE_FIRE			= VS_ALARM_IN_FIRE			, 
	VS_ALARM_TYPE_SMOKE			= VS_ALARM_IN_SMOKE			, 
	VS_ALARM_TYPE_INFRARED		= VS_ALARM_IN_INFRARED		, 
	VS_ALARM_TYPE_GAS				= VS_ALARM_IN_GAS			,
	VS_ALARM_TYPE_TEMPERATURE	= VS_ALARM_IN_TEMPERATURE	, 
	VS_ALARM_TYPE_GATING			= VS_ALARM_IN_GATING		,  
	VS_ALARM_TYPE_MANUAL			= VS_ALARM_IN_OTHER			,   

//摄像头告警
	VS_ALARM_TYPE_MOTIONDECTECT = 0x101,	//移动侦测
	VS_ALARM_TYPE_FACEDECTECT,		//人脸检测
	VS_ALARM_TYPE_FACERECOGNIZED,	//人脸识别
	VS_ALARM_TYPE_VIDEO_LOST,		//视频丢失
	VS_ALARM_TYPE_VIDEO_COVERED,	//视频遮挡
	VS_ALARM_TYPE_STORAGE_FULL,	//存储空间不足
	VS_ALARM_TYPE_RECORD_FAILED,	//录像失败
	
	VS_ALARM_TYPE_EMERGENCY_CALL,//增加紧急呼叫告警，收到该告警后，用户可手动从客户端开启对讲

//以下2个，如果配置了告警输入设备，则根据通道号查找相应的告警输入类型
	VS_ALARM_TYPE_IO_LOW2HIGH,		//IO由低变高
	VS_ALARM_TYPE_IO_HIGH2LOW,		//IO由高变低

	VS_ALARM_TYPE_UNKNOWN,
}AlarmType;


#define VS_ALARM_CLEAR				0
#define VS_ALARM_RAISE				1

typedef struct TabDevAlmInfo_s
{
	S8  szDevId[VS_DEV_ID_LEN];
	U32 Timestamp;
	U32 nType;	//AlarmType
	U32 bIsRaise;					   /* raise or clear */
	U32 nAlarmLevel;					/* alarm level: VS_ALARM_LEVEL_XXX */		
	S8	szDescription[VS_EVENTALARM_DESCRIPTION_LEN];
}TabDevAlmInfo_t;

//系统事件日志
#define VS_SYSEVENT_SVRID					"SvrId"
#define VS_SYSEVENT_SVRIP				  	"SvrIp"
#define VS_SYSEVENT_SVRTYPE				"SvrType"
#define VS_SYSEVENT_MODULETYPE			"ModuleType"
#define VS_SYSEVENT_OCCURTIME				"OccurTime"
#define VS_SYSEVENT_EVENTTYPE				"EventType"
#define VS_SYSEVENT_EVENTINFO				"EventInfo"
#define VS_SYSEVENT_ADDTEXT				"AddText"

typedef struct TabSysEvent_s
{
	U32 nSvrId;
	U32 nSvrIp;
	U32	nSvrType;
	U32 nModuleType;
	U32 nOccurTime;	
	U32 nEventType;
	U32 nEventInfo;
	S8	szAddText[VS_SYS_EVNETALARM_TEXT_LEN];
}TabSysEvent_t;

//系统告警日志
#define VS_SYSALARM_SVRID					"SvrId"
#define VS_SYSALARM_SVRIP				  	"SvrIp"
#define VS_SYSALARM_SVRTYPE				"SvrType"
#define VS_SYSALARM_MODULETYPE			"ModuleType"
#define VS_SYSALARM_PROBCAUSE			"ProbCause"
#define VS_SYSALARM_SPECPROB				"SpecProb"
#define VS_SYSALARM_ALARMTYPE			"AlarmType"
#define VS_SYSALARMALARMSEVERITY			"AlarmLevel"
#define VS_SYSALARM_OCCURTIME			"OccurTime"
#define VS_SYSALARM_CLEARTIME			"ClearTime"
#define VS_SYSALARM_ADDTEXT				"AddText"

typedef struct TabSysAlarm_s
{
	U32 nSvrId;
	U32 nSvrIp;
	U32	nSvrType;
	U32 nModuleType;
	U32 nProbCause;
	U32 nSpecProb;
	U32 nAlarmType;
	U32 nAlarmLevel;
	U32 nOccurTime;
	U32 nClearTime;
	S8	szAddText[VS_SYS_EVNETALARM_TEXT_LEN];
}TabSysAlarm_t;


//操作日志
#define VS_OPERATIONLOG_TIMESTAMP 	"TimeStamp"
#define VS_OPERATIONLOG_OPERATORID 		"OperatorId"
#define VS_OPERATIONLOG_OPERATORNAME 	"OperatorName"
#define VS_OPERATIONLOG_OBJECTID 		"ObjectId"
#define VS_OPERATIONLOG_OBJECTNAME 	"ObjectName"
#define VS_OPERATIONLOG_OPTYPE 		"OpType"
#define VS_OPERATIONLOG_OPERATORIP 	"OperatorIp"
#define VS_OPERATIONLOG_DESC 			"Description"

typedef struct TabOpLog_s
{
	U32 nTimeStamp;
	S8 szOperatorId[VS_USER_ID_LEN];
	S8 szOperatorName[VS_USER_NAME_LEN];
	S8 szObjectId[VS_DEV_ID_LEN];
	S8 szObjectName[VS_DEV_NAME_LEN];

#define VS_OPLOG_LOGIN		1			//use login
#define VS_OPLOG_LOGOUT		2			//user logout
#define VS_OPLOG_DEVREG		3			//device regist
#define VS_OPLOG_DEVDEREG		4			//device deregist
#define VS_OPLOG_ADDUSER		5			//add user
#define VS_OPLOG_DELUSER		6			//delete user
#define VS_OPLOG_MODUSER		7			//modify user
#define VS_OPLOG_ADDCLIENT	8			//add client
#define VS_OPLOG_DELCLIENT	9			//delete client
#define VS_OPLOG_MODCLIENT	10			//modify client
#define VS_OPLOG_ADDDEV		11			//add device
#define VS_OPLOG_DELDEV		12			//delete device
#define VS_OPLOG_MODDEV		13			//modify device
#define VS_OPLOG_ASSIGNDEV	14			//assign device
#define VS_OPLOG_REASSIGNDEV	15			//reassign device
#define VS_OPLOG_PTZCTRL		16			//PTZ control
#define VS_OPLOG_ALMACT		17			//alarm action
#define VS_OPLOG_REMVVIDEO	18			//remove video
#define VS_OPLOG_MANUALREC	19			//manual recording
#define VS_OPLOG_UPDATERECCFG	20			//update recording config
	U32 nOpType;

	S8 szOperatorIp[VS_IPADDR_LEN];
	S8 szDescription[VS_LOG_DESC_LEN];
}TabOpLog_t;


//监控用户显示方案
#define VS_DISPMODE_USERID		"UserId"
#define VS_DISPMODE_MODENO	"DispMode"
typedef struct TabDispMode_s
{
	S8  szUserId[VS_USER_ID_LEN];
	U32 nDispMode;		//由监控客户端自行写入,1 4 6 8 9 16 25 36
}TabDispMode_t;


//监控书签表，用于用户重新登录时从数据库读取监控的设备
#define VS_BOOKMARK_USERID		"UserId"
#define VS_BOOKMARK_WNDID		"WndId"
#define VS_BOOKMARK_DEVID		"DevId"
#define VS_BOOKMARK_STREAMNO	"StreamNo"
#define VS_BOOKMARK_BPATROL	"bPatral"

typedef struct TabBookmark_s
{
	S8  szUserId[VS_USER_ID_LEN];
	U32 nWndId;
	S8  szDevId[VS_DEV_ID_LEN];
	U32 nStreamNo;
	U32 bPatral;	//是否轮巡，默认为0
}TabBookmark_t;

//轮巡配置表
#define VS_PATROLCFG_USERID		"UserId"
#define VS_PATROLCFG_WNDID		"WndId"
#define VS_PATROLCFG_STRING		"CfgString"

typedef struct TabPatrolCfg_s
{
	S8  szUserId[VS_USER_ID_LEN];
	U32 nWndId;
	S8  cfgString[VS_PATROL_CFGSTRING_LEN];
}TabPatrolCfg_t;

//解码器配置表，DevId为从设备的平台号
#define VS_DECODER_SCHEME_DEVID		"DevId"
#define VS_DECODER_SCHEME_CONTENT	"Scheme"


#endif /* __VS_TABLE_STRUCTS_HEADER__ */

