Instrument Neutral Distributed Interface INDI 2.2.5
indiguiderinterface.cpp
Go to the documentation of this file.
1/*
2 Guider Interface
3 Copyright (C) 2011 Jasem Mutlaq ([email protected])
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
25namespace INDI
26{
27
34
41
45void GuiderInterface::initProperties(const char *groupName)
46{
47 // @INDI_STANDARD_PROPERTY@
48 GuideNSNP[DIRECTION_NORTH].fill("TIMED_GUIDE_N", "North (ms)", "%.f", 0, 60000, 100, 0);
49 GuideNSNP[DIRECTION_SOUTH].fill("TIMED_GUIDE_S", "South (ms)", "%.f", 0, 60000, 100, 0);
50 GuideNSNP.fill(m_defaultDevice->getDeviceName(), "TELESCOPE_TIMED_GUIDE_NS", "Guide N/S", groupName, IP_RW, 60, IPS_IDLE);
51
52 // @INDI_STANDARD_PROPERTY@
53 GuideWENP[DIRECTION_WEST].fill("TIMED_GUIDE_W", "West (ms)", "%.f", 0, 60000, 100, 0);
54 GuideWENP[DIRECTION_EAST].fill("TIMED_GUIDE_E", "East (ms)", "%.f", 0, 60000, 100, 0);
55 GuideWENP.fill(m_defaultDevice->getDeviceName(), "TELESCOPE_TIMED_GUIDE_WE", "Guide E/W", groupName, IP_RW, 60, IPS_IDLE);
56}
57
62{
63 if (m_defaultDevice->isConnected())
64 {
65 m_defaultDevice->defineProperty(GuideNSNP);
66 m_defaultDevice->defineProperty(GuideWENP);
67 }
68 else
69 {
70 m_defaultDevice->deleteProperty(GuideNSNP);
71 m_defaultDevice->deleteProperty(GuideWENP);
72 }
73
74 return true;
75}
76
80bool GuiderInterface::processNumber(const char *dev, const char *name, double values[], char *names[], int n)
81{
82 if (dev && !strcmp(dev, m_defaultDevice->getDeviceName()))
83 {
84 if (GuideNSNP.isNameMatch(name))
85 {
86 // We are being asked to send a guide pulse north/south on the st4 port
87 GuideNSNP.update(values, names, n);
88
89 if (GuideNSNP[DIRECTION_NORTH].getValue() != 0)
90 {
91 GuideNSNP[DIRECTION_SOUTH].setValue(0);
93 }
94 else if (GuideNSNP[DIRECTION_SOUTH].getValue() != 0)
96
98 return true;
99 }
100
101 if (GuideWENP.isNameMatch(name))
102 {
103 // We are being asked to send a guide pulse north/south on the st4 port
104 GuideWENP.update(values, names, n);
105
106 if (GuideWENP[DIRECTION_WEST].getValue() != 0)
107 {
108 GuideWENP[DIRECTION_EAST].setValue(0);
110 }
111 else if (GuideWENP[DIRECTION_EAST].getValue() != 0)
113
115 return true;
116 }
117 }
118
119 return false;
120}
121
123{
124 switch (axis)
125 {
126 case AXIS_DE:
129 break;
130
131 case AXIS_RA:
134 break;
135 }
136}
137}
hid_device * device
bool isConnected() const
const char * getDeviceName() const
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
INDI::PropertyNumber GuideNSNP
virtual void GuideComplete(INDI_EQ_AXIS axis)
Call GuideComplete once the guiding pulse is complete.
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
virtual IPState GuideEast(uint32_t ms)=0
Guide east for ms milliseconds. East is defined as RA+.
INDI::PropertyNumber GuideWENP
virtual IPState GuideWest(uint32_t ms)=0
Guide west for ms milliseconds. West is defined as RA-.
void initProperties(const char *groupName)
Initialize guider properties. It is recommended to call this function within initProperties() of your...
GuiderInterface(DefaultDevice *defaultDevice)
virtual IPState GuideNorth(uint32_t ms)=0
Guide north for ms milliseconds. North is defined as DEC+.
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Call this function whenever client updates GuideNSNP or GuideWSP properties in the primary device....
virtual IPState GuideSouth(uint32_t ms)=0
Guide south for ms milliseconds. South is defined as DEC-.
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isNameMatch(const char *otherName) const
bool update(const double values[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
@ IP_RW
Definition indiapi.h:184
@ IPS_IDLE
Definition indiapi.h:159
INDI_EQ_AXIS
@ AXIS_DE
@ AXIS_RA
@ DIRECTION_EAST
@ DIRECTION_WEST
@ DIRECTION_SOUTH
@ DIRECTION_NORTH
Namespace to encapsulate INDI client, drivers, and mediator classes.