35static std::unique_ptr<AAGSolo> aag_solo(
new AAGSolo());
37static size_t write_data(
void *contents,
size_t size,
size_t nmemb,
void *userp)
39 ((std::string *)userp)->append((
char *)contents, size * nmemb);
51 return "AAG Solo Cloudwatcher";
56 if (soloHostTP[0].
getText() ==
nullptr
57 || soloHostTP[0].
getText()[0] ==
'\0')
59 LOG_ERROR(
"AAG Solo Cloudwatcher host name or IP must be specified in options tab. Example: aagsolo.local.net");
71bool AAGSolo::createProperties()
73 if (readWatchFile() ==
false)
75 double minOK = 0, maxOK = 0, percWarn = 15;
76 for (
auto const &x : weatherMap)
88 addParameter(
"WEATHER_RAIN",
"Rain", minOK, maxOK, percWarn);
101 addParameter(
"WEATHER_LIGHT",
"Light", minOK, maxOK, percWarn);
114 addParameter(
"WEATHER_TEMPERATURE",
"Temperature", minOK, maxOK, percWarn);
127 addParameter(
"WEATHER_WIND_SPEED",
"Wind speed", minOK, maxOK, percWarn);
140 addParameter(
"WEATHER_WIND_GUST",
"Gust", minOK, maxOK, percWarn);
153 addParameter(
"WEATHER_CLOUDS",
"Clouds", minOK, maxOK, percWarn);
166 addParameter(
"WEATHER_HUMIDITY",
"Humidity", minOK, maxOK, percWarn);
179 addParameter(
"WEATHER_PRESSURE",
"rel. pressure", minOK, maxOK, percWarn);
192 addParameter(
"WEATHER_ISSAFE",
"Safe", minOK, maxOK, percWarn);
219 soloInfoTP[0].
fill(
"CWINFO",
"cwinfo",
nullptr);
220 soloInfoTP[1].
fill(
"DATATIME",
"GMT Time",
nullptr);
240 oneProperty.resize(0);
256 soloHostTP[0].
fill(
"HOSTNAME",
"HOSTNAME",
nullptr);
268 soloHostTP.
update(texts, names, n);
290 LOG_WARN(
"Changing criticals requires driver reconnect");
300 if (readWatchFile() ==
false)
303 for (
auto const &x : weatherMap)
305 for (
int i = 0; i <
numKeys; i++)
313 if (x.first ==
"cwinfo")
315 soloInfoTP[0].
fill(
"CWINFO",
"cwinfo", x.second.c_str());
319 else if (x.first ==
"dataGMTTime")
321 soloInfoTP[1].
fill(
"DATATIME",
"GMT Time", x.second.c_str());
329bool AAGSolo::readWatchFile()
338 snprintf(requestURL,
MAXRBUF,
"http://%s/cgi-bin/cgiLastData", soloHostTP[0].
getText());
340 curl = curl_easy_init();
344 std::string readBuffer;
345 curl_easy_setopt(curl, CURLOPT_URL, requestURL);
346 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
347 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
348 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
349 res = curl_easy_perform(curl);
353 weatherMap = createMap(readBuffer);
356 curl_easy_cleanup(curl);
371std::map<std::string, std::string> AAGSolo::createMap(std::string
const &s)
373 std::map<std::string, std::string> m;
375 std::string key, val;
376 std::istringstream iss(s);
378 while(std::getline(std::getline(iss, key,
'=') >> std::ws, val))
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
const char * getDefaultName() override
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
bool Disconnect() override
Disconnect from device.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
INDI::PropertySwitch criticalSP
INDI::PropertyText getText(const char *name) const
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.
void defineProperty(INumberVectorProperty *property)
void addDebugControl()
Add Debug control to the driver.
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool load()
load Attempt to load property values from configuration file.
void save(FILE *f) const
save Save property to configuration file.
bool isNameMatch(const char *otherName) const
bool update(const ISState states[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, 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)
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....
void setParameterValue(std::string name, double value)
setParameterValue Update weather parameter value
INDI::PropertyNumber ParametersNP
std::vector< INDI::PropertyNumber > ParametersRangeNP
INDI::PropertyLight critialParametersLP
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
void setWeatherConnection(const uint8_t &value)
setWeatherConnection Set Weather connection mode. Child class should call this in the constructor bef...
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
const char * INFO_TAB
INFO_TAB Where all the properties for general information are located.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
int IUGetConfigNumber(const char *dev, const char *property, const char *member, double *value)
IUGetConfigNumber Opens configuration file and reads single number property.
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...