Commit 091d95de authored by Marco De Marco's avatar Marco De Marco
Browse files

Fits importer and state machine modified

parent 2e788dec
Loading
Loading
Loading
Loading
+39 −39
Original line number Original line Diff line number Diff line
#include <DataModelManager.h>
#include <DMDBImporter.h>


#include <soci.h>
#include <soci.h>
#include <soci/rowset.h>
#include <soci/rowset.h>
@@ -8,9 +8,9 @@
#include <soci/boost-tuple.h>
#include <soci/boost-tuple.h>


//==============================================================================
//==============================================================================
//      DataModelManager::DataModelManager()
//      DMDBImporter::DMDBImporter()
//==============================================================================
//==============================================================================
DataModelManager::DataModelManager(Tango::DeviceImpl* device_impl_p,
DMDBImporter::DMDBImporter(Tango::DeviceImpl* device_impl_p,
    std::string host, unsigned short port, std::string user, std::string password, 
    std::string host, unsigned short port, std::string user, std::string password, 
    std::string schema, std::string instrumentTable, std::string destinationTable,
    std::string schema, std::string instrumentTable, std::string destinationTable,
    std::string mappingTable) : Tango::LogAdapter(device_impl_p), m_host(host),
    std::string mappingTable) : Tango::LogAdapter(device_impl_p), m_host(host),
