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

Provides interface to implement weather reporting and safety monitoring functionality. More...

#include <indiweatherinterface.h>

Inheritance diagram for INDI::WeatherInterface:
CelestronDewPower INDI::Weather IndiAstroLink4mini2 IndiAstrolink4 LX200_OnStep PegasusFlatMasterNeo PegasusPPB PegasusPPBA PegasusSPB PegasusUPB PegasusUPB3 TerransPowerBoxProV2 UranusMeteo WandererBoxPlusV3 WandererBoxProV3 myDewControllerPro

Protected Types

enum  { MIN_OK , MAX_OK , PERCENT_WARNING , FLIP_RANGE_TEST }
 

Protected Member Functions

 WeatherInterface (DefaultDevice *defaultDevice)
 
virtual ~WeatherInterface ()
 
void initProperties (const char *statusGroup, const char *paramsGroup)
 Initialize focuser properties. It is recommended to call this function within initProperties() of your primary device.
 
bool updateProperties ()
 updateProperties Define or Delete Rotator properties based on the connection status of the base device
 
bool processNumber (const char *dev, const char *name, double values[], char *names[], int n)
 Process weather number properties.
 
bool processSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
 Process weather switch properties.
 
void checkWeatherUpdate ()
 checkWeatherUpdate Calls updateWeather and update critical parameters accordingly.
 
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.
 
virtual bool saveConfigItems (FILE *fp)
 saveConfigItems Save parameters ranges in the config file.
 
void addParameter (std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning, bool flipWarning=false)
 Add a physical weather measurable parameter to the weather driver.
 
bool setCriticalParameter (std::string name)
 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.
 
void setParameterValue (std::string name, double value)
 setParameterValue Update weather parameter value
 
IPState checkParameterState (const std::string &param) const
 Checks the given parameter against the defined bounds.
 
bool syncCriticalParameters ()
 Synchronize and update the state of all critical parameters.
 

Protected Attributes

INDI::PropertyNumber ParametersNP {0}
 
std::vector< INDI::PropertyNumber > ParametersRangeNP
 
INDI::PropertyLight critialParametersLP {0}
 
INDI::PropertyLight SafetyStatusLP {1}
 
INDI::PropertyNumber UpdatePeriodNP {1}
 
INDI::PropertySwitch RefreshSP {1}
 
INDI::PropertySwitch OverrideSP {1}
 

Detailed Description

Provides interface to implement weather reporting and safety monitoring functionality.

The WeatherInterface class provides a comprehensive framework for implementing weather monitoring and observatory safety systems. It allows devices to report weather conditions and determine if the environment is safe for observatory operations.

Overview

The weather functionality can be implemented in two ways:

The interface provides:

Weather Parameters

Weather parameters represent physical measurements such as:

Each parameter has configurable ranges that determine its state:

Parameter Evaluation Models

The interface supports two models for evaluating parameters:

  1. Standard model (default): min–+ +-low-% high-%-+ +–max | | | | v v v v [ ( ) ] danger warning good warning danger
  2. Flipped model: min–+ +-low-% high-%-+ +–max | | | | v v v v [ ( ) ] good warning danger warning good

The flipped model is useful for parameters where extreme values indicate good conditions (e.g., cloud sensors where very low/high readings indicate clear skies).

Implementation

When developing a driver:

In your driver, 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
WI::processSwitchISNewSwitch(...) Check if the property name contains WEATHER_* and then call WI::processSwitch(..) for such properties

You must implement the updateWeather() method to update the raw values of your weather parameters. This method should not change the state of any property, as that is handled by the WeatherInterface.

Example Implementation

A typical implementation would:

  1. Initialize the interface in your driver's initProperties()
  2. Add parameters with addParameter()
  3. Set critical parameters with setCriticalParameter()
  4. Implement updateWeather() to update parameter values
  5. Forward property updates to the interface's process methods

The INDI Pegasus Ultimate Power Box driver is a good example of an actual implementation of a weather interface within an auxiliary driver.

Author
Jasem Mutlaq

Definition at line 132 of file indiweatherinterface.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
MIN_OK 
MAX_OK 
PERCENT_WARNING 
FLIP_RANGE_TEST 

Definition at line 286 of file indiweatherinterface.h.

Constructor & Destructor Documentation

◆ WeatherInterface()

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

Definition at line 32 of file indiweatherinterface.cpp.

◆ ~WeatherInterface()

INDI::WeatherInterface::~WeatherInterface ( )
protectedvirtual

Definition at line 39 of file indiweatherinterface.cpp.

Member Function Documentation

◆ addParameter()

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

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 outside of Ok and Warning zone is marked as Alert.

The warning zone is calculated as a percentage of the range between min and max values. For example, if min=0, max=100, and percWarning=10, then:

  • Warning zone near min: 0-10
  • OK zone: 10-90
  • Warning zone near max: 90-100
Parameters
nameName of parameter
labelLabel of parameter (in GUI)
numMinOkminimum Ok range value.
numMaxOkmaximum Ok range value.
percWarningpercentage for Warning.
flipWarningboolean indicating if range warning should be flipped to in-bounds, rather than out-of-bounds. When true, the evaluation model is flipped so that values outside min/max limits are considered GOOD, values in warning zones are WARNING, and values in the middle zone are DANGER. This is useful for parameters where extreme values indicate good conditions.

The weather value has three zones:

  • OK: Set minimum and maximum values for acceptable values.
  • Warning: Set minimum and maximum values for values outside of Ok range and in the dangerous warning zone.
  • Alert: Any value outside of Ok and Warning zone is marked as Alert.

The warning zone is calculated as a percentage of the range between min and max values. For example, if min=0, max=100, and percWarning=10, then:

  • Warning zone near min: 0-10
  • OK zone: 10-90
  • Warning zone near max: 90-100
Parameters
nameName of parameter
labelLabel of parameter (in GUI)
numMinOkminimum Ok range value.
numMaxOkmaximum Ok range value.
percWarningpercentage for Warning.
flipWarningboolean indicating if range warning should be flipped to in-bounds, rather than out-of-bounds

Definition at line 313 of file indiweatherinterface.cpp.

◆ checkParameterState()

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

Checks the given parameter against the defined bounds.

This method evaluates a parameter's value against its defined ranges and determines its state. The state can be one of:

  • IPS_IDLE: The parameter is not found or not configured
  • IPS_OK: The parameter value is in the safe zone
  • IPS_BUSY: The parameter value is in the warning zone
  • IPS_ALERT: The parameter value is in the danger zone

There are two models for parameter evaluation:

  1. Standard model (flipRangeTest = false): min–+ +-low-% high-%-+ +–max | | | | v v v v [ ( ) ] danger warning good warning danger
    • Values outside min/max limits = DANGER (IPS_ALERT)
    • Values in warning zones = WARNING (IPS_BUSY)
    • Values in the middle safe zone = GOOD (IPS_OK)
  2. Flipped model (flipRangeTest = true): min–+ +-low-% high-%-+ +–max | | | | v v v v [ ( ) ] good warning danger warning good
    • Values outside min/max limits = GOOD (IPS_OK)
    • Values in warning zones = WARNING (IPS_BUSY)
    • Values in the middle zone = DANGER (IPS_ALERT)

The flipped model is useful for parameters where values below minimum or above maximum are actually good conditions (e.g., certain atmospheric measurements where extreme values indicate clear conditions).

Parameters
paramName of parameter to check
Returns
IPS_IDLE if parameter not found, otherwise the state based on parameter value

This method evaluates a parameter's value against its defined ranges and determines its state. The state can be one of:

  • IPS_IDLE: The parameter is not found or not configured
  • IPS_OK: The parameter value is in the safe zone
  • IPS_BUSY: The parameter value is in the warning zone
  • IPS_ALERT: The parameter value is in the danger zone

There are two models for parameter evaluation:

  1. Standard model (flipRangeTest = false): min–+ +-low-% high-%-+ +–max | | | | v v v v [ ( ) ] danger warning good warning danger
    • Values outside min/max limits = DANGER (IPS_ALERT)
    • Values in warning zones = WARNING (IPS_BUSY)
    • Values in the middle safe zone = GOOD (IPS_OK)
  2. Flipped model (flipRangeTest = true): min–+ +-low-% high-%-+ +–max | | | | v v v v [ ( ) ] good warning danger warning good
    • Values outside min/max limits = GOOD (IPS_OK)
    • Values in warning zones = WARNING (IPS_BUSY)
    • Values in the middle zone = DANGER (IPS_ALERT)

The flipped model is useful for parameters where values below minimum or above maximum are actually good conditions (e.g., certain atmospheric measurements where extreme values indicate clear conditions).

Parameters
nameName of parameter to check
Returns
IPS_IDLE if parameter not found, otherwise the state based on parameter value

Definition at line 404 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

Initialize 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 43 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 244 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 195 of file indiweatherinterface.cpp.

◆ saveConfigItems()

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

saveConfigItems Save parameters ranges in the config file.

Save parameters ranges in the config file.

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

This method saves the update period and all parameter ranges to the configuration file.

Parameters
fpPointer to open config file
Returns
True if successful, false otherwise

Reimplemented in WunderGround, IndiAstrolink4, IndiAstroLink4mini2, PegasusFlatMasterNeo, WandererBoxPlusV3, WandererBoxProV3, CelestronDewPower, myDewControllerPro, PegasusPPB, PegasusPPBA, PegasusSPB, PegasusUPB, PegasusUPB3, TerransPowerBoxProV2, LX200_OnStep, AAGSolo, OpenWeatherMap, UranusMeteo, WeatherSafetyAlpaca, WeatherSafetyProxy, WeatherFlow, WeatherSimulator, WeatherWatcher, and INDI::Weather.

Definition at line 566 of file indiweatherinterface.cpp.

◆ setCriticalParameter()

bool INDI::WeatherInterface::setCriticalParameter ( std::string  name)
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.

Set parameter that is considered critical to the operation of the observatory.

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

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
nameName of critical parameter.
Returns
True if critical parameter was set, false if parameter is not found.

Definition at line 348 of file indiweatherinterface.cpp.

◆ setParameterValue()

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

setParameterValue Update weather parameter value

Update weather parameter value.

Parameters
namename of weather parameter
valuenew value of weather parameter;
namename of weather parameter
valuenew value of weather parameter

Definition at line 332 of file indiweatherinterface.cpp.

◆ syncCriticalParameters()

bool INDI::WeatherInterface::syncCriticalParameters ( )
protected

Synchronize and update the state of all critical parameters.

This method checks the state of all critical parameters and updates their individual states as well as the overall state of the weather system. The overall state is determined by the worst individual state.

Returns
True if any parameter state changed, false otherwise

Definition at line 465 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 WunderGround, IndiAstrolink4, IndiAstroLink4mini2, PegasusFlatMasterNeo, WandererBoxPlusV3, WandererBoxProV3, CelestronDewPower, PegasusPPB, PegasusPPBA, PegasusSPB, PegasusUPB, PegasusUPB3, TerransPowerBoxProV2, LX200_OnStep, AAGSolo, HitechWeather, MBox, OpenWeatherMap, UranusMeteo, Vantage, WeatherSafetyAlpaca, WeatherSafetyProxy, WeatherFlow, WeatherSimulator, and WeatherWatcher.

Definition at line 286 of file indiweatherinterface.cpp.

Member Data Documentation

◆ critialParametersLP

INDI::PropertyLight INDI::WeatherInterface::critialParametersLP {0}
protected

Definition at line 295 of file indiweatherinterface.h.

◆ OverrideSP

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

Definition at line 306 of file indiweatherinterface.h.

◆ ParametersNP

INDI::PropertyNumber INDI::WeatherInterface::ParametersNP {0}
protected

Definition at line 282 of file indiweatherinterface.h.

◆ ParametersRangeNP

std::vector<INDI::PropertyNumber> INDI::WeatherInterface::ParametersRangeNP
protected

Definition at line 285 of file indiweatherinterface.h.

◆ RefreshSP

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

Definition at line 303 of file indiweatherinterface.h.

◆ SafetyStatusLP

INDI::PropertyLight INDI::WeatherInterface::SafetyStatusLP {1}
protected

Definition at line 298 of file indiweatherinterface.h.

◆ UpdatePeriodNP

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

Definition at line 301 of file indiweatherinterface.h.


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