Instrument Neutral Distributed Interface INDI  1.5.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
INDI::Weather Class Reference

Class to provide general functionality of a weather device. More...

#include <indiweather.h>

Inheritance diagram for INDI::Weather:
INDI::DefaultDevice INDI::BaseDevice Vantage WunderGround

Public Types

- Public Types inherited from INDI::BaseDevice

Public Member Functions

 Weather ()
 
virtual ~Weather ()
 
virtual bool initProperties ()
 Initilize properties initial state and value. The child class must implement this function. More...
 
virtual bool updateProperties ()
 updateProperties is called whenever there is a change in the CONNECTION status of the driver. This will enable the driver to react to changes of switching ON/OFF a device. For example, a driver may only define a set of properties after a device is connected, but not before. More...
 
virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
 Process the client newSwitch command. More...
 
virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
 Process the client newNumber command. More...
 
virtual bool ISSnoopDevice (XMLEle *root)
 Process a snoop event from INDI server. This function is called when a snooped property is updated in a snooped driver. More...
 
- Public Member Functions inherited from INDI::DefaultDevice
 DefaultDevice ()
 
virtual ~DefaultDevice ()
 
void addAuxControls ()
 Add Debug, Simulation, and Configuration options to the driver. More...
 
void addDebugControl ()
 Add Debug control to the driver. More...
 
void addSimulationControl ()
 Add Simulation control to the driver. More...
 
void addConfigurationControl ()
 Add Configuration control to the driver. More...
 
void resetProperties ()
 Set all properties to IDLE state. More...
 
void defineNumber (INumberVectorProperty *nvp)
 Define number vector to client & register it. Alternatively, IDDefNumber can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
void defineText (ITextVectorProperty *tvp)
 Define text vector to client & register it. Alternatively, IDDefText can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
void defineSwitch (ISwitchVectorProperty *svp)
 Define switch vector to client & register it. Alternatively, IDDefswitch can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
void defineLight (ILightVectorProperty *lvp)
 Define light vector to client & register it. Alternatively, IDDeflight can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
void defineBLOB (IBLOBVectorProperty *bvp)
 Define BLOB vector to client & register it. Alternatively, IDDefBLOB can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
virtual bool deleteProperty (const char *propertyName)
 Delete a property and unregister it. It will also be deleted from all clients. More...
 
virtual void setConnected (bool status, IPState state=IPS_OK, const char *msg=nullptr)
 Set connection switch status in the client. More...
 
int SetTimer (int ms)
 Set a timer to call the function TimerHit after ms milliseconds. More...
 
void RemoveTimer (int id)
 Remove timer added with SetTimer. More...
 
virtual const char * getDriverExec ()
 
virtual const char * getDriverName ()
 
void setVersion (uint16_t vMajor, uint16_t vMinor)
 Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor. More...
 
uint16_t getMajorVersion ()
 
uint16_t getMinorVersion ()
 
virtual void ISGetProperties (const char *dev)
 define the driver's properties to the client. Usually, only a minimum set of properties are defined to the client in this function if the device is in disconnected state. Those properties should be enough to enable the client to establish a connection to the device. In addition to CONNECT/DISCONNECT, such properties may include port name, IP address, etc. You should check if the device is already connected, and if this is true, then you must define the remainder of the the properties to the client in this function. Otherwise, the remainder of the driver's properties are defined to the client in updateProperties() function which is called when a client connects/disconnects from a device. More...
 
virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
 Process the client newSwitch command. More...
 
virtual bool ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
 Process the client newBLOB command. More...
 
virtual uint16_t getDriverInterface ()
 
void setDriverInterface (uint16_t value)
 setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE. You may send an ORed list of DeviceInterface values. More...
 
- Public Member Functions inherited from INDI::BaseDevice
 BaseDevice ()
 
virtual ~BaseDevice ()
 
INumberVectorPropertygetNumber (const char *name)
 
ITextVectorPropertygetText (const char *name)
 
ISwitchVectorPropertygetSwitch (const char *name)
 
ILightVectorPropertygetLight (const char *name)
 
IBLOBVectorPropertygetBLOB (const char *name)
 
IPState getPropertyState (const char *name)
 
IPerm getPropertyPermission (const char *name)
 
void registerProperty (void *p, INDI_PROPERTY_TYPE type)
 
int removeProperty (const char *name, char *errmsg)
 Remove a property. More...
 
void * getRawProperty (const char *name, INDI_PROPERTY_TYPE type=INDI_UNKNOWN)
 Return a property and its type given its name. More...
 
INDI::PropertygetProperty (const char *name, INDI_PROPERTY_TYPE type=INDI_UNKNOWN)
 Return a property and its type given its name. More...
 
std::vector< INDI::Property * > * getProperties ()
 Return a list of all properties in the device. More...
 
bool buildSkeleton (const char *filename)
 Build driver properties from a skeleton file. More...
 
bool isConnected ()
 
void setDeviceName (const char *dev)
 Set the device name. More...
 
const char * getDeviceName ()
 
void addMessage (const std::string &msg)
 Add message to the driver's message queue. More...
 
void checkMessage (XMLEle *root)
 
void doMessage (XMLEle *msg)
 
std::string messageQueue (int index) const
 
std::string lastMessage ()
 
void setMediator (INDI::BaseMediator *med)
 Set the driver's mediator to receive notification of news devices and updated property values. More...
 
INDI::BaseMediatorgetMediator ()
 
const char * getDriverName ()
 
const char * getDriverExec ()
 
const char * getDriverVersion ()
 

Public Attributes

enum INDI::Weather:: { ... }  WeatherConnection
 

Protected Member Functions

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 INDI::Weather. It should only update the raw values. More...
 
virtual void TimerHit ()
 TimerHit Keep calling updateWeather() until it is successful, if it fails upon first connection. More...
 
virtual bool updateLocation (double latitude, double longitude, double elevation)
 Update telescope location settings. More...
 
void addParameter (std::string name, std::string label, double minimumOK, double maximumOK, double minimumWarning, double maximumWarning)
 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...
 
void setWeatherConnection (const uint8_t &value)
 setWeatherConnection Set Weather connection mode. Child class should call this in the constructor before INDI::Weather registers any connection interfaces More...
 
uint8_t getWeatherConnection () const
 
virtual bool saveConfigItems (FILE *fp)
 saveConfigItems Save specific properties in the provide config file handler. Child class usually override this function to save their own properties and the base class saveConfigItems(fp) must be explicitly called by each child class. The Default Device saveConfigItems(fp) only save Debug properties options in the config file. More...
 
virtual bool Handshake ()
 perform handshake with device to check communication More...
 
- Protected Member Functions inherited from INDI::DefaultDevice
void setDynamicPropertiesBehavior (bool defineEnabled, bool deleteEnabled)
 setDynamicPropertiesBehavior controls handling of dynamic properties. Dyanmic properties are those generated from an external skeleton XML file. By default all properties, including dynamic properties, are defined to the client in ISGetProperties(). Furthermore, when ┼▒deleteProperty(properyName) is called, the dynamic property is deleted by default, and can only be restored by calling buildSkeleton(filename) again. However, it is sometimes desirable to skip the definition of the dynamic properties on startup and delegate this task to the child class. To control this behavior, set enabled to false. More...
 
virtual bool loadConfig (bool silent=false, const char *property=nullptr)
 Load the last saved configuration file. More...
 
virtual bool saveConfig (bool silent=false, const char *property=nullptr)
 Save the current properties in a configuration file. More...
 
virtual bool saveAllConfigItems (FILE *fp)
 saveAllConfigItems Save all the drivers' properties in the configuration file More...
 
virtual bool loadDefaultConfig ()
 Load the default configuration file. More...
 
void setDebug (bool enable)
 Toggle driver debug status A driver can be more verbose if Debug option is enabled by the client. More...
 
void setSimulation (bool enable)
 Toggle driver simulation status A driver can run in simulation mode if Simulation option is enabled by the client. More...
 
virtual void debugTriggered (bool enable)
 Inform driver that the debug option was triggered. This function is called after setDebug is triggered by the client. Reimplement this function if your driver needs to take specific action after debug is enabled/disabled. Otherwise, you can use isDebug() to check if simulation is enabled or disabled. More...
 
virtual void simulationTriggered (bool enable)
 Inform driver that the simulation option was triggered. This function is called after setSimulation is triggered by the client. Reimplement this function if your driver needs to take specific action after simulation is enabled/disabled. Otherwise, you can use isSimulation() to check if simulation is enabled or disabled. More...
 
bool isDebug ()
 
bool isSimulation ()
 
virtual bool Connect ()
 Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interface (Serial or TCP) governed by connectionMode. If connection is successful, it proceed to call Handshake() function to ensure communication with device is successful. For other communication interface, override the method in the child class implementation. More...
 
virtual bool Disconnect ()
 Disconnect from device. More...
 
void registerConnection (Connection::Interface *newConnection)
 registerConnection Add new connection plugin to the existing connection pool. The connection type shall be defined to the client in ISGetProperties() More...
 
bool unRegisterConnection (Connection::Interface *existingConnection)
 unRegisterConnection Remove connection from existing pool More...
 
Connection::InterfacegetActiveConnection ()
 
virtual const char * getDefaultName ()=0
 
- Protected Member Functions inherited from INDI::BaseDevice
int buildProp (XMLEle *root, char *errmsg)
 Build a property given the supplied XML element (defXXX) More...
 
int setValue (XMLEle *root, char *errmsg)
 handle SetXXX commands from client More...
 
int setBLOB (IBLOBVectorProperty *pp, XMLEle *root, char *errmsg)
 Parse and store BLOB in the respective vector. More...
 

Protected Attributes

INumberVectorProperty LocationNP
 
INumber LocationN [3]
 
ISwitch RefreshS [1]
 
ISwitchVectorProperty RefreshSP
 
INumberParametersN
 
INumberVectorProperty ParametersNP
 
INumberVectorPropertyParametersRangeNP
 
uint8_t nRanges
 
ILightcritialParametersL
 
ILightVectorProperty critialParametersLP
 
ITextVectorProperty ActiveDeviceTP
 
IText ActiveDeviceT [1]
 
INumber UpdatePeriodN [1]
 
INumberVectorProperty UpdatePeriodNP
 
Connection::SerialserialConnection = NULL
 
Connection::TCPtcpConnection = NULL
 
int PortFD = -1
 
- Protected Attributes inherited from INDI::DefaultDevice
uint32_t updatePeriodMS = 1000
 Period in milliseconds to call TimerHit(). Default 1000 ms. More...
 

Detailed Description

Class to provide general functionality of a weather device.

The INDI::Weather provides a simple interface for weather devices. Parameters such as temperature, wind, humidity etc can be added by the child class as supported by the physical device. With each parameter, the caller specifies the minimum and maximum ranges of OK and WARNING zones. Any value outside of the warning zone is automatically treated as ALERT.

The class also specifies the list of critical parameters for observatory operations. When any of the parameters changes state to WARNING or ALERT, then the overall state of the WEATHER_STATUS property reflects the worst state of any individual parameter. The WEATHER_STATUS property may be used by clients to determine whether to proceed with observation tasks or not, and whether to take any safety measures to protect the observatory from severe weather conditions.

The child class should start by first adding all the weather parameters via the addParameter() function, then set all the critial parameters via the setCriticalParameter() function, and finally call generateParameterRanges() function to generate all the parameter ranges properties.

Weather update period is controlled by the WEATHER_UPDATE property which stores the update period in seconds and calls updateWeather() every X seconds as given in the property.

IMPORTANT: GEOGRAPHIC_COORD stores latitude and longitude in INDI specific format, refer to INDI Standard Properties for details.

Author
Jasem Mutlaq

Definition at line 65 of file indiweather.h.

Member Enumeration Documentation

anonymous enum
Enumerator
CONNECTION_NONE 
CONNECTION_SERIAL 

Do not use any connection plugin

CONNECTION_TCP 

For regular serial and bluetooth connections

Definition at line 78 of file indiweather.h.

Enumerator
LOCATION_LATITUDE 
LOCATION_LONGITUDE 
LOCATION_ELEVATION 

Definition at line 68 of file indiweather.h.

Constructor & Destructor Documentation

INDI::Weather::Weather ( )

Definition at line 34 of file indiweather.cpp.

INDI::Weather::~Weather ( )
virtual

Definition at line 44 of file indiweather.cpp.

Member Function Documentation

void INDI::Weather::addParameter ( std::string  name,
std::string  label,
double  minimumOK,
double  maximumOK,
double  minimumWarning,
double  maximumWarning 
)
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)
minimumOKMinimum OK value.
maximumOKMaximum OK value.
minimumWarningMinimum Warning value.
maximumWarningMaximum Warning value.

Definition at line 373 of file indiweather.cpp.

uint8_t INDI::Weather::getWeatherConnection ( ) const
protected
Returns
Get current Weather connection mode

Definition at line 534 of file indiweather.cpp.

bool INDI::Weather::Handshake ( )
protectedvirtual

perform handshake with device to check communication

Reimplemented in Vantage.

Definition at line 516 of file indiweather.cpp.

bool INDI::Weather::initProperties ( )
virtual

Initilize properties initial state and value. The child class must implement this function.

Returns
True if initilization is successful, false otherwise.

Reimplemented from INDI::DefaultDevice.

Reimplemented in WunderGround, and Vantage.

Definition at line 58 of file indiweather.cpp.

bool INDI::Weather::ISNewNumber ( const char *  dev,
const char *  name,
double  values[],
char *  names[],
int  n 
)
virtual

Process the client newNumber command.

Note
This function is called by the INDI framework, do not call it directly.
Returns
True if any property was successfully processed, false otherwise.

Reimplemented from INDI::DefaultDevice.

Definition at line 184 of file indiweather.cpp.

bool INDI::Weather::ISNewSwitch ( const char *  dev,
const char *  name,
ISState states,
char *  names[],
int  n 
)
virtual

Process the client newSwitch command.

Note
This function is called by the INDI framework, do not call it directly.
Returns
True if any property was successfully processed, false otherwise.

Reimplemented from INDI::DefaultDevice.

Definition at line 167 of file indiweather.cpp.

bool INDI::Weather::ISSnoopDevice ( XMLEle root)
virtual

Process a snoop event from INDI server. This function is called when a snooped property is updated in a snooped driver.

Note
This function is called by the INDI framework, do not call it directly.
Returns
True if any property was successfully processed, false otherwise.

Reimplemented from INDI::DefaultDevice.

Definition at line 253 of file indiweather.cpp.

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

saveConfigItems Save specific properties in the provide config file handler. Child class usually override this function to save their own properties and the base class saveConfigItems(fp) must be explicitly called by each child class. The Default Device saveConfigItems(fp) only save Debug properties options in the config file.

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

Reimplemented from INDI::DefaultDevice.

Reimplemented in WunderGround.

Definition at line 503 of file indiweather.cpp.

bool INDI::Weather::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 411 of file indiweather.cpp.

void INDI::Weather::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 399 of file indiweather.cpp.

void INDI::Weather::setWeatherConnection ( const uint8_t &  value)
protected

setWeatherConnection Set Weather connection mode. Child class should call this in the constructor before INDI::Weather registers any connection interfaces

Parameters
valueORed combination of WeatherConnection values.

Definition at line 539 of file indiweather.cpp.

void INDI::Weather::TimerHit ( )
protectedvirtual

TimerHit Keep calling updateWeather() until it is successful, if it fails upon first connection.

Reimplemented from INDI::DefaultDevice.

Definition at line 287 of file indiweather.cpp.

bool INDI::Weather::updateLocation ( double  latitude,
double  longitude,
double  elevation 
)
protectedvirtual

Update telescope location settings.

Parameters
latitudeSite latitude in degrees.
longitudeSite latitude in degrees increasing eastward from Greenwich (0 to 360).
elevationSite elevation in meters.
Returns
True if successful, false otherwise
Note
This function performs no action unless subclassed by the child class if required.

Reimplemented in WunderGround.

Definition at line 334 of file indiweather.cpp.

bool INDI::Weather::updateProperties ( )
virtual

updateProperties is called whenever there is a change in the CONNECTION status of the driver. This will enable the driver to react to changes of switching ON/OFF a device. For example, a driver may only define a set of properties after a device is connected, but not before.

Returns
True if update is successful, false otherwise.

Reimplemented from INDI::DefaultDevice.

Definition at line 111 of file indiweather.cpp.

IPState INDI::Weather::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 INDI::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, and Vantage.

Definition at line 327 of file indiweather.cpp.

Member Data Documentation

IText INDI::Weather::ActiveDeviceT[1]
protected

Definition at line 195 of file indiweather.h.

ITextVectorProperty INDI::Weather::ActiveDeviceTP
protected

Definition at line 194 of file indiweather.h.

ILight* INDI::Weather::critialParametersL
protected

Definition at line 190 of file indiweather.h.

ILightVectorProperty INDI::Weather::critialParametersLP
protected

Definition at line 191 of file indiweather.h.

INumber INDI::Weather::LocationN[3]
protected

Definition at line 175 of file indiweather.h.

INumberVectorProperty INDI::Weather::LocationNP
protected

Definition at line 174 of file indiweather.h.

uint8_t INDI::Weather::nRanges
protected

Definition at line 187 of file indiweather.h.

INumber* INDI::Weather::ParametersN
protected

Definition at line 182 of file indiweather.h.

INumberVectorProperty INDI::Weather::ParametersNP
protected

Definition at line 183 of file indiweather.h.

INumberVectorProperty* INDI::Weather::ParametersRangeNP
protected

Definition at line 186 of file indiweather.h.

int INDI::Weather::PortFD = -1
protected

Definition at line 204 of file indiweather.h.

ISwitch INDI::Weather::RefreshS[1]
protected

Definition at line 178 of file indiweather.h.

ISwitchVectorProperty INDI::Weather::RefreshSP
protected

Definition at line 179 of file indiweather.h.

Connection::Serial* INDI::Weather::serialConnection = NULL
protected

Definition at line 201 of file indiweather.h.

Connection::TCP* INDI::Weather::tcpConnection = NULL
protected

Definition at line 202 of file indiweather.h.

INumber INDI::Weather::UpdatePeriodN[1]
protected

Definition at line 198 of file indiweather.h.

INumberVectorProperty INDI::Weather::UpdatePeriodNP
protected

Definition at line 199 of file indiweather.h.

enum { ... } INDI::Weather::WeatherConnection

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