Changeset 642 for BAORadio/libindi/libindi/libs/indibase/indifocuser.cpp
- Timestamp:
- Feb 24, 2012, 12:37:36 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BAORadio/libindi/libindi/libs/indibase/indifocuser.cpp
r504 r642 1 1 /******************************************************************************* 2 Copyright(c) 201 0Gerry Rozema. All rights reserved.2 Copyright(c) 2011 Gerry Rozema. All rights reserved. 3 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. 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License version 2 as published by the Free Software Foundation. 8 7 9 This program is distributed in the hope that it will be useful, but WITHOUT10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for12 more details.8 This library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Library General Public License for more details. 13 12 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. 13 You should have received a copy of the GNU Library General Public License 14 along with this library; see the file COPYING.LIB. If not, write to 15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 Boston, MA 02110-1301, USA. 17 *******************************************************************************/ 17 18 18 The full GNU General Public License is included in this distribution in the19 file called LICENSE.20 *******************************************************************************/21 19 #include "indifocuser.h" 22 20 … … 25 23 INDI::Focuser::Focuser() 26 24 { 27 //ctor 25 FocusSpeedNP = new INumberVectorProperty; 26 FocusTimerNP = new INumberVectorProperty; 27 FocusMotionSP = new ISwitchVectorProperty; 28 28 } 29 29 30 30 INDI::Focuser::~Focuser() 31 31 { 32 //dtor 32 delete FocusSpeedNP; 33 delete FocusTimerNP; 34 delete FocusMotionSP; 35 33 36 } 34 37 … … 37 40 DefaultDriver::initProperties(); // let the base class flesh in what it wants 38 41 39 IUFillNumber(&Focus speedN[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);42 IUFillNumber(&FocusSpeedN[0],"FOCUS_SPEED_VALUE","Focus Speed","%3.0f",0.0,255.0,1.0,255.0); 43 IUFillNumberVector(FocusSpeedNP,FocusSpeedN,1,deviceName(),"FOCUS_SPEED","Speed",MAIN_CONTROL_TAB,IP_RW,60,IPS_OK); 41 44 42 IUFillNumber(&Focus timerN[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);45 IUFillNumber(&FocusTimerN[0],"FOCUS_TIMER_VALUE","Focus Timer","%4.0f",0.0,1000.0,10.0,1000.0); 46 IUFillNumberVector(FocusTimerNP,FocusTimerN,1,deviceName(),"FOCUS_TIMER","Timer",MAIN_CONTROL_TAB,IP_RW,60,IPS_OK); 44 47 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 48 IUFillSwitch(&FocusMotionS[0],"FOCUS_INWARD","Focus In",ISS_ON); 49 IUFillSwitch(&FocusMotionS[1],"FOCUS_OUTWARD","Focus Out",ISS_OFF); 50 IUFillSwitchVector(FocusMotionSP,FocusMotionS,2,deviceName(),"FOCUS_MOTION","Direction",MAIN_CONTROL_TAB,IP_RW,ISR_1OFMANY,60,IPS_OK); 49 51 50 52 return 0; … … 54 56 { 55 57 // First we let our parent populate 56 IDLog("INDI::Focuser::ISGetProperties %s\n",dev);57 58 DefaultDriver::ISGetProperties(dev); 58 59 … … 65 66 { 66 67 // Now we add our focusser specific stuff 67 IDDefSwitch(&FocusmotionSV, NULL);68 IDDefNumber(&FocusspeedNV, NULL);69 IDDefNumber(&FocustimerNV, NULL);68 defineSwitch(FocusMotionSP); 69 defineNumber(FocusSpeedNP); 70 defineNumber(FocusTimerNP); 70 71 } else 71 72 { 72 deleteProperty(Focus motionSV.name);73 deleteProperty(Focus speedNV.name);74 deleteProperty(Focus timerNV.name);73 deleteProperty(FocusMotionSP->name); 74 deleteProperty(FocusSpeedNP->name); 75 deleteProperty(FocusTimerNP->name); 75 76 } 76 77 return true; … … 81 82 { 82 83 // first check if it's for our device 83 IDLog("INDI::Focuser::ISNewNumber %s\n",name);84 if(strcmp(dev,deviceName())==0){84 if(strcmp(dev,deviceName())==0) 85 { 85 86 // This is for our device 86 87 // Now lets see if it's something we process here 87 if(strcmp(name,"FOCUS_TIMER")==0) { 88 if(strcmp(name,"FOCUS_TIMER")==0) 89 { 88 90 // Ok, gotta move the focusser now 89 intdir;91 FocusDirection dir; 90 92 int speed; 91 93 int t; … … 93 95 //IDLog(") 94 96 // first we get all the numbers just sent to us 95 Focus timerNV.s=IPS_OK;96 IUUpdateNumber( &FocustimerNV,values,names,n);97 FocusTimerNP->s=IPS_OK; 98 IUUpdateNumber(FocusTimerNP,values,names,n); 97 99 98 100 // Now lets find what we need for this move 99 speed=Focus speedN[0].value;100 if(Focus motionS[0].s==ISS_ON) dir=1;101 else dir= 0;102 t=Focus timerN[0].value;101 speed=FocusSpeedN[0].value; 102 if(FocusMotionS[0].s==ISS_ON) dir=FOCUS_INWARD; 103 else dir=FOCUS_OUTWARD; 104 t=FocusTimerN[0].value; 103 105 104 Move(dir,speed,t); 106 if (Move(dir,speed,t) == false) 107 FocusTimerNP->s = IPS_ALERT; 105 108 106 107 // Update client display 108 IDSetNumber(&FocustimerNV,NULL); 109 IDSetNumber(FocusTimerNP,NULL); 109 110 return true; 110 111 } 111 112 112 113 113 if(strcmp(name,"FOCUS_SPEED")==0) { 114 115 116 FocusspeedNV.s=IPS_OK; 117 IUUpdateNumber(&FocusspeedNV,values,names,n); 114 if(strcmp(name,"FOCUS_SPEED")==0) 115 { 116 FocusSpeedNP->s=IPS_OK; 117 IUUpdateNumber(FocusSpeedNP,values,names,n); 118 118 119 119 120 120 121 121 // Update client display 122 IDSetNumber( &FocusspeedNV,NULL);122 IDSetNumber(FocusSpeedNP,NULL); 123 123 return true; 124 124 } … … 132 132 bool INDI::Focuser::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) 133 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 134 139 if(strcmp(dev,deviceName())==0) { 135 if(strcmp(dev,deviceName())==0) 136 { 140 137 // This one is for us 141 if(strcmp(name,"FOCUS_MOTION")==0) { 138 if(strcmp(name,"FOCUS_MOTION")==0) 139 { 142 140 // client is telling us what to do with focus direction 143 Focus motionSV.s=IPS_OK;144 IUUpdateSwitch( &FocusmotionSV,states,names,n);141 FocusMotionSP->s=IPS_OK; 142 IUUpdateSwitch(FocusMotionSP,states,names,n); 145 143 // Update client display 146 IDSetSwitch( &FocusmotionSV,NULL);144 IDSetSwitch(FocusMotionSP,NULL); 147 145 148 146 return true; … … 155 153 } 156 154 157 int INDI::Focuser::Move(int,int,int) 155 bool INDI::Focuser::ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) 156 { 157 return DefaultDriver::ISNewText(dev, name, texts, names, n); 158 } 159 160 void INDI::Focuser::ISSnoopDevice (XMLEle *root) 161 { 162 return; 163 } 164 165 bool INDI::Focuser::Move(FocusDirection dir, int speed, int duration) 158 166 { 159 167 // This should be a virtual function, because the low level hardware class … … 161 169 // but it's much easier early development if the method actually 162 170 // exists for now 163 return -1;171 return false; 164 172 } 165 173
Note: See TracChangeset
for help on using the changeset viewer.