Skip to content

Commit

Permalink
Migrate Agent group (#2015)
Browse files Browse the repository at this point in the history
  • Loading branch information
naheedsa authored Mar 3, 2024
1 parent e76b3c5 commit 27e59c3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 36 deletions.
36 changes: 18 additions & 18 deletions drivers/agent/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand All @@ -78,20 +78,20 @@ 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;
}

void Group::defineProperties()
{
imager->defineProperty(&GroupSettingsNP);
imager->defineProperty(GroupSettingsNP);
}

void Group::deleteProperties()
{
imager->deleteProperty(GroupSettingsNP.name);
imager->deleteProperty(GroupSettingsNP.getName());
}
43 changes: 25 additions & 18 deletions drivers/agent/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<INumber> 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<INumber> GroupSettingsN;
};


0 comments on commit 27e59c3

Please sign in to comment.