Commit 21ceb825 authored by Marco De Marco's avatar Marco De Marco
Browse files

Sessions basic methods implemented, not yet completed

parent 77a51e63
Loading
Loading
Loading
Loading
+67 −1
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@
//================================================================
//  State         |  Inherited (no method)
//  Status        |  Inherited (no method)
//  On            |  on
//  Off           |  off
//================================================================

//================================================================
@@ -343,7 +345,7 @@ void MetadataExporter::always_executed_hook()

    if(get_state() != Tango::FAULT)
    {

        //TODO: state and status
    }

	/*----- PROTECTED REGION END -----*/	//	MetadataExporter::always_executed_hook
@@ -382,6 +384,70 @@ void MetadataExporter::add_dynamic_attributes()
	/*----- PROTECTED REGION END -----*/	//	MetadataExporter::add_dynamic_attributes
}

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

    try
    {
        if(m_server_sp)
            m_server_sp->start();
    }
    catch(std::exception& ex)
    {
        set_state(Tango::FAULT);
        std::stringstream error_stream;
        error_stream << "MetadataExporter::On() " << ex.what() << std::endl;
        set_status(error_stream.str());
    }
    catch(...)
    {
        set_state(Tango::FAULT);
        set_status("MetadataExporter::On() unknown error");
    }

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

    try
    {
        if(m_server_sp)
            m_server_sp->start();
    }
    catch(std::exception& ex)
    {
        set_state(Tango::FAULT);
        std::stringstream error_stream;
        error_stream << "MetadataExporter::Off() " << ex.what() << std::endl;
        set_status(error_stream.str());
    }
    catch(...)
    {
        set_state(Tango::FAULT);
        set_status("MetadataExporter::Off() unknown error");
    }

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

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

+15 −1
Original line number Diff line number Diff line
@@ -169,6 +169,20 @@ public:

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


/*----- PROTECTED REGION ID(MetadataExporter::Additional Method prototypes) ENABLED START -----*/
+18 −0
Original line number Diff line number Diff line
@@ -65,6 +65,24 @@
      </argout>
      <status abstract="true" inherited="true" concrete="true"/>
    </commands>
    <commands name="On" description="Activate metadata exporter" execMethod="on" 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>
    <commands name="Off" description="Deactivate fits importer" 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>
</pogoDsl:PogoSystem>
+54 −0
Original line number Diff line number Diff line
@@ -158,6 +158,42 @@ MetadataExporterClass *MetadataExporterClass::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<MetadataExporter *>(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<MetadataExporter *>(device))->off());
	return new CORBA::Any();
}


//===================================================================
//	Properties management
@@ -654,6 +690,24 @@ void MetadataExporterClass::command_factory()
	/*----- PROTECTED REGION END -----*/	//	MetadataExporterClass::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(MetadataExporterClass::command_factory_after) ENABLED START -----*/
	
	//	Add your own code
+50 −0
Original line number Diff line number Diff line
@@ -56,6 +56,56 @@ namespace MetadataExporter_ns

/*----- PROTECTED REGION END -----*/	//	MetadataExporterClass::classes for dynamic creation

//=========================================
//	Define classes for commands
//=========================================
//	Command On class definition
class OnClass : public Tango::Command
{
public:
	OnClass(const char   *name,
	               Tango::CmdArgType in,
				   Tango::CmdArgType out,
				   const char        *in_desc,
				   const char        *out_desc,
				   Tango::DispLevel  level)
	:Command(name,in,out,in_desc,out_desc, level)	{};

	OnClass(const char   *name,
	               Tango::CmdArgType in,
				   Tango::CmdArgType out)
	:Command(name,in,out)	{};
	~OnClass() {};
	
	virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
	virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
	{return (static_cast<MetadataExporter *>(dev))->is_On_allowed(any);}
};

//	Command Off class definition
class OffClass : public Tango::Command
{
public:
	OffClass(const char   *name,
	               Tango::CmdArgType in,
				   Tango::CmdArgType out,
				   const char        *in_desc,
				   const char        *out_desc,
				   Tango::DispLevel  level)
	:Command(name,in,out,in_desc,out_desc, level)	{};

	OffClass(const char   *name,
	               Tango::CmdArgType in,
				   Tango::CmdArgType out)
	:Command(name,in,out)	{};
	~OffClass() {};
	
	virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
	virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
	{return (static_cast<MetadataExporter *>(dev))->is_Off_allowed(any);}
};


/**
 *	The MetadataExporterClass singleton definition
 */
Loading