Commit 0ce0e96b authored by Marco De Marco's avatar Marco De Marco
Browse files

Properties added, rcsid removed

parent b7532089
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
/*----- PROTECTED REGION ID(MetadataImporter::ClassFactory.cpp) ENABLED START -----*/
static const char *RcsId = "$Id:  $";
//=============================================================================
//
// file :        ClassFactory.cpp
+204 −6
Original line number Diff line number Diff line
/*----- PROTECTED REGION ID(MetadataImporter.cpp) ENABLED START -----*/
static const char *RcsId = "$Id:  $";
//=============================================================================
//
// file :        MetadataImporter.cpp
@@ -58,8 +57,10 @@ static const char *RcsId = "$Id: $";
//
//  Command name  |  Method name
//================================================================
//  State         |  Inherited (no method)
//  Status        |  Inherited (no method)
//  State         |  Inherited (no method)
//  On            |  on
//  Off           |  off
//================================================================

//================================================================
@@ -136,20 +137,150 @@ void MetadataImporter::init_device()
	DEBUG_STREAM << "MetadataImporter::init_device() create device " << device_name << endl;
	/*----- PROTECTED REGION ID(MetadataImporter::init_device_before) ENABLED START -----*/

	//	Initialization before get_device_property() call
    set_state(Tango::INIT);
    set_status("Initializing device");

	/*----- PROTECTED REGION END -----*/	//	MetadataImporter::init_device_before

	//	No device property to be read from database

	//	Get the device properties from database
	get_device_property();


	/*----- PROTECTED REGION ID(MetadataImporter::init_device) ENABLED START -----*/

	//	Initialize device
    if(get_state() != Tango::FAULT)
    {
        try
        {
            /*
            if(enableSSL)
                m_client_sp;
            else
                m_client_sp;
            */
        }
        catch(std::exception& ex)
        {
            set_state(Tango::FAULT);
            std::stringstream error_stream;
            error_stream << "MetadataImporter::init_device() " << ex.what() << std::endl;
            set_status(error_stream.str());
        }
        catch(...)
        {
            set_state(Tango::FAULT);
            set_status("MetadataImporter::init_device() unknown error");
        }
    }

	/*----- PROTECTED REGION END -----*/	//	MetadataImporter::init_device
}

//--------------------------------------------------------
/**
 *	Method      : MetadataImporter::get_device_property()
 *	Description : Read database to initialize property data members.
 */
//--------------------------------------------------------
void MetadataImporter::get_device_property()
{
	/*----- PROTECTED REGION ID(MetadataImporter::get_device_property_before) ENABLED START -----*/

	//	Initialize property data members

	/*----- PROTECTED REGION END -----*/	//	MetadataImporter::get_device_property_before


	//	Read device properties from database.
	Tango::DbData	dev_prop;
	dev_prop.push_back(Tango::DbDatum("CertificateFile"));
	dev_prop.push_back(Tango::DbDatum("Address"));
	dev_prop.push_back(Tango::DbDatum("Port"));
	dev_prop.push_back(Tango::DbDatum("EnableSSL"));

	//	is there at least one property to be read ?
	if (dev_prop.size()>0)
	{
		//	Call database and extract values
		if (Tango::Util::instance()->_UseDb==true)
			get_db_device()->get_property(dev_prop);

		//	get instance on MetadataImporterClass to get class property
		Tango::DbDatum	def_prop, cl_prop;
		MetadataImporterClass	*ds_class =
			(static_cast<MetadataImporterClass *>(get_device_class()));
		int	i = -1;

		//	Try to initialize CertificateFile from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  certificateFile;
		else {
			//	Try to initialize CertificateFile from default device value
			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
			if (def_prop.is_empty()==false)	def_prop  >>  certificateFile;
		}
		//	And try to extract CertificateFile value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  certificateFile;

		//	Try to initialize Address from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  address;
		else {
			//	Try to initialize Address from default device value
			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
			if (def_prop.is_empty()==false)	def_prop  >>  address;
		}
		//	And try to extract Address value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  address;

		//	Try to initialize Port from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  port;
		else {
			//	Try to initialize Port from default device value
			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
			if (def_prop.is_empty()==false)	def_prop  >>  port;
		}
		//	And try to extract Port value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  port;

		//	Try to initialize EnableSSL from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  enableSSL;
		else {
			//	Try to initialize EnableSSL from default device value
			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
			if (def_prop.is_empty()==false)	def_prop  >>  enableSSL;
		}
		//	And try to extract EnableSSL value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  enableSSL;

	}

	/*----- PROTECTED REGION ID(MetadataImporter::get_device_property_after) ENABLED START -----*/

	try
    {
        if(address.empty())
            throw(invalid_argument("Address property is empty or not defined"));

        if(port<1 || port>MAX_DMDB_PORT)
            throw(invalid_argument("Port property out of range or not defined"));

        if(enableSSL && certificateFile.empty())
            throw(invalid_argument("CertificateFile property is empty or not defined"));
    }
    catch(invalid_argument& ex)
    {
        set_state(Tango::FAULT);
        stringstream error_stream;
        error_stream << "FitsImporter::get_device_property() " << ex.what() << endl;
        set_status(error_stream.str());
    }

	/*----- PROTECTED REGION END -----*/	//	MetadataImporter::get_device_property_after
}

