1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/*******************************************************************************
Copyright(c) 2010, 2011 Gerry Rozema. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*******************************************************************************/
#include "indifilterwheel.h"
#include <string.h>
INDI::FilterWheel::FilterWheel()
{
//ctor
MaxFilter=-1;
}
INDI::FilterWheel::~FilterWheel()
{
//dtor
}
bool INDI::FilterWheel::initProperties()
{
DefaultDriver::initProperties();
initFilterProperties(deviceName(), FILTER_TAB);
return true;
}
void INDI::FilterWheel::ISGetProperties (const char *dev)
{
// First we let our parent populate
//IDLog("INDI::FilterWheel::ISGetProperties %s\n",dev);
DefaultDriver::ISGetProperties(dev);
if(isConnected())
{
defineNumber(FilterSlotNP);
if (GetFilterNames(deviceName(), FILTER_TAB))
defineText(FilterNameTP);
}
return;
}
bool INDI::FilterWheel::updateProperties()
{
// Define more properties after we are connected
// first we want to update the values to reflect our actual wheel
if(isConnected())
{
initFilterProperties(deviceName(), FILTER_TAB);
defineNumber(FilterSlotNP);
if (GetFilterNames(deviceName(), FILTER_TAB))
defineText(FilterNameTP);
} else
{
deleteProperty(FilterSlotNP->name);
deleteProperty(FilterNameTP->name);
}
return true;
}
bool INDI::FilterWheel::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
{
return DefaultDriver::ISNewSwitch(dev, name, states, names,n);
}
bool INDI::FilterWheel::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
// first check if it's for our device
//IDLog("INDI::FilterWheel::ISNewNumber %s\n",name);
if(strcmp(dev,deviceName())==0)
{
// This is for our device
// Now lets see if it's something we process here
if(strcmp(name,"FILTER_SLOT")==0)
{
int f;
f=-1;
for(int x=0; x<n; x++)
{
if(strcmp(names[x],"FILTER_SLOT_VALUE")==0)
{
// This is the new filter number we are being asked
// to set as active
f=values[x];
}
}
if(f != -1)
{
//IDLog("Filter wheel got a filter slot change\n");
// tell the client we are busy changing the filter
FilterSlotNP->s=IPS_BUSY;
IDSetNumber(FilterSlotNP,NULL);
// Tell the hardware to change
SelectFilter(f);
// tell the caller we processed this
return true;
}
}
}
// if we didn't process it, continue up the chain, let somebody else
// give it a shot
return DefaultDriver::ISNewNumber(dev,name,values,names,n);
}
bool INDI::FilterWheel::ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
{
// Ok, lets see if this is a property wer process
//IDLog("INDI::FilterWheel got %d new text items name %s\n",n,name);
// first check if it's for our device
if(strcmp(dev,deviceName())==0)
{
// This is for our device
// Now lets see if it's something we process here
if(strcmp(name,FilterNameTP->name)==0)
{
int rc;
//IDLog("calling update text\n");
FilterNameTP->s=IPS_OK;
rc=IUUpdateText(FilterNameTP,texts,names,n);
if (SetFilterNames() == true)
IDSetText(FilterNameTP,NULL);
else
{
FilterNameTP->s = IPS_ALERT;
IDSetText(FilterNameTP, "Error updating names of filters.");
}
// We processed this one, so, tell the world we did it
return true;
}
}
return DefaultDriver::ISNewText(dev,name,texts,names,n);
}
int INDI::FilterWheel::QueryFilter()
{
return -1;
}
bool INDI::FilterWheel::SelectFilter(int)
{
return false;
}
bool INDI::FilterWheel::SetFilterNames()
{
return true;
}
void INDI::FilterWheel::ISSnoopDevice (XMLEle *root)
{
return;
}
bool INDI::FilterWheel::GetFilterNames(const char *deviceName, const char* groupName)
{
INDI_UNUSED(deviceName);
INDI_UNUSED(groupName);
return false;
}
|