Newer
Older
/*----- PROTECTED REGION ID(AlarmHandlerClass.cpp) ENABLED START -----*/

Graziano Scalamera
committed
//=============================================================================
//

Graziano Scalamera
committed
//
// description : C++ source for the AlarmHandlerClass.

Graziano Scalamera
committed
// A singleton class derived from DeviceClass.
// It implements the command and attribute list
// and all properties and methods required
// by the AlarmHandler once per process.

Graziano Scalamera
committed
//
// project : Elettra alarm handler device server

Graziano Scalamera
committed
//
// 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)
//=============================================================================

Graziano Scalamera
committed
/*----- PROTECTED REGION END -----*/ // AlarmHandlerClass.cpp

Graziano Scalamera
committed
//-------------------------------------------------------------------
/**
* Create AlarmHandlerClass singleton and

Graziano Scalamera
committed
* return it in a C function for Python usage
*/
//-------------------------------------------------------------------
extern "C" {
#ifdef _TG_WINDOWS_
__declspec(dllexport)
#endif
Tango::DeviceClass *_create_AlarmHandler_class(const char *name) {
return AlarmHandler_ns::AlarmHandlerClass::init(name);

Graziano Scalamera
committed
}
}

Graziano Scalamera
committed
{
//===================================================================
// Initialize pointer for singleton pattern
//===================================================================
AlarmHandlerClass *AlarmHandlerClass::_instance = NULL;

Graziano Scalamera
committed
//--------------------------------------------------------
/**
* method : AlarmHandlerClass::AlarmHandlerClass(string &s)
* description : constructor for the AlarmHandlerClass

Graziano Scalamera
committed
*
* @param s The class name
*/
//--------------------------------------------------------
AlarmHandlerClass::AlarmHandlerClass(string &s):Tango::DeviceClass(s)

Graziano Scalamera
committed
{
TANGO_LOG_INFO << "Entering AlarmHandlerClass constructor" << endl;

Graziano Scalamera
committed
set_default_property();

Graziano Scalamera
committed
write_class_property();
/*----- PROTECTED REGION ID(AlarmHandlerClass::constructor) ENABLED START -----*/

Graziano Scalamera
committed
/*----- PROTECTED REGION END -----*/ // AlarmHandlerClass::constructor

Graziano Scalamera
committed
TANGO_LOG_INFO << "Leaving AlarmHandlerClass constructor" << endl;

Graziano Scalamera
committed
}
//--------------------------------------------------------
/**
* method : AlarmHandlerClass::~AlarmHandlerClass()
* description : destructor for the AlarmHandlerClass

Graziano Scalamera
committed
*/
//--------------------------------------------------------
AlarmHandlerClass::~AlarmHandlerClass()

Graziano Scalamera
committed
{
/*----- PROTECTED REGION ID(AlarmHandlerClass::destructor) ENABLED START -----*/

Graziano Scalamera
committed
/*----- PROTECTED REGION END -----*/ // AlarmHandlerClass::destructor

Graziano Scalamera
committed
_instance = NULL;
}
//--------------------------------------------------------
/**
* method : AlarmHandlerClass::init

Graziano Scalamera
committed
* description : Create the object if not already done.
* Otherwise, just return a pointer to the object
*
* @param name The class name
*/
//--------------------------------------------------------
AlarmHandlerClass *AlarmHandlerClass::init(const char *name)

Graziano Scalamera
committed
{
if (_instance == NULL)
{
try
{
string s(name);
_instance = new AlarmHandlerClass(s);

Graziano Scalamera
committed
}
catch (bad_alloc &)
{
throw;
}
}
return _instance;
}
//--------------------------------------------------------
/**
* method : AlarmHandlerClass::instance

Graziano Scalamera
committed
* description : Check if object already created,
* and return a pointer to the object
*/
//--------------------------------------------------------
AlarmHandlerClass *AlarmHandlerClass::instance()

Graziano Scalamera
committed
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{
if (_instance == NULL)
{
cerr << "Class is not initialised !!" << endl;
exit(-1);
}
return _instance;
}
//===================================================================
// Command execution method calls
//===================================================================
//--------------------------------------------------------
/**
* method : AckClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *AckClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "AckClass::execute(): arrived" << endl;

Graziano Scalamera
committed
const Tango::DevVarStringArray *argin;
extract(in_any, argin);
((static_cast<AlarmHandler *>(device))->ack(argin));

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : LoadClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *LoadClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "LoadClass::execute(): arrived" << endl;

Graziano Scalamera
committed
Tango::DevString argin;
extract(in_any, argin);
((static_cast<AlarmHandler *>(device))->load(argin));

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : RemoveClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *RemoveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "RemoveClass::execute(): arrived" << endl;

Graziano Scalamera
committed
Tango::DevString argin;
extract(in_any, argin);
((static_cast<AlarmHandler *>(device))->remove(argin));

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**

Graziano Scalamera
committed
* method : SearchAlarmClass::execute()

Graziano Scalamera
committed
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------

Graziano Scalamera
committed
CORBA::Any *SearchAlarmClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)

Graziano Scalamera
committed
{
TANGO_LOG_INFO << "SearchAlarmClass::execute(): arrived" << endl;

Graziano Scalamera
committed
Tango::DevString argin;
extract(in_any, argin);
return insert((static_cast<AlarmHandler *>(device))->search_alarm(argin));

Graziano Scalamera
committed
}
//--------------------------------------------------------
/**

Graziano Scalamera
committed
* method : StopAudibleClass::execute()

Graziano Scalamera
committed
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------

Graziano Scalamera
committed
CORBA::Any *StopAudibleClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))

Graziano Scalamera
committed
{
TANGO_LOG_INFO << "StopAudibleClass::execute(): arrived" << endl;
((static_cast<AlarmHandler *>(device))->stop_audible());

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : SilenceClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *SilenceClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "SilenceClass::execute(): arrived" << endl;

Graziano Scalamera
committed
const Tango::DevVarStringArray *argin;
extract(in_any, argin);
((static_cast<AlarmHandler *>(device))->silence(argin));

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : ModifyClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *ModifyClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "ModifyClass::execute(): arrived" << endl;

Graziano Scalamera
committed
Tango::DevString argin;
extract(in_any, argin);
((static_cast<AlarmHandler *>(device))->modify(argin));

Graziano Scalamera
committed
return new CORBA::Any();
}

Graziano Scalamera
committed
//--------------------------------------------------------
/**
* method : ShelveClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *ShelveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "ShelveClass::execute(): arrived" << endl;

Graziano Scalamera
committed
const Tango::DevVarStringArray *argin;
extract(in_any, argin);
((static_cast<AlarmHandler *>(device))->shelve(argin));

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : EnableClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *EnableClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "EnableClass::execute(): arrived" << endl;

Graziano Scalamera
committed
Tango::DevString argin;
extract(in_any, argin);
((static_cast<AlarmHandler *>(device))->enable(argin));

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : DisableClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *DisableClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "DisableClass::execute(): arrived" << endl;

Graziano Scalamera
committed
Tango::DevString argin;
extract(in_any, argin);
((static_cast<AlarmHandler *>(device))->disable(argin));

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : ResetStatisticsClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *ResetStatisticsClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
TANGO_LOG_INFO << "ResetStatisticsClass::execute(): arrived" << endl;
((static_cast<AlarmHandler *>(device))->reset_statistics());

Graziano Scalamera
committed
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : StopNewClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *StopNewClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
TANGO_LOG_INFO << "StopNewClass::execute(): arrived" << endl;
((static_cast<AlarmHandler *>(device))->stop_new());
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : GetAlarmInfoClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *GetAlarmInfoClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
TANGO_LOG_INFO << "GetAlarmInfoClass::execute(): arrived" << endl;

Graziano Scalamera
committed
const Tango::DevVarStringArray *argin;
extract(in_any, argin);
return insert((static_cast<AlarmHandler *>(device))->get_alarm_info(argin));
}
//--------------------------------------------------------
/**
* method : ReLoadAllClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *ReLoadAllClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
TANGO_LOG_INFO << "ReLoadAllClass::execute(): arrived" << endl;
((static_cast<AlarmHandler *>(device))->re_load_all());
return new CORBA::Any();
}

Graziano Scalamera
committed
//===================================================================
// Properties management
//===================================================================
//--------------------------------------------------------
/**
* Method : AlarmHandlerClass::get_class_property()

Graziano Scalamera
committed
* Description : Get the class property for specified name.
*/
//--------------------------------------------------------
Tango::DbDatum AlarmHandlerClass::get_class_property(string &prop_name)

Graziano Scalamera
committed
{
for (unsigned int i=0 ; i<cl_prop.size() ; i++)
if (cl_prop[i].name == prop_name)
return cl_prop[i];
// if not found, returns an empty DbDatum
return Tango::DbDatum(prop_name);
}
//--------------------------------------------------------
/**
* Method : AlarmHandlerClass::get_default_device_property()

Graziano Scalamera
committed
* Description : Return the default value for device property.
*/
//--------------------------------------------------------
Tango::DbDatum AlarmHandlerClass::get_default_device_property(string &prop_name)

Graziano Scalamera
committed
{
for (unsigned int i=0 ; i<dev_def_prop.size() ; i++)
if (dev_def_prop[i].name == prop_name)
return dev_def_prop[i];
// if not found, return an empty DbDatum
return Tango::DbDatum(prop_name);
}
//--------------------------------------------------------
/**
* Method : AlarmHandlerClass::get_default_class_property()

Graziano Scalamera
committed
* Description : Return the default value for class property.
*/
//--------------------------------------------------------
Tango::DbDatum AlarmHandlerClass::get_default_class_property(string &prop_name)

Graziano Scalamera
committed
{
for (unsigned int i=0 ; i<cl_def_prop.size() ; i++)
if (cl_def_prop[i].name == prop_name)
return cl_def_prop[i];
// if not found, return an empty DbDatum
return Tango::DbDatum(prop_name);
}
//--------------------------------------------------------
/**
* Method : AlarmHandlerClass::get_class_property()
* Description : Read database to initialize class property data members.
*/
//--------------------------------------------------------
void AlarmHandlerClass::get_class_property()
{
/*----- PROTECTED REGION ID(AlarmHandlerClass::get_class_property_before) ENABLED START -----*/
// Initialize class property data members
/*----- PROTECTED REGION END -----*/ // AlarmHandlerClass::get_class_property_before
// Read class properties from database.
cl_prop.push_back(Tango::DbDatum("GroupNames"));
cl_prop.push_back(Tango::DbDatum("SubscribeRetryPeriod"));
cl_prop.push_back(Tango::DbDatum("StatisticsTimeWindow"));
cl_prop.push_back(Tango::DbDatum("ErrorDelay"));

Graziano Scalamera
committed
cl_prop.push_back(Tango::DbDatum("SetAlarmQuality"));
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
// Call database and extract values
if (Tango::Util::instance()->_UseDb==true)
get_db_class()->get_property(cl_prop);
Tango::DbDatum def_prop;
int i = -1;
// Try to extract GroupNames value
if (cl_prop[++i].is_empty()==false) cl_prop[i] >> groupNames;
else
{
// Check default value for GroupNames
def_prop = get_default_class_property(cl_prop[i].name);
if (def_prop.is_empty()==false)
{
def_prop >> groupNames;
cl_prop[i] << groupNames;
}
}
// Try to extract SubscribeRetryPeriod value
if (cl_prop[++i].is_empty()==false) cl_prop[i] >> subscribeRetryPeriod;
else
{
// Check default value for SubscribeRetryPeriod
def_prop = get_default_class_property(cl_prop[i].name);
if (def_prop.is_empty()==false)
{
def_prop >> subscribeRetryPeriod;
cl_prop[i] << subscribeRetryPeriod;
}
}
// Try to extract StatisticsTimeWindow value
if (cl_prop[++i].is_empty()==false) cl_prop[i] >> statisticsTimeWindow;
else
{
// Check default value for StatisticsTimeWindow
def_prop = get_default_class_property(cl_prop[i].name);
if (def_prop.is_empty()==false)
{
def_prop >> statisticsTimeWindow;
cl_prop[i] << statisticsTimeWindow;
}
}
// Try to extract ErrorDelay value
if (cl_prop[++i].is_empty()==false) cl_prop[i] >> errorDelay;
else
{
// Check default value for ErrorDelay
def_prop = get_default_class_property(cl_prop[i].name);
if (def_prop.is_empty()==false)
{
def_prop >> errorDelay;
cl_prop[i] << errorDelay;
}
}

Graziano Scalamera
committed
// Try to extract SetAlarmQuality value
if (cl_prop[++i].is_empty()==false) cl_prop[i] >> setAlarmQuality;
else
{
// Check default value for SetAlarmQuality
def_prop = get_default_class_property(cl_prop[i].name);
if (def_prop.is_empty()==false)
{
def_prop >> setAlarmQuality;
cl_prop[i] << setAlarmQuality;
}
}
/*----- PROTECTED REGION ID(AlarmHandlerClass::get_class_property_after) ENABLED START -----*/
// Check class property data members init
/*----- PROTECTED REGION END -----*/ // AlarmHandlerClass::get_class_property_after
}

Graziano Scalamera
committed
//--------------------------------------------------------
/**
* Method : AlarmHandlerClass::set_default_property()

Graziano Scalamera
committed
* Description : Set default property (class and device) for wizard.
* For each property, add to wizard property name and description.
* If default value has been set, add it to wizard property and
* store it in a DbDatum.
*/
//--------------------------------------------------------
void AlarmHandlerClass::set_default_property()

Graziano Scalamera
committed
{
string prop_name;
string prop_desc;
string prop_def;
vector<string> vect_data;
// Set Default Class Properties
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
prop_name = "GroupNames";
prop_desc = "Labels for Group mask, first is for mask 0x00";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
cl_def_prop.push_back(data);
add_wiz_class_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_class_prop(prop_name, prop_desc);
prop_name = "SubscribeRetryPeriod";
prop_desc = "Retry subscription period in seconds";
prop_def = "30";
vect_data.clear();
vect_data.push_back("30");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
cl_def_prop.push_back(data);
add_wiz_class_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_class_prop(prop_name, prop_desc);
prop_name = "StatisticsTimeWindow";
prop_desc = "Time window to compute statistics in seconds";
prop_def = "60";
vect_data.clear();
vect_data.push_back("60");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
cl_def_prop.push_back(data);
add_wiz_class_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_class_prop(prop_name, prop_desc);
prop_name = "ErrorDelay";
prop_desc = "Delay in seconds before changing to ERROR state after an exception is received.";
prop_def = "30";
vect_data.clear();
vect_data.push_back("30");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
cl_def_prop.push_back(data);
add_wiz_class_prop(prop_name, prop_desc, prop_def);
}

Graziano Scalamera
committed
else
add_wiz_class_prop(prop_name, prop_desc);
prop_name = "SetAlarmQuality";
prop_desc = "Set alarm attribute quality as computed using quality of attributes in the formula";
prop_def = "false";
vect_data.clear();
vect_data.push_back("false");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
cl_def_prop.push_back(data);
add_wiz_class_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_class_prop(prop_name, prop_desc);

Graziano Scalamera
committed
// Set Default device Properties
prop_name = "GroupNames";
prop_desc = "Labels for Group mask, first is for mask 0x00";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);

