/* 
** PACS-WLL 2000 project, WAVEloop System.
** 
** The module Copyright (C) 2000-2001 interWAVE Inc.
** Written completely by Zhang Shuzhong at iCRD Sep, 2001
**
** file name: svrstat.h
** CVS $Id: $
**
** The header file is defination about shared memory 
** of server state information. 
**
*/


#ifndef SVRSTAT__H
#define SVRSTAT__H

#define SVRSTAT_SHM_KEY  0x00010000
#define SVRSTAT_SHM_PERM 0666
#define SVRSTAT_SEM_KEY  0x00010000
#define SVRSTAT_SEM_PERM 0666
#define	SVRSTAT_SEM_NUM  1

enum _server_state_enum {
		SS_IDLE,
		SS_INITIATE, 
		SS_NORMAL, 
		SS_SERVICE_SUSPEND,
		SS_SERVICE_HALT,
		SS_SHM_REINITIATE,
		SS_SERVICE_RESTART,
		SS_SYSTEM_RESTART,
		SS_SYSTEM_HALT,
};

enum _oper_state_enum {
		OS_NO_COMMAND,
		OS_SET_COMMAND,
		OS_GOT_COMMAND,
		OS_FINISHED_COMMAND,
		OS_REFUSED_COMMAND,
};

typedef struct {
		u_char        component_type;
		u_char        component_id;
                u_char        alarm_level;
		u_char        alarm_code;
		DWORD        timestamp;
} _alarm_log;

typedef struct {
		u_short       read_sub;
		u_short       write_sub;
		_alarm_log    alarm_log[16];
} _alarm_buffer;

typedef struct {
		u_char        version[3];    
		DWORD        distrib_date;   
		u_char        current_state;  // Please view server's state enum.
		                              // The server's current state.
		u_char        received_state; // State received from OMC.
		                              // Please view server's state enum 
									  // for detail.
		u_char        oper_state;     /* 0: No command.
                                      ** 1: Agent set command.
                                      ** 2: Function server got the command.
                                      ** 3: Function server finished. 
									  ** 4: Function server refused.
									  ** refer to enum of _oper_state_enum
                                      */
		u_char        net_status;     // 0/1=normal/abnormal,
		                              // status of network
		u_char        rate_progress;  // Rate of progress.
		DWORD        time_updated;
		_alarm_buffer alarm_buffer; // Alarm code 		
} _server_state;

typedef struct {
		DWORD        time_created;   // Heartbeating module set the field
		DWORD        server_list;    /* Bit0-15: 
		                              ** Server exist if set '1' in bit 
									  ** Bit16-31:
									  ** 0/1 = Primary/Secondary server.
									  ** that base server object id.
									  */
		u_char        led_state[16];  /* Led's state:
                                              ** 0: Idle/Disable/Suspend/Halt
									  ** 1: Enable/Normal
									  ** 2: Initiating/Activated
									  */
		u_char        port_stat[3];									  
		_server_state server_state[16]; /* Subscript of array 
		                                ** base on server object ID
										*/
} _ss_buffer;

#endif
