Commit d4cc81cc authored by Andrea Orlati's avatar Andrea Orlati Committed by GitHub
Browse files

fix issue #323: meteoCient is now the generic interface of weather station....

fix issue #323: meteoCient is now the generic interface of weather station. The wind threashold (#339)

to park the telescope is not hardcode anymore but read from the weather component
parent 0c44abd0
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/
	allows to setup a set of programmable attenuators in order to control the singal levels. config select
	which configuration to apply between a set of predefined one.
	
	issue #323 - The metClient moved to common part as it is now the general cleint for weather stations. 
	Also the autopark wind threshld is now read from confiugration and not hardcoded.

  issue #324 - full support for CHC receiver at Medicina telescope now added.The receiver will be avaiable 
	under two diffent configurations: 1.2 GHz and 150MHz bandwidth. The respective setup are achived by issueing
	the following procedures "SETUPCHC" and "SETUPCHCL".  
+306 −307
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ import sys
import ACSErrTypeCommonImpl
import ACSErrTypeCommon
import ACSErrTypeOKImpl
import ClientErrorsImpl
from IRAPy import logger
from Acspy.Common.Err import ACSError
from Acspy.Common.Log           import acsPrintExcDebug
from numpy import concatenate,zeros
@@ -86,10 +88,7 @@ class PropertyMonitor(ACS__POA.CBdouble,Qt.QObject):
			self.emit(Qt.SIGNAL("PropertyChanghed(float)"),value)
		
		except:            
		
			acsPrintExcDebug()

		
			print "exception"	
			displayMessageEx = ACSErrTypeCommonImpl.GenericErrorExImpl() 
			displayMessageEx.setErrorDesc("badMethod has thrown an UNEXPECTED exception")
@@ -196,9 +195,10 @@ class TimeScaleDraw(Qwt.QwtScaleDraw):

class Background(Qwt.QwtPlotItem):

    def __init__(self):
	def __init__(self,limit):
		Qwt.QwtPlotItem.__init__(self)
		self.setZ(0.0)
		self.limit=limit

	# __init__()

@@ -214,8 +214,8 @@ class Background(Qwt.QwtPlotItem):
		yellow=Qt.QColor(Qt.Qt.yellow)
  
 
        r.setBottom(yMap.transform(50))
        r.setTop(yMap.transform(50))
		r.setBottom(yMap.transform(self.limit))
		r.setTop(yMap.transform(self.limit))
		painter.fillRect(r,red)

        
@@ -307,7 +307,7 @@ class Values(Qt.QFrame):

class PlotWindWidget(Qwt.QwtPlot):

	def __init__(self,*args):
	def __init__(self,limit,*args):
		Qwt.QwtPlot.__init__(self,*args)
		self.setAutoReplot(False)
		self.t=Qt.QTime()
@@ -326,7 +326,7 @@ class PlotWindWidget(Qwt.QwtPlot):
#		self.curve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,Qt.QBrush(Qt.Qt.blue), Qt.QPen(Qt.Qt.yellow),Qt.QSize(4, 4)))
#                self.curve.setZ(2);
                
                background = Background()
		background = Background(limit)
		background.attach(self)
                
		grid = Qwt.QwtPlotGrid()
@@ -374,12 +374,9 @@ class PlotWindWidget(Qwt.QwtPlot):
#		     self.y2[0]=self.y[self.indice]
		
	def setWindSpeedPeak(self,val):
                     self.timeData += 1.0;
                     

		self.timeData += 1.0
		self.setAxisScale(Qwt.QwtPlot.xBottom,self.timeData[-1],self.timeData[0])
#     self.curve.setData(self.timeData,self.y)

		self.windSpeedPeak[1:]=self.windSpeedPeak[0:-1] 
		self.windSpeedPeak[0]=val
		self.curveWSpeedPeak.setData(self.timeData,self.windSpeedPeak)
@@ -392,10 +389,19 @@ class PlotProperty(Qt.QFrame):
		Qt.QFrame.__init__(self) # you must initialize the superclass
		self.componentname=componentname
		self.propertyname = propertyname
		try:
			self.simpleClient=PySimpleClient()
			component=self.simpleClient.getComponent(self.componentname)
			self.limit=component._get_autoparkThreshold().get_sync()[0]	
		except Exception as ex:			
			newEx = ClientErrorsImpl.CouldntAccessPropertyExImpl(exception=ex,create=1)
			newEx.setPropertyName("autoparkThreshold")
			raise newEx	
			
			
		self.simpleClient.getLogger().logInfo("Wheather station client startup")
        
        self.plotwidget=     PlotWindWidget()  
		self.plotwidget=PlotWindWidget(self.limit)  
		self.windspeedw = SpeedoMeter()
		self.winddirw= WindWidget()
		self.temperaturew= Temperature()
@@ -439,15 +445,8 @@ class PlotProperty(Qt.QFrame):
		windSpeedPeakProperty =component._get_windspeedpeak()
		tempPr  = component._get_temperature()
		windDirPr  = component._get_winddir()      
        
        
        
        
		desc = ACS.CBDescIn(0L, 0L, 0L)

     
        
        
		propMonitor = PropertyMonitor(self.plotwidget,self.propertyname)
		cbMonServant = self.simpleClient.activateOffShoot(propMonitor)
		self.actMon = windSpeadAvgPr.create_monitor(cbMonServant, desc)
@@ -473,16 +472,12 @@ class PlotProperty(Qt.QFrame):
		self.connect(temperatureMon, Qt.SIGNAL("PropertyChanghed(float)"),self.temperaturew.setVal)

    
        
      
      
      
	def __del__(self):
		self.actMon.destroy()
		self.WDiractMon.destroy()
		self.temperatureactMon.destroy()
		self.WSpeedPeakactMon.destroy()
	self.actMonwspeed.destroy()
		#self.actMonwspeed.destroy()
		self.simpleClient.releaseComponent(self.componentname)
		self.simpleClient.disconnect()
		print "The end __oOo__"
@@ -490,8 +485,12 @@ class PlotProperty(Qt.QFrame):
			
		
def make( ):
	
	try:
		plot = PlotProperty("WEATHERSTATION/WeatherStation","windspeed")
	except ClientErrorsImpl.CouldntAccessPropertyExImpl as ex:
		logger.logException(ex)
		sys.exit(-1)
		
	plot.resize(800, 600)
	plot.run()
	plot.show() 
+4 −0
Original line number Diff line number Diff line
@@ -113,6 +113,10 @@ module Weather {
		*/
		readonly attribute ACS::RWdouble windspeedpeak;

		/**
		 * This is the wind speed threshold used by the autopark system in order to force an antenna stow
		*/
		readonly attribute ACS::ROdouble autoparkThreshold;
						
	};
};
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
					<xs:element name="windspeedpeak" type="baci:RWdouble"/>
		  			<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"/>
+16 −4
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ WeatherStationImpl::WeatherStationImpl(
		       m_windspeed(this),
		       m_windspeedpeak(this),
		       m_humidity(this),
		       m_pressure(this)
		       m_pressure(this),
		       m_autoParkThreshold(this)
{	

      
@@ -316,7 +317,7 @@ void WeatherStationImpl::execute() throw (ACSErr::ACSbaseExImpl)
 
void WeatherStationImpl::initialize() throw (ACSErr::ACSbaseExImpl)
{

	ACS::Time timestamp;
	WeatherSocket *sock;
	ACSErr::Completion_var completion;
	IRA::CString mountInterface;
@@ -345,6 +346,9 @@ void WeatherStationImpl::initialize() throw (ACSErr::ACSbaseExImpl)
		m_windspeedpeak=new RWdouble(getContainerServices()->getName()+":windspeedpeak", getComponent(), new DevIOWindspeedpeak(m_socket),true);
		m_humidity=new RWdouble(getContainerServices()->getName()+":humidity", getComponent(), new DevIOHumidity(m_socket),true);
		m_pressure=new RWdouble(getContainerServices()->getName()+":pressure", getComponent(), new DevIOPressure(m_socket),true);
		m_autoParkThreshold=new ROdouble(getContainerServices()->getName()+":autoparkThreshold", getComponent());		
		
		m_autoParkThreshold->getDevIO()->write(m_threshold,timestamp);
		
		WeatherStationImpl* self_p =this;
		m_controlThread_p = getContainerServices()->getThreadManager()->create<CWindCheckerThread, WeatherStationImpl*>("MeteoStation",self_p );
@@ -465,6 +469,14 @@ WeatherStationImpl::pressure ()
    return prop._retn();
}

ACS::ROdouble_ptr WeatherStationImpl::autoparkThreshold() throw (CORBA::SystemException)
{
	if (m_autoParkThreshold == 0) {
		return ACS::ROdouble::_nil();
	}
	ACS::ROdouble_var prop = ACS::ROdouble::_narrow(m_autoParkThreshold->getCORBAReference());
	return prop._retn();
}

void WeatherStationImpl::parkAntenna()
{
Loading