Skip to content
Snippets Groups Projects
AlarmHandler.cpp 201 KiB
Newer Older
/*----- PROTECTED REGION ID(AlarmHandler.cpp) ENABLED START -----*/
//=============================================================================
//
// file :        AlarmHandler.cpp
// description : C++ source for the AlarmHandler class and its commands.
//               The class is derived from Device. It represents the
//               CORBA servant object which will be accessed from the
//               network. All commands which can be executed on the
//               AlarmHandler are implemented in this file.
// project :     Elettra alarm handler device server
//
// This file is part of Tango device class.
// 
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
// 
//
//
//=============================================================================
//                This file is generated by POGO
//        (Program Obviously used to Generate tango Object)
//=============================================================================


#include <AlarmHandler.h>
#include <AlarmHandlerClass.h>
#include <ctype.h>		//for tolower

#include "alarm-thread.h"
#include "alarm_grammar.h"
#include "update-thread.h"

//#define _DUMP_TREE_XML
#ifdef _DUMP_TREE_XML
#if BOOST_VERSION  < 103600
#include <boost/spirit/iterator/fixed_size_queue.hpp>

#include <boost/spirit/core.hpp>
#include <boost/spirit/tree/ast.hpp>
#include <boost/spirit/tree/tree_to_xml.hpp>

using namespace boost::spirit;
#else
#include <boost/spirit/include/classic_fixed_size_queue.hpp>

#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_ast.hpp>
#include <boost/spirit/include/classic_tree_to_xml.hpp>

using namespace boost::spirit::classic;
#endif
#include <iostream>
#include <stack>
#include <functional>
#include <string>
#include <cassert>
#endif 		//_DUMP_TREE_XML
#include <sstream>

std::map<parser_id, std::string> rule_names;  //only for log messages

int AlarmHandler_ns::AlarmHandler::instanceCounter = 0;

#ifndef ALARM_BUILDTIME
#define ALARM_BUILDTIME    __DATE__ " "  __TIME__ " boost=" BOOST_LIB_VERSION
#endif

const char version_string[] = "$Build: @buildID@ " ALARM_BUILDTIME " $";
static const char __FILE__rev[] = __FILE__ " $Revision: 1.29 $";

/*----- PROTECTED REGION END -----*/	//	AlarmHandler.cpp
 *  AlarmHandler class description:
 *    Elettra alarm handler device server
 */

//================================================================
//  The following table gives the correspondence
//  between command and method names.
//
//================================================================
//  State            |  Inherited (no method)
//  Status           |  Inherited (no method)
//  Ack              |  ack
//  Load             |  load
//  Remove           |  remove
//  SearchAlarm      |  search_alarm
//  StopAudible      |  stop_audible
//  Silence          |  silence
//  Modify           |  modify
//  Shelve           |  shelve
//  Enable           |  enable
//  Disable          |  disable
//  ResetStatistics  |  reset_statistics
//  StopNew          |  stop_new
//  GetAlarmInfo     |  get_alarm_info
//================================================================

//================================================================
//================================================================
//  audibleAlarm                |  Tango::DevBoolean	Scalar
//  StatisticsResetTime         |  Tango::DevDouble	Scalar
//  alarm                       |  Tango::DevString	Spectrum  ( max = 1024)
//  normalAlarms                |  Tango::DevString	Spectrum  ( max = 10000)
//  unacknowledgedAlarms        |  Tango::DevString	Spectrum  ( max = 10000)
//  acknowledgedAlarms          |  Tango::DevString	Spectrum  ( max = 10000)
//  unacknowledgedNormalAlarms  |  Tango::DevString	Spectrum  ( max = 10000)
//  shelvedAlarms               |  Tango::DevString	Spectrum  ( max = 10000)
//  outOfServiceAlarms          |  Tango::DevString	Spectrum  ( max = 10000)
//  silencedAlarms              |  Tango::DevString	Spectrum  ( max = 10000)
//  listAlarms                  |  Tango::DevString	Spectrum  ( max = 10000)
//  frequencyAlarms             |  Tango::DevDouble	Spectrum  ( max = 10000)
//  alarmSummary                |  Tango::DevString	Spectrum  ( max = 10000)
//================================================================

namespace AlarmHandler_ns
/*----- PROTECTED REGION ID(AlarmHandler::namespace_starting) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/	//	AlarmHandler::namespace_starting

//--------------------------------------------------------
/**
 *	Method      : AlarmHandler::AlarmHandler()
 *	Description : Constructors for a Tango device
 *                implementing the classAlarmHandler
 */
//--------------------------------------------------------
AlarmHandler::AlarmHandler(Tango::DeviceClass *cl, string &s)
	/*----- PROTECTED REGION ID(AlarmHandler::constructor_1) ENABLED START -----*/
	/*----- PROTECTED REGION END -----*/	//	AlarmHandler::constructor_1
}
//--------------------------------------------------------
AlarmHandler::AlarmHandler(Tango::DeviceClass *cl, const char *s)
	/*----- PROTECTED REGION ID(AlarmHandler::constructor_2) ENABLED START -----*/
	/*----- PROTECTED REGION END -----*/	//	AlarmHandler::constructor_2
}
//--------------------------------------------------------
AlarmHandler::AlarmHandler(Tango::DeviceClass *cl, const char *s, const char *d)
	/*----- PROTECTED REGION ID(AlarmHandler::constructor_3) ENABLED START -----*/
	/*----- PROTECTED REGION END -----*/	//	AlarmHandler::constructor_3
}

//--------------------------------------------------------
/**
 *	Method      : AlarmHandler::delete_device()
 *	Description : will be called at device destruction or at init command
 */
//--------------------------------------------------------
void AlarmHandler::delete_device()
	DEBUG_STREAM << "AlarmHandler::delete_device() " << device_name << endl;
	/*----- PROTECTED REGION ID(AlarmHandler::delete_device) ENABLED START -----*/
	bool starting = Tango::Util::instance()->is_svr_starting();
	bool shutting_down = Tango::Util::instance()->is_svr_shutting_down();
	bool restarting = Tango::Util::instance()->is_device_restarting(device_name);
	DEBUG_STREAM << __func__ << " starting="<<(int)starting << " shutting_down="<<(int)shutting_down<<" restarting="<<(int)restarting;

	DEBUG_STREAM << "AlarmHandler::delete_device(): after abortflag=true..." << endl;
		events->unsubscribe_events();
	} catch (string& err) {
		ERROR_STREAM << err << endl;
	}
	DEBUG_STREAM << "AlarmHandler::delete_device(): events unsubscribed!" << endl;
Loading full blame...