Graziano Scalamera
committed
prop_name = "SubscribeRetryPeriod";
prop_desc = "Retry subscription period in seconds";
prop_def = "30";

Graziano Scalamera
committed
vect_data.clear();

Graziano Scalamera
committed
vect_data.push_back("30");

Graziano Scalamera
committed
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);

Graziano Scalamera
committed
prop_name = "StatisticsTimeWindow";
prop_desc = "Time window to compute statistics in seconds";
prop_def = "60";

Graziano Scalamera
committed
vect_data.push_back("60");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "ErrorDelay";
prop_desc = "Delay in seconds before changing to ERROR state after an exception is received.";
prop_def = "30";
vect_data.clear();
vect_data.push_back("30");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);

Graziano Scalamera
committed
prop_name = "SetAlarmQuality";
prop_desc = "Set alarm attribute quality as computed using quality of attributes in the formula";
prop_def = "false";
vect_data.clear();
vect_data.push_back("false");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);

Graziano Scalamera
committed
}
//--------------------------------------------------------
/**
* Method : AlarmHandlerClass::write_class_property()

Graziano Scalamera
committed
* Description : Set class description fields as property in database
*/
//--------------------------------------------------------
void AlarmHandlerClass::write_class_property()

Graziano Scalamera
committed
{
// First time, check if database used
if (Tango::Util::_UseDb == false)
return;
Tango::DbData data;
string classname = get_name();
string header;
string::size_type start, end;
// Put title
Tango::DbDatum title("ProjectTitle");
string str_title("Elettra alarm handler device server");

Graziano Scalamera
committed
title << str_title;
data.push_back(title);
// Put Description
Tango::DbDatum description("Description");
vector<string> str_desc;
str_desc.push_back("Elettra alarm handler device server");

Graziano Scalamera
committed
description << str_desc;
data.push_back(description);
// Put inheritance
Tango::DbDatum inher_datum("InheritedFrom");
vector<string> inheritance;
inheritance.push_back("TANGO_BASE_CLASS");
inher_datum << inheritance;
data.push_back(inher_datum);
// Call database and and values
get_db_class()->put_property(data);
}
//===================================================================
// Factory methods
//===================================================================
//--------------------------------------------------------
/**
* Method : AlarmHandlerClass::device_factory()

Graziano Scalamera
committed
* Description : Create the device object(s)
* and store them in the device list
*/
//--------------------------------------------------------
void AlarmHandlerClass::device_factory(const Tango::DevVarStringArray *devlist_ptr)

