Commit 4f290d05 authored by Marco De Marco's avatar Marco De Marco
Browse files

Data model properties and counters added

parent 26e6b3e9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
#================================================================================
EXEC_NAME := fitsImporter-srv
INST_NAME := test
DEBUG := -v5
DEBUG_LEV := -v4
#================================================================================
INC_DIR := /usr/local/omniORB-4.1.7/include \
	   /usr/local/zeromq-3.2.3/include/zmq \
	   /usr/local/tango-8.1.2/include/tango \
@@ -29,7 +30,7 @@ OBJ_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o)))
all: $(EXECUTABLE)

run: $(EXECUTABLE)
	$(EXECUTABLE) $(INST_NAME) $(DEBUG)
	$(EXECUTABLE) $(INST_NAME) $(DEBUG_LEV)

$(EXECUTABLE): makedir $(OBJ_FILES)
	$(CC) $(LDFLAGS) $(LIB_PARM) -o $@ $(OBJ_FILES)
@@ -57,3 +58,4 @@ echo:
	@echo $(INC_PARM)
	@echo LIB_PARM
	@echo $(LIB_PARM)
+235 −42
Original line number Diff line number Diff line
@@ -58,11 +58,17 @@ static const char *RcsId = "$Id: $";
//================================================================
//  State         |  Inherited (no method)
//  Status        |  Inherited (no method)
//  On            |  on
//  Off           |  off
//  ResetCounter  |  reset_counter
//================================================================

//================================================================
//  Attributes managed is:
//  Attributes managed are:
//================================================================
//  RegularFileCounter  |  Tango::DevULong	Scalar
//  WarningFileCounter  |  Tango::DevULong	Scalar
//  ErrorFileCounter    |  Tango::DevULong	Scalar
//================================================================

namespace FitsImporter_ns
@@ -121,6 +127,9 @@ void FitsImporter::delete_device()
	//	Delete device allocated objects
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::delete_device
	delete[] attr_RegularFileCounter_read;
	delete[] attr_WarningFileCounter_read;
	delete[] attr_ErrorFileCounter_read;
}

//--------------------------------------------------------
@@ -141,9 +150,10 @@ void FitsImporter::init_device()

	//	Get the device properties from database
	get_device_property();
	if (mandatoryNotDefined)
		return;
	
	attr_RegularFileCounter_read = new Tango::DevULong[1];
	attr_WarningFileCounter_read = new Tango::DevULong[1];
	attr_ErrorFileCounter_read = new Tango::DevULong[1];

	/*----- PROTECTED REGION ID(FitsImporter::init_device) ENABLED START -----*/
	
@@ -166,7 +176,6 @@ void FitsImporter::get_device_property()
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::get_device_property_before

	mandatoryNotDefined = false;

	//	Read device properties from database.
	Tango::DbData	dev_prop;
@@ -175,6 +184,16 @@ void FitsImporter::get_device_property()
	dev_prop.push_back(Tango::DbDatum("ConnectionNumber"));
	dev_prop.push_back(Tango::DbDatum("EventList"));
	dev_prop.push_back(Tango::DbDatum("WaitTime"));
	dev_prop.push_back(Tango::DbDatum("InstrumentList"));
	dev_prop.push_back(Tango::DbDatum("DefaultInstrument"));
	dev_prop.push_back(Tango::DbDatum("DMDBHost"));
	dev_prop.push_back(Tango::DbDatum("DMDBPort"));
	dev_prop.push_back(Tango::DbDatum("DMDBUser"));
	dev_prop.push_back(Tango::DbDatum("DMDBPassword"));
	dev_prop.push_back(Tango::DbDatum("DMDBSchema"));
	dev_prop.push_back(Tango::DbDatum("DMDBInstrumentTable"));
	dev_prop.push_back(Tango::DbDatum("DMDBDestinationTable"));
	dev_prop.push_back(Tango::DbDatum("DMDBMappingTable"));

	//	is there at least one property to be read ?
	if (dev_prop.size()>0)
@@ -199,8 +218,6 @@ void FitsImporter::get_device_property()
		}
		//	And try to extract WatchPath value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  watchPath;
		//	Property StartDsPath is mandatory, check if has been defined in database.
		check_mandatory_property(cl_prop, dev_prop[i]);

		//	Try to initialize WorkerNumber from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
@@ -246,42 +263,124 @@ void FitsImporter::get_device_property()
		//	And try to extract WaitTime value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  waitTime;

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

	/*----- PROTECTED REGION ID(FitsImporter::get_device_property_after) ENABLED START -----*/
		//	Try to initialize DefaultInstrument from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  defaultInstrument;
		else {
			//	Try to initialize DefaultInstrument from default device value
			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
			if (def_prop.is_empty()==false)	def_prop  >>  defaultInstrument;
		}
		//	And try to extract DefaultInstrument value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  defaultInstrument;

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

	/*----- PROTECTED REGION END -----*/	//	FitsImporter::get_device_property_after
		//	Try to initialize DMDBPort from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  dMDBPort;
		else {
			//	Try to initialize DMDBPort from default device value
			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
			if (def_prop.is_empty()==false)	def_prop  >>  dMDBPort;
		}
