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

Fix #411, splitted WeatherStation::getData in two different methods. See below. (#412)

* Splitted WeatherStation::getData in two different methods. See below.

The two methods are `getData`, which returns the last read weather parameters immediately, and `updateData`, which performs the request to the devIOs tu update every weather parameter.
The `updateData` method is now called periodically (every 2 seconds) from the `UpdatingThread` (the former `WindCheckerThread`). This thread also checks if the wind is too strong and automatically stows the antenna.

* Fix #411, set `KeepAliveTime=-1` to the weather station component

This will prevent the component to stop updating the weather parameters when it is not referenced by any other component/client.

* Fix #411, updated NotoWeatherStation as well.

The upgrades on Noto code are basically the same as the GenericWeatherStation component.
Also, fixed some typos on common code and a small bug relative to the period of the weather update thread.
parent 2dd92007
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -37,7 +37,9 @@ module Weather {
		double temperature;
		double humidity;
		double pressure;
		double wind;	
		double windspeed;
		double winddir;
		double windspeedpeak;
/*		short doy;
		short year;
		short hh;
+1 −1
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ void CCore::_getWeatherStationParameters(double &temp,double& hum,double& pres,
	temp=m_weatherPar.temperature;
	hum=m_weatherPar.humidity;
	pres=m_weatherPar.pressure;
	wind=m_weatherPar.wind;
	wind=m_weatherPar.windspeed;
}

void CCore::_initRecording(const long& scanid) throw (ComponentErrors::CouldntGetComponentExImpl,ComponentErrors::UnexpectedExImpl,ComponentErrors::OperationErrorExImpl,
+32 −27
Original line number Diff line number Diff line
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns="urn:schemas-cosylab-com:WeatherStation:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" targetNamespace="urn:schemas-cosylab-com:WeatherStation:1.0" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:schema  xmlns="urn:schemas-cosylab-com:WeatherStation:1.0"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0"
            xmlns:baci="urn:schemas-cosylab-com:BACI:1.0"
            targetNamespace="urn:schemas-cosylab-com:WeatherStation:1.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified" >

<xs:import namespace="urn:schemas-cosylab-com:CDB:1.0" schemaLocation="CDB.xsd"/>
<xs:import namespace="urn:schemas-cosylab-com:BACI:1.0" schemaLocation="BACI.xsd"/>
@@ -14,14 +20,13 @@
                <xs:element name="humidity" type="baci:RWdouble"/>
                <xs:element name="pressure" type="baci:RWdouble"/>
                <xs:element name="autoparkThreshold" type="baci:ROdouble"/>
		  			
		  			
            </xs:sequence>

            <xs:attribute name="IPAddress" type="xs:string" use="required"/>
            <xs:attribute name="port" type="xs:unsignedInt" use="required"/>
            <xs:attribute name="MountInterface" type="xs:string" use="required" />
            <xs:attribute name="windthreshold" type="xs:unsignedInt" use="optional"/>

            <xs:attribute name="UpdatingThreadTime" type="xs:unsignedLong" use="required" />
        </xs:extension>
    </xs:complexContent>
</xs:complexType>
+123 −147
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include <cstdlib>
#include "WeatherSocket.h"
#include "WeatherStationData.h"
// #include "WindCheckerThread.h"
#include <acsThread.h>
#include <AntennaBossC.h>
#include <SchedulerC.h>
@@ -49,7 +48,6 @@
const CString ADDRESS="192.167.8.13"; //DEBUG
const int THREADSLEEPSECONDS=10000; // 1 s in unit of 100ns, from thread sleep time*/


using namespace maci; 
using namespace std; 

@@ -91,16 +89,15 @@ namespace Antenna
using ACS::ThreadBase;
class WeatherStationImpl;

class CWindCheckerThread : public ACS::Thread
class CUpdatingThread : public ACS::Thread
{

public:
	 CWindCheckerThread (const ACE_CString& name,
    CUpdatingThread (const ACE_CString& name,
                     WeatherStationImpl* weatherStation,
                     const ACS::TimeInterval& responseTime=ThreadBase::defaultResponseTime,
                     const ACS::TimeInterval& sleepTime=ThreadBase::defaultSleepTime);

	 ~CWindCheckerThread() { ACS_TRACE("CWindCheckerThread::~CWindCheckerThread"); }
    ~CUpdatingThread() { ACS_TRACE("CUpdatingThread::~CUpdatingThread"); }
    virtual void onStop();
    virtual void onStart();
    virtual void runLoop();
@@ -108,30 +105,20 @@ class CWindCheckerThread : public ACS::Thread
private:
    int loopCounter_m;
    int m_threshold; // wind threshold in km/h
		WeatherStationImpl  * m_srtweatherstation_p;

    WeatherStationImpl* m_weatherstation_p;
};




class  WeatherStationImpl : public virtual CharacteristicComponentImpl,         //Standard component superclass
			                public virtual POA_Weather::GenericWeatherStation   //CORBA servant stub
				   

{
public:
    /**
    Constructor
	
    * @param CompName component's name. This is also the name that will be used to find the configuration data for the component in the Configuration Database.
    * @param containerServices p/ACS_SRT/Common/Interfaces/MetrologyInterface/idlointer to the class that exposes all services offered by container
	
	
    */
	WeatherStationImpl(const ACE_CString &CompName,
			maci::ContainerServices *containerServices);

    WeatherStationImpl(const ACE_CString &CompName, maci::ContainerServices *containerServices);

    /**
    * Destructor.
@@ -148,13 +135,12 @@ public:
    */
    virtual CORBA::Boolean command(const char *cmd, CORBA::String_out answer) throw (CORBA::SystemException);

   
    /**
	*return  the all the data parameters formatted into a 
	*meteoparameters structure
    *return  the all the data parameters formatted into a meteoparameters structure
    * @return  meteoparameters
    */
	virtual Weather::parameters getData() throw (ACSErr::ACSbaseEx,CORBA::SystemException);
    virtual Weather::parameters getData();
    virtual void updateData() throw (ACSErr::ACSbaseEx,CORBA::SystemException);

    virtual double getWindSpeedAverage() throw (ACSErr::ACSbaseEx,CORBA::SystemException);
    virtual double getWindspeedPeak() throw (ACSErr::ACSbaseEx,CORBA::SystemException);
@@ -170,51 +156,43 @@ public:

    void parkAntenna(void);


    /**
    * Returns a reference to the air temperature  property Implementation of IDL interface.
    * @return pointer to read-write double temperature
    */
	 virtual ACS::RWdouble_ptr  temperature ()
	throw (CORBA::SystemException);
    virtual ACS::RWdouble_ptr temperature() throw (CORBA::SystemException);

    /**
    * Returns a reference to the wind direction property Implementation of IDL interface.
    * @return pointer to read-write double wind direction
    */
 	 virtual ACS::RWdouble_ptr  winddir ()
	throw (CORBA::SystemException);
    virtual ACS::RWdouble_ptr winddir() throw (CORBA::SystemException);

    /**
    * Returns a reference to the wind speed property Implementation of IDL interface.
    * @return pointer to read-write double wind speed
    */
    virtual ACS::RWdouble_ptr windspeed() throw (CORBA::SystemException);

 	 virtual ACS::RWdouble_ptr  windspeed ()
	throw (CORBA::SystemException);
    /**
	 * Returns a reference to the wind speed  property Implementation of IDL interface.
	 * @return pointer to read-write double wind speed
    * Returns a reference to the wind speed peak property Implementation of IDL interface.
    * @return pointer to read-write double wind speed peak
    */
    virtual ACS::RWdouble_ptr windspeedpeak() throw (CORBA::SystemException);

 	 virtual ACS::RWdouble_ptr  windspeedpeak ()
	throw (CORBA::SystemException);
    /**
    * Returns a reference to the relative humidity property Implementation of IDL interface.
	 * @return pointer to read-write double wind speed
    * @return pointer to read-write double humidity
    */
    virtual ACS::RWdouble_ptr humidity() throw (CORBA::SystemException);

  	 virtual ACS::RWdouble_ptr  humidity ()
	throw (CORBA::SystemException);
    /**
	 * Returns a reference to the wind speed  property Implementation of IDL interface.
	 * @return pointer to read-write double relative humidity
    * Returns a reference to the pressure property Implementation of IDL interface.
    * @return pointer to read-write double pressure
    */
  	 virtual ACS::RWdouble_ptr  pressure ()
	throw (CORBA::SystemException);

 	virtual ACS::ROdouble_ptr autoparkThreshold() 
	throw (CORBA::SystemException);
    virtual ACS::RWdouble_ptr pressure() throw (CORBA::SystemException);

    virtual ACS::ROdouble_ptr autoparkThreshold() throw (CORBA::SystemException);

    double getWind();
    unsigned int m_threshold;
@@ -227,7 +205,7 @@ private:
    //Antenna::SRTMount_proxy m_mount;        	
    void deleteAll();
    CSecureArea<WeatherSocket> *m_socket;
	CWindCheckerThread *m_controlThread_p;
    CUpdatingThread *m_controlThread_p;
    WeatherStationData m_wsdata;
    CError err;
    CString ADDRESS;
@@ -242,11 +220,9 @@ private:
    SimpleParser::CParser<WeatherSocket> * m_parser;
    unsigned int m_elevationStatus;
    Antenna::ROTCommonModes_ptr m_property;

        
    void operator=(const WeatherStationImpl&);
		
    Weather::parameters m_parameters;
    BACIMutex m_meteoParametersMutex;
};


#endif
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ EXECUTABLES_L =

#
# <brief description of xxxxx program>
WeatherStationImpl_OBJECTS   =	 WeatherStationImpl    WeatherSocket WindCheckerThread 
WeatherStationImpl_OBJECTS   =	 WeatherStationImpl    WeatherSocket UpdatingThread
#xxxxx_LDFLAGS   =
WeatherStationImpl_LIBS      =ComponentErrors \
			IRALibrary\
Loading