Instrument Neutral Distributed Interface INDI  1.9.2
indiguiderinterface.cpp
Go to the documentation of this file.
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 
23 #include <cstring>
24 
25 namespace INDI
26 {
27 
29 {
30 }
31 
33 {
34 }
35 
36 void GuiderInterface::initGuiderProperties(const char *deviceName, const char *groupName)
37 {
38  IUFillNumber(&GuideNSN[DIRECTION_NORTH], "TIMED_GUIDE_N", "North (ms)", "%.f", 0, 60000, 100, 0);
39  IUFillNumber(&GuideNSN[DIRECTION_SOUTH], "TIMED_GUIDE_S", "South (ms)", "%.f", 0, 60000, 100, 0);
40  IUFillNumberVector(&GuideNSNP, GuideNSN, 2, deviceName, "TELESCOPE_TIMED_GUIDE_NS", "Guide N/S", groupName, IP_RW,
41  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,
46  60, IPS_IDLE);
47 }
48 
49 void GuiderInterface::processGuiderProperties(const char *name, double values[], char *names[], int n)
50 {
51  if (strcmp(name, GuideNSNP.name) == 0)
52  {
53  // We are being asked to send a guide pulse north/south on the st4 port
54  IUUpdateNumber(&GuideNSNP, values, names, n);
55 
56  if (GuideNSN[DIRECTION_NORTH].value != 0)
57  {
58  GuideNSN[DIRECTION_SOUTH].value = 0;
60  }
61  else if (GuideNSN[DIRECTION_SOUTH].value != 0)
63 
64  IDSetNumber(&GuideNSNP, nullptr);
65  return;
66  }
67 
68  if (strcmp(name, GuideWENP.name) == 0)
69  {
70  // We are being asked to send a guide pulse north/south on the st4 port
71  IUUpdateNumber(&GuideWENP, values, names, n);
72 
73  if (GuideWEN[DIRECTION_WEST].value != 0)
74  {
75  GuideWEN[DIRECTION_EAST].value = 0;
77  }
78  else if (GuideWEN[DIRECTION_EAST].value != 0)
80 
81  IDSetNumber(&GuideWENP, nullptr);
82  return;
83  }
84 }
85 
87 {
88  switch (axis)
89  {
90  case AXIS_DE:
92  IDSetNumber(&GuideNSNP, nullptr);
93  break;
94 
95  case AXIS_RA:
97  IDSetNumber(&GuideWENP, nullptr);
98  break;
99  }
100 }
101 }
DIRECTION_NORTH
@ DIRECTION_NORTH
Definition: indibasetypes.h:45
DIRECTION_SOUTH
@ DIRECTION_SOUTH
Definition: indibasetypes.h:46
INDI::GuiderInterface::GuiderInterface
GuiderInterface()
Definition: indiguiderinterface.cpp:28
_INumberVectorProperty::s
IPState s
Definition: indiapi.h:332
INDI::GuiderInterface::GuideWENP
INumberVectorProperty GuideWENP
Definition: indiguiderinterface.h:113
IUFillNumber
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:348
DIRECTION_EAST
@ DIRECTION_EAST
Definition: indibasetypes.h:52
INDI::GuiderInterface::initGuiderProperties
void initGuiderProperties(const char *deviceName, const char *groupName)
Initilize guider properties. It is recommended to call this function within initProperties() of your ...
Definition: indiguiderinterface.cpp:36
INDI::GuiderInterface::GuideSouth
virtual IPState GuideSouth(uint32_t ms)=0
Guide south for ms milliseconds. South is defined as DEC-.
INDI::GuiderInterface::GuideNSNP
INumberVectorProperty GuideNSNP
Definition: indiguiderinterface.h:111
IUFillNumberVector
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:455
IPS_IDLE
@ IPS_IDLE
Definition: indiapi.h:160
_INumberVectorProperty::name
char name[MAXINDINAME]
Definition: indiapi.h:322
INDI::GuiderInterface::~GuiderInterface
~GuiderInterface()
Definition: indiguiderinterface.cpp:32
INDI::GuiderInterface::GuideEast
virtual IPState GuideEast(uint32_t ms)=0
Guide east for ms milliseconds. East is defined as RA+.
INDI::GuiderInterface::GuideWest
virtual IPState GuideWest(uint32_t ms)=0
Guide west for ms milliseconds. West is defined as RA-.
INDI::GuiderInterface::GuideWEN
INumber GuideWEN[2]
Definition: indiguiderinterface.h:112
INDI::GuiderInterface::GuideNorth
virtual IPState GuideNorth(uint32_t ms)=0
Guide north for ms milliseconds. North is defined as DEC+.
INDI::GuiderInterface::GuideComplete
virtual void GuideComplete(INDI_EQ_AXIS axis)
Call GuideComplete once the guiding pulse is complete.
Definition: indiguiderinterface.cpp:86
indiguiderinterface.h
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
AXIS_RA
@ AXIS_RA
Definition: indibasetypes.h:33
INDI_EQ_AXIS
INDI_EQ_AXIS
Definition: indibasetypes.h:32
IUUpdateNumber
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
Definition: indidriver.c:225
DIRECTION_WEST
@ DIRECTION_WEST
Definition: indibasetypes.h:51
IP_RW
@ IP_RW
Definition: indiapi.h:185
INDI::GuiderInterface::GuideNSN
INumber GuideNSN[2]
Definition: indiguiderinterface.h:110
IDSetNumber
void void void IDSetNumber(const INumberVectorProperty *n, const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(2
Tell client to update an existing number vector property.
AXIS_DE
@ AXIS_DE
Definition: indibasetypes.h:34
INDI::GuiderInterface::processGuiderProperties
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....
Definition: indiguiderinterface.cpp:49