Instrument Neutral Distributed Interface INDI 2.2.5
group.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2013-2016 CloudMakers, s. r. o. All rights reserved.
3 Copyright(c) 2017-2018 Marco Gulino <[email protected]>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18 *******************************************************************************/
19
20#include "group.h"
21#include "agent_imager.h"
22#include <iomanip>
23#include <sstream>
24
25#define GROUP_PREFIX "GROUP_"
26#define GROUP_PREFIX_LEN 6
27
28#define IMAGE_COUNT 0
29#define CCD_BINNING 1
30#define FILTER_SLOT 2
31#define CCD_EXPOSURE_VALUE 3
32
34{
35 id++;
36 std::stringstream groupNameStream;
37 groupNameStream << "Image group " << id;
38 groupName = groupNameStream.str();
39
40 std::stringstream groupSettingsNameStream;
41 groupSettingsNameStream << GROUP_PREFIX << std::setw(2) << std::setfill('0') << id;
42 groupSettingsName = groupSettingsNameStream.str();
43
44 GroupSettingsNP.resize(4);
45
46 GroupSettingsNP[IMAGE_COUNT].fill("IMAGE_COUNT", "Image count", "%3.0f", 1, 100, 1, 1);
47 GroupSettingsNP[CCD_BINNING].fill("CCD_BINNING", "Binning", "%1.0f", 1, 4, 1, 1);
48 GroupSettingsNP[FILTER_SLOT].fill( "FILTER_SLOT", "Filter", "%2.f", 0, 12, 1, 0);
49 GroupSettingsNP[CCD_EXPOSURE_VALUE].fill("CCD_EXPOSURE_VALUE", "Duration (s)", "%5.2f", 0, 36000, 0, 1.0);
50 GroupSettingsNP.fill(Imager::DEVICE_NAME.c_str(),
51 groupSettingsName.c_str(), "Image group settings",
52 groupName.c_str(), IP_RW, 60, IPS_IDLE);
53}
54
55int Group::binning() const
56{
57 return GroupSettingsNP[CCD_BINNING].getValue();
58}
59
61{
62 return GroupSettingsNP[FILTER_SLOT].getValue();
63}
64
65double Group::exposure() const
66{
67 return GroupSettingsNP[CCD_EXPOSURE_VALUE].getValue();
68}
69
70int Group::count() const
71{
72 return GroupSettingsNP[IMAGE_COUNT].getValue();
73}
74
75
76bool Group::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
77{
78 INDI_UNUSED(dev);
79 if (groupSettingsName == name)
80 {
81 GroupSettingsNP.update(values, names, n);
82 GroupSettingsNP.setState(IPS_OK);
83 GroupSettingsNP.apply();
84 return true;
85 }
86 return false;
87}
88
90{
91 imager->defineProperty(GroupSettingsNP);
92}
93
95{
96 imager->deleteProperty(GroupSettingsNP);
97}
std::shared_ptr< Imager > imager(new Imager())
#define GROUP_PREFIX
void defineProperties()
Definition group.cpp:89
int binning() const
Definition group.cpp:55
int count() const
Definition group.cpp:70
double exposure() const
Definition group.cpp:65
Group(int id, Imager *imager)
Definition group.cpp:33
void deleteProperties()
Definition group.cpp:94
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Definition group.cpp:76
int filterSlot() const
Definition group.cpp:60
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
void resize(size_t size)
bool update(const double values[], 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)
static const std::string DEVICE_NAME
@ IP_RW
Definition indiapi.h:184
@ IPS_IDLE
Definition indiapi.h:159
@ IPS_OK
Definition indiapi.h:160
#define INDI_UNUSED(x)
Definition indidevapi.h:132