Graziano Scalamera
committed
{
/*----- PROTECTED REGION ID(AlarmHandlerClass::device_factory_before) ENABLED START -----*/

Graziano Scalamera
committed
// Add your own code
/*----- PROTECTED REGION END -----*/ // AlarmHandlerClass::device_factory_before

Graziano Scalamera
committed
// Create devices and add it into the device list
for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
{
TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << endl;
device_list.push_back(new AlarmHandler(this, (*devlist_ptr)[i]));

Graziano Scalamera
committed
}
// Manage dynamic attributes if any
erase_dynamic_attributes(devlist_ptr, get_class_attr()->get_attr_list());
// Export devices to the outside world
for (unsigned long i=1 ; i<=devlist_ptr->length() ; i++)
{
// Add dynamic attributes if any
AlarmHandler *dev = static_cast<AlarmHandler *>(device_list[device_list.size()-i]);

Graziano Scalamera
committed
dev->add_dynamic_attributes();
// Check before if database used.
if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false))
export_device(dev);
else
export_device(dev, dev->get_name().c_str());
}
/*----- PROTECTED REGION ID(AlarmHandlerClass::device_factory_after) ENABLED START -----*/

Graziano Scalamera
committed
// Add your own code
/*----- PROTECTED REGION END -----*/ // AlarmHandlerClass::device_factory_after

