Skip to content
Snippets Groups Projects
Alarm.cpp 139 KiB
Newer Older
/*----- PROTECTED REGION ID(Alarm.cpp) ENABLED START -----*/
static const char *RcsId = "$Id:  $";
//=============================================================================
//
// file :        Alarm.cpp
//
// description : C++ source for the Alarm 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
//               Alarm are implemented in this file.
//
// project :     alarm
//
// 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/>.
// 
// $Author:  $
//
// $Revision:  $
// $Date:  $
//
// $HeadURL:  $
//
//=============================================================================
//                This file is generated by POGO
//        (Program Obviously used to Generate tango Object)
//=============================================================================


#include <tango.h>
#include <Alarm.h>
#include <AlarmClass.h>
#include <ctype.h>		//for tolower

#include "alarm-thread.h"
#include "alarm_grammar.h"
#include "log_thread.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 Alarm_ns::Alarm::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 -----*/	//	Alarm.cpp

/**
 *  Alarm class description:
 *    Elettra alarm device server
 */

//================================================================
//  The following table gives the correspondence
//  between command and method names.
//
//  Command name  |  Method name
//================================================================
//  State         |  Inherited (no method)
//  Status        |  Inherited (no method)
//  Ack           |  ack
//  Load          |  load
//  Remove        |  remove
//  Configured    |  configured
//  StopNew       |  stop_new
//  Silence       |  silence
//  Modify        |  modify
//================================================================

//================================================================
//  Attributes managed is:
//================================================================
//  alarm  |  Tango::DevString	Spectrum  ( max = 1024)
//================================================================

namespace Alarm_ns
{
/*----- PROTECTED REGION ID(Alarm::namespace_starting) ENABLED START -----*/

//	static initializations

/*----- PROTECTED REGION END -----*/	//	Alarm::namespace_starting

//--------------------------------------------------------
/**
 *	Method      : Alarm::Alarm()
 *	Description : Constructors for a Tango device
 *                implementing the classAlarm
 */
//--------------------------------------------------------
Alarm::Alarm(Tango::DeviceClass *cl, string &s)
 : TANGO_BASE_CLASS(cl, s.c_str())
{
	/*----- PROTECTED REGION ID(Alarm::constructor_1) ENABLED START -----*/
	init_device();
	
	/*----- PROTECTED REGION END -----*/	//	Alarm::constructor_1
}
//--------------------------------------------------------
Alarm::Alarm(Tango::DeviceClass *cl, const char *s)
 : TANGO_BASE_CLASS(cl, s)
{
	/*----- PROTECTED REGION ID(Alarm::constructor_2) ENABLED START -----*/
	init_device();
	
	/*----- PROTECTED REGION END -----*/	//	Alarm::constructor_2
}
//--------------------------------------------------------
Alarm::Alarm(Tango::DeviceClass *cl, const char *s, const char *d)
 : TANGO_BASE_CLASS(cl, s, d)
{
	/*----- PROTECTED REGION ID(Alarm::constructor_3) ENABLED START -----*/
	init_device();
	
	/*----- PROTECTED REGION END -----*/	//	Alarm::constructor_3
}

//--------------------------------------------------------
/**
 *	Method      : Alarm::delete_device()
 *	Description : will be called at device destruction or at init command
 */
//--------------------------------------------------------
void Alarm::delete_device()
{
	DEBUG_STREAM << "Alarm::delete_device() " << device_name << endl;
	/*----- PROTECTED REGION ID(Alarm::delete_device) ENABLED START -----*/
	
	//	Delete device allocated objects
	//	Delete device's allocated object
	/*
	 * unsubscribe events and release memory
	 */
	DEBUG_STREAM << "Alarm::delete_device(): entering..." << endl;
	abortflag = true;
	DEBUG_STREAM << "Alarm::delete_device(): after abortflag=true..." << endl;
	try {
		events->unsubscribe_events();
	} catch (string& err) {
		ERROR_STREAM << err << endl;
	}
	DEBUG_STREAM << "Alarm::delete_device(): events unsubscribed!" << endl;
	/*
	 * kill alarm thread
	 */
	bei_t e;
	e.ev_name = ALARM_THREAD_EXIT;
	e.value.push_back(ALARM_THREAD_EXIT_VALUE);
	e.value.push_back(ALARM_THREAD_EXIT_VALUE);
	evlist.push_back(e);
#ifdef _RW_LOCK
	alarms.del_rwlock();
#endif
	alarms.stop_logdb();
	alarms.stop_cmdthread();
Loading full blame...