Instrument Neutral Distributed Interface INDI  2.0.2
lx200autostar.cpp
Go to the documentation of this file.
1 /*
2  LX200 Autostar
3  Copyright (C) 2003 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 "lx200autostar.h"
22 
23 #include "lx200driver.h"
24 
25 #include <cstring>
26 
27 #define FIRMWARE_TAB "Firmware data"
28 
29 /********************************************
30  Property: Park telescope to HOME
31 *********************************************/
32 
34 {
36 }
37 
39 {
40  return "LX200 Autostar";
41 }
42 
44 {
46 
47  IUFillText(&VersionT[0], "Date", "", "");
48  IUFillText(&VersionT[1], "Time", "", "");
49  IUFillText(&VersionT[2], "Number", "", "");
50  IUFillText(&VersionT[3], "Full", "", "");
51  IUFillText(&VersionT[4], "Name", "", "");
52  IUFillTextVector(&VersionTP, VersionT, 5, getDeviceName(), "Firmware Info", "", FIRMWARE_TAB, IP_RO, 0, IPS_IDLE);
53 
54  // IUFillNumber(&FocusSpeedN[0], "SPEED", "Speed", "%0.f", 0, 4.0, 1.0, 0);
55  // IUFillNumberVector(&FocusSpeedNP, FocusSpeedN, 1, getDeviceName(), "FOCUS_SPEED", "Speed", FOCUS_TAB, IP_RW, 0,
56  // IPS_IDLE);
57 
58  FocusSpeedN[0].min = 1;
59  FocusSpeedN[0].max = 4;
60  FocusSpeedN[0].value = 1;
61 
62  return true;
63 }
64 
65 //void LX200Autostar::ISGetProperties(const char *dev)
66 //{
67 // if (dev != nullptr && strcmp(dev, getDeviceName()) != 0)
68 // return;
69 
70 // LX200Generic::ISGetProperties(dev);
71 
72 // /*
73 // if (isConnected())
74 // {
75 // defineProperty(&VersionTP);
76 // defineProperty(&FocusSpeedNP);
77 
78 // // For Autostar, we have a different focus speed method
79 // // Therefore, we don't need the classical one
80 // deleteProperty(FocusModeSP.name);
81 // }
82 // */
83 //}
84 
86 {
88 
89  if (isConnected())
90  {
92  //defineProperty(&FocusSpeedNP);
93 
94  // For Autostar, we have a different focus speed method
95  // Therefore, we don't need the classical one
96  //deleteProperty(FocusModeSP.name);
97  return true;
98  }
99  else
100  {
102  //deleteProperty(FocusSpeedNP.name);
103  return true;
104  }
105 }
106 
107 //bool LX200Autostar::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
108 //{
109 // if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
110 // {
111 // // Focus speed
112 // if (!strcmp(name, FocusSpeedNP.name))
113 // {
114 // if (IUUpdateNumber(&FocusSpeedNP, values, names, n) < 0)
115 // return false;
116 
117 // if (!isSimulation())
118 // setGPSFocuserSpeed(PortFD, ((int)FocusSpeedN[0].value));
119 // FocusSpeedNP.s = IPS_OK;
120 // IDSetNumber(&FocusSpeedNP, nullptr);
121 // return true;
122 // }
123 // }
124 
125 // return LX200Generic::ISNewNumber(dev, name, values, names, n);
126 //}
127 
128 //bool LX200Autostar::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
129 //{
130 // int index = 0;
131 
132 // if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
133 // {
134 // // Focus Motion
135 // if (!strcmp(name, FocusMotionSP.name))
136 // {
137 // // If speed is "halt"
138 // if (FocusSpeedN[0].value == 0)
139 // {
140 // FocusMotionSP.s = IPS_IDLE;
141 // IDSetSwitch(&FocusMotionSP, nullptr);
142 // return false;
143 // }
144 
145 // int last_motion = IUFindOnSwitchIndex(&FocusMotionSP);
146 
147 // if (IUUpdateSwitch(&FocusMotionSP, states, names, n) < 0)
148 // return false;
149 
150 // index = IUFindOnSwitchIndex(&FocusMotionSP);
151 
152 // // If same direction and we're busy, stop
153 // if (last_motion == index && FocusMotionSP.s == IPS_BUSY)
154 // {
155 // IUResetSwitch(&FocusMotionSP);
156 // FocusMotionSP.s = IPS_IDLE;
157 // setFocuserSpeedMode(PortFD, 0);
158 // IDSetSwitch(&FocusMotionSP, nullptr);
159 // return true;
160 // }
161 
162 // if (!isSimulation() && setFocuserMotion(PortFD, index) < 0)
163 // {
164 // FocusMotionSP.s = IPS_ALERT;
165 // IDSetSwitch(&FocusMotionSP, "Error setting focuser speed.");
166 // return false;
167 // }
168 
169 // FocusMotionSP.s = IPS_BUSY;
170 
171 // // with a timer
172 // if (FocusTimerNP.np[0].value > 0)
173 // {
174 // FocusTimerNP.s = IPS_BUSY;
175 // if (isDebug())
176 // IDLog("Starting Focus Timer BUSY\n");
177 
178 // IEAddTimer(50, LX200Generic::updateFocusHelper, this);
179 // }
180 
181 // IDSetSwitch(&FocusMotionSP, nullptr);
182 // return true;
183 // }
184 // }
185 
186 // return LX200Generic::ISNewSwitch(dev, name, states, names, n);
187 //}
188 
190 {
191  return (setGPSFocuserSpeed(PortFD, speed) == 0);
192 }
193 
195 {
196  // process parent
198 
199  if (!isSimulation())
200  {
201  VersionTP.tp[0].text = new char[64];
202  getVersionDate(PortFD, VersionTP.tp[0].text);
203  VersionTP.tp[1].text = new char[64];
204  getVersionTime(PortFD, VersionTP.tp[1].text);
205  VersionTP.tp[2].text = new char[64];
207  VersionTP.tp[3].text = new char[128];
208  getFullVersion(PortFD, VersionTP.tp[3].text);
209  VersionTP.tp[4].text = new char[128];
210  getProductName(PortFD, VersionTP.tp[4].text);
211 
212  IDSetText(&VersionTP, nullptr);
213  }
214 }
bool isConnected() const
Definition: basedevice.cpp:520
const char * getDeviceName() const
Definition: basedevice.cpp:821
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
bool isSimulation() const
virtual void getBasicData() override
IText VersionT[5]
Definition: lx200autostar.h:43
virtual bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
const char * getDefaultName() override
ITextVectorProperty VersionTP
Definition: lx200autostar.h:42
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual void getBasicData()
@ IP_RO
Definition: indiapi.h:184
@ IPS_IDLE
Definition: indiapi.h:161
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidevapi.c:291
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
Definition: indidevapi.c:198
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
Definition: indidriver.c:1191
#define FIRMWARE_TAB
int setGPSFocuserSpeed(int fd, int speed)
#define getVersionDate(fd, x)
Definition: lx200driver.h:129
#define getVersionTime(fd, x)
Definition: lx200driver.h:130
#define getVersionNumber(fd, x)
Definition: lx200driver.h:132
#define getProductName(fd, x)
Definition: lx200driver.h:133
#define getFullVersion(fd, x)
Definition: lx200driver.h:131
char name[MAXINDINAME]
Definition: indiapi.h:250