source: BAORadio/libindi/libindi/libs/indibase/indifocuser.cpp @ 504

Last change on this file since 504 was 504, checked in by frichard, 13 years ago

-Version 0.8 de libini
-Formule de Marc
-Nouvelles fonctionnalités (goto nom-de l'objet etc...)

File size: 4.9 KB
Line 
1/*******************************************************************************
2  Copyright(c) 2010 Gerry Rozema. All rights reserved.
3
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License as published by the Free
6  Software Foundation; either version 2 of the License, or (at your option)
7  any later version.
8
9  This program is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  more details.
13
14  You should have received a copy of the GNU General Public License along with
15  this program; if not, write to the Free Software Foundation, Inc., 59
16  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17
18  The full GNU General Public License is included in this distribution in the
19  file called LICENSE.
20*******************************************************************************/
21#include "indifocuser.h"
22
23#include <string.h>
24
25INDI::Focuser::Focuser()
26{
27    //ctor
28}
29
30INDI::Focuser::~Focuser()
31{
32    //dtor
33}
34
35bool INDI::Focuser::initProperties()
36{
37    DefaultDriver::initProperties();   //  let the base class flesh in what it wants
38
39    IUFillNumber(&FocusspeedN[0],"FOCUS_SPEED_VALUE","Focus Speed","%3.0f",0.0,255.0,1.0,255.0);
40    IUFillNumberVector(&FocusspeedNV,FocusspeedN,1,deviceName(),"FOCUS_SPEED","Speed","Main Control",IP_RW,60,IPS_OK);
41
42    IUFillNumber(&FocustimerN[0],"FOCUS_TIMER_VALUE","Focus Timer","%4.0f",0.0,1000.0,10.0,1000.0);
43    IUFillNumberVector(&FocustimerNV,FocustimerN,1,deviceName(),"FOCUS_TIMER","Timer","Main Control",IP_RW,60,IPS_OK);
44
45    IUFillSwitch(&FocusmotionS[0],"FOCUS_INWARD","Focus In",ISS_ON);
46    IUFillSwitch(&FocusmotionS[1],"FOCUS_OUTWARD","Focus Out",ISS_OFF);
47    IUFillSwitchVector(&FocusmotionSV,FocusmotionS,2,deviceName(),"FOCUS_MOTION","Focus Direction","Main Control",IP_RW,ISR_1OFMANY,60,IPS_OK);
48
49
50    return 0;
51}
52
53void INDI::Focuser::ISGetProperties (const char *dev)
54{
55    //  First we let our parent populate
56    IDLog("INDI::Focuser::ISGetProperties %s\n",dev);
57    DefaultDriver::ISGetProperties(dev);
58
59    return;
60}
61
62bool INDI::Focuser::updateProperties()
63{
64    if(isConnected())
65    {
66        //  Now we add our focusser specific stuff
67        IDDefSwitch(&FocusmotionSV, NULL);
68        IDDefNumber(&FocusspeedNV, NULL);
69        IDDefNumber(&FocustimerNV, NULL);
70    } else
71    {
72        deleteProperty(FocusmotionSV.name);
73        deleteProperty(FocusspeedNV.name);
74        deleteProperty(FocustimerNV.name);
75    }
76    return true;
77}
78
79
80bool INDI::Focuser::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
81{
82    //  first check if it's for our device
83    IDLog("INDI::Focuser::ISNewNumber %s\n",name);
84    if(strcmp(dev,deviceName())==0) {
85        //  This is for our device
86        //  Now lets see if it's something we process here
87        if(strcmp(name,"FOCUS_TIMER")==0) {
88            //  Ok, gotta move the focusser now
89            int dir;
90            int speed;
91            int t;
92
93            //IDLog(")
94            //  first we get all the numbers just sent to us
95            FocustimerNV.s=IPS_OK;
96            IUUpdateNumber(&FocustimerNV,values,names,n);
97
98            //  Now lets find what we need for this move
99            speed=FocusspeedN[0].value;
100            if(FocusmotionS[0].s==ISS_ON) dir=1;
101            else dir=0;
102            t=FocustimerN[0].value;
103
104            Move(dir,speed,t);
105
106
107            //  Update client display
108            IDSetNumber(&FocustimerNV,NULL);
109            return true;
110        }
111
112
113        if(strcmp(name,"FOCUS_SPEED")==0) {
114
115
116            FocusspeedNV.s=IPS_OK;
117            IUUpdateNumber(&FocusspeedNV,values,names,n);
118
119
120
121            //  Update client display
122            IDSetNumber(&FocusspeedNV,NULL);
123            return true;
124        }
125
126    }
127
128
129    return DefaultDriver::ISNewNumber(dev,name,values,names,n);
130}
131
132bool INDI::Focuser::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
133{
134    IDLog("Enter IsNewSwitch for %s\n",name);
135    //for(int x=0; x<n; x++) {
136    //    IDLog("Switch %s %d\n",names[x],states[x]);
137    //}
138
139    if(strcmp(dev,deviceName())==0) {
140        //  This one is for us
141        if(strcmp(name,"FOCUS_MOTION")==0) {
142            //  client is telling us what to do with focus direction
143            FocusmotionSV.s=IPS_OK;
144            IUUpdateSwitch(&FocusmotionSV,states,names,n);
145            //  Update client display
146            IDSetSwitch(&FocusmotionSV,NULL);
147
148            return true;
149        }
150
151    }
152
153    //  Nobody has claimed this, so, ignore it
154    return DefaultDriver::ISNewSwitch(dev,name,states,names,n);
155}
156
157int INDI::Focuser::Move(int,int,int)
158{
159    //  This should be a virtual function, because the low level hardware class
160    //  must override this
161    //  but it's much easier early development if the method actually
162    //  exists for now
163    return -1;
164}
165
Note: See TracBrowser for help on using the repository browser.