Instrument Neutral Distributed Interface INDI  0.9.6
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(&GuideNS[0],"TIMED_GUIDE_N","North (msec)","%g",0,60000,10,0);
40  IUFillNumber(&GuideNS[1],"TIMED_GUIDE_S","South (msec)","%g",0,60000,10,0);
41  IUFillNumberVector(&GuideNSP,GuideNS,2,deviceName,"TELESCOPE_TIMED_GUIDE_NS","Guide North/South",groupName,IP_RW,60,IPS_IDLE);
42 
43  IUFillNumber(&GuideEW[0],"TIMED_GUIDE_E","East (msec)","%g",0,60000,10,0);
44  IUFillNumber(&GuideEW[1],"TIMED_GUIDE_W","West (msec)","%g",0,60000,10,0);
45  IUFillNumberVector(&GuideEWP,GuideEW,2,deviceName,"TELESCOPE_TIMED_GUIDE_WE","Guide East/West",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,GuideNSP.name)==0)
51  {
52  // We are being asked to send a guide pulse north/south on the st4 port
53  GuideNSP.s=IPS_BUSY;
54  IUUpdateNumber(&GuideNSP,values,names,n);
55  // Update client display
56  IDSetNumber(&GuideNSP,NULL);
57 
58 
59  if(GuideNS[0].value != 0)
60  {
61  GuideNorth(GuideNS[0].value);
62  }
63  if(GuideNS[1].value != 0) {
64  GuideSouth(GuideNS[1].value);
65  }
66  GuideNS[0].value=0;
67  GuideNS[1].value=0;
68  GuideNSP.s=IPS_OK;
69  IDSetNumber(&GuideNSP,NULL);
70 
71  return;
72  }
73 
74  if(strcmp(name,GuideEWP.name)==0)
75  {
76  // We are being asked to send a guide pulse north/south on the st4 port
77  GuideEWP.s=IPS_BUSY;
78  IUUpdateNumber(&GuideEWP,values,names,n);
79  // Update client display
80  IDSetNumber(&GuideEWP,NULL);
81 
82 
83  if(GuideEW[0].value != 0)
84  {
85  GuideEast(GuideEW[0].value);
86  } else
87  {
88  GuideWest(GuideEW[1].value);
89  }
90 
91  GuideEW[0].value=0;
92  GuideEW[1].value=0;
93  GuideEWP.s=IPS_OK;
94  IDSetNumber(&GuideEWP,NULL);
95 
96  return;
97  }
98 }