Commit e665d6f0 authored by Giuseppe Carboni's avatar Giuseppe Carboni Committed by GitHub
Browse files

Fix #413, reworked weather station devIOs behavior (#414)

* Fix #413, reworker weather station devIOs behavior

* Fixed some type casting inconsistencies

* Fix #413, updated Noto weather station

Also, fixed some typos in the common WeatherStation
parent 3033f539
Loading
Loading
Loading
Loading
+17 −37
Original line number Diff line number Diff line
@@ -10,30 +10,24 @@
/* Who                                when            What                                              */
/* Sergio  Poppi(spoppi@oa-cagliari.inaf.it)  	02/01/2009     Creation                                         */


#include <baci.h>
#include <baciDevIO.h>
#include <IRA>
#include <map>
#include "WeatherSocket.h"
#include "WeatherStationData.h"
using namespace IRA;

/**
 * This class is derived from template DevIO and it is used by the temperature  property  of the MeteoStation component
 * This class is derived from template DevIO and it is used by the humidity property of the MeteoStation component
 * @author <a href=mailto:spoppi@oa-cagliari.inaf.it>Sergio Poppi</a>,
 * Istituto di Radioastronomia, Italia<br> 
*/
class DevIOHumidity : public DevIO<CORBA::Double>
{
public:
	
 	/** 
	 * Constructor
	 * @param Socket pointer to a SecureArea that proctects a the  socket. This object must be already initialized and configured.
	*/
	DevIOHumidity(CSecureArea<WeatherSocket>* socket):m_socket(socket) 
	DevIOHumidity()
	{		
 		m_initparser=false;
		AUTO_TRACE("DevIOHumidity::DevIOHumidity()");		
	}

@@ -56,44 +50,30 @@ public:
	
