Commit 935cfcc9 authored by Marco De Marco's avatar Marco De Marco
Browse files

Aux database parameters added

parent 1a62ead2
Loading
Loading
Loading
Loading
+51 −4
Original line number Diff line number Diff line
@@ -24,14 +24,23 @@ private:
        std::string databaseHost, unsigned int databasePort,
        std::string databaseUsername, std::string databasePassword,
        std::string databaseSchema, std::string databaseTable,
        unsigned int refreshTime, unsigned int timeout) :
        unsigned int refreshTime, unsigned int timeout,
        std::string temporaryPath, std::string auxDatabaseHost,
        unsigned int auxDatabasePort, std::string auxDatabaseUsername,
        std::string auxDatabasePassword, std::string auxDatabaseSchema,
        std::string auxDatabaseTimestampTable, std::string auxDatabaseFailedTable) :
        m_certificateFile (certificateFile), m_storagePath(storagePath),
        m_remoteHost(remoteHost), m_remotePort(remotePort),
        m_remoteUsername(remoteUsername), m_remotePassword(remotePassword),
        m_databaseHost(databaseHost), m_databasePort(databasePort),
        m_databaseUsername(databaseUsername), m_databasePassword(databasePassword),
        m_databaseSchema(databaseSchema), m_databaseTable(databaseTable),
        m_refreshTime(refreshTime), m_timeout(timeout) { };
        m_refreshTime(refreshTime), m_timeout(timeout),
        m_temporaryPath(temporaryPath), m_auxDatabaseHost(auxDatabaseHost),
        m_auxDatabasePort(auxDatabasePort), m_auxDatabaseUsername(auxDatabaseUsername),
        m_auxDatabasePassword(auxDatabasePassword), m_auxDatabaseSchema(auxDatabaseSchema),
        m_auxDatabaseTimestampTable(auxDatabaseTimestampTable),
        m_auxDatabaseFailedTable(auxDatabaseFailedTable) { };

	virtual ~Configuration() {}

@@ -53,12 +62,18 @@ public:
        std::string databaseHost, unsigned int databasePort,
        std::string databaseUsername, std::string databasePassword,
        std::string databaseSchema, std::string databaseTable,
        unsigned int refreshTime, unsigned int timeout)
        unsigned int refreshTime, unsigned int timeout,
        std::string temporaryPath, std::string auxDatabaseHost,
        unsigned int auxDatabasePort, std::string auxDatabaseUsername,
        std::string auxDatabasePassword, std::string auxDatabaseSchema,
        std::string auxDatabaseTimestampTable, std::string auxDatabaseFailedTable)
	{
		Configuration::SP c_sp(new Configuration(certificateFile, storagePath,
            remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
            databasePort, databaseUsername, databasePassword, databaseSchema,
            databaseTable, refreshTime, timeout), Configuration::Deleter());
            databaseTable, refreshTime, timeout, temporaryPath, auxDatabaseHost,
            auxDatabasePort, auxDatabaseUsername, auxDatabasePassword, auxDatabaseSchema,
            auxDatabaseTimestampTable, auxDatabaseFailedTable), Configuration::Deleter());

		return c_sp;
	}
@@ -80,6 +95,14 @@ public:
	std::string	getDatabaseTable() const { return m_databaseTable; }
	unsigned int getRefreshTime() const { return m_refreshTime; }
	unsigned int getTimeout() const { return m_timeout; }
    std::string getTemporaryPath() const { return m_temporaryPath; }
    std::string getAuxDatabaseHost() const { return m_auxDatabaseHost; }
    unsigned int getAuxDatabasePort() const { return m_auxDatabasePort; }
    std::string getAuxDatabaseUsername() const { return m_auxDatabaseUsername; }
    std::string getAuxDatabasePassword() const { return m_auxDatabasePassword; }
    std::string getAuxDatabaseSchema() const { return m_auxDatabaseSchema; }
    std::string getAuxDatabaseTimestampTable() const { return m_auxDatabaseTimestampTable; }
    std::string getAuxDatabaseFailedTable() const { return m_auxDatabaseFailedTable; }

private:
//------------------------------------------------------------------------------
@@ -126,6 +149,30 @@ private:

	//Connection timeout (seconds)
	const unsigned int m_timeout;

	//Temporary path
	const std::string m_temporaryPath;

	//Auxiliary database host
	const std::string m_auxDatabaseHost;

	//Auxiliary database port
	const unsigned int m_auxDatabasePort;

	//Auxiliary database username
	const std::string m_auxDatabaseUsername;

	//Auxiliary database password
	const std::string m_auxDatabasePassword;

	//Auxiliary database schema
	const std::string m_auxDatabaseSchema;

	//Auxiliary database timestamp table
	const std::string m_auxDatabaseTimestampTable;

	//Auxiliary database failed table
	const std::string m_auxDatabaseFailedTable;
};

}   //End of namespace
+125 −1
Original line number Diff line number Diff line
@@ -217,6 +217,14 @@ void DataImporter::get_device_property()
	dev_prop.push_back(Tango::DbDatum("RefreshTime"));
	dev_prop.push_back(Tango::DbDatum("Timeout"));
	dev_prop.push_back(Tango::DbDatum("AutoStart"));
	dev_prop.push_back(Tango::DbDatum("TemporaryPath"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseHost"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabasePort"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseUsername"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabasePassword"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseSchema"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseTimestampTable"));
	dev_prop.push_back(Tango::DbDatum("AuxDatabaseFailedTable"));

	//	is there at least one property to be read ?
	if (dev_prop.size()>0)