//--------------------------------------------------------
/**
@@ -162,7 +293,10 @@ void MetadataImporter::always_executed_hook()
	INFO_STREAM << "MetadataImporter::always_executed_hook()  " << device_name << endl;
	/*----- PROTECTED REGION ID(MetadataImporter::always_executed_hook) ENABLED START -----*/

	//	code always executed before all requests
    if(get_state() != Tango::FAULT)
    {

    }

	/*----- PROTECTED REGION END -----*/	//	MetadataImporter::always_executed_hook
}
@@ -200,6 +334,70 @@ void MetadataImporter::add_dynamic_attributes()
	/*----- PROTECTED REGION END -----*/	//	MetadataImporter::add_dynamic_attributes
}

//--------------------------------------------------------
/**
 *	Command On related method
 *	Description:
 *
 */
//--------------------------------------------------------
void MetadataImporter::on()
{
	DEBUG_STREAM << "MetadataImporter::On()  - " << device_name << endl;
	/*----- PROTECTED REGION ID(MetadataImporter::on) ENABLED START -----*/

    try
    {

    }
    catch(std::exception& ex)
    {
        set_state(Tango::FAULT);
        std::stringstream error_stream;
        error_stream << "MetadataImporter::On() " << ex.what() << std::endl;
        set_status(error_stream.str());
    }
    catch(...)
    {
        set_state(Tango::FAULT);
        set_status("MetadataImporter::On() unknown error");
    }


	/*----- PROTECTED REGION END -----*/	//	MetadataImporter::on
}
//--------------------------------------------------------
/**
 *	Command Off related method
 *	Description:
 *
 */
//--------------------------------------------------------
void MetadataImporter::off()
{
	DEBUG_STREAM << "MetadataImporter::Off()  - " << device_name << endl;
	/*----- PROTECTED REGION ID(MetadataImporter::off) ENABLED START -----*/

    try
    {

    }
    catch(std::exception& ex)
    {
        set_state(Tango::FAULT);
        std::stringstream error_stream;
        error_stream << "MetadataImporter::Off() " << ex.what() << std::endl;
        set_status(error_stream.str());
    }
    catch(...)
    {
        set_state(Tango::FAULT);
        set_status("MetadataImporter::Off() unknown error");
    }


	/*----- PROTECTED REGION END -----*/	//	MetadataImporter::off
}

/*----- PROTECTED REGION ID(MetadataImporter::namespace_ending) ENABLED START -----*/

+31 −0
Original line number Diff line number Diff line
@@ -65,11 +65,24 @@ class MetadataImporter : public TANGO_BASE_CLASS
//------------------------------------------------------------------------------
//  [Private] Class variables
//------------------------------------------------------------------------------
    //Client class shared pointer
    Client::SP m_client_sp;

    //Max port number allowed value
    static const unsigned int MAX_DMDB_PORT = 65535;