//--------------------------------------------------------
/**
 *	Method      : FitsImporter::check_mandatory_property()
 *	Description : For mandatory properties check if defined in database.
 */
//--------------------------------------------------------
void FitsImporter::check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop)
{
	//	Check if all properties are empty
	if (class_prop.is_empty() && dev_prop.is_empty())
	{
		TangoSys_OMemStream	tms;
		tms << endl <<"Property \'" << dev_prop.name;
		if (Tango::Util::instance()->_UseDb==true)
			tms << "\' is mandatory but not defined in database";
		else
			tms << "\' is mandatory but cannot be defined without database";
		string	status(get_status());
		status += tms.str();
		set_status(status);
		mandatoryNotDefined = true;
		/*----- PROTECTED REGION ID(FitsImporter::check_mandatory_property) ENABLED START -----*/
		cerr << tms.str() << " for " << device_name << endl;
		
		/*----- PROTECTED REGION END -----*/	//	FitsImporter::check_mandatory_property
		//	And try to extract DMDBPort value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  dMDBPort;

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

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

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

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

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

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

	}

	/*----- PROTECTED REGION ID(FitsImporter::get_device_property_after) ENABLED START -----*/
	
	//	Check device property data members init
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::get_device_property_after
}

//--------------------------------------------------------
/**
@@ -292,14 +391,6 @@ void FitsImporter::check_mandatory_property(Tango::DbDatum &class_prop, Tango::D
void FitsImporter::always_executed_hook()
{
	INFO_STREAM << "FitsImporter::always_executed_hook()  " << device_name << endl;
	if (mandatoryNotDefined)
	{
		string	status(get_status());
		Tango::Except::throw_exception(
					(const char *)"PROPERTY_NOT_SET",
					status.c_str(),
					(const char *)"FitsImporter::always_executed_hook()");
	}
	/*----- PROTECTED REGION ID(FitsImporter::always_executed_hook) ENABLED START -----*/
	
	//	code always executed before all requests
@@ -323,6 +414,60 @@ void FitsImporter::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_attr_hardware
}

//--------------------------------------------------------
/**
 *	Read attribute RegularFileCounter related method
 *	Description: Indicate file correctly ingested
 *
 *	Data type:	Tango::DevULong
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void FitsImporter::read_RegularFileCounter(Tango::Attribute &attr)
{
	DEBUG_STREAM << "FitsImporter::read_RegularFileCounter(Tango::Attribute &attr) entering... " << endl;
	/*----- PROTECTED REGION ID(FitsImporter::read_RegularFileCounter) ENABLED START -----*/
	//	Set the attribute value
	attr.set_value(attr_RegularFileCounter_read);
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_RegularFileCounter
}
//--------------------------------------------------------
/**
 *	Read attribute WarningFileCounter related method
 *	Description: Indicate file ingested in default instrument
 *
 *	Data type:	Tango::DevULong
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void FitsImporter::read_WarningFileCounter(Tango::Attribute &attr)
{
	DEBUG_STREAM << "FitsImporter::read_WarningFileCounter(Tango::Attribute &attr) entering... " << endl;
	/*----- PROTECTED REGION ID(FitsImporter::read_WarningFileCounter) ENABLED START -----*/
	//	Set the attribute value
	attr.set_value(attr_WarningFileCounter_read);
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_WarningFileCounter
}
//--------------------------------------------------------
/**
 *	Read attribute ErrorFileCounter related method
 *	Description: Indicate file not ingested due to an error
 *
 *	Data type:	Tango::DevULong
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void FitsImporter::read_ErrorFileCounter(Tango::Attribute &attr)
{
	DEBUG_STREAM << "FitsImporter::read_ErrorFileCounter(Tango::Attribute &attr) entering... " << endl;
	/*----- PROTECTED REGION ID(FitsImporter::read_ErrorFileCounter) ENABLED START -----*/
	//	Set the attribute value
	attr.set_value(attr_ErrorFileCounter_read);
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::read_ErrorFileCounter
}

//--------------------------------------------------------
/**
@@ -340,6 +485,54 @@ void FitsImporter::add_dynamic_attributes()
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::add_dynamic_attributes
}

//--------------------------------------------------------
/**
 *	Command On related method
 *	Description: Activate fits importer
 *
 */