	/**
	 * Used to read the property value.
	 * @throw ComponentErrors::PropertyError
	 * @param timestamp epoch when the operation completes
	*/ 
	CORBA::Double  read(ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	CORBA::Double read(ACS::Time& timestamp)
	{
		// get the CommandLine .......
		try {
			CError err;
			CString rdata="";
			CSecAreaResourceWrapper<WeatherSocket> sock=m_socket->Get();
			m_val=sock->getHumidity();
			timestamp=getTimeStamp();  //complition time
		timestamp = getTimeStamp();
        baci::ThreadSyncGuard guard(&m_mutex);
        return m_val;
	}
		catch (ACSErr::ACSbaseExImpl& E) {
			_ADD_BACKTRACE(ComponentErrors::PropertyErrorExImpl,dummy,E,"DevIOHumidity::read()");
			dummy.setPropertyName("humidity");
			dummy.setReason("Property could not be read");
			//_IRA_LOGGUARD_LOG_EXCEPTION(m_logGuard,dummy,LM_DEBUG);
			throw dummy;
		} 				

	}
	/**
	 * It writes values into controller. Unused because the properties are read-only.
	 * It writes values into controller.
     * @param value the new value to set
	 * @param timestamp epoch when the operation completes
	*/ 
	void write(const CORBA::Double& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	void write(const CORBA::Double& value, ACS::Time& timestamp)
	{
		timestamp = getTimeStamp();
		return;
        baci::ThreadSyncGuard guard(&m_mutex);
        m_val = value;
	}
	
private:
	CSecureArea<WeatherSocket>* m_socket;
	WeatherStationData m_wsdata; 

	CORBA::Double m_val;
	bool m_initparser;
    BACIMutex m_mutex;
};


+15 −34
Original line number Diff line number Diff line
@@ -10,16 +10,13 @@
/* Who                                when            What                                              */
/* Sergio  Poppi(spoppi@oa-cagliari.inaf.it)  	02/01/2009     Creation                                         */


#include <baci.h>
#include <baciDevIO.h>
#include <IRA>
#include <map>
#include "WeatherSocket.h"
#include "WeatherStationData.h"
using namespace IRA;

/**
 * This class is derived from template DevIO and it is used by the temperature  property  of the MeteoStation component
 * This class is derived from template DevIO and it is used by the pressure property  of the MeteoStation component
 * @author <a href=mailto:spoppi@oa-cagliari.inaf.it>Sergio Poppi</a>,
 * Istituto di Radioastronomia, Italia<br> 
*/
@@ -29,11 +26,9 @@ public:
	
 	/** 
	 * Constructor
	 * @param Socket pointer to a SecureArea that proctects a the  socket. This object must be already initialized and configured.
	*/
	DevIOPressure(CSecureArea<WeatherSocket>* socket):m_socket(socket)
	DevIOPressure()
	{		
 		m_initparser=false;
		AUTO_TRACE("DevIOPressure::DevIOPressure()");		
	}

@@ -56,43 +51,29 @@ public:
	
	/**
	 * Used to read the property value.
	 * @throw ComponentErrors::PropertyError
	 * @param timestamp epoch when the operation completes
	*/ 
	CORBA::Double  read(ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	CORBA::Double read(ACS::Time& timestamp)
	{
		// get the CommandLine .......
		try {
			CError err;
			CString rdata="";
			CSecAreaResourceWrapper<WeatherSocket> sock=m_socket->Get();
  			m_val=sock->getPressure();
		}
		catch (ACSErr::ACSbaseExImpl& E) {
			_ADD_BACKTRACE(ComponentErrors::PropertyErrorExImpl,dummy,E,"DevIOPressure::read()");
			dummy.setPropertyName("pressure");
			dummy.setReason("Property could not be read");
			//_IRA_LOGGUARD_LOG_EXCEPTION(m_logGuard,dummy,LM_DEBUG);
			throw dummy;
		} 				
		timestamp=getTimeStamp();  //complition time
        timestamp = getTimeStamp();
        baci::ThreadSyncGuard guard(&m_mutex);
        return m_val;
	}
	/**
	 * It writes values into controller. Unused because the properties are read-only.
	 * It writes values into controller.
     * @param value the new value to set
	 * @param timestamp epoch when the operation completes
	*/ 
	void write(const CORBA::Double& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	void write(const CORBA::Double& value, ACS::Time& timestamp)
	{
		timestamp = getTimeStamp();
		return;
        baci::ThreadSyncGuard guard(&m_mutex);
        m_val = value;
	}
	
private:
	CSecureArea<WeatherSocket>* m_socket;
	CORBA::Double m_val;
	WeatherStationData m_wsdata; 

	bool m_initparser;
    BACIMutex m_mutex;
 };


+15 −35
Original line number Diff line number Diff line
@@ -10,12 +10,9 @@
/* Who                                when            What                                              */
/* Sergio  Poppi(spoppi@oa-cagliari.inaf.it)  	02/01/2009     Creation                                         */


#include <baci.h>
#include <baciDevIO.h>
#include <IRA>
#include <map>
#include "WeatherSocket.h"
#include "WeatherStationData.h"
using namespace IRA;

/**
@@ -29,11 +26,9 @@ public:
	
 	/** 
	 * Constructor
	 * @param Socket pointer to a SecureArea that proctects a the  socket. This object must be already initialized and configured.
	*/
	DevIOTemperature(CSecureArea<WeatherSocket>* socket ):m_socket(socket) 
	DevIOTemperature()
	{		
 		m_initparser=false;
		AUTO_TRACE("DevIOTemperature::DevIOTemperature()");		
	}

@@ -56,45 +51,30 @@ public:
	
	/**
	 * Used to read the property value.
	 * @throw ComponentErrors::PropertyError
	 * @param timestamp epoch when the operation completes
	*/ 
	CORBA::Double  read(ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	CORBA::Double read(ACS::Time& timestamp)
	{
		// get the CommandLine .......
		try {
			CError err;
			CString rdata="";
			CSecAreaResourceWrapper<WeatherSocket> sock=m_socket->Get();
 			m_val=sock->getTemperature();
		        return m_val;

		}
		catch (ACSErr::ACSbaseExImpl& E) {
			_ADD_BACKTRACE(ComponentErrors::PropertyErrorExImpl,dummy,E,"DevIOTemperature::read()");
			dummy.setPropertyName("temperature");
			dummy.setReason("Property could not be read");
			//_IRA_LOGGUARD_LOG_EXCEPTION(m_logGuard,dummy,LM_DEBUG);
			throw dummy;
		} 				
		timestamp=getTimeStamp();  //complition time
		timestamp = getTimeStamp();
        baci::ThreadSyncGuard guard(&m_mutex);
		return m_val;
	}

	/**
	 * It writes values into controller. Unused because the properties are read-only.
	 * It writes values into controller.
     * @param value the new value to set
	 * @param timestamp epoch when the operation completes
	*/ 
	void write(const CORBA::Double& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	void write(const CORBA::Double& value, ACS::Time& timestamp)
	{
		timestamp = getTimeStamp();
		return;
        baci::ThreadSyncGuard guard(&m_mutex);
        m_val = value;
	}
	
private:
	CSecureArea<WeatherSocket>* m_socket;
	WeatherStationData m_wsdata; 

	CORBA::Double m_val;
	bool m_initparser;
    BACIMutex m_mutex;
 };


+15 −35
Original line number Diff line number Diff line
@@ -10,12 +10,9 @@
/* Who                                when            What                                              */
/* Sergio  Poppi(spoppi@oa-cagliari.inaf.it)  	02/01/2009     Creation                                         */


#include <baci.h>
#include <baciDevIO.h>
#include <IRA>
#include <map>
#include "WeatherSocket.h"
#include "WeatherStationData.h"
using namespace IRA;

/**
@@ -29,11 +26,9 @@ public:
	
 	/** 
	 * Constructor
	 * @param Socket pointer to a SecureArea that proctects a the  socket. This object must be already initialized and configured.
	*/
	DevIOWinddir(CSecureArea<WeatherSocket>* socket ):m_socket(socket) 
	DevIOWinddir()
	{		
 		m_initparser=false;
		AUTO_TRACE("DevIOWinddir::DevIOWinddir()");		
	}

@@ -56,45 +51,30 @@ public:
	
	/**
	 * Used to read the property value.
	 * @throw ComponentErrors::PropertyError
	 * @param timestamp epoch when the operation completes
	*/ 
	CORBA::Double  read(ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	CORBA::Double read(ACS::Time& timestamp)
	{
		// get the CommandLine .......
		try {
			CError err;
			CString rdata="";
			CSecAreaResourceWrapper<WeatherSocket> sock=m_socket->Get();
 			m_val=sock->getWinDir();

		
		}
		catch (ACSErr::ACSbaseExImpl& E) {
			_ADD_BACKTRACE(ComponentErrors::PropertyErrorExImpl,dummy,E,"DevIOWinddir::read()");
			dummy.setPropertyName("windDirection");
			dummy.setReason("Property could not be read");
			//_IRA_LOGGUARD_LOG_EXCEPTION(m_logGuard,dummy,LM_DEBUG);
			throw dummy;
		} 				
		timestamp=getTimeStamp();  //complition time
		timestamp = getTimeStamp();
        baci::ThreadSyncGuard guard(&m_mutex);
		return m_val;
	}

	/**
	 * It writes values into controller. Unused because the properties are read-only.
	 * It writes values into controller.
     * @param value the new value to set
	 * @param timestamp epoch when the operation completes
	*/ 
	void write(const CORBA::Double& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	void write(const CORBA::Double& value, ACS::Time& timestamp)
	{
		timestamp = getTimeStamp();
		return;
        baci::ThreadSyncGuard guard(&m_mutex);
        m_val = value;
	}
	
private:
	CSecureArea<WeatherSocket>* m_socket;
	CORBA::Double m_val;
	WeatherStationData m_wsdata; 

	bool m_initparser;
    BACIMutex m_mutex;
};


+17 −42
Original line number Diff line number Diff line
@@ -10,18 +10,14 @@
/* Who                                when            What                                              */
/* Sergio  Poppi(spoppi@oa-cagliari.inaf.it)  	02/01/2009     Creation                                         */


#include <baci.h>
#include <baciDevIO.h>
#include <IRA>
#include <map>
#include "WeatherSocket.h"
#include "WeatherStationData.h"
#include <ComponentErrors.h>

using namespace IRA;

/**
 * This class is derived from template DevIO and it is used by the temperature  property  of the MeteoStation component
 * This class is derived from template DevIO and it is used by the windspeed property of the MeteoStation component
 * @author <a href=mailto:spoppi@oa-cagliari.inaf.it>Sergio Poppi</a>,
 * Istituto di Radioastronomia, Italia<br> 
*/
@@ -31,11 +27,9 @@ public:
	
 	/** 
	 * Constructor
	 * @param Socket pointer to a SecureArea that proctects a the  socket. This object must be already initialized and configured.
	*/
	DevIOWindspeed(CSecureArea<WeatherSocket>* socket):m_socket(socket)
	DevIOWindspeed()
	{		
 		m_initparser=false;
		AUTO_TRACE("DevIOWindspeed::DevIOWindspeed()");		
	}

@@ -58,49 +52,30 @@ public:
	
	/**
	 * Used to read the property value.
	 * @throw ComponentErrors::PropertyError
	 * @param timestamp epoch when the operation completes
	*/ 
	CORBA::Double  read(ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	CORBA::Double read(ACS::Time& timestamp)
	{
		// get the CommandLine .......
		try {
			CSecAreaResourceWrapper<WeatherSocket> sock=m_socket->Get();

			m_val=	sock->getWind();	

			timestamp=getTimeStamp();  //complition time
        timestamp = getTimeStamp();
        baci::ThreadSyncGuard guard(&m_mutex);
        return m_val;
	}
		catch (ComponentErrors::SocketErrorExImpl& E) {
			_ADD_BACKTRACE(ComponentErrors::SocketErrorExImpl,dummy,E,"DevIOWindspeed::read()");
			//_IRA_LOGGUARD_LOG_EXCEPTION(m_logGuard,dummy,LM_DEBUG);
			throw dummy;
		} 				
		catch (ACSErr::ACSbaseExImpl& E) {
			_ADD_BACKTRACE(ComponentErrors::PropertyErrorExImpl,dummy,E,"DevIOWindspeed::read()");
			dummy.setPropertyName("WindSpeed");
			dummy.setReason("Property could not be read");
			//_IRA_LOGGUARD_LOG_EXCEPTION(m_logGuard,dummy,LM_DEBUG);
			throw dummy;
		} 				


	}
	/**
	 * It writes values into controller. Unused because the properties are read-only.
	 * It writes values into controller.
     * @param value the new value to set
	 * @param timestamp epoch when the operation completes
	*/ 
	void write(const CORBA::Double& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	void write(const CORBA::Double& value, ACS::Time& timestamp)
	{
		timestamp = getTimeStamp();
		return;
        baci::ThreadSyncGuard guard(&m_mutex);
        m_val = value;
	}
	
private:
	CSecureArea<WeatherSocket>* m_socket;
	CORBA::Double m_val;
	WeatherStationData m_wsdata; 
	bool m_initparser;
    BACIMutex m_mutex;
};


Loading