/*----- PROTECTED REGION END -----*/	//	MetadataImporter::Data Members

//	Device property data members
public:
	//	CertificateFile:	Absolute path to certificate chain file
	string	certificateFile;
	//	Address:	Remote connection address
	string	address;
	//	Port:	Remote connection port
	Tango::DevULong	port;
	//	EnableSSL:	Enable or disable SSL connections
	Tango::DevBoolean	enableSSL;


//	Constructors and destructors
@@ -112,6 +125,10 @@ public:
	 *	Initialize the device
	 */
	virtual void init_device();
	/*
	 *	Read the device properties from database
	 */
	void get_device_property();
	/*
	 *	Always executed method before execution command method.
	 */
@@ -141,6 +158,20 @@ public:

//	Command related methods
public:
	/**
	 *	Command On related method
	 *	Description:
	 *
	 */
	virtual void on();
	virtual bool is_On_allowed(const CORBA::Any &any);
	/**
	 *	Command Off related method
	 *	Description:
	 *
	 */
	virtual void off();
	virtual bool is_Off_allowed(const CORBA::Any &any);


/*----- PROTECTED REGION ID(MetadataImporter::Additional Method prototypes) ENABLED START -----*/
+45 −6
Original line number Diff line number Diff line
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
  <classes name="MetadataImporter" pogoRevision="8.1">
    <description description="Metadata importer device server" title="Metadata importer device server" sourcePath="/home/mdm/workspace/nadir/metadata_importer/src" language="Cpp" filestogenerate="XMI   file,Code files" license="LGPL" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false">
    <description description="Metadata importer device server" title="Metadata importer device server" sourcePath="/home/mdm/workspace/nadir/metadata_importer/src" language="Cpp" filestogenerate="XMI   file,Code files" license="LGPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
      <inheritances classname="Device_Impl" sourcePath=""/>
      <identification contact="at oats.inaf.it - demarco" author="demarco" emailDomain="oats.inaf.it" classFamily="Communication" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference=""/>
    </description>
    <classProperties name="CertificateFile" description="Absolute path to certificate chain file">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <deviceProperties name="CertificateFile" description="Absolute path to certificate chain file">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="Address" description="Remote connection address">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="Port" description="Remote connection port">
      <type xsi:type="pogoDsl:UIntType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="EnableSSL" description="Enable or disable SSL connections">
      <type xsi:type="pogoDsl:BooleanType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
      <DefaultPropValue>false</DefaultPropValue>
    </deviceProperties>
    <commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
      <argin description="none">
        <type xsi:type="pogoDsl:VoidType"/>
      </argin>
      <argout description="Device status">
        <type xsi:type="pogoDsl:ConstStringType"/>
      </argout>
      <status abstract="true" inherited="true" concrete="true"/>
    </commands>
    <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
      <argin description="none">
        <type xsi:type="pogoDsl:VoidType"/>
@@ -14,14 +44,23 @@
      </argout>
      <status abstract="true" inherited="true" concrete="true"/>
    </commands>
    <commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
      <argin description="none">
    <commands name="On" description="" execMethod="on" displayLevel="OPERATOR" polledPeriod="0">
      <argin description="">
        <type xsi:type="pogoDsl:VoidType"/>
      </argin>
      <argout description="Device status">
        <type xsi:type="pogoDsl:ConstStringType"/>
      <argout description="">
        <type xsi:type="pogoDsl:VoidType"/>
      </argout>
      <status abstract="true" inherited="true" concrete="true"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </commands>
    <commands name="Off" description="" execMethod="off" displayLevel="OPERATOR" polledPeriod="0">
      <argin description="">
        <type xsi:type="pogoDsl:VoidType"/>
      </argin>
      <argout description="">
        <type xsi:type="pogoDsl:VoidType"/>
      </argout>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </commands>
    <preferences docHome="./doc_html" makefileHome="/usr/local/tango-8.1.2/share/pogo/preferences"/>
  </classes>
