Skip to content
Snippets Groups Projects
Commit 7d82abb2 authored by Marco De Marco's avatar Marco De Marco
Browse files

Recovery time property added

parent 8000709c
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ 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, unsigned int recoveryTime,
std::string auxDatabaseHost, unsigned int auxDatabasePort,
std::string auxDatabaseUsername, std::string auxDatabasePassword,
std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable,
......@@ -35,7 +35,7 @@ private:
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_recoveryTime(recoveryTime),
m_auxDatabaseHost(auxDatabaseHost), m_auxDatabasePort(auxDatabasePort),
m_auxDatabaseUsername(auxDatabaseUsername),
m_auxDatabasePassword(auxDatabasePassword),
......@@ -63,7 +63,7 @@ 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, unsigned int recoveryTime,
std::string auxDatabaseHost, unsigned int auxDatabasePort,
std::string auxDatabaseUsername, std::string auxDatabasePassword,
std::string auxDatabaseSchema, std::string auxDatabaseTimestampTable,
......@@ -72,9 +72,9 @@ public:
Configuration::SP c_sp(new Configuration(certificateFile, storagePath,
remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
databasePort, databaseUsername, databasePassword, databaseSchema,
databaseTable, refreshTime, timeout, auxDatabaseHost, auxDatabasePort,
auxDatabaseUsername, auxDatabasePassword, auxDatabaseSchema,
auxDatabaseTimestampTable, auxDatabaseFailedTable),
databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost,
auxDatabasePort, auxDatabaseUsername, auxDatabasePassword,
auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable),
Configuration::Deleter());
return c_sp;
......@@ -97,6 +97,7 @@ public:
std::string getDatabaseTable() const { return m_databaseTable; }
unsigned int getRefreshTime() const { return m_refreshTime; }
unsigned int getTimeout() const { return m_timeout; }
unsigned int getRecoveryTime() const { return m_recoveryTime; }
std::string getAuxDatabaseHost() const { return m_auxDatabaseHost; }
unsigned int getAuxDatabasePort() const { return m_auxDatabasePort; }
std::string getAuxDatabaseUsername() const { return m_auxDatabaseUsername; }
......@@ -151,6 +152,9 @@ private:
//Connection timeout (seconds)
const unsigned int m_timeout;
//Recovery time (seconds)
const unsigned int m_recoveryTime;
//Auxiliary database host
const std::string m_auxDatabaseHost;
......
......@@ -216,6 +216,7 @@ void DataImporter::get_device_property()
dev_prop.push_back(Tango::DbDatum("DatabaseTable"));
dev_prop.push_back(Tango::DbDatum("RefreshTime"));
dev_prop.push_back(Tango::DbDatum("Timeout"));
dev_prop.push_back(Tango::DbDatum("RecoveryTime"));
dev_prop.push_back(Tango::DbDatum("AutoStart"));
dev_prop.push_back(Tango::DbDatum("AuxDatabaseHost"));
dev_prop.push_back(Tango::DbDatum("AuxDatabasePort"));
......@@ -403,6 +404,17 @@ void DataImporter::get_device_property()
// And try to extract Timeout value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> timeout;
// Try to initialize RecoveryTime from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> recoveryTime;
else {
// Try to initialize RecoveryTime from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> recoveryTime;
}
// And try to extract RecoveryTime value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> recoveryTime;
// Try to initialize AutoStart from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> autoStart;
......@@ -546,6 +558,9 @@ void DataImporter::get_device_property()
if(timeout<1 || timeout>MAX_TIMEOUT)
throw(invalid_argument("Timeout property out of range or not defined"));
if(recoveryTime<1 || recoveryTime>MAX_RECOVERY_TIME)
throw(invalid_argument("RecoveryTime property out of range or not defined"));
if(auxDatabaseHost.empty())
throw(invalid_argument("AuxDatabaseHost property is empty or not defined"));
......@@ -570,9 +585,9 @@ void DataImporter::get_device_property()
m_configuration_sp = Configuration::create(certificateFile, storagePath,
remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
databasePort, databaseUsername, databasePassword, databaseSchema,
databaseTable, refreshTime, timeout, auxDatabaseHost, auxDatabasePort,
auxDatabaseUsername, auxDatabasePassword, auxDatabaseSchema,
auxDatabaseTimestampTable, auxDatabaseFailedTable);
databaseTable, refreshTime, timeout, recoveryTime, auxDatabaseHost,
auxDatabasePort, auxDatabaseUsername, auxDatabasePassword,
auxDatabaseSchema, auxDatabaseTimestampTable, auxDatabaseFailedTable);
}
catch(invalid_argument& ex)
{
......@@ -593,7 +608,7 @@ void DataImporter::get_device_property()
//--------------------------------------------------------
void DataImporter::always_executed_hook()
{
DEBUG_STREAM << "DataImporter::always_executed_hook() " << device_name << endl;
INFO_STREAM << "DataImporter::always_executed_hook() " << device_name << endl;
/*----- PROTECTED REGION ID(DataImporter::always_executed_hook) ENABLED START -----*/
if(get_state() != Tango::FAULT)
......
......@@ -82,6 +82,8 @@ class DataImporter : public TANGO_BASE_CLASS
//Max time between remote server request and response
static const unsigned int MAX_TIMEOUT = 60;
//Time between failed download attempt
static const unsigned int MAX_RECOVERY_TIME = 86400;
/*----- PROTECTED REGION END -----*/ // DataImporter::Data Members
......@@ -113,10 +115,12 @@ public:
string databaseSchema;
// DatabaseTable: Metadata local database table
string databaseTable;
// RefreshTime: Remote database request period (seconds)
// RefreshTime: Local database request period (seconds)
Tango::DevULong refreshTime;
// Timeout: Connection timeout (seconds)
Tango::DevULong timeout;
// RecoveryTime: Time between failed file download attempt
Tango::DevULong recoveryTime;
// AutoStart: Exec On command after init if state is not fault
Tango::DevBoolean autoStart;
// AuxDatabaseHost: File transfer auxiliary database host
......
......@@ -93,7 +93,7 @@
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="RefreshTime" description="Remote database request period (seconds)">
<deviceProperties name="RefreshTime" description="Local database request period (seconds)">
<type xsi:type="pogoDsl:UIntType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>10</DefaultPropValue>
......@@ -103,6 +103,11 @@
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>60</DefaultPropValue>
</deviceProperties>
<deviceProperties name="RecoveryTime" description="Time between failed file download attempt">
<type xsi:type="pogoDsl:UIntType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>60</DefaultPropValue>
</deviceProperties>
<deviceProperties name="AutoStart" description="Exec On command after init if state is not fault">
<type xsi:type="pogoDsl:BooleanType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
......
......@@ -695,7 +695,7 @@ void DataImporterClass::set_default_property()
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "RefreshTime";
prop_desc = "Remote database request period (seconds)";
prop_desc = "Local database request period (seconds)";
prop_def = "10";
vect_data.clear();
vect_data.push_back("10");
......@@ -720,6 +720,20 @@ void DataImporterClass::set_default_property()
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 = "RecoveryTime";
prop_desc = "Time between failed file download attempt";
prop_def = "60";
vect_data.clear();
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 = "AutoStart";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment