Instrument Neutral Distributed Interface INDI  1.5.0
Go to the documentation of this file.
1 /*
2  Filter Interface
3  Copyright (C) 2011 Jasem Mutlaq (
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  Lesser General Public License for more details.
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
21 #include "indifilterinterface.h"
23 #include "indilogger.h"
26 {
28  FilterNameT = nullptr;
29 }
31 void INDI::FilterInterface::initFilterProperties(const char *deviceName, const char *groupName)
32 {
33  IUFillNumber(&FilterSlotN[0], "FILTER_SLOT_VALUE", "Filter", "%3.0f", 1.0, 12.0, 1.0, 1.0);
34  IUFillNumberVector(&FilterSlotNP, FilterSlotN, 1, deviceName, "FILTER_SLOT", "Filter Slot", groupName, IP_RW, 60,
35  IPS_IDLE);
36 }
39 {
40  delete FilterNameTP;
41 }
44 {
45  // The hardware has finished changing
46  // filters
47  FilterSlotN[0].value = f;
49  // Tell the clients we are done, and
50  // filter is now useable
51  IDSetNumber(&FilterSlotNP, nullptr);
52 }
54 void INDI::FilterInterface::processFilterSlot(const char *deviceName, double values[], char *names[])
55 {
56  TargetFilter = values[0];
58  INumber *np = IUFindNumber(&FilterSlotNP, names[0]);
60  if (!np)
61  {
63  DEBUGFDEVICE(deviceName, Logger::DBG_ERROR, "Unknown error. %s is not a member of %s property.", names[0],
65  IDSetNumber(&FilterSlotNP, nullptr);
66  return;
67  }
70  {
72  DEBUGFDEVICE(deviceName, Logger::DBG_ERROR, "Error: valid range of filter is from %g to %g", FilterSlotN[0].min,
73  FilterSlotN[0].max);
74  IDSetNumber(&FilterSlotNP, nullptr);
75  return;
76  }
79  DEBUGFDEVICE(deviceName, Logger::DBG_SESSION, "Setting current filter to slot %d", TargetFilter);
81  if (SelectFilter(TargetFilter) == false)
82  {
84  }
86  IDSetNumber(&FilterSlotNP, nullptr);
87  return;
88 }
90 void INDI::FilterInterface::processFilterName(const char *deviceName, char *texts[], char *names[], int n)
91 {
93  IUUpdateText(FilterNameTP, texts, names, n);
95  if (SetFilterNames() == true)
96  IDSetText(FilterNameTP, nullptr);
97  else
98  {
100  DEBUGDEVICE(deviceName, Logger::DBG_ERROR, "Error updating names of filters.");
101  IDSetText(FilterNameTP, nullptr);
102  }
103 }
void processFilterSlot(const char *deviceName, double values[], char *names[])
Process client request to change filter position. Call this function in the filter wheel implementati...
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL...
Definition: indidriver.c:545
void IDSetText(const ITextVectorProperty *t, const char *msg,...)
Tell client to update an existing text vector property.
Definition: indidriver.c:1796
void SelectFilterDone(int newpos)
The child class calls this function when the hardware successfully finished selecting a new filter wh...
#define DEBUGDEVICE(device, priority, msg)
Definition: indilogger.h:59
int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n)
Update all text members in a text vector property.
Definition: indidriver.c:319
One number descriptor.
Definition: indiapi.h:246
virtual bool SelectFilter(int position)=0
Select a new filter position.
INumberVectorProperty FilterSlotNP
double max(void)
void processFilterName(const char *deviceName, char *texts[], char *names[], int n)
Process client request to change filter name(s). Call this function in the filter wheel implementatio...
Definition: indiapi.h:157
void IDSetNumber(const INumberVectorProperty *n, const char *msg,...)
Tell client to update an existing number vector property.
Definition: indidriver.c:1838
ITextVectorProperty * FilterNameTP
char name[MAXINDINAME]
Definition: indiapi.h:294
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL...
Definition: indidriver.c:420
INumber * IUFindNumber(const INumberVectorProperty *nvp, const char *name)
Find an INumber member in a number text property.
Definition: indicom.c:1234
void initFilterProperties(const char *deviceName, const char *groupName)
Initilize filter wheel properties. It is recommended to call this function within initProperties() of...
virtual bool SetFilterNames()=0
Set filter names as defined by the client for each filter position. The desired filter names are stor...
struct _ITextVectorProperty ITextVectorProperty
double min(void)
#define DEBUGFDEVICE(device, priority, msg,...)
Definition: indilogger.h:60
double value
Definition: indiapi.h:261