Instrument Neutral Distributed Interface INDI  2.0.2
Protected Member Functions | Protected Attributes | List of all members
INDI::WeatherInterface Class Reference

Provides interface to implement weather reporting functionality. More...

#include <indiweatherinterface.h>

Inheritance diagram for INDI::WeatherInterface:
INDI::Weather LX200_OnStep PegasusPPB PegasusPPBA PegasusUPB UranusMeteo MBox OpenWeatherMap Vantage WeatherSafetyProxy WeatherSimulator WeatherWatcher WunderGround

Protected Member Functions

 WeatherInterface (DefaultDevice *defaultDevice)
 
virtual ~WeatherInterface ()
 
void initProperties (const char *statusGroup, const char *paramsGroup)
 Initilize focuser properties. It is recommended to call this function within initProperties() of your primary device. More...
 
bool updateProperties ()
 updateProperties Define or Delete Rotator properties based on the connection status of the base device More...
 
bool processNumber (const char *dev, const char *name, double values[], char *names[], int n)
 Process weather number properties. More...
 
bool processSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
 Process weather switch properties. More...
 
void checkWeatherUpdate ()
 checkWeatherUpdate Calls updateWeather and update critical parameters accordingly. More...
 
virtual IPState updateWeather ()
 updateWeather Update weather conditions from device or service. The function should not change the state of any property in the device as this is handled by Weather. It should only update the raw values. More...
 
virtual bool saveConfigItems (FILE *fp)
 saveConfigItems Save parameters ranges in the config file. More...
 
void addParameter (std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning)
 addParameter Add a physical weather measurable parameter to the weather driver. The weather value has three zones: More...
 
bool setCriticalParameter (std::string param)
 setCriticalParameter Set parameter that is considered critical to the operation of the observatory. The parameter state can affect the overall weather driver state which signals the client to take appropriate action depending on the severity of the state. More...
 
void setParameterValue (std::string name, double value)
 setParameterValue Update weather parameter value More...
 
IPState checkParameterState (const std::string &param) const
 checkParameterState Checks the given parameter against the defined bounds More...
 
IPState checkParameterState (const INumber &parameter) const
 
bool syncCriticalParameters ()
 updateWeatherState Send update weather state to client More...
 

Protected Attributes

INumberParametersN {nullptr}
 
INumberVectorProperty ParametersNP
 
INumberVectorPropertyParametersRangeNP {nullptr}
 
uint8_t nRanges {0}
 
ILightcritialParametersL {nullptr}
 
ILightVectorProperty critialParametersLP
 
INDI::PropertyNumber UpdatePeriodNP {1}
 
INDI::PropertySwitch RefreshSP {1}
 
INDI::PropertySwitch OverrideSP {1}
 

Detailed Description

Provides interface to implement weather reporting functionality.

The weather functionality can be an independent device (e.g. weather station), or weather-related reports within another device.

When developing a driver for a fully independent weather device, use INDI::Weather directly. To add focus functionality to an existing driver, subclass INDI::WeatherInterface. In your driver, then call the necessary weather interface functions.

FunctionWhere to call it from your driver
WI::initPropertiesinitProperties()
WI::updatePropertiesupdateProperties()
WI::processNumberISNewNumber(...) Check if the property name contains WEATHER_* and then call WI::processNumber(..) for such properties

Implement and overwrite the rest of the virtual functions as needed. INDI Pegasus Ultimate Power Box driver is a good example to check for an actual implementation of a weather interface within an auxiliary driver.

Author
Jasem Mutlaq

Definition at line 57 of file indiweatherinterface.h.

Constructor & Destructor Documentation

◆ WeatherInterface()

INDI::WeatherInterface::WeatherInterface ( DefaultDevice defaultDevice)
explicitprotected

Definition at line 30 of file indiweatherinterface.cpp.

◆ ~WeatherInterface()

INDI::WeatherInterface::~WeatherInterface ( )
protectedvirtual

Definition at line 37 of file indiweatherinterface.cpp.

Member Function Documentation

◆ addParameter()

void INDI::WeatherInterface::addParameter ( std::string  name,
std::string  label,
double  numMinOk,
double  numMaxOk,
double  percWarning 
)
protected

addParameter Add a physical weather measurable parameter to the weather driver. The weather value has three zones:

  1. OK: Set minimum and maximum values for acceptable values.
  2. Warning: Set minimum and maximum values for values outside of Ok range and in the dangerous warning zone.
  3. Alert: Any value outsize of Ok and Warning zone is marked as Alert.
Parameters
nameName of parameter
labelLabel of paremeter (in GUI)
numMinOkminimum Ok range value.
numMaxOkmaximum Ok range value.
percWarningpercentage for Warning.

Definition at line 266 of file indiweatherinterface.cpp.

◆ checkParameterState() [1/2]

IPState INDI::WeatherInterface::checkParameterState ( const INumber parameter) const
protected

Definition at line 328 of file indiweatherinterface.cpp.

◆ checkParameterState() [2/2]

IPState INDI::WeatherInterface::checkParameterState ( const std::string &  param) const
protected

checkParameterState Checks the given parameter against the defined bounds

Parameters
paramName of parameter to check.
Returns
IPS_IDLE: The given parameter name is not valid.
IPS_OK: The given parameter is within the safe zone.
IPS_BUSY: The given parameter is in the warning zone.
IPS_ALERT: The given parameter is in the danger zone.

Definition at line 352 of file indiweatherinterface.cpp.

◆ checkWeatherUpdate()

void INDI::WeatherInterface::checkWeatherUpdate ( )
protected

checkWeatherUpdate Calls updateWeather and update critical parameters accordingly.

Definition at line 124 of file indiweatherinterface.cpp.

◆ initProperties()

void INDI::WeatherInterface::initProperties ( const char *  statusGroup,
const char *  paramsGroup 
)
protected

Initilize focuser properties. It is recommended to call this function within initProperties() of your primary device.

Parameters
statusGroupgroup for status properties
paramsGroupgroup for parameter properties

Definition at line 51 of file indiweatherinterface.cpp.

◆ processNumber()

bool INDI::WeatherInterface::processNumber ( const char *  dev,
const char *  name,
double  values[],
char *  names[],
int  n 
)
protected

Process weather number properties.

Definition at line 212 of file indiweatherinterface.cpp.

◆ processSwitch()

bool INDI::WeatherInterface::processSwitch ( const char *  dev,
const char *  name,
ISState states,
char *  names[],
int  n 
)
protected

Process weather switch properties.

Definition at line 169 of file indiweatherinterface.cpp.

◆ saveConfigItems()

bool INDI::WeatherInterface::saveConfigItems ( FILE *  fp)
protectedvirtual

saveConfigItems Save parameters ranges in the config file.

Parameters
fppointer to open config file
Returns
true of success, false otherwise.

Reimplemented in INDI::Weather, WeatherWatcher, WeatherSimulator, WeatherSafetyProxy, UranusMeteo, OpenWeatherMap, LX200_OnStep, PegasusUPB, PegasusPPBA, PegasusPPB, and WunderGround.

Definition at line 447 of file indiweatherinterface.cpp.

◆ setCriticalParameter()

bool INDI::WeatherInterface::setCriticalParameter ( std::string  param)
protected

setCriticalParameter Set parameter that is considered critical to the operation of the observatory. The parameter state can affect the overall weather driver state which signals the client to take appropriate action depending on the severity of the state.

Parameters
paramName of critical parameter.
Returns
True if critical parameter was set, false if parameter is not found.

Definition at line 302 of file indiweatherinterface.cpp.

◆ setParameterValue()

void INDI::WeatherInterface::setParameterValue ( std::string  name,
double  value 
)
protected

setParameterValue Update weather parameter value

Parameters
namename of weather parameter
valuenew value of weather parameter;

Definition at line 290 of file indiweatherinterface.cpp.

◆ syncCriticalParameters()

bool INDI::WeatherInterface::syncCriticalParameters ( )
protected

updateWeatherState Send update weather state to client

Returns
true if any parameters changed from last update. False if no states changed.

Definition at line 365 of file indiweatherinterface.cpp.

◆ updateProperties()

bool INDI::WeatherInterface::updateProperties ( )
protected

updateProperties Define or Delete Rotator properties based on the connection status of the base device

Returns
True if successful, false otherwise.

Definition at line 79 of file indiweatherinterface.cpp.

◆ updateWeather()

IPState INDI::WeatherInterface::updateWeather ( )
protectedvirtual

updateWeather Update weather conditions from device or service. The function should not change the state of any property in the device as this is handled by Weather. It should only update the raw values.

Returns
Return overall state. The state should be IPS_OK if data is valid. IPS_BUSY if weather update is in progress. IPS_ALERT is there is an error. The clients will only accept values with IPS_OK state.

Reimplemented in WeatherWatcher, WeatherSimulator, WeatherSafetyProxy, Vantage, UranusMeteo, OpenWeatherMap, MBox, LX200_OnStep, PegasusUPB, PegasusPPBA, PegasusPPB, and WunderGround.

Definition at line 259 of file indiweatherinterface.cpp.

Member Data Documentation

◆ critialParametersL

ILight* INDI::WeatherInterface::critialParametersL {nullptr}
protected

Definition at line 167 of file indiweatherinterface.h.

◆ critialParametersLP

ILightVectorProperty INDI::WeatherInterface::critialParametersLP
protected

Definition at line 168 of file indiweatherinterface.h.

◆ nRanges

uint8_t INDI::WeatherInterface::nRanges {0}
protected

Definition at line 164 of file indiweatherinterface.h.

◆ OverrideSP

INDI::PropertySwitch INDI::WeatherInterface::OverrideSP {1}
protected

Definition at line 176 of file indiweatherinterface.h.

◆ ParametersN

INumber* INDI::WeatherInterface::ParametersN {nullptr}
protected

Definition at line 159 of file indiweatherinterface.h.

◆ ParametersNP

INumberVectorProperty INDI::WeatherInterface::ParametersNP
protected

Definition at line 160 of file indiweatherinterface.h.

◆ ParametersRangeNP

INumberVectorProperty* INDI::WeatherInterface::ParametersRangeNP {nullptr}
protected

Definition at line 163 of file indiweatherinterface.h.

◆ RefreshSP

INDI::PropertySwitch INDI::WeatherInterface::RefreshSP {1}
protected

Definition at line 173 of file indiweatherinterface.h.

◆ UpdatePeriodNP

INDI::PropertyNumber INDI::WeatherInterface::UpdatePeriodNP {1}
protected

Definition at line 171 of file indiweatherinterface.h.


The documentation for this class was generated from the following files: