37 updatePeriods[0] = updatePeriods[1] = updatePeriods[2] = updatePeriods[3] = -1;
42 return (
const char *)
"Weather Meta";
60 ActiveDeviceTP[ACTIVE_WEATHER_1].
fill(
"ACTIVE_WEATHER_1",
"Station #1",
nullptr);
61 ActiveDeviceTP[ACTIVE_WEATHER_2].
fill(
"ACTIVE_WEATHER_2",
"Station #2",
nullptr);
62 ActiveDeviceTP[ACTIVE_WEATHER_3].
fill(
"ACTIVE_WEATHER_3",
"Station #3",
nullptr);
63 ActiveDeviceTP[ACTIVE_WEATHER_4].
fill(
"ACTIVE_WEATHER_4",
"Station #4",
nullptr);
68 StationLP[STATION_STATUS_1].
fill(
"STATION_STATUS_1",
"Station #1",
IPS_IDLE);
69 StationLP[STATION_STATUS_2].
fill(
"STATION_STATUS_2",
"Station #2",
IPS_IDLE);
70 StationLP[STATION_STATUS_3].
fill(
"STATION_STATUS_3",
"Station #3",
IPS_IDLE);
71 StationLP[STATION_STATUS_4].
fill(
"STATION_STATUS_4",
"Station #4",
IPS_IDLE);
75 UpdatePeriodNP[0].
fill(
"PERIOD",
"Period (secs)",
"%4.2f", 0, 3600, 60, 60);
102 for (
int i = 0; i < 4; i++)
104 if (ActiveDeviceTP[i].
getText() !=
nullptr && ActiveDeviceTP[i].
getText()[0] != 0)
126 ActiveDeviceTP.
update(texts, names, n);
128 ActiveDeviceTP.
apply();
130 if (ActiveDeviceTP[ACTIVE_WEATHER_1].
getText() !=
nullptr)
135 if (ActiveDeviceTP[ACTIVE_WEATHER_1].text !=
nullptr)
140 if (ActiveDeviceTP[ACTIVE_WEATHER_3].
getText() !=
nullptr)
145 if (ActiveDeviceTP[ACTIVE_WEATHER_4].
getText() !=
nullptr)
164 ActiveDeviceTP.
save(fp);
165 UpdatePeriodNP.
save(fp);
177 if (strcmp(propName,
"WEATHER_STATUS") == 0)
179 for (
int i = 0; i < 4; i++)
181 if (ActiveDeviceTP[i].
getText() !=
nullptr && strcmp(ActiveDeviceTP[i].
getText(), deviceName) == 0)
188 StationLP[i].
setState(stationState);
190 updateOverallState();
199 if (strcmp(propName,
"WEATHER_UPDATE") == 0)
203 for (
int i = 0; i < 4; i++)
205 if (ActiveDeviceTP[i].
getText() !=
nullptr && strcmp(ActiveDeviceTP[i].
getText(), deviceName) == 0)
209 updateUpdatePeriod();
219void WeatherMeta::updateOverallState()
223 for (
int i = 0; i < 4; i++)
225 if (StationLP[i].getState() > StationLP.
getState())
226 StationLP.
setState(StationLP[i].getState());
232void WeatherMeta::updateUpdatePeriod()
234 double minPeriod = UpdatePeriodNP[0].getMin();
236 for (
int i = 0; i < 4; i++)
238 if (updatePeriods[i] > 0 && updatePeriods[i] < minPeriod)
239 minPeriod = updatePeriods[i];
242 if (minPeriod != UpdatePeriodNP[0].getMax())
244 UpdatePeriodNP[0].setValue(minPeriod);
245 UpdatePeriodNP.
apply();
const char * getDeviceName() const
INDI::PropertyText getText(const char *name) const
virtual bool updateProperties()
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
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 setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
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()
Initialize properties initial state and value. The child class must implement this function.
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.
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
void save(FILE *f) const
save Save property to configuration file.
void setLabel(const char *label)
bool isNameMatch(const char *otherName) const
void fill(const char *device, const char *name, const char *label, const char *group, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
bool update(const char *const texts[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
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,...
int crackIPState(const char *str, IPState *ip)
Extract property state (Idle, OK, Busy, Alert) from the supplied string.
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...
const char * findXMLAttValu(XMLEle *ep, const char *name)
Find an XML element's attribute value.
XMLEle * nextXMLEle(XMLEle *ep, int init)
Iterate an XML element for a list of nesetd XML elements.
char * pcdataXMLEle(XMLEle *ep)
Return the pcdata of an XML element.