@@ -407,6 +415,94 @@ void DataImporter::get_device_property()
		//	And try to extract AutoStart value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  autoStart;

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

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

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

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

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

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

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

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

	}

	/*----- PROTECTED REGION ID(DataImporter::get_device_property_after) ENABLED START -----*/
@@ -462,10 +558,38 @@ void DataImporter::get_device_property()
        if(timeout<1 || timeout>MAX_TIMEOUT)
            throw(invalid_argument("Timeout property out of range or not defined"));

        if(temporaryPath.empty())
            throw(invalid_argument("TemporaryPath property is empty or not defined"));

        checkIfDirectoryExists(temporaryPath);

        if(auxDatabaseHost.empty())
                throw(invalid_argument("AuxDatabaseHost property is empty or not defined"));

        if(auxDatabasePort<1 || auxDatabasePort>MAX_PORT_NUMBER)
            throw(invalid_argument("AuxDatabasePort property out of range or not defined"));

        if(auxDatabaseUsername.empty())
            throw(invalid_argument("AuxDatabaseUsername property is empty or not defined"));

        if(auxDatabasePassword.empty())
            throw(invalid_argument("AuxDatabasePassword property is empty or not defined"));

        if(auxDatabaseSchema.empty())
            throw(invalid_argument("AuxDatabaseSchema property is empty or not defined"));

        if(auxDatabaseTimestampTable.empty())
            throw(invalid_argument("AuxDatabaseTimestampTable property is empty or not defined"));

        if(auxDatabaseFailedTable.empty())
            throw(invalid_argument("AuxDatabaseFailedTable property is empty or not defined"));

        m_configuration_sp = Configuration::create(certificateFile, storagePath,
            remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
            databasePort, databaseUsername, databasePassword, databaseSchema,
            databaseTable, refreshTime, timeout);
            databaseTable, refreshTime, timeout, temporaryPath, auxDatabaseHost,
            auxDatabasePort, auxDatabaseUsername, auxDatabasePassword,
            auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable);
    }
    catch(invalid_argument& ex)
    {
+16 −0
Original line number Diff line number Diff line
@@ -119,6 +119,22 @@ public:
	Tango::DevULong	timeout;
	//	AutoStart:	Exec On command after init if state is not fault
	Tango::DevBoolean	autoStart;
	//	TemporaryPath:	Absolute path used during file transfer
	string	temporaryPath;
	//	AuxDatabaseHost:	File transfer auxiliary database host
	string	auxDatabaseHost;
	//	AuxDatabasePort:	File transfer auxiliary database port
	Tango::DevULong	auxDatabasePort;
	//	AuxDatabaseUsername:	File transfer auxiliary database username
	string	auxDatabaseUsername;
	//	AuxDatabasePassword:	File transfer auxiliary database password
	string	auxDatabasePassword;
	//	AuxDatabaseSchema:	File transfer auxiliary database schema
	string	auxDatabaseSchema;
	//	AuxDatabaseTimestampTable:	File transfer auxiliary database device timestamp table
	string	auxDatabaseTimestampTable;
	//	AuxDatabaseFailedTable:	File transfer auxiliary database failed transfer table
	string	auxDatabaseFailedTable;


//	Constructors and destructors
+64 −0
Original line number Diff line number Diff line
@@ -13,6 +13,38 @@
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <classProperties name="TemporaryPath" description="Absolute path used during file transfer">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <classProperties name="AuxDatabaseHost" description="File transfer auxiliary database host">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <classProperties name="AuxDatabasePort" description="File transfer auxiliary database port">
      <type xsi:type="pogoDsl:UIntType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <classProperties name="AuxDatabaseUsername" description="File transfer auxiliary database username">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <classProperties name="AuxDatabasePassword" description="File transfer auxiliary database password">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <classProperties name="AuxDatabaseSchema" description="File transfer auxiliary database schema">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <classProperties name="AuxDatabaseTimestampTable" description="File transfer auxiliary database device timestamp table">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </classProperties>
    <classProperties name="AuxDatabaseFailedTable" description="File transfer auxiliary database failed transfer table">
      <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"/>
@@ -80,6 +112,38 @@
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
      <DefaultPropValue>false</DefaultPropValue>
    </deviceProperties>
    <deviceProperties name="TemporaryPath" description="Absolute path used during file transfer">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="AuxDatabaseHost" description="File transfer auxiliary database host">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="AuxDatabasePort" description="File transfer auxiliary database port">
      <type xsi:type="pogoDsl:UIntType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="AuxDatabaseUsername" description="File transfer auxiliary database username">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="AuxDatabasePassword" description="File transfer auxiliary database password">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="AuxDatabaseSchema" description="File transfer auxiliary database schema">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="AuxDatabaseTimestampTable" description="File transfer auxiliary database device timestamp table">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="AuxDatabaseFailedTable" description="File transfer auxiliary database failed transfer table">
      <type xsi:type="pogoDsl:StringType"/>
      <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"/>
+312 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading