46045-syslab/syslab/physical/MeteoMast.py

73 lines
2.9 KiB
Python

from ..core.SyslabUnit import SyslabUnit
class MeteoMast(SyslabUnit):
__METMASTS = {
'metmast1': ('syslab-13.syslab.dk', '8080', 'meteo1'),
}
def __init__(self, which=None, host=None, port=None, unitname=None):
baseurl = 'http://{host}:{port}/typebased_WebService_Meteo/MeteoStationWebService/{unit_name}/'
super().__init__(
baseurl=baseurl,
which=which,
units=self.__METMASTS,
host=host,
port=port,
unit_name=unitname,
unit_type="MeteoMast")
def getAirPressure(self, instrumentIndex: int or str):
if type(instrumentIndex) is str:
return self._request_resource('getAirPressure2', instrumentIndex)
if type(instrumentIndex) is int:
return self._request_resource('getAirPressure1', instrumentIndex)
def getAirTemperature(self, instrumentIndex: int or str):
if type(instrumentIndex) is str:
return self._request_resource('getAirTemperature2', instrumentIndex)
if type(instrumentIndex) is int:
return self._request_resource('getAirTemperature1', instrumentIndex)
def getHeightAboveGround(self):
return self._request_resource('getHeightAboveGround')
def getInsolation(self, instrumentIndex: int or str):
if type(instrumentIndex) is str:
return self._request_resource('getInsolation2', instrumentIndex)
if type(instrumentIndex) is int:
return self._request_resource('getInsolation1', instrumentIndex)
def getMeteoGPSLocation(self):
return self._request_resource('getMeteoGPSLocation')
def getRelativeHumidity(self, instrumentIndex: int or str):
if type(instrumentIndex) is str:
return self._request_resource('getRelativeHumidity2', instrumentIndex)
if type(instrumentIndex) is int:
return self._request_resource('getRelativeHumidity1', instrumentIndex)
def getWindDirection(self, instrumentIndex: int or str):
if type(instrumentIndex) is str:
return self._request_resource('getWindDirection2', instrumentIndex)
if type(instrumentIndex) is int:
return self._request_resource('getWindDirection1', instrumentIndex)
def getWindSpeed(self, instrumentIndex: int or str):
if type(instrumentIndex) is str:
return self._request_resource('getWindSpeed2', instrumentIndex)
if type(instrumentIndex) is int:
return self._request_resource('getWindSpeed1', instrumentIndex)
def getInstrumentNames(self):
return self._request_resource('getInstrumentNames')
def getSupportedInstrumentTypes(self):
return self._request_resource('getSupportedInstrumentTypes')
def getInstrumentNamesForType(self, instrumentType: str):
return self._request_resource('getInstrumentNamesForType', instrumentType)