@@ -18,42 +18,42 @@ DataModelManager::DataModelManager(Tango::DeviceImpl* device_impl_p,
    m_instrumentTable(instrumentTable), m_destinationTable(destinationTable), 
    m_instrumentTable(instrumentTable), m_destinationTable(destinationTable), 
    m_mappingTable(mappingTable)
    m_mappingTable(mappingTable)
{
{
    DEBUG_STREAM << "DataModelManager::DataModelManager()" << endl;
    DEBUG_STREAM << "DMDBImporter::DMDBImporter()" << endl;
    
    
    m_session_sp.reset(new soci::session);
    m_session_sp.reset(new soci::session);
}
}


//==============================================================================
//==============================================================================
//      DataModelManager::~DataModelManager()
//      DMDBImporter::~DMDBImporter()
//==============================================================================
//==============================================================================
DataModelManager::~DataModelManager()
DMDBImporter::~DMDBImporter()
{
{
    DEBUG_STREAM << "DataModelManager::~DataModelManager()" << endl;
    DEBUG_STREAM << "DMDBImporter::~DMDBImporter()" << endl;
    
    
    m_session_sp->close();
    m_session_sp->close();
}
}


//==============================================================================
//==============================================================================
//      DataModelManager::create()
//      DMDBImporter::create()
//==============================================================================
//==============================================================================
DataModelManager::SP DataModelManager::create(Tango::DeviceImpl* device_impl_p, 
DMDBImporter::SP DMDBImporter::create(Tango::DeviceImpl* device_impl_p, 
    std::string host, unsigned short port, std::string user, std::string password, 
    std::string host, unsigned short port, std::string user, std::string password, 
    std::string schema, std::string instrumentTable, std::string destinationTable, 
    std::string schema, std::string instrumentTable, std::string destinationTable, 
    std::string mappingTable)     
    std::string mappingTable)     
{
{
    DataModelManager::SP d_sp(new DataModelManager(device_impl_p, host, port, 
    DMDBImporter::SP d_sp(new DMDBImporter(device_impl_p, host, port, 
        user, password, schema, instrumentTable, destinationTable, mappingTable), 
        user, password, schema, instrumentTable, destinationTable, mappingTable), 
        DataModelManager::Deleter());
        DMDBImporter::Deleter());
    
    
    return d_sp;
    return d_sp;
}        
}        


//==============================================================================
//==============================================================================
//      DataModelManager::connect()
//      DMDBImporter::connect()
//==============================================================================
//==============================================================================
void DataModelManager::connect() throw(soci::soci_error)
void DMDBImporter::connect() throw(soci::soci_error)
{
{
    DEBUG_STREAM << "DataModelManager::connect()" << endl;
    DEBUG_STREAM << "DMDBImporter::connect()" << endl;
    
    
    std::stringstream connection;
    std::stringstream connection;
    connection << " host=" << m_host;
    connection << " host=" << m_host;
@@ -70,11 +70,11 @@ void DataModelManager::connect() throw(soci::soci_error)
}
}


//==============================================================================
//==============================================================================
//      DataModelManager::isConnected()
//      DMDBImporter::isConnected()
//==============================================================================
//==============================================================================
bool DataModelManager::isConnected()
bool DMDBImporter::isConnected()
{
{
    DEBUG_STREAM << "DataModelManager::isConnect()" << endl;
    DEBUG_STREAM << "DMDBImporter::isConnect()" << endl;
        
        
    if(m_session_sp->get_backend() == NULL)
    if(m_session_sp->get_backend() == NULL)
        return false;
        return false;
@@ -83,22 +83,22 @@ bool DataModelManager::isConnected()
}
}


//==============================================================================
//==============================================================================
//      DataModelManager::disconnect()
//      DMDBImporter::disconnect()
//==============================================================================
//==============================================================================
void DataModelManager::disconnect()
void DMDBImporter::disconnect()
{
{
    DEBUG_STREAM << "DataModelManager::disconnect()" << endl;
    DEBUG_STREAM << "DMDBImporter::disconnect()" << endl;
    
    
    m_session_sp->close();    
    m_session_sp->close();    
}
}


//==============================================================================
//==============================================================================
//      DataModelManager::importInstrumentList()
//      DMDBImporter::retrieveInstrumentList()
//==============================================================================
//==============================================================================
Instrument::SPVector DataModelManager::importInstrumentList(std::vector<std::string>&
Instrument::SPVector DMDBImporter::retrieveInstrumentList(std::vector<std::string>&
      instrumentList) throw(std::invalid_argument, soci::soci_error)
      instrumentList) throw(std::invalid_argument, soci::soci_error)
{
{
    DEBUG_STREAM << "DataModelManager::importInstrumentList()" << endl;
    DEBUG_STREAM << "DMDBImporter::retrieveInstrumentList()" << endl;


    if(instrumentList.empty())
    if(instrumentList.empty())
        throw std::invalid_argument("Instrument list is empty");
        throw std::invalid_argument("Instrument list is empty");
@@ -111,33 +111,33 @@ Instrument::SPVector DataModelManager::importInstrumentList(std::vector<std::str
        if(it->empty())
        if(it->empty())
            throw std::invalid_argument("Instrument list contains empty element");
            throw std::invalid_argument("Instrument list contains empty element");
                
                
        instrument_spvector.push_back(retrieveInstrument(*it));
        instrument_spvector.push_back(getInstrument(*it));
    }
    }
    
    
    return instrument_spvector;
    return instrument_spvector;
}
}


//==============================================================================
//==============================================================================
//      DataModelManager::importInstrument()
//      DMDBImporter::retrieveInstrument()
//==============================================================================
//==============================================================================
Instrument::SP DataModelManager::importInstrument(std::string instrument)
Instrument::SP DMDBImporter::retrieveInstrument(std::string instrument)
    throw(std::invalid_argument, soci::soci_error)
    throw(std::invalid_argument, soci::soci_error)
{
{
    DEBUG_STREAM << "DataModelManager::importInstrument()" << endl;
    DEBUG_STREAM << "DMDBImporter::retrieveInstrument()" << endl;
    
    
    if(instrument.empty())
    if(instrument.empty())
        throw std::invalid_argument("Instrument is empty");
        throw std::invalid_argument("Instrument is empty");
    
    
    return retrieveInstrument(instrument);
    return getInstrument(instrument);
}
}