//--------------------------------------------------------
void FitsImporter::on()
{
	DEBUG_STREAM << "FitsImporter::On()  - " << device_name << endl;
	/*----- PROTECTED REGION ID(FitsImporter::on) ENABLED START -----*/
	
	//	Add your own code
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::on
}
//--------------------------------------------------------
/**
 *	Command Off related method
 *	Description: Deactivate fits importer
 *
 */
//--------------------------------------------------------
void FitsImporter::off()
{
	DEBUG_STREAM << "FitsImporter::Off()  - " << device_name << endl;
	/*----- PROTECTED REGION ID(FitsImporter::off) ENABLED START -----*/
	
	//	Add your own code
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::off
}
//--------------------------------------------------------
/**
 *	Command ResetCounter related method
 *	Description: 
 *
 */
//--------------------------------------------------------
void FitsImporter::reset_counter()
{
	DEBUG_STREAM << "FitsImporter::ResetCounter()  - " << device_name << endl;
	/*----- PROTECTED REGION ID(FitsImporter::reset_counter) ENABLED START -----*/
	
	//	Add your own code
	
	/*----- PROTECTED REGION END -----*/	//	FitsImporter::reset_counter
}

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

+77 −7
Original line number Diff line number Diff line
@@ -91,9 +91,34 @@ public:
	vector<string>	eventList;
	//	WaitTime:	Time fits importer has to sleep between new time event and ingestion
	Tango::DevULong	waitTime;

	bool	mandatoryNotDefined;

	//	InstrumentList:	List of instrument used by fits importer when ingesting file
	string	instrumentList;
	//	DefaultInstrument:	Default instrument used by fits importer when:
	//  1) no instrument match with file
	//  2) an error occurs during metadata extraction
	string	defaultInstrument;
	//	DMDBHost:	Hostname where data model database is running
	string	dMDBHost;
	//	DMDBPort:	Port where data model database is listening
	Tango::DevUShort	dMDBPort;
	//	DMDBUser:	User to login in data model database
	string	dMDBUser;
	//	DMDBPassword:	Password to login in data model database
	string	dMDBPassword;
	//	DMDBSchema:	Schema where data model tables are located
	string	dMDBSchema;
	//	DMDBInstrumentTable:	Instrument table name
	string	dMDBInstrumentTable;
	//	DMDBDestinationTable:	Destination table name
	string	dMDBDestinationTable;
	//	DMDBMappingTable:	Mapping table name
	string	dMDBMappingTable;

//	Attribute data members
public:
	Tango::DevULong	*attr_RegularFileCounter_read;
	Tango::DevULong	*attr_WarningFileCounter_read;
	Tango::DevULong	*attr_ErrorFileCounter_read;

//	Constructors and destructors
public:
@@ -144,10 +169,6 @@ public:
	 */
	virtual void always_executed_hook();

	/*
	 *	Check if mandatory property has been set
	 */
	 void check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop);

//	Attribute methods
public:
@@ -159,6 +180,34 @@ public:
	//--------------------------------------------------------
	virtual void read_attr_hardware(vector<long> &attr_list);

/**
 *	Attribute RegularFileCounter related methods
 *	Description: Indicate file correctly ingested
 *
 *	Data type:	Tango::DevULong
 *	Attr type:	Scalar
 */
	virtual void read_RegularFileCounter(Tango::Attribute &attr);
	virtual bool is_RegularFileCounter_allowed(Tango::AttReqType type);
/**
 *	Attribute WarningFileCounter related methods
 *	Description: Indicate file ingested in default instrument
 *
 *	Data type:	Tango::DevULong
 *	Attr type:	Scalar
 */
	virtual void read_WarningFileCounter(Tango::Attribute &attr);
	virtual bool is_WarningFileCounter_allowed(Tango::AttReqType type);
/**
 *	Attribute ErrorFileCounter related methods
 *	Description: Indicate file not ingested due to an error
 *
 *	Data type:	Tango::DevULong
 *	Attr type:	Scalar
 */
	virtual void read_ErrorFileCounter(Tango::Attribute &attr);
	virtual bool is_ErrorFileCounter_allowed(Tango::AttReqType type);


	//--------------------------------------------------------
	/**
@@ -172,6 +221,27 @@ public:

//	Command related methods
public:
	/**
	 *	Command On related method
	 *	Description: Activate fits importer
	 *
	 */
	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);
	/**
	 *	Command ResetCounter related method
	 *	Description: 
	 *
	 */
	virtual void reset_counter();
	virtual bool is_ResetCounter_allowed(const CORBA::Any &any);


/*----- PROTECTED REGION ID(FitsImporter::Additional Method prototypes) ENABLED START -----*/
+107 −5

File changed.

Preview size limit exceeded, changes collapsed.

+297 −3

File changed.

Preview size limit exceeded, changes collapsed.

Loading