Commit b1f90263 authored by Marco De Marco's avatar Marco De Marco
Browse files

Script path property path added

parent 207b9160
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -21,10 +21,11 @@ private:
//------------------------------------------------------------------------------
//	[Private] Constructor destructor deleter
//------------------------------------------------------------------------------
	Configuration(std::string watchPath, int workerNumber, int sleepTime, int waitTime,
		int connectionNumber, uint32_t iNotifyMask): m_watchPath(watchPath),
		m_workerNumber(workerNumber), m_sleepTime(sleepTime), m_waitTime(waitTime),
		m_connectionNumber(connectionNumber), m_iNotifyMask(iNotifyMask) {}
	Configuration(std::string watchPath, std::string destPath, int workerNumber,
        int sleepTime, int waitTime, uint32_t iNotifyMask) : m_watchPath(watchPath),
        m_destPath(destPath), m_workerNumber(workerNumber), m_sleepTime(sleepTime),
        m_waitTime(waitTime), m_iNotifyMask(iNotifyMask) { }

	virtual ~Configuration() {}

	class Deleter;
@@ -39,20 +40,20 @@ public:
//------------------------------------------------------------------------------
//	[Public] User methods
//------------------------------------------------------------------------------
	static Configuration::SP create(std::string watchPath, int workerNumber,
        int sleepTime, int waitTime, int connectionNumber, uint32_t iNotifyMask)
	static Configuration::SP create(std::string watchPath, std::string destPath,
        int workerNumber, int sleepTime, int waitTime, uint32_t iNotifyMask)
	{
		Configuration::SP c_sp(new Configuration(watchPath, workerNumber, sleepTime,
			 waitTime, connectionNumber, iNotifyMask), Configuration::Deleter());
		Configuration::SP c_sp(new Configuration(watchPath, destPath, workerNumber,
			 sleepTime, waitTime, iNotifyMask), Configuration::Deleter());

		return c_sp;
	}

	std::string getWatchPath() const { return m_watchPath; }
    std::string getDestPath() const { return m_destPath; }
	unsigned int getWorkerNumber() const { return m_workerNumber; }
    unsigned int getSleepTime() const { return m_sleepTime; }
	unsigned int getWaitTime() const { return m_waitTime; }
	unsigned int getConnectionNumber() const { return m_connectionNumber; }
	uint32_t getINotifyMask() const { return m_iNotifyMask; }

private:
@@ -62,6 +63,9 @@ private:
	//INotify watch path
	const std::string m_watchPath;

    //File destination path
    const std::string m_destPath;

	//Worker thread number
	const unsigned int m_workerNumber;

@@ -71,9 +75,6 @@ private:
	//Worker thread wait time
	const unsigned int m_waitTime;

	//Number of connection per destination
	const unsigned int m_connectionNumber;

	//INotify mask
	const uint32_t m_iNotifyMask;
};
+152 −28
Original line number Diff line number Diff line
@@ -139,7 +139,9 @@ void PreProcessor::init_device()

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

	//	No device property to be read from database

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


	/*----- PROTECTED REGION ID(PreProcessor::init_device) ENABLED START -----*/
@@ -149,6 +151,128 @@ void PreProcessor::init_device()
	/*----- PROTECTED REGION END -----*/	//	PreProcessor::init_device
}

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

	//	Initialize property data members

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


	//	Read device properties from database.
	Tango::DbData	dev_prop;
	dev_prop.push_back(Tango::DbDatum("WatchPath"));
	dev_prop.push_back(Tango::DbDatum("DestPath"));
	dev_prop.push_back(Tango::DbDatum("ScriptPath"));
	dev_prop.push_back(Tango::DbDatum("EventList"));
	dev_prop.push_back(Tango::DbDatum("SleepTime"));
	dev_prop.push_back(Tango::DbDatum("WaitTime"));
	dev_prop.push_back(Tango::DbDatum("WorkerNumber"));

	//	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 PreProcessorClass to get class property
		Tango::DbDatum	def_prop, cl_prop;
		PreProcessorClass	*ds_class =
			(static_cast<PreProcessorClass *>(get_device_class()));
		int	i = -1;

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

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

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

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

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

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

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

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

	//	Check device property data members init

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

//--------------------------------------------------------
/**
+27 −7
Original line number Diff line number Diff line
@@ -65,6 +65,22 @@ class PreProcessor : public TANGO_BASE_CLASS

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

//	Device property data members
public:
	//	WatchPath:
	string	watchPath;
	//	DestPath:
	string	destPath;
	//	ScriptPath:
	string	scriptPath;
	//	EventList:
	vector<string>	eventList;
	//	SleepTime:
	Tango::DevULong	sleepTime;
	//	WaitTime:
	Tango::DevUShort	waitTime;
	//	WorkerNumber:
	Tango::DevUShort	workerNumber;


//	Constructors and destructors
@@ -107,6 +123,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.
	 */
+29 −1
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="PreProcessor" pogoRevision="8.1">
    <description description="Pre proccesing generic server" title="PreProcessor" sourcePath="/home/mdm/workspace/nadir/pre_precessor/src" language="Cpp" filestogenerate="XMI   file,Code files" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false">
    <description description="Pre proccesing generic server" title="PreProcessor" sourcePath="/home/mdm/workspace/nadir/pre_precessor/src" language="Cpp" filestogenerate="XMI   file,Code files" license="GPL" 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="Acquisition" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference=""/>
    </description>
    <deviceProperties name="WatchPath" description="">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="DestPath" description="">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="ScriptPath" description="">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="EventList" description="">
      <type xsi:type="pogoDsl:StringVectorType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="SleepTime" description="">
      <type xsi:type="pogoDsl:UIntType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="WaitTime" description="">
      <type xsi:type="pogoDsl:UShortType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="WorkerNumber" description="">
      <type xsi:type="pogoDsl:UShortType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <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"/>
+124 −33
Original line number Diff line number Diff line
@@ -262,6 +262,97 @@ void PreProcessorClass::set_default_property()
	//	Set Default Class Properties

	//	Set Default device Properties
	prop_name = "WatchPath";
	prop_desc = "";
	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 = "DestPath";
	prop_desc = "";
	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 = "ScriptPath";
	prop_desc = "";
	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 = "EventList";
	prop_desc = "";
	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 = "SleepTime";
	prop_desc = "";
	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 = "WaitTime";
	prop_desc = "";
	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 = "WorkerNumber";
	prop_desc = "";
	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);
}

//--------------------------------------------------------