Instrument Neutral Distributed Interface INDI  1.1.0
indiguiderinterface.cpp
1 /*
2  Guider Interface
3  Copyright (C) 2011 Jasem Mutlaq (mutlaqja@ikarustech.com)
4 
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.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
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
18 
19 */
20 
21 #include "indiguiderinterface.h"
22 #include <indiapi.h>
23 
24 #include <string.h>
25 
26 INDI::GuiderInterface::GuiderInterface()
27 {
28 
29 }
30 
31 INDI::GuiderInterface::~GuiderInterface()
32 {
33 
34 }
35 
36 void INDI::GuiderInterface::initGuiderProperties(const char *deviceName, const char* groupName)
37 {
38 
39  IUFillNumber(&GuideNSN[DIRECTION_NORTH],"TIMED_GUIDE_N","North (ms)","%.f",0,60000,100,0);
40  IUFillNumber(&GuideNSN[DIRECTION_SOUTH],"TIMED_GUIDE_S","South (ms)","%.f",0,60000,100,0);
41  IUFillNumberVector(&GuideNSNP,GuideNSN,2,deviceName,"TELESCOPE_TIMED_GUIDE_NS","Guide N/S",groupName,IP_RW,60,IPS_IDLE);
42 
43  IUFillNumber(&GuideWEN[DIRECTION_WEST],"TIMED_GUIDE_W","West (ms)","%.f",0,60000,100,0);
44  IUFillNumber(&GuideWEN[DIRECTION_EAST],"TIMED_GUIDE_E","East (ms)","%.f",0,60000,100,0);
45  IUFillNumberVector(&GuideWENP,GuideWEN,2,deviceName,"TELESCOPE_TIMED_GUIDE_WE","Guide E/W",groupName,IP_RW,60,IPS_IDLE);
46 }
47 
48 void INDI::GuiderInterface::processGuiderProperties(const char *name, double values[], char *names[], int n)
49 {
50  if(strcmp(name,GuideNSNP.name)==0)
51  {
52  // We are being asked to send a guide pulse north/south on the st4 port
53  IUUpdateNumber(&GuideNSNP,values,names,n);
54 
55  if(GuideNSN[DIRECTION_NORTH].value != 0)
56  {
57  GuideNSN[DIRECTION_SOUTH].value = 0;
58  GuideNSNP.s = GuideNorth(GuideNSN[DIRECTION_NORTH].value);
59  }
60  else if(GuideNSN[DIRECTION_SOUTH].value != 0)
61  GuideNSNP.s = GuideSouth(GuideNSN[DIRECTION_SOUTH].value);
62 
63  IDSetNumber(&GuideNSNP,NULL);
64  return;
65  }
66 
67  if(strcmp(name,GuideWENP.name)==0)
68  {
69  // We are being asked to send a guide pulse north/south on the st4 port
70  IUUpdateNumber(&GuideWENP,values,names,n);
71 
72  if(GuideWEN[DIRECTION_WEST].value != 0)
73  {
74  GuideWEN[DIRECTION_EAST].value = 0;
75  GuideWENP.s = GuideWest(GuideWEN[DIRECTION_WEST].value);
76  }
77  else if(GuideWEN[DIRECTION_EAST].value != 0)
78  GuideWENP.s = GuideEast(GuideWEN[DIRECTION_EAST].value);
79 
80  IDSetNumber(&GuideWENP,NULL);
81  return;
82  }
83 }
84 
85 void INDI::GuiderInterface::GuideComplete(INDI_EQ_AXIS axis)
86 {
87  switch (axis)
88  {
89  case AXIS_DE:
90  GuideNSNP.s = IPS_IDLE;
91  IDSetNumber(&GuideNSNP, NULL);
92  break;
93 
94  case AXIS_RA:
95  GuideWENP.s = IPS_IDLE;
96  IDSetNumber(&GuideWENP, NULL);
97  break;
98  }
99 }
100 
101 
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:503
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
Definition: indidriver.c:263
Definition: indiapi.h:154
void IDSetNumber(const INumberVectorProperty *n, const char *msg,...)
Tell client to update an existing number vector property.
Definition: indidriver.c:1740
void initGuiderProperties(const char *deviceName, const char *groupName)
Initilize guider properties. It is recommended to call this function within initProperties() of your ...
Constants and Data structure definitions for the interface to the reference INDI C API implementation...
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:398
void processGuiderProperties(const char *name, double values[], char *names[], int n)
Call this function whenever client updates GuideNSNP or GuideWSP properties in the primary device...
virtual void GuideComplete(INDI_EQ_AXIS axis)
Call GuideComplete once the guiding pulse is complete.