/*************************************************
File name:	beatSend.h
Author: 	Cui Ticun
Version:	9:00:00 
Date:  		2007-8-28
Description:beatSend.c的头文件
			
			
			
												
History:               
No. 		
Author:		  
Date:		 
Version:	   
Description:
*************************************************/

/* by simon at 23/9/25 */
#ifndef _LINUX_ES
	#include "mysql.h"
#else
	#include "mysql.h"
#endif	
/* end by simon */

#include "../../../../plat/snmp/src/include/snmp.h"
#include "../../../faultMgr/c_program/sysStat/sysStat.h"
#include "../../../omcLib/c_program//omcLib/omcLib.h"
#include "../../../faultMgr/c_program/sysStat/sysStat.h"
#ifndef _BEAT_SEND
#define _BEAT_SEND

#ifndef beatSend_DEBUG
#define beatSend_DEBUG 0
#endif

#define	HbSrcPort	4957

//unsigned long int HbDstIp;
/* by simon at 23/9/25 */
// unsigned int HbDstIp;

#define	HbDstPort	4957

#define HEARTBEAT_INTERVAL 10
#define PROC_CHECK_TIMEOUT 60
#define PROC_SUSPEND_TIMEOUT 90
#define MAX_SUSPEND_TIME 24

#define ProcAlarmStart	128
#define ProcAlarmEnd 143

typedef struct omcBaseInfo {
	BYTE omcTypeNo;				//EMS系统设备号
	BYTE sysNo;					//EMS系统号
	BYTE subSysNo;				//EMS子系统号
	BYTE runMode;				//运行模式,0:single 1:dual
	BYTE version[3];			//EMS版本号
} omcBaseInfo;

typedef struct BeatInfo {
	BYTE sysNo;					//系统号
	BYTE subSysNo;				//子系统号
	BYTE timeStamp[4];			//时间戳
	BYTE ledArr[8];				//led状态
	BYTE reservedForCompCode;	//保留
	BYTE compCode;				//compCode
	BYTE alarmCode;				//警报
	BYTE reservedForDetailLen;	//保留
	BYTE detailLen;				//信息长度
	BYTE detail[80];			// > sizeof DetailInfo(48)
	//BYTE detail[68];			// > sizeof DetailInfo(48)
} BeatInfo;

typedef struct DetailInfo {
	BYTE reservedForComp_id;	//保留
	BYTE comp_id;				//comp id
	BYTE reservedForComp_length;//保留
	BYTE comp_length;			//comp长度
	BYTE version[3];			//版本号
	BYTE status;				//状态
	BYTE checkSum[4];			//校验和
	BYTE maxLicenses[4];		//Licenses
	BYTE onLineUsers[4];		//在线用户
	BYTE sequenceNum[4];		//序列号
	BYTE clock[3];				//for 8k E1 hh:mm:ss
	BYTE syncInfo[32];			//同步信息
	//BYTE syncInfo[20];			//同步信息
	BYTE procNum;				//进程模块个数
	BYTE procInfo[MAX_PROC_NUM];//进程信息,MAX_PROC_NUM = 20
} DetailInfo;

int beatSendInit(omcBaseInfo * baseInfo,BYTE *sequenceNum);
int beatSend(int isMaster,int omcRunMode);
void chOmcStatus(BYTE status);
void fillSyncInfo(BYTE * info);
void fillProcStatus(BYTE procnum,BYTE *procstatus);

#endif