Graziano Scalamera
committed
}
//--------------------------------------------------------
/**
* Method : AlarmHandlerClass::attribute_factory()

Graziano Scalamera
committed
* Description : Create the attribute object(s)
* and store them in the attribute list
*/
//--------------------------------------------------------
void AlarmHandlerClass::attribute_factory(vector<Tango::Attr *> &att_list)

Graziano Scalamera
committed
{
/*----- PROTECTED REGION ID(AlarmHandlerClass::attribute_factory_before) ENABLED START -----*/

Graziano Scalamera
committed
// Add your own code
/*----- PROTECTED REGION END -----*/ // AlarmHandlerClass::attribute_factory_before
// Attribute : alarmAudible
alarmAudibleAttrib *alarmaudible = new alarmAudibleAttrib();
Tango::UserDefaultAttrProp alarmaudible_prop;
alarmaudible_prop.set_description("True if there is at least one alarm that needs audible indication on the GUI");
// label not set for alarmAudible
// unit not set for alarmAudible
// standard_unit not set for alarmAudible
// display_unit not set for alarmAudible
// format not set for alarmAudible
// max_value not set for alarmAudible
// min_value not set for alarmAudible
// max_alarm not set for alarmAudible
// min_alarm not set for alarmAudible
// max_warning not set for alarmAudible
// min_warning not set for alarmAudible
// delta_t not set for alarmAudible
// delta_val not set for alarmAudible

Graziano Scalamera
committed
alarmaudible->set_default_properties(alarmaudible_prop);

Graziano Scalamera
committed
// Not Polled
alarmaudible->set_disp_level(Tango::OPERATOR);

Graziano Scalamera
committed
// Not Memorized

Graziano Scalamera
committed
alarmaudible->set_change_event(true, true);
alarmaudible->set_archive_event(true, true);

Graziano Scalamera
committed
// Attribute : StatisticsResetTime
StatisticsResetTimeAttrib *statisticsresettime = new StatisticsResetTimeAttrib();
Tango::UserDefaultAttrProp statisticsresettime_prop;
statisticsresettime_prop.set_description("Time elapsed in seconds since last Resetstatistics");
// label not set for StatisticsResetTime
statisticsresettime_prop.set_unit("s");
statisticsresettime_prop.set_standard_unit("1");
statisticsresettime_prop.set_display_unit("s");
// format not set for StatisticsResetTime
// max_value not set for StatisticsResetTime
// min_value not set for StatisticsResetTime
// max_alarm not set for StatisticsResetTime
// min_alarm not set for StatisticsResetTime
// max_warning not set for StatisticsResetTime
// min_warning not set for StatisticsResetTime
// delta_t not set for StatisticsResetTime
// delta_val not set for StatisticsResetTime
statisticsresettime->set_default_properties(statisticsresettime_prop);
// Not Polled
statisticsresettime->set_disp_level(Tango::OPERATOR);
// Not Memorized
att_list.push_back(statisticsresettime);

Graziano Scalamera
committed
// Attribute : alarm
alarmAttrib *alarm = new alarmAttrib();
Tango::UserDefaultAttrProp alarm_prop;
// description not set for alarm
// label not set for alarm
// unit not set for alarm
// standard_unit not set for alarm
// display_unit not set for alarm
// format not set for alarm
// max_value not set for alarm
// min_value not set for alarm
// max_alarm not set for alarm
// min_alarm not set for alarm
// max_warning not set for alarm
// min_warning not set for alarm
// delta_t not set for alarm
// delta_val not set for alarm
alarm->set_default_properties(alarm_prop);
// Not Polled
alarm->set_disp_level(Tango::OPERATOR);
// Not Memorized
att_list.push_back(alarm);
// Attribute : alarmNormal
alarmNormalAttrib *alarmnormal = new alarmNormalAttrib();
Tango::UserDefaultAttrProp alarmnormal_prop;
alarmnormal_prop.set_description("List of alarms in normal state");
// label not set for alarmNormal
// unit not set for alarmNormal
// standard_unit not set for alarmNormal
// display_unit not set for alarmNormal
// format not set for alarmNormal
// max_value not set for alarmNormal
// min_value not set for alarmNormal
// max_alarm not set for alarmNormal
// min_alarm not set for alarmNormal
// max_warning not set for alarmNormal
// min_warning not set for alarmNormal
// delta_t not set for alarmNormal
// delta_val not set for alarmNormal

Graziano Scalamera
committed
alarmnormal->set_default_properties(alarmnormal_prop);

Graziano Scalamera
committed
// Not Polled
alarmnormal->set_disp_level(Tango::OPERATOR);

Graziano Scalamera
committed
// Not Memorized
alarmnormal->set_change_event(true, true);
alarmnormal->set_archive_event(true, true);
att_list.push_back(alarmnormal);
// Attribute : alarmUnacknowledged
alarmUnacknowledgedAttrib *alarmunacknowledged = new alarmUnacknowledgedAttrib();
Tango::UserDefaultAttrProp alarmunacknowledged_prop;
alarmunacknowledged_prop.set_description("List of alarms in unacknowledged state");
// label not set for alarmUnacknowledged
// unit not set for alarmUnacknowledged
// standard_unit not set for alarmUnacknowledged
// display_unit not set for alarmUnacknowledged
// format not set for alarmUnacknowledged
// max_value not set for alarmUnacknowledged
// min_value not set for alarmUnacknowledged
// max_alarm not set for alarmUnacknowledged
// min_alarm not set for alarmUnacknowledged
// max_warning not set for alarmUnacknowledged
// min_warning not set for alarmUnacknowledged
// delta_t not set for alarmUnacknowledged
// delta_val not set for alarmUnacknowledged

Graziano Scalamera
committed
alarmunacknowledged->set_default_properties(alarmunacknowledged_prop);

Graziano Scalamera
committed
// Not Polled
alarmunacknowledged->set_disp_level(Tango::OPERATOR);

Graziano Scalamera
committed
// Not Memorized
alarmunacknowledged->set_change_event(true, true);
alarmunacknowledged->set_archive_event(true, true);
att_list.push_back(alarmunacknowledged);
// Attribute : alarmAcknowledged
alarmAcknowledgedAttrib *alarmacknowledged = new alarmAcknowledgedAttrib();
Tango::UserDefaultAttrProp alarmacknowledged_prop;
alarmacknowledged_prop.set_description("List of alarms in acknowledged state");
// label not set for alarmAcknowledged
// unit not set for alarmAcknowledged
// standard_unit not set for alarmAcknowledged
// display_unit not set for alarmAcknowledged
// format not set for alarmAcknowledged
// max_value not set for alarmAcknowledged
// min_value not set for alarmAcknowledged
// max_alarm not set for alarmAcknowledged
// min_alarm not set for alarmAcknowledged
// max_warning not set for alarmAcknowledged
// min_warning not set for alarmAcknowledged
// delta_t not set for alarmAcknowledged
// delta_val not set for alarmAcknowledged

Graziano Scalamera
committed
alarmacknowledged->set_default_properties(alarmacknowledged_prop);

Graziano Scalamera
committed
// Not Polled
alarmacknowledged->set_disp_level(Tango::OPERATOR);

Graziano Scalamera
committed
// Not Memorized
alarmacknowledged->set_change_event(true, true);
alarmacknowledged->set_archive_event(true, true);
att_list.push_back(alarmacknowledged);
// Attribute : alarmUnacknowledgedNormal
alarmUnacknowledgedNormalAttrib *alarmunacknowledgednormal = new alarmUnacknowledgedNormalAttrib();
Tango::UserDefaultAttrProp alarmunacknowledgednormal_prop;
alarmunacknowledgednormal_prop.set_description("List of alarms in unacknowledged normal state");
// label not set for alarmUnacknowledgedNormal
// unit not set for alarmUnacknowledgedNormal
// standard_unit not set for alarmUnacknowledgedNormal
// display_unit not set for alarmUnacknowledgedNormal
// format not set for alarmUnacknowledgedNormal
// max_value not set for alarmUnacknowledgedNormal
// min_value not set for alarmUnacknowledgedNormal
// max_alarm not set for alarmUnacknowledgedNormal
// min_alarm not set for alarmUnacknowledgedNormal
// max_warning not set for alarmUnacknowledgedNormal
// min_warning not set for alarmUnacknowledgedNormal
// delta_t not set for alarmUnacknowledgedNormal
// delta_val not set for alarmUnacknowledgedNormal

Graziano Scalamera
committed
alarmunacknowledgednormal->set_default_properties(alarmunacknowledgednormal_prop);

Graziano Scalamera
committed
// Not Polled
alarmunacknowledgednormal->set_disp_level(Tango::OPERATOR);