diff --git a/drivers/agent/group.cpp b/drivers/agent/group.cpp index 71cf3b4390..5ab44501f8 100644 --- a/drivers/agent/group.cpp +++ b/drivers/agent/group.cpp @@ -41,35 +41,35 @@ Group::Group(int id, Imager *imager) : imager{imager} groupSettingsNameStream << GROUP_PREFIX << std::setw(2) << std::setfill('0') << id; groupSettingsName = groupSettingsNameStream.str(); - GroupSettingsN.resize(4); - - IUFillNumber(&GroupSettingsN[IMAGE_COUNT], "IMAGE_COUNT", "Image count", "%3.0f", 1, 100, 1, 1); - IUFillNumber(&GroupSettingsN[CCD_BINNING], "CCD_BINNING", "Binning", "%1.0f", 1, 4, 1, 1); - IUFillNumber(&GroupSettingsN[FILTER_SLOT], "FILTER_SLOT", "Filter", "%2.f", 0, 12, 1, 0); - IUFillNumber(&GroupSettingsN[CCD_EXPOSURE_VALUE], "CCD_EXPOSURE_VALUE", "Duration (s)", "%5.2f", 0, 36000, 0, 1.0); - IUFillNumberVector(&GroupSettingsNP, GroupSettingsN.data(), GroupSettingsN.size(), Imager::DEVICE_NAME.c_str(), - groupSettingsName.c_str(), "Image group settings", - groupName.c_str(), IP_RW, 60, IPS_IDLE); + GroupSettingsNP.resize(4); + + GroupSettingsNP[IMAGE_COUNT].fill("IMAGE_COUNT", "Image count", "%3.0f", 1, 100, 1, 1); + GroupSettingsNP[CCD_BINNING].fill("CCD_BINNING", "Binning", "%1.0f", 1, 4, 1, 1); + GroupSettingsNP[FILTER_SLOT].fill( "FILTER_SLOT", "Filter", "%2.f", 0, 12, 1, 0); + GroupSettingsNP[CCD_EXPOSURE_VALUE].fill("CCD_EXPOSURE_VALUE", "Duration (s)", "%5.2f", 0, 36000, 0, 1.0); + GroupSettingsNP.fill(Imager::DEVICE_NAME.c_str(), + groupSettingsName.c_str(), "Image group settings", + groupName.c_str(), IP_RW, 60, IPS_IDLE); } int Group::binning() const { - return GroupSettingsN[CCD_BINNING].value; + return GroupSettingsNP[CCD_BINNING].getValue(); } int Group::filterSlot() const { - return GroupSettingsN[FILTER_SLOT].value; + return GroupSettingsNP[FILTER_SLOT].getValue(); } double Group::exposure() const { - return GroupSettingsN[CCD_EXPOSURE_VALUE].value; + return GroupSettingsNP[CCD_EXPOSURE_VALUE].getValue(); } int Group::count() const { - return GroupSettingsN[IMAGE_COUNT].value; + return GroupSettingsNP[IMAGE_COUNT].getValue(); } @@ -78,9 +78,9 @@ bool Group::ISNewNumber(const char *dev, const char *name, double values[], char INDI_UNUSED(dev); if (groupSettingsName == name) { - IUUpdateNumber(&GroupSettingsNP, values, names, n); - GroupSettingsNP.s = IPS_OK; - IDSetNumber(&GroupSettingsNP, nullptr); + GroupSettingsNP.update(values, names, n); + GroupSettingsNP.setState(IPS_OK); + GroupSettingsNP.apply(); return true; } return false; @@ -88,10 +88,10 @@ bool Group::ISNewNumber(const char *dev, const char *name, double values[], char void Group::defineProperties() { - imager->defineProperty(&GroupSettingsNP); + imager->defineProperty(GroupSettingsNP); } void Group::deleteProperties() { - imager->deleteProperty(GroupSettingsNP.name); + imager->deleteProperty(GroupSettingsNP.getName()); } diff --git a/drivers/agent/group.h b/drivers/agent/group.h index 62d41210ed..5bcf8dccbb 100644 --- a/drivers/agent/group.h +++ b/drivers/agent/group.h @@ -27,24 +27,31 @@ class Imager; class Group { - public: - explicit Group(int id, Imager *imager); - - bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n); - - void defineProperties(); - void deleteProperties(); - - int filterSlot() const; - int binning() const; - double exposure() const; - int count() const; - private: - std::string groupName; - std::string groupSettingsName; - Imager* imager; - INumberVectorProperty GroupSettingsNP; - std::vector GroupSettingsN; +public: + explicit Group(int id, Imager *imager); + + bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n); + + void defineProperties(); + void deleteProperties(); + + int filterSlot() const; + int binning() const; + double exposure() const; + int count() const; +private: + std::string groupName; + std::string groupSettingsName; + Imager* imager; + INDI::PropertyNumber GroupSettingsNP {4}; + enum + { + IMAGE_COUNT, + CCD_BINNING, + FILTER_SLOT, + CCD_EXPOSURE_VALUE + }; + // std::vector GroupSettingsN; };