source: BAORadio/libindi/v1.0.1/drivers/telescope/temmadriver.h @ 620

Last change on this file since 620 was 490, checked in by campagne, 14 years ago

import libindi (JEC)

File size: 9.0 KB
Line 
1/*
2        Temma INDI driver
3        Copyright (C) 2004 Francois Meyer (dulle @ free.fr)
4        Remi Petitdemange for the temma protocol
5  Reference site is http://dulle.free.fr/alidade/indi.php
6
7        This library is free software; you can redistribute it and/or
8        modify it under the terms of the GNU Lesser General Public
9        License as published by the Free Software Foundation; either
10        version 2.1 of the License, or (at your option) any later version.
11
12        This library is distributed in the hope that it will be useful,
13        but WITHOUT ANY WARRANTY; without even the implied warranty of
14        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15        Lesser General Public License for more details.
16
17        You should have received a copy of the GNU Lesser General Public
18        License along with this library; if not, write to the Free Software
19        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 */
22
23#ifndef TEMMADRIVER_H
24#define TEMMADRIVER_H
25#define VERSION "Temma indi driver Ver 0.0, fm-2004/10/09"
26#if 0
27bit definition for M message : slew speed and parameters
28#endif
29#define HS 0x01   /* high speed */
30#define RR 0x02         /* RA right */
31#define RL 0x04         /* RA left */
32#define DU 0x08         /* DEC up */
33#define DD 0x10   /* DEC down */
34#define EN 0x20         /* ENC on */
35#define BB 0x40         /* Always set */
36#if 0
37(HS|RR|EN|BB)
38#endif
39#define HRAD    (M_PI/12)
40#define DEGRAD  (M_PI/180)
41#define TEMMA_TIMEOUT   1               /* FD timeout in seconds */
42
43        /* error codes */
44#define SUCCESS (2) /* return value for successful read */
45#define ETIMEOUT (-2)   /* timeout */
46#define EREAD (-3)                       /* error reading from port */ 
47#define EWRITE (-4)              /* error writing to port */
48#define ECOMMAND (-5) /* unexpected answer */
49        /* Definitions */
50
51#define mydev    "Temma"        /* Device name */
52#define MAIN_GROUP "Main Control"       /* Group name */
53#define COMM_GROUP "Communication"      /* Group name */
54#define MOVE_GROUP      "Movement Control"
55#define DATETIME_GROUP  "Date/Time/Location"
56
57#define SLEWSW  OnCoordSetS[0].s
58#define SYNCSW  OnCoordSetS[1].s
59#define TRACKSW OnCoordSetS[2].s
60#define POWSW   (power[0].s==ISS_ON)
61
62#define SLEWRATE 1                      /* slew rate, degrees/s */
63#define POLLMS   1000           /* poll period, ms */
64
65#define         latitude        geo[0].value    /* scope's current rads. */
66#define         longitude       geo[1].value    /* scope's current rads. */
67#define         currentUTC      UTC[0].value    /* scope's current rads. */
68#define         currentLST      STime[0].value  /* scope's current rads. */
69#define         currentRA       eq[0].value     /* scope's current RA, rads. */
70#define         currentDec      eq[1].value     /* scope's current Dec, rads. */
71#define         temmaRA eqtem[0].value  /* scope's current RA, rads. */
72#define         temmaDec        eqtem[1].value  /* scope's current Dec, rads. */
73
74
75int openPort(const char *portID);
76int portRead(char *buf, int nbytes, int timeout);
77int portWrite(char * buf);
78int TemmareadOut(int timeout);
79static void mountInit(void);
80void ISGetProperties (const char *dev);
81void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
82void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
83void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
84double calcLST(char *strlst);
85int TemmaConnect(const char *device) ;
86int TemmaDisconnect(void) ;
87int  set_CometTracking(int RArate, int DECrate);
88int TemmaabortSlew(void) ;
89int do_TemmaGOTO(void) ;
90int extractRA(char *buf);
91int extractDEC(char *buf);
92int get_TemmaCurrentpos(char *buffer);
93int set_TemmaCurrentpos(void) ;
94int do_TemmaSLEW(char mode);
95int get_TemmaVERSION(char *buffer);
96int get_TemmaGOTOstatus(char *buffer);
97int get_TemmaBOTHcorrspeed(char *buffer);
98int get_TemmaDECcorrspeed(char *buffer);
99int set_TemmaDECcorrspeed(char *buffer);
100int get_TemmaRAcorrspeed(char *buffer);
101int set_TemmaRAcorrspeed(char *buffer);
102int get_TemmaLatitude(char *buffer);
103int set_TemmaLatitude(char *buffer);
104int get_TemmaLST(char *buffer);
105int set_TemmaLST(char *buffer);
106int  set_TemmaStandbyState(int on);
107int  get_TemmaStandbyState(unsigned char *buffer);
108int  get_TemmaCometTracking(char *buffer);
109int  set_TemmaCometTracking(char *buffer);
110int  set_TemmaSolarRate(void);
111int  set_TemmaStellarRate(void);
112int  switch_Temmamountside(void);
113
114static void disconnectMount (void);
115static void connectMount (void);
116static void readMountcurrentpos (void *);
117
118/***************************/
119/* RA motor control switch */
120/***************************/
121static ISwitch RAmotor[] = {
122        {"RUN", "On", ISS_OFF, 0, 0}, 
123        {"STOP", "Off", ISS_ON, 0, 0} };
124
125static ISwitchVectorProperty RAmotorSw = { 
126        mydev, "RA motor", "RA motor", MOVE_GROUP, IP_RW, ISR_ATMOST1, 
127        0, IPS_IDLE, RAmotor, NARRAY(RAmotor), "", 0};
128
129/*****************************/
130/* Track mode control switch */
131/*****************************/
132static ISwitch trackmode[] = {
133        {"Sidereal", "Sidereal", ISS_ON, 0, 0}, 
134        {"Lunar", "Lunar", ISS_OFF, 0, 0}, 
135        {"Comet", "Comet", ISS_OFF, 0, 0}, };
136
137static ISwitchVectorProperty trackmodeSw = { 
138        mydev, "Tracking mode", "Tracking mode", MOVE_GROUP, IP_RW, ISR_1OFMANY, 
139        0, IPS_IDLE, trackmode, NARRAY(trackmode), "", 0};
140
141/*****************************/
142/* Power control switch                  */
143/*****************************/
144static ISwitch power[] = {
145        {"CONNECT", "On", ISS_OFF, 0, 0}, {"DISCONNECT", "Off", ISS_ON, 0, 0}, };
146
147static ISwitchVectorProperty powSw = { 
148        mydev, "CONNECTION", "Connection", MAIN_GROUP, IP_RW, ISR_ATMOST1, 
149        0, IPS_IDLE, power, NARRAY(power), "", 0};
150
151/*******************************/
152/* Temma version text property */
153/*******************************/
154static IText TemmaVersionT[]                    = {{"VERSION", "Version", 0, 0, 0, 0}};
155static ITextVectorProperty TemmaVersion         = { 
156        mydev, "VERSION", "Temma version", COMM_GROUP, IP_RO, 0,
157        IPS_OK, TemmaVersionT, NARRAY(TemmaVersionT), "", 0};
158
159
160/*******************************/
161/* Driver notes text property */
162/*******************************/
163static IText TemmaNoteT[]                       = {{"Note", "", 0, 0, 0, 0}, {"Feedback", "", 0, 0,0 ,0}};
164static ITextVectorProperty TemmaNoteTP          = { mydev, "Temma Driver", "", MAIN_GROUP, IP_RO, 0, IPS_OK, TemmaNoteT, NARRAY(TemmaNoteT), "", 0};
165               
166/*******************************/
167/* Port names text property */
168/*******************************/
169static IText PortT[]                    = {{"PORT", "Port", 0, 0, 0, 0}};
170static ITextVectorProperty Port         = { 
171        mydev, "DEVICE_PORT", "Ports", COMM_GROUP, 
172        IP_RW, 0, IPS_OK, PortT, NARRAY(PortT), "", 0};
173
174/*******************************/
175/* EQUATORIAL_COORD RW property */
176/*******************************/
177static INumber eq[] = {
178        {"RA"           ,"RA H:M:S" , "%10.6m", 0, 24, 0, 0, 0, 0, 0}, 
179        {"DEC", "Dec D:M:S", "%10.6m", -90, 90, 0, 0, 0, 0, 0}
180};
181static INumberVectorProperty eqNum = { 
182        mydev, "EQUATORIAL_EOD_COORD", "Equatorial JNow", 
183        MAIN_GROUP , IP_RW, 0, IPS_IDLE, eq, NARRAY(eq), "", 0};
184
185/*******************************/
186/* MOUNT_COORD RO property */
187/*******************************/
188static INumber eqtem[] = {
189  {"RA", "RA H:M:S", "%10.6m", 0, 24, 0, 0, 0, 0, 0},
190  {"DEC", "Dec D:M:S", "%10.6m", -90, 90, 0, 0, 0, 0, 0}
191};
192static INumberVectorProperty eqTemma = { 
193        mydev, "Temma", "Mount coordinates", 
194        MAIN_GROUP , IP_RO, 0, IPS_IDLE, eqtem, NARRAY(eqtem), "", 0};
195
196
197/* Traccking correction parameters (i.e. to track comets) */
198static INumber comet[] = {
199        {"RAcorrspeed","Comet RA motion arcmin/day","%+5d",-21541,21541,0,0,0,0,0},     
200        {"DECcor rspeed", "Comet DEC motion arcmin/day", "%+4d", -600, 600,0, 0., 0, 0, 0}
201};
202
203static INumberVectorProperty cometNum = { 
204        mydev, "COMET_TRACKING", "Comet tracking parameters", 
205        MOVE_GROUP, IP_RW, 0, IPS_IDLE, comet, NARRAY(comet), "", 0};
206
207/* Date & Time */
208static INumber UTC[] = {
209        {"UTC", "UTC", "%10.6m" , 0.,0.,0.,0., 0, 0, 0}};
210INumberVectorProperty Time = { 
211        mydev, "TIME_UTC", "UTC Time", DATETIME_GROUP, 
212        IP_RW, 0, IPS_IDLE, UTC, NARRAY(UTC), "", 0};
213
214static INumber STime[] = {
215        {"LST", "Sidereal time", "%10.6m" , 
216                0.,0.,0.,0., 0, 0, 0}};
217
218INumberVectorProperty SDTime = { 
219        mydev, "TIME_LST", "Sidereal Time", 
220        DATETIME_GROUP, IP_RW, 0, IPS_IDLE, 
221        STime, NARRAY(STime), "", 0};
222
223static ISwitch OnCoordSetS[] = {
224        {"SLEW", "Goto", ISS_OFF, 0, 0 }, 
225        {"SYNC", "Sync", ISS_ON, 0 , 0},
226        {"TRACK", "Track", ISS_OFF, 0, 0 }}; 
227
228static ISwitchVectorProperty OnCoordSetSw = { 
229        mydev, "ON_COORD_SET", "On Set", 
230        MAIN_GROUP, IP_RW, ISR_1OFMANY, 0,
231        IPS_IDLE, OnCoordSetS, NARRAY(OnCoordSetS), "", 0};
232
233
234
235static ISwitch abortSlewS[] = {
236        {"ABORT", "Abort", ISS_OFF, 0, 0 }};
237static ISwitchVectorProperty abortSlewSw = { 
238        mydev, "ABORT_MOTION", "******* ABORT GOTO *********",
239        MAIN_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE, 
240        abortSlewS, NARRAY(abortSlewS), "", 0};
241
242/* geographic location */
243static INumber geo[] = {
244        {"LAT", "Lat. D:M:S +N", "%10.6m", -90., 90., 0., 0., 0, 0, 0},
245        {"LONG", "Long. D:M:S +E", "%10.6m", 0., 360., 0., 0., 0, 0, 0} };
246
247static INumberVectorProperty geoNum = {
248        mydev, "GEOGRAPHIC_COORD", "Geographic Location", 
249        DATETIME_GROUP, IP_RW, 0., IPS_IDLE,
250        geo, NARRAY(geo), "", 0};
251
252#endif
Note: See TracBrowser for help on using the repository browser.