//==============================================================================
//==============================================================================
//      DataModelManager::()
//      DMDBImporter::getInstrument()
//==============================================================================
//==============================================================================
Instrument::SP DataModelManager::retrieveInstrument(std::string instrumentName)
Instrument::SP DMDBImporter::getInstrument(std::string instrumentName)
        throw(soci::soci_error)
        throw(soci::soci_error)
{
{
    DEBUG_STREAM << "DataModelManager::retrieveInstrument()" << endl;
    DEBUG_STREAM << "DMDBImporter::getInstrument()" << endl;
            
            
    soci::rowset< InstrumentTuple > rows = (m_session_sp->prepare <<
    soci::rowset< InstrumentTuple > rows = (m_session_sp->prepare <<
        "SELECT id, name, fits_key, fits_value, fits_date, dest_id "
        "SELECT id, name, fits_key, fits_value, fits_date, dest_id "
@@ -185,7 +185,7 @@ Instrument::SP DataModelManager::retrieveInstrument(std::string instrumentName)
    INFO_STREAM << "-------------------------------------------------" << endl;
    INFO_STREAM << "-------------------------------------------------" << endl;
#endif
#endif
    
    
    Destination::SP destination_sp = retrieveDestination(destinationId);
    Destination::SP destination_sp = getDestination(destinationId);
    
    
    Instrument::SP instrument_sp = Instrument::create(name, fitsKey, fitsValue, 
    Instrument::SP instrument_sp = Instrument::create(name, fitsKey, fitsValue, 
        fitsDate, destination_sp);
        fitsDate, destination_sp);
@@ -194,12 +194,12 @@ Instrument::SP DataModelManager::retrieveInstrument(std::string instrumentName)
}        
}        


//==============================================================================
//==============================================================================
//      DataModelManager::retrieveDestinations()
//      DMDBImporter::getDestination()
//==============================================================================
//==============================================================================
Destination::SP DataModelManager::retrieveDestination(int destinationId) 
Destination::SP DMDBImporter::getDestination(int destinationId) 
    throw(soci::soci_error)
    throw(soci::soci_error)
{
{
    DEBUG_STREAM << "DataModelManager::retrieveDestinations()" << endl;
    DEBUG_STREAM << "DMDBImporter::getDestination()" << endl;
  
  
    soci::rowset< DestinationTuple > rows = (m_session_sp->prepare <<
    soci::rowset< DestinationTuple > rows = (m_session_sp->prepare <<
        "SELECT id, host, port, user, password, schema_name, table_name, "
        "SELECT id, host, port, user, password, schema_name, table_name, "
@@ -252,7 +252,7 @@ Destination::SP DataModelManager::retrieveDestination(int destinationId)
    INFO_STREAM << "-------------------------------------------------" << endl;    
    INFO_STREAM << "-------------------------------------------------" << endl;    
#endif
#endif
    
    
    Mapping::SPVector mapping_spvector = retrieveMapping(destinationId);    
    Mapping::SPVector mapping_spvector = getMapping(destinationId);    


    Destination::SP destination_sp( Destination::create(host, port, user, password,
    Destination::SP destination_sp( Destination::create(host, port, user, password,
            schema, table, storage, mapping_spvector) );
            schema, table, storage, mapping_spvector) );
@@ -261,12 +261,12 @@ Destination::SP DataModelManager::retrieveDestination(int destinationId)
}
}


//==============================================================================
//==============================================================================
//      DataModelManager::retrieveInstrumentTuple()
//      DMDBImporter::getMapping()
//==============================================================================
//==============================================================================
Mapping::SPVector DataModelManager::retrieveMapping(int destinationId)
Mapping::SPVector DMDBImporter::getMapping(int destinationId)
    throw(soci::soci_error)
    throw(soci::soci_error)
{
{
    DEBUG_STREAM << "DataModelManager::retrieveMappings()" << endl;
    DEBUG_STREAM << "DMDBImporter::getMapping()" << endl;
    
    
    soci::rowset< MappingTuple > rows = (m_session_sp->prepare <<
    soci::rowset< MappingTuple > rows = (m_session_sp->prepare <<
    "SELECT id, column_name, column_type, fits_key_pri, fits_key_sec, mandatory "
    "SELECT id, column_name, column_type, fits_key_pri, fits_key_sec, mandatory "
+14 −14
Original line number Original line Diff line number Diff line
#ifndef DATAMODELMANAGER_H
#ifndef DMDB_IMPORTER_H
#define	DATAMODELMANAGER_H
#define	DMDB_IMPORTER_H


#include <Instrument.h>
#include <Instrument.h>
#include <tango.h>
#include <tango.h>
@@ -11,36 +11,36 @@
#include <soci/error.h>
#include <soci/error.h>
#include <soci/session.h>
#include <soci/session.h>


class DataModelManager : public Tango::LogAdapter
class DMDBImporter : public Tango::LogAdapter
{
{
public:
public:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//  [Public] Shared pointer typedef
//  [Public] Shared pointer typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
    typedef boost::shared_ptr<DataModelManager> SP;
    typedef boost::shared_ptr<DMDBImporter> SP;


protected:    
protected:    
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//	[Protected] Constructor destructor deleter
//	[Protected] Constructor destructor deleter
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
    DataModelManager(Tango::DeviceImpl*, std::string, unsigned short, std::string,
    DMDBImporter(Tango::DeviceImpl*, std::string, unsigned short, std::string,
        std::string, std::string, std::string, std::string, std::string);
        std::string, std::string, std::string, std::string, std::string);
        
        
    virtual ~DataModelManager();
    virtual ~DMDBImporter();
    
    
	class Deleter;
	class Deleter;
	friend class Deleter;
	friend class Deleter;
	class Deleter
	class Deleter
	{
	{
	public:
	public:
		void operator()(DataModelManager* d) { delete d; }
		void operator()(DMDBImporter* d) { delete d; }
	};    
	};    


public:    
public:    
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//	[Public] Users methods
//	[Public] Users methods
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
    static DataModelManager::SP create(Tango::DeviceImpl*, std::string, 
    static DMDBImporter::SP create(Tango::DeviceImpl*, std::string, 
        unsigned short, std::string, std::string, std::string, std::string, 
        unsigned short, std::string, std::string, std::string, std::string, 
        std::string, std::string);        
        std::string, std::string);        
                
                
@@ -50,23 +50,23 @@ public:
    
    
    virtual void disconnect();
    virtual void disconnect();
        
        
    virtual Instrument::SPVector importInstrumentList(std::vector<std::string>&)
    virtual Instrument::SPVector retrieveInstrumentList(std::vector<std::string>&)
        throw(std::invalid_argument, soci::soci_error);
        throw(std::invalid_argument, soci::soci_error);
    
    
    virtual Instrument::SP importInstrument(std::string)
    virtual Instrument::SP retrieveInstrument(std::string)
        throw(std::invalid_argument, soci::soci_error);
        throw(std::invalid_argument, soci::soci_error);
  
  
protected:
protected:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//  [Protected] Utilities methods
//  [Protected] Utilities methods
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
    virtual Instrument::SP retrieveInstrument(std::string)
    virtual Instrument::SP getInstrument(std::string)
        throw(soci::soci_error);
        throw(soci::soci_error);
    
    
    virtual Destination::SP retrieveDestination(int)
    virtual Destination::SP getDestination(int)
        throw(soci::soci_error);        
        throw(soci::soci_error);        
    
    
    virtual Mapping::SPVector retrieveMapping(int)
    virtual Mapping::SPVector getMapping(int)
        throw(soci::soci_error);        
        throw(soci::soci_error);        


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
@@ -128,4 +128,4 @@ protected:
    boost::scoped_ptr<soci::session> m_session_sp;        
    boost::scoped_ptr<soci::session> m_session_sp;        
};
};


#endif	/* DATAMODELMANAGER_H */
#endif	/* DMDB_IMPORTER_H */
+107 −40
Original line number Original line Diff line number Diff line
@@ -39,12 +39,13 @@ static const char *RcsId = "$Id: $";
//        (Program Obviously used to Generate tango Object)
//        (Program Obviously used to Generate tango Object)
//=============================================================================
//=============================================================================



#include <FitsImporter.h>
#include <FitsImporter.h>
#include <FitsImporterClass.h>
#include <FitsImporterClass.h>
#include <sys/inotify.h>
#include <Configuration.h>
#include <DMDBImporter.h>
#include <Instrument.h>


#include "DataModelManager.h"
#include <sys/inotify.h>


/*----- PROTECTED REGION END -----*/	//	FitsImporter.cpp
/*----- PROTECTED REGION END -----*/	//	FitsImporter.cpp


@@ -166,28 +167,33 @@ void FitsImporter::init_device()
        try
        try
        {
        {
            //Create i-notify mask from event list property
            //Create i-notify mask from event list property
            const uint32_t inotify_mask = create_inotify_mask(event_list);
            const uint32_t inotifyMask = create_inotify_mask(eventList);
            
            
            //Initialize configuration container class
            //Initialize configuration container class
            m_configuration_sp = Configuration::create(watchPath, workerNumber,
            Configuration::SP m_configuration_sp = Configuration::create(watchPath, 
                    waitTime, connectionNumber, inotify_mask);
                    workerNumber, waitTime, connectionNumber, inotifyMask);                    
            
            
            //Initialize data model manager using tango properties as parameters
            //Initialize data model manager using tango properties as parameters
            DataModelManager::SP data_model_manager_sp( new DataModelManager(this,
            DMDBImporter::SP dMDBImporter = DMDBImporter::create(this, dMDBHost, 
                     dMDBHost, dMDBPort, dMDBUser, dMDBPassword, dMDBSchema,
                dMDBPort, dMDBUser, dMDBPassword, dMDBSchema, dMDBInstrumentTable,
                        dMDBInstrumentTable, dMDBDestinationTable, dMDBMappingTable));
                dMDBDestinationTable, dMDBMappingTable);                                       
            
            
            //Connect to data model database
            //Connect to data model database
            data_model_manager_sp->connect();
            dMDBImporter->connect();
            
            
            //Initialize instrument vector from data model database parameters
            //Initialize instrument vector from data model database parameters
            m_instrumentList_spvector = data_model_manager_sp->importInstrumentList(instrumentList);
            Instrument::SPVector m_instrumentList_spvector = 
                dMDBImporter->retrieveInstrumentList(instrumentList);
            
            
            //Initialize default instrument from data model database parameters
            //Initialize default instrument from data model database parameters
            m_defaultInstrument_sp = data_model_manager_sp->importInstrument(defaultInstrument);
            Instrument::SP m_defaultInstrument_sp = 
                dMDBImporter->retrieveInstrument(defaultInstrument);
            
            
            //Disconnect
            //Disconnect
            data_model_manager_sp->disconnect();
            dMDBImporter->disconnect();
            
            //TODO: initialize thread
            //m_eventThread_sp = EventThread::create();
        }
        }
        catch(std::exception& ex)
        catch(std::exception& ex)
        {
        {
@@ -287,14 +293,14 @@ void FitsImporter::get_device_property()


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


		//	Try to initialize WaitTime from class property
		//	Try to initialize WaitTime from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
@@ -432,11 +438,11 @@ void FitsImporter::get_device_property()
        if(connectionNumber<MIN_CONNECTION_NUMBER || connectionNumber>MAX_CONNECTION_NUMBER)
        if(connectionNumber<MIN_CONNECTION_NUMBER || connectionNumber>MAX_CONNECTION_NUMBER)
            throw(invalid_argument("ConnectionNumber property out of range or not defined"));
            throw(invalid_argument("ConnectionNumber property out of range or not defined"));


        if(event_list.empty())
        if(eventList.empty())
            throw(invalid_argument("EventList property is empty or not defined"));
            throw(invalid_argument("EventList property is empty or not defined"));
        
        
        for(vector<string>::size_type e_ind=0; e_ind<event_list.size(); ++e_ind)
        for(vector<string>::size_type e_ind=0; e_ind<eventList.size(); ++e_ind)
            if(event_list.at(e_ind).empty())
            if(eventList.at(e_ind).empty())
            {
            {
                stringstream event_list_error;
                stringstream event_list_error;
                event_list_error << "EventList property has an empty element at \""
                event_list_error << "EventList property has an empty element at \""
@@ -510,7 +516,12 @@ void FitsImporter::always_executed_hook()
	
	
	if(get_state() != Tango::FAULT)
	if(get_state() != Tango::FAULT)
    {
    {
        //TODO: change state and status
        if(m_eventThread_sp)
        {
            set_state(m_eventThread_sp->readState());
            
            set_status(m_eventThread_sp->readStatus());
        }
    }
    }
	
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::always_executed_hook
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::always_executed_hook
@@ -545,7 +556,10 @@ void FitsImporter::read_RegularFileCounter(Tango::Attribute &attr)
{
{
	DEBUG_STREAM << "FitsImporter::read_RegularFileCounter(Tango::Attribute &attr) entering... " << endl;
	DEBUG_STREAM << "FitsImporter::read_RegularFileCounter(Tango::Attribute &attr) entering... " << endl;
	/*----- PROTECTED REGION ID(FitsImporter::read_RegularFileCounter) ENABLED START -----*/
	/*----- PROTECTED REGION ID(FitsImporter::read_RegularFileCounter) ENABLED START -----*/
	//	Set the attribute value

    if(m_eventThread_sp)
        *attr_RegularFileCounter_read = m_eventThread_sp->readRegularCounter();
    
	attr.set_value(attr_RegularFileCounter_read);
	attr.set_value(attr_RegularFileCounter_read);
	
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_RegularFileCounter
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_RegularFileCounter
@@ -563,7 +577,10 @@ void FitsImporter::read_WarningFileCounter(Tango::Attribute &attr)
{
{
	DEBUG_STREAM << "FitsImporter::read_WarningFileCounter(Tango::Attribute &attr) entering... " << endl;
	DEBUG_STREAM << "FitsImporter::read_WarningFileCounter(Tango::Attribute &attr) entering... " << endl;
	/*----- PROTECTED REGION ID(FitsImporter::read_WarningFileCounter) ENABLED START -----*/
	/*----- PROTECTED REGION ID(FitsImporter::read_WarningFileCounter) ENABLED START -----*/
	//	Set the attribute value

    if(m_eventThread_sp)
        *attr_WarningFileCounter_read = m_eventThread_sp->readWarningCounter();
        
	attr.set_value(attr_WarningFileCounter_read);
	attr.set_value(attr_WarningFileCounter_read);
	
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_WarningFileCounter
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_WarningFileCounter
@@ -581,7 +598,10 @@ void FitsImporter::read_ErrorFileCounter(Tango::Attribute &attr)
{
{
	DEBUG_STREAM << "FitsImporter::read_ErrorFileCounter(Tango::Attribute &attr) entering... " << endl;
	DEBUG_STREAM << "FitsImporter::read_ErrorFileCounter(Tango::Attribute &attr) entering... " << endl;
	/*----- PROTECTED REGION ID(FitsImporter::read_ErrorFileCounter) ENABLED START -----*/
	/*----- PROTECTED REGION ID(FitsImporter::read_ErrorFileCounter) ENABLED START -----*/
	//	Set the attribute value

    if(m_eventThread_sp)
        *attr_ErrorFileCounter_read = m_eventThread_sp->readErrorCounter();
    
	attr.set_value(attr_ErrorFileCounter_read);
	attr.set_value(attr_ErrorFileCounter_read);
	
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_ErrorFileCounter
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_ErrorFileCounter
@@ -615,7 +635,23 @@ void FitsImporter::on()
	DEBUG_STREAM << "FitsImporter::On()  - " << device_name << endl;
	DEBUG_STREAM << "FitsImporter::On()  - " << device_name << endl;
	/*----- PROTECTED REGION ID(FitsImporter::on) ENABLED START -----*/
	/*----- PROTECTED REGION ID(FitsImporter::on) ENABLED START -----*/
	
	
	//	Add your own code
	try
    {
        if(m_eventThread_sp)
            m_eventThread_sp->start();    
    }
    catch(std::exception& ex)
    {
        set_state(Tango::FAULT);
        std::stringstream error_stream;
        error_stream << "FitsImporter::On(): " << ex.what() << std::endl;
        set_status(error_stream.str());
    }
    catch(...)
    {
        set_state(Tango::FAULT);
        set_status("FitsImporter::On(): unknown error");
    }
	
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::on
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::on
}
}
@@ -631,7 +667,23 @@ void FitsImporter::off()
	DEBUG_STREAM << "FitsImporter::Off()  - " << device_name << endl;
	DEBUG_STREAM << "FitsImporter::Off()  - " << device_name << endl;
	/*----- PROTECTED REGION ID(FitsImporter::off) ENABLED START -----*/
	/*----- PROTECTED REGION ID(FitsImporter::off) ENABLED START -----*/
	
	
	//	Add your own code
	try
    {
        if(m_eventThread_sp)
            m_eventThread_sp->stop();
    }
    catch(std::exception& ex)
    {
        set_state(Tango::FAULT);
        std::stringstream error_stream;
        error_stream << "FitsImporter::Off(): " << ex.what() << std::endl;
        set_status(error_stream.str());
    }
    catch(...)
    {
        set_state(Tango::FAULT);
        set_status("FitsImporter::Off(): unknown error");
    }
	
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::off
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::off
}
}
@@ -647,7 +699,14 @@ void FitsImporter::reset_counter()
	DEBUG_STREAM << "FitsImporter::ResetCounter()  - " << device_name << endl;
	DEBUG_STREAM << "FitsImporter::ResetCounter()  - " << device_name << endl;
	/*----- PROTECTED REGION ID(FitsImporter::reset_counter) ENABLED START -----*/
	/*----- PROTECTED REGION ID(FitsImporter::reset_counter) ENABLED START -----*/
	
	
	//	Add your own code
    if(m_eventThread_sp)
    {
        m_eventThread_sp->resetRegularCounter();
        
        m_eventThread_sp->resetWarningCounter();
        
        m_eventThread_sp->resetErrorCounter();
    }
	
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::reset_counter
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::reset_counter
}
}
@@ -655,85 +714,93 @@ void FitsImporter::reset_counter()
/*----- PROTECTED REGION ID(FitsImporter::namespace_ending) ENABLED START -----*/
/*----- PROTECTED REGION ID(FitsImporter::namespace_ending) ENABLED START -----*/


const uint32_t FitsImporter::create_inotify_mask(const std::vector<std::string>& event_list)
const uint32_t FitsImporter::create_inotify_mask(const std::vector<std::string>& event_list)
    throw(std::invalid_argument)
{
{
    DEBUG_STREAM << "FitsImporter::create_inotify_mask()  - " << device_name << endl;
    DEBUG_STREAM << "FitsImporter::create_inotify_mask()  - " << device_name << endl;
    
    
	uint32_t iNotifyMask = 0;
	uint32_t iNotifyMask = 0;


	if(event_list.empty())
	if(event_list.empty())
		throw std::invalid_argument("FitsImporter::create_inotify_mask(): event list is empty");
		throw std::invalid_argument("FitsImporter::create_inotify_mask(): "
                "event list is empty");


	std::vector<std::string>::const_iterator it;
	std::vector<std::string>::const_iterator it;
	for(it=event_list.begin(); it!=event_list.end(); it++)
	for(it=event_list.begin(); it!=event_list.end(); it++)
	{
	{
        std::stringstream event_stream;
        event_stream << "FitsImporter::create_inotify_mask(): ";
        
		if(it->compare("IN_ACCESS")==0)
		if(it->compare("IN_ACCESS")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_ACCESS event found" << endl;
            event_stream << "IN_ACCESS event found";
			iNotifyMask += IN_ACCESS;
			iNotifyMask += IN_ACCESS;
		}
		}
		else if(it->compare("IN_MODIFY")==0)
		else if(it->compare("IN_MODIFY")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_MODIFY event found" << endl;

            event_stream << "IN_MODIFY event found";
			iNotifyMask += IN_MODIFY;
			iNotifyMask += IN_MODIFY;
		}
		}
		else if(it->compare("IN_ATTRIB")==0)
		else if(it->compare("IN_ATTRIB")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_ATTRIB event found" << endl;
            event_stream << "IN_ATTRIB event found";
			iNotifyMask += IN_ATTRIB;
			iNotifyMask += IN_ATTRIB;
		}
		}
		else if(it->compare("IN_CLOSE_WRITE")==0)
		else if(it->compare("IN_CLOSE_WRITE")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_CLOSE_WRITE event found" << endl;
            event_stream << "IN_CLOSE_WRITE event found";
			iNotifyMask += IN_CLOSE_WRITE;
			iNotifyMask += IN_CLOSE_WRITE;
		}
		}
		else if(it->compare("IN_CLOSE_NOWRITE")==0)
		else if(it->compare("IN_CLOSE_NOWRITE")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_CLOSE_NOWRITE event found" << endl;
            event_stream << "IN_CLOSE_NOWRITE event found";
			iNotifyMask += IN_CLOSE_NOWRITE;
			iNotifyMask += IN_CLOSE_NOWRITE;
		}
		}
		else if(it->compare("IN_OPEN")==0)
		else if(it->compare("IN_OPEN")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_OPEN event found" << endl;
            event_stream << "IN_OPEN event found";
			iNotifyMask += IN_OPEN;
			iNotifyMask += IN_OPEN;
		}
		}
		else if(it->compare("IN_MOVED_FROM")==0)
		else if(it->compare("IN_MOVED_FROM")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_MOVED_FROM event found" << endl;
            event_stream << "IN_MOVED_FROM event found";
			iNotifyMask += IN_MOVED_FROM;
			iNotifyMask += IN_MOVED_FROM;
		}
		}
		else if(it->compare("IN_MOVED_TO")==0)
		else if(it->compare("IN_MOVED_TO")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_MOVED_TO event found" << endl;
            event_stream << "IN_MOVED_TO event found";
			iNotifyMask += IN_MOVED_TO;
			iNotifyMask += IN_MOVED_TO;
		}
		}
		else if(it->compare("IN_DELETE")==0)
		else if(it->compare("IN_DELETE")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_DELETE event found" << endl;
            event_stream << "IN_DELETE event found";
			iNotifyMask += IN_DELETE;
			iNotifyMask += IN_DELETE;
		}
		}
		else if(it->compare("IN_DELETE_SELF")==0)
		else if(it->compare("IN_DELETE_SELF")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_DELETE_SELF event found" << endl;
            event_stream << "IN_DELETE_SELF event found";
			iNotifyMask += IN_DELETE_SELF;
			iNotifyMask += IN_DELETE_SELF;
		}
		}
		else if(it->compare("IN_CLOSE")==0)
		else if(it->compare("IN_CLOSE")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_CLOSE event found" << endl;
            event_stream << "IN_CLOSE event found";
			iNotifyMask += IN_CLOSE;
			iNotifyMask += IN_CLOSE;
		}
		}
		else if(it->compare("IN_MOVE")==0)
		else if(it->compare("IN_MOVE")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_MOVE event found" << endl;
            event_stream << "IN_MOVE event found";
			iNotifyMask += IN_MOVE;
			iNotifyMask += IN_MOVE;
		}
		}
		else if(it->compare("IN_ALL_EVENTS")==0)
		else if(it->compare("IN_ALL_EVENTS")==0)
		{
		{
            DEBUG_STREAM << "FitsImporter::create_inotify_mask(): IN_ALL_EVENTS event found" << endl;
            event_stream << "IN_ALL_EVENTS event found";
			iNotifyMask += IN_ALL_EVENTS;
			iNotifyMask += IN_ALL_EVENTS;
		}
		}
		else
		else
			throw std::invalid_argument("FitsImporter::create_inotify_mask(): "
			throw std::invalid_argument("FitsImporter::create_inotify_mask(): "
                    "string \"" + *it + " \" is invalid inotify event");
                    "string \"" + *it + " \" is invalid inotify event");
        
        DEBUG_STREAM << event_stream.str() << endl;
	}	
	}	
	
	
	return iNotifyMask;    
	return iNotifyMask;    
+18 −23

File changed.

Preview size limit exceeded, changes collapsed.

+8 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading