37 updatePeriods[0] = updatePeriods[1] = updatePeriods[2] = updatePeriods[3] = -1;
42 return (
const char *)
"Weather Meta";
60 IUFillText(&ActiveDeviceT[0],
"ACTIVE_WEATHER_1",
"Station #1",
nullptr);
61 IUFillText(&ActiveDeviceT[1],
"ACTIVE_WEATHER_2",
"Station #2",
nullptr);
62 IUFillText(&ActiveDeviceT[2],
"ACTIVE_WEATHER_3",
"Station #3",
nullptr);
63 IUFillText(&ActiveDeviceT[3],
"ACTIVE_WEATHER_4",
"Station #4",
nullptr);
75 IUFillNumber(&UpdatePeriodN[0],
"PERIOD",
"Period (secs)",
"%4.2f", 0, 3600, 60, 60);
102 for (
int i = 0; i < 4; i++)
104 if (ActiveDeviceT[i].text !=
nullptr && ActiveDeviceT[i].text[0] != 0)
105 strncpy(StationL[i].label, ActiveDeviceT[i].text,
MAXINDILABEL);
123 if (strcmp(name, ActiveDeviceTP.
name) == 0)
130 if (ActiveDeviceT[0].text !=
nullptr)
135 if (ActiveDeviceT[1].text !=
nullptr)
140 if (ActiveDeviceT[2].text !=
nullptr)
145 if (ActiveDeviceT[3].text !=
nullptr)
175 if (strcmp(propName,
"WEATHER_STATUS") == 0)
177 for (
int i = 0; i < 4; i++)
179 if (ActiveDeviceT[i].text !=
nullptr && strcmp(ActiveDeviceT[i].text, deviceName) == 0)
186 StationL[i].s = stationState;
188 updateOverallState();
197 if (strcmp(propName,
"WEATHER_UPDATE") == 0)
201 for (
int i = 0; i < 4; i++)
203 if (ActiveDeviceT[i].text !=
nullptr && strcmp(ActiveDeviceT[i].text, deviceName) == 0)
207 updateUpdatePeriod();
217 void WeatherMeta::updateOverallState()
221 for (
int i = 0; i < 4; i++)
223 if (StationL[i].s > StationLP.
s)
224 StationLP.
s = StationL[i].s;
230 void WeatherMeta::updateUpdatePeriod()
232 double minPeriod = UpdatePeriodN[0].max;
234 for (
int i = 0; i < 4; i++)
236 if (updatePeriods[i] > 0 && updatePeriods[i] < minPeriod)
237 minPeriod = updatePeriods[i];
240 if (minPeriod != UpdatePeriodN[0].
max)
242 UpdatePeriodN[0].value = minPeriod;
const char * getDeviceName() const
virtual bool updateProperties()
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual void ISGetProperties(const char *dev)
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool ISSnoopDevice(XMLEle *root)
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool loadConfig(bool silent=false, const char *property=nullptr)
Load the last saved configuration file.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool initProperties()
Initilize properties initial state and value. The child class must implement this function.
void setDriverInterface(uint16_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
void addDebugControl()
Add Debug control to the driver.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
void IUFillLight(ILight *lp, const char *name, const char *label, IPState s)
Assign attributes for a light property. The light's auxiliary elements will be set to NULL.
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
void IUFillLightVector(ILightVectorProperty *lvp, ILight *lp, int nlp, const char *dev, const char *name, const char *label, const char *group, IPState s)
Assign attributes for a light vector property. The vector's auxiliary elements will be set to NULL.
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
void IUSaveConfigText(FILE *fp, const ITextVectorProperty *tvp)
Add a text vector property value to the configuration file.
int crackIPState(const char *str, IPState *ip)
Extract property state (Idle, OK, Busy, Alert) from the supplied string.
void IDSetLight(const ILightVectorProperty *lvp, const char *fmt,...)
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n)
Update all text members in a text vector property.
void IDSnoopDevice(const char *snooped_device, const char *snooped_property)
Function a Driver calls to snoop on another Device. Snooped messages will then arrive via ISSnoopDevi...
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
const char * findXMLAttValu(XMLEle *ep, const char *name)
Find an XML element's attribute value.
char * pcdataXMLEle(XMLEle *ep)
Return the pcdata of an XML element.
XMLEle * nextXMLEle(XMLEle *ep, int init)
Iterate an XML element for a list of nesetd XML elements.