From 0fdeef6ea045658b01659db4b041bb9182bfaecd Mon Sep 17 00:00:00 2001 From: Salman Naheed Date: Sun, 18 Feb 2024 16:53:01 +0300 Subject: [PATCH] update GroupSettingsNP Property --- drivers/agent/group.cpp | 30 +++++++++++++++--------------- drivers/agent/group.h | 11 +++++++++-- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/agent/group.cpp b/drivers/agent/group.cpp index 71cf3b4390..59dee5db9f 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); + GroupSettingsNP.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(), + 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..af47b6b263 100644 --- a/drivers/agent/group.h +++ b/drivers/agent/group.h @@ -43,8 +43,15 @@ class Group std::string groupName; std::string groupSettingsName; Imager* imager; - INumberVectorProperty GroupSettingsNP; - std::vector GroupSettingsN; + INDI::PropertyNumber GroupSettingsNP {4}; + enum + { + IMAGE_COUNT, + CCD_BINNING, + FILTER_SLOT, + CCD_EXPOSURE_VALUE + }; +// std::vector GroupSettingsN; };