Ignore:
Timestamp:
Feb 24, 2012, 12:37:36 PM (12 years ago)
Author:
frichard
Message:

-Alignement des antennes
-Version 0.0.9 de libindi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BAORadio/libindi/libindi/libs/indibase/indifocuser.cpp

    r504 r642  
    11/*******************************************************************************
    2   Copyright(c) 2010 Gerry Rozema. All rights reserved.
     2  Copyright(c) 2011 Gerry Rozema. All rights reserved.
    33
    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.
    87
    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.
     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.
    1312
    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*******************************************************************************/
    1718
    18   The full GNU General Public License is included in this distribution in the
    19   file called LICENSE.
    20 *******************************************************************************/
    2119#include "indifocuser.h"
    2220
     
    2523INDI::Focuser::Focuser()
    2624{
    27     //ctor
     25    FocusSpeedNP  = new INumberVectorProperty;
     26    FocusTimerNP  = new INumberVectorProperty;
     27    FocusMotionSP = new ISwitchVectorProperty;
    2828}
    2929
    3030INDI::Focuser::~Focuser()
    3131{
    32     //dtor
     32    delete FocusSpeedNP;
     33    delete FocusTimerNP;
     34    delete FocusMotionSP;
     35
    3336}
    3437
     
    3740    DefaultDriver::initProperties();   //  let the base class flesh in what it wants
    3841
    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);
     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);
    4144
    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);
     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);
    4447
    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);
    4951
    5052    return 0;
     
    5456{
    5557    //  First we let our parent populate
    56     IDLog("INDI::Focuser::ISGetProperties %s\n",dev);
    5758    DefaultDriver::ISGetProperties(dev);
    5859
     
    6566    {
    6667        //  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);
    7071    } else
    7172    {
    72         deleteProperty(FocusmotionSV.name);
    73         deleteProperty(FocusspeedNV.name);
    74         deleteProperty(FocustimerNV.name);
     73        deleteProperty(FocusMotionSP->name);
     74        deleteProperty(FocusSpeedNP->name);
     75        deleteProperty(FocusTimerNP->name);
    7576    }
    7677    return true;
     
    8182{
    8283    //  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    {
    8586        //  This is for our device
    8687        //  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        {
    8890            //  Ok, gotta move the focusser now
    89             int dir;
     91            FocusDirection dir;
    9092            int speed;
    9193            int t;
     
    9395            //IDLog(")
    9496            //  first we get all the numbers just sent to us
    95             FocustimerNV.s=IPS_OK;
    96             IUUpdateNumber(&FocustimerNV,values,names,n);
     97            FocusTimerNP->s=IPS_OK;
     98            IUUpdateNumber(FocusTimerNP,values,names,n);
    9799
    98100            //  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;
     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;
    103105
    104             Move(dir,speed,t);
     106            if (Move(dir,speed,t) == false)
     107                FocusTimerNP->s = IPS_ALERT;
    105108
    106 
    107             //  Update client display
    108             IDSetNumber(&FocustimerNV,NULL);
     109            IDSetNumber(FocusTimerNP,NULL);
    109110            return true;
    110111        }
    111112
    112113
    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);
    118118
    119119
    120120
    121121            //  Update client display
    122             IDSetNumber(&FocusspeedNV,NULL);
     122            IDSetNumber(FocusSpeedNP,NULL);
    123123            return true;
    124124        }
     
    132132bool INDI::Focuser::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
    133133{
    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     //}
    138134
    139     if(strcmp(dev,deviceName())==0) {
     135    if(strcmp(dev,deviceName())==0)
     136    {
    140137        //  This one is for us
    141         if(strcmp(name,"FOCUS_MOTION")==0) {
     138        if(strcmp(name,"FOCUS_MOTION")==0)
     139        {
    142140            //  client is telling us what to do with focus direction
    143             FocusmotionSV.s=IPS_OK;
    144             IUUpdateSwitch(&FocusmotionSV,states,names,n);
     141            FocusMotionSP->s=IPS_OK;
     142            IUUpdateSwitch(FocusMotionSP,states,names,n);
    145143            //  Update client display
    146             IDSetSwitch(&FocusmotionSV,NULL);
     144            IDSetSwitch(FocusMotionSP,NULL);
    147145
    148146            return true;
     
    155153}
    156154
    157 int INDI::Focuser::Move(int,int,int)
     155bool 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
     160void INDI::Focuser::ISSnoopDevice (XMLEle *root)
     161{
     162 return;
     163}
     164
     165bool INDI::Focuser::Move(FocusDirection dir, int speed, int duration)
    158166{
    159167    //  This should be a virtual function, because the low level hardware class
     
    161169    //  but it's much easier early development if the method actually
    162170    //  exists for now
    163     return -1;
     171    return false;
    164172}
    165173
Note: See TracChangeset for help on using the changeset viewer.