Commit 441e0c98 authored by Sergio Poppi's avatar Sergio Poppi
Browse files

Noto WeatherStation impl

parent 8bb8756c
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
    
 -->


<xs:schema
	  targetNamespace="urn:schemas-cosylab-com:NotoWeatherStation:1.0"
	  xmlns="urn:schemas-cosylab-com:NotoWeatherStation: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"	  
	  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"/>
	<xs:complexType name="NotoWeatherStationType">
        <xs:sequence>
      			<xs:element name="temperature" type="baci:RWdouble"/>
		  			<xs:element name="winddir" type="baci:RWdouble"/>
		  			<xs:element name="windspeed" type="baci:RWdouble"/>
		  			<xs:element name="humidity" type="baci:RWdouble"/>
		  			<xs:element name="pressure" type="baci:RWdouble"/>
                                     
                                        <xs:element name="windspeedpeak" type="baci:RWdouble"/>
                                        
		    </xs:sequence>
        <xs:attribute name="IPAddress" type="xs:string" use="required"/>
	       <xs:attribute name="port" type="xs:unsignedInt" use="required"/>
  
  	</xs:complexType>
  
  	<xs:element name="WeatherStation" type="NotoWeatherStationType"/>
</xs:schema>
+0 −2
Original line number Diff line number Diff line
@@ -62,8 +62,6 @@ public:
	{
		// get the CommandLine .......
		try {
			CError err;
			CString rdata="";
			CSecAreaResourceWrapper<MeteoSocket> sock=m_socket->Get();
 			m_val=sock->getTemperature();
		        return m_val;
+107 −0
Original line number Diff line number Diff line
#ifndef DevIOWindspeedPEAK_H_
#define DevIOWindspeedPEAK_H_

/* **************************************************************************************************** */
/*INAF - OACA                                                                      */
/*  					           */
/*                                                                                                      */
/* This code is under GNU General Public Licence (GPL).                                                 */
/*                                                                                                      */
/* Who                                when            What                                              */
/* Sergio  Poppi(spoppi@oa-cagliari.inaf.it)  	02/01/2009     Creation                                         */


#include <baciDevIO.h>
#include <IRA>
#include <map>
#include "MeteoSocket.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
 * @author <a href=mailto:spoppi@oa-cagliari.inaf.it>Sergio Poppi</a>,
 * Istituto di Radioastronomia, Italia<br> 
*/
class DevIOWindspeedPeak : 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.
	*/
	DevIOWindspeedPeak(CSecureArea<MeteoSocket>* socket):m_socket(socket)
	{		
 		m_initparser=false;
		AUTO_TRACE("DevIOWindspeed::DevIOWindspeed()");		
	}

	/**
	 * Destructor
	*/ 
	~DevIOWindspeedPeak()
	{
		ACS_TRACE("DevIOWindspeed::~DevIOWindspeed()");		
	}

	/** 
	 * @return true to initialize the property with default value from CDB.
	*/
	bool initializeValue()
	{		
		AUTO_TRACE("DevIOWindspeed::initializeValue()");		
		return false;
	}
	
	/**
	 * 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)
	{
		// get the CommandLine .......
		try {
			CSecAreaResourceWrapper<MeteoSocket> sock=m_socket->Get();

			m_val=	sock->getWindSpeed();

			timestamp=getTimeStamp();  //complition time
		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.
	*/ 
	void write(const CORBA::Double& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl)
	{
		timestamp=getTimeStamp();
		return;
	}
	
private:
	CSecureArea<MeteoSocket>* m_socket;
	CORBA::Double m_val;
 	bool m_initparser;
 };



#endif /*DevIOWindspeed_H_*/
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ private:
	bool m_isConnected;
static int Depth;
	char Buff[BUFFSIZE];
        char *m_received_data;
	MeteoData *m_meteodata;
	map<string,double> m_map;
	vector<string> split (string message, string delimiter=",");
+9 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "DevIOpressure.h"
#include "DevIOwindspeed.h"
#include "DevIOhumidity.h"
#include "DevIOwindspeedPeak.h"

#include <SP_parser.h>
///Include the smart pointer for properties
@@ -95,7 +96,9 @@ public:
	virtual	CORBA::Double getPressure() throw (CORBA::SystemException);
	virtual	CORBA::Double getHumidity() throw (CORBA::SystemException);
	virtual	CORBA::Double getWindspeed() throw (CORBA::SystemException);

        virtual CORBA::Double getWindspeedPeak() throw (CORBA::SystemException);
        virtual CORBA::Double getWindSpeedAverage() throw (CORBA::SystemException);
        virtual CORBA::Double getWindDir() throw (CORBA::SystemException);

	virtual CORBA::Boolean command(const char *cmd,CORBA::String_out answer) throw (CORBA::SystemException);

@@ -125,6 +128,9 @@ public:

 	 virtual ACS::RWdouble_ptr  windspeed ()
	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
@@ -161,6 +167,8 @@ private:
	SmartPropertyPointer<RWdouble> m_windspeed;
	SmartPropertyPointer<RWdouble> m_humidity;
	SmartPropertyPointer<RWdouble> m_pressure;
        SmartPropertyPointer<RWdouble> m_windspeedPeak;
        
	SimpleParser::CParser<MeteoSocket> * m_parser;

    void operator=(const NotoWeatherStationImpl&);
Loading