+195 −34
Original line number Diff line number Diff line
/*----- PROTECTED REGION ID(MetadataImporterClass.cpp) ENABLED START -----*/
static const char *RcsId      = "$Id:  $";
static const char *TagName    = "$Name:  $";
static const char *CvsPath    = "$Source:  $";
static const char *SvnPath    = "$HeadURL:  $";
@@ -85,6 +84,7 @@ MetadataImporterClass::MetadataImporterClass(string &s):Tango::DeviceClass(s)
{
	cout2 << "Entering MetadataImporterClass constructor" << endl;
	set_default_property();
	get_class_property();
	write_class_property();

	/*----- PROTECTED REGION ID(MetadataImporterClass::constructor) ENABLED START -----*/
@@ -158,6 +158,42 @@ MetadataImporterClass *MetadataImporterClass::instance()
//===================================================================
//	Command execution method calls
//===================================================================
//--------------------------------------------------------
/**
 * method : 		OnClass::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 *OnClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	cout2 << "OnClass::execute(): arrived" << endl;
	((static_cast<MetadataImporter *>(device))->on());
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		OffClass::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 *OffClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	cout2 << "OffClass::execute(): arrived" << endl;
	((static_cast<MetadataImporter *>(device))->off());
	return new CORBA::Any();
}


//===================================================================
//	Properties management
@@ -207,6 +243,47 @@ Tango::DbDatum MetadataImporterClass::get_default_class_property(string &prop_na
	return Tango::DbDatum(prop_name);
}

//--------------------------------------------------------
/**
 *	Method      : MetadataImporterClass::get_class_property()
 *	Description : Read database to initialize class property data members.
 */
//--------------------------------------------------------
void MetadataImporterClass::get_class_property()
{
	/*----- PROTECTED REGION ID(MetadataImporterClass::get_class_property_before) ENABLED START -----*/

	//	Initialize class property data members

	/*----- PROTECTED REGION END -----*/	//	MetadataImporterClass::get_class_property_before
	//	Read class properties from database.
	cl_prop.push_back(Tango::DbDatum("CertificateFile"));

	//	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 CertificateFile value
	if (cl_prop[++i].is_empty()==false)	cl_prop[i]  >>  certificateFile;
	else
	{
		//	Check default value for CertificateFile
		def_prop = get_default_class_property(cl_prop[i].name);
		if (def_prop.is_empty()==false)
		{
			def_prop    >>  certificateFile;
			cl_prop[i]  <<  certificateFile;
		}
	}
	/*----- PROTECTED REGION ID(MetadataImporterClass::get_class_property_after) ENABLED START -----*/

	//	Check class property data members init

	/*----- PROTECTED REGION END -----*/	//	MetadataImporterClass::get_class_property_after

}

//--------------------------------------------------------
/**
@@ -225,8 +302,74 @@ void MetadataImporterClass::set_default_property()
	vector<string>	vect_data;

	//	Set Default Class Properties
	prop_name = "CertificateFile";
	prop_desc = "Absolute path to certificate chain file";
	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);

	//	Set Default device Properties
	prop_name = "CertificateFile";
	prop_desc = "Absolute path to certificate chain file";
	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);
	prop_name = "Address";
	prop_desc = "Remote connection address";
	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);
	prop_name = "Port";
	prop_desc = "Remote connection port";
	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);
	prop_name = "EnableSSL";
	prop_desc = "Enable or disable SSL connections";
	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);
}

//--------------------------------------------------------
@@ -455,6 +598,24 @@ void MetadataImporterClass::command_factory()
	/*----- PROTECTED REGION END -----*/	//	MetadataImporterClass::command_factory_before


	//	Command On
	OnClass	*pOnCmd =
		new OnClass("On",
			Tango::DEV_VOID, Tango::DEV_VOID,
			"",
			"",
			Tango::OPERATOR);
	command_list.push_back(pOnCmd);

	//	Command Off
	OffClass	*pOffCmd =
		new OffClass("Off",
			Tango::DEV_VOID, Tango::DEV_VOID,
			"",
			"",
			Tango::OPERATOR);
	command_list.push_back(pOffCmd);

	/*----- PROTECTED REGION ID(MetadataImporterClass::command_factory_after) ENABLED START -----*/

	//	Add your own code
Loading