#ifndef ALARM_H
#define ALARM_H



#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include "errors.h"
#include "io_element_control.h"


enum OTHER_ALARM {  FOG_PAR, FOG_TO, FOG_CRC,
		    TRANS_PAR, TRANS_TO, TRANS_CRC,	
		    DVL_PAR, DVL_TO, DVL_CRC,
		    VISION_PAR, VISION_TO, VISION_CRC,
		    TMS_PAR, TMS_TO, TMS_CRC,
		    LOG_PAR, LOG_TO, LOG_CRC,
		    HDTV_PAR, HDTV_TO, HDTV_CRC,
		    AUX_HEAD, FIFO };


struct Digital_Alarm
{
    	string 	name;
   	string 	descr;
        int status;		// On = 1, Off = 0
   	

};


struct Analog_Alarm
{
    	string 	name;
   	string 	descr;
        int status;		// On = 1, Off = 0
   	

};


struct Other_Alarm
{
    	string 	name;
   	string 	descr;
        int status;		// On = 1, Off = 0
   	

};



class Alarm {

   public:
   	Alarm();
   	~Alarm();
   	
   	
   	string get_alarm_description (int type);
	int write_alarm_history();
   	  	
   	 //------------------------- ALARM ---------------------------

   Alarm	*alarm_ptr;
   Alarm	*first_alarm;
   Alarm 	*next;
   string 	name;
   string 	descr;

   Digital_Alarm 	digital_alarm[35];
   Analog_Alarm		analog_alarm[50];
   Other_Alarm		other_alarm[100];


   void		set_io_alarm_descr();
   int		add_alarm_to_db(int diganal, int elem_num, string name);    // set the alarm name from IO ELEMENT
int 		check_alarm_db(string name);
   void 	display_alarm_on();
   void 	display_digital_alarm();
   void 	display_analog_alarm();
   int		set_dig_alarm(int elem_num);    // set the digital alarm status ON
   int		set_ana_alarm(int elem_num);    // set the analog alarm status ON
   int 		set_other_alarm(int index);     // set the other alarm status ON
   void		reset_alarm();


   // might not be needed here.....remove later
   int 		check_ana_status (int elem_num);
   int 		check_dig_status (int elem_num);
   int 		check_other_status (int index);

   string	get_ana_alarm_name (int elem_num);
   string	get_dig_alarm_name (int elem_num);
   string	get_other_alarm_name (int index);

   //-------------------------------------------

   string 	get_alarm_descr (string name);
   void		clear_alarm_list();
   void		initialize();

   int ana_count;
   int dig_count;
   int other_count;
   int alarm_status;
   string alarm_name;


   private:
   	
   	
};

extern Alarm alarm_obj;

#endif
