/*************************************************/
/*Title:    heartbeat.h                          */
/*Descr:    heartbeat processor(Head File)       */
/*Author:   Liang Hanxi                          */
/*Create:   2002-4-5                             */
/*Modify:   2002-6-25                            */
/*************************************************/
#ifndef __HEART_BEAT__H
#define __HEART_BEAT__H

#include "snmp.h"
#include "time.h"
#include "sysctrl.h"


#define HEARTBEAT_SHM_KEY	0x01112233
#define HEARTBEAT_SHM_PERM	0666
#define COMPONENT_NUM		10
#define ALARM_COMPONENT_NUM	1024
#define LED_NUM				16

#define FLATFORM_HB_OID		{1,3,6,1,4,1,1373,2,3,2,0}
#define FLATFORM_HB_OIDLEN	11

#define HB_PORT				4957
#define HB_IP				"172.18.255.255"
#define INFO_LEN			1024

#define	MasterSubSysID		0
#define	MasterSysID			0

// by simon at 23/9/25
//DWORD		ExistIP[64];
//DWORD		ExistIPNum;

typedef struct component_buf{
	BOOL	flag;
	BYTE	alarm_code;
	BYTE	status_len;
	BYTE	status[256];
}component_buf;

typedef struct alarm_buf{
	BOOL	flag;
	BYTE	alarm_code;
}alarm_buf;

typedef struct heartbeat_msg{	
	BYTE	sys_id;
	BYTE	subsys_id;
	BYTE	timestamp[4];
	BYTE	led_color[8];
#if _CDMA_SNMP
	BYTE	component_id[2];
#else
	BYTE	component_id;
#endif
	BYTE	alarm_code;
#if _CDMA_SNMP
	BYTE	length[2];
#else
	BYTE	reserved;
	BYTE	length;
#endif
	BYTE	info[INFO_LEN];
}heartbeat_msg;

typedef struct heartbeat_shm{
	BYTE			sys_id;
	BYTE			subsys_id;
	BYTE			led[LED_NUM];
	component_buf	component[COMPONENT_NUM];
	alarm_buf		alarm[ALARM_COMPONENT_NUM];
	BYTE			alarm_num;
	heartbeat_msg	msg;
}heartbeat_shm;

void set_led(BYTE nled,BYTE ncolor);
void set_alarm(WORD component_id,BYTE alarm_code);
void set_status(BYTE component_id,BYTE info_len,BYTE *info);
void heartbeat_init(u_short sys_id);
void heartbeat_timer();

#endif



