| 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 | 
|---|
| 27 | bit 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 |  | 
|---|
| 75 | int openPort(const char *portID); | 
|---|
| 76 | int portRead(char *buf, int nbytes, int timeout); | 
|---|
| 77 | int portWrite(char * buf); | 
|---|
| 78 | int TemmareadOut(int timeout); | 
|---|
| 79 | static void mountInit(void); | 
|---|
| 80 | void ISGetProperties (const char *dev); | 
|---|
| 81 | void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n); | 
|---|
| 82 | void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n); | 
|---|
| 83 | void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n); | 
|---|
| 84 | double calcLST(char *strlst); | 
|---|
| 85 | int TemmaConnect(const char *device) ; | 
|---|
| 86 | int TemmaDisconnect(void) ; | 
|---|
| 87 | int  set_CometTracking(int RArate, int DECrate); | 
|---|
| 88 | int TemmaabortSlew(void) ; | 
|---|
| 89 | int do_TemmaGOTO(void) ; | 
|---|
| 90 | int extractRA(char *buf); | 
|---|
| 91 | int extractDEC(char *buf); | 
|---|
| 92 | int get_TemmaCurrentpos(char *buffer); | 
|---|
| 93 | int set_TemmaCurrentpos(void) ; | 
|---|
| 94 | int do_TemmaSLEW(char mode); | 
|---|
| 95 | int get_TemmaVERSION(char *buffer); | 
|---|
| 96 | int get_TemmaGOTOstatus(char *buffer); | 
|---|
| 97 | int get_TemmaBOTHcorrspeed(char *buffer); | 
|---|
| 98 | int get_TemmaDECcorrspeed(char *buffer); | 
|---|
| 99 | int set_TemmaDECcorrspeed(char *buffer); | 
|---|
| 100 | int get_TemmaRAcorrspeed(char *buffer); | 
|---|
| 101 | int set_TemmaRAcorrspeed(char *buffer); | 
|---|
| 102 | int get_TemmaLatitude(char *buffer); | 
|---|
| 103 | int set_TemmaLatitude(char *buffer); | 
|---|
| 104 | int get_TemmaLST(char *buffer); | 
|---|
| 105 | int set_TemmaLST(char *buffer); | 
|---|
| 106 | int  set_TemmaStandbyState(int on); | 
|---|
| 107 | int  get_TemmaStandbyState(unsigned char *buffer); | 
|---|
| 108 | int  get_TemmaCometTracking(char *buffer); | 
|---|
| 109 | int  set_TemmaCometTracking(char *buffer); | 
|---|
| 110 | int  set_TemmaSolarRate(void); | 
|---|
| 111 | int  set_TemmaStellarRate(void); | 
|---|
| 112 | int  switch_Temmamountside(void); | 
|---|
| 113 |  | 
|---|
| 114 | static void disconnectMount (void); | 
|---|
| 115 | static void connectMount (void); | 
|---|
| 116 | static void readMountcurrentpos (void *); | 
|---|
| 117 |  | 
|---|
| 118 | /***************************/ | 
|---|
| 119 | /* RA motor control switch */ | 
|---|
| 120 | /***************************/ | 
|---|
| 121 | static ISwitch RAmotor[] = { | 
|---|
| 122 | {"RUN", "On", ISS_OFF, 0, 0}, | 
|---|
| 123 | {"STOP", "Off", ISS_ON, 0, 0} }; | 
|---|
| 124 |  | 
|---|
| 125 | static 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 | /*****************************/ | 
|---|
| 132 | static ISwitch trackmode[] = { | 
|---|
| 133 | {"Sidereal", "Sidereal", ISS_ON, 0, 0}, | 
|---|
| 134 | {"Lunar", "Lunar", ISS_OFF, 0, 0}, | 
|---|
| 135 | {"Comet", "Comet", ISS_OFF, 0, 0}, }; | 
|---|
| 136 |  | 
|---|
| 137 | static 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 | /*****************************/ | 
|---|
| 144 | static ISwitch power[] = { | 
|---|
| 145 | {"CONNECT", "On", ISS_OFF, 0, 0}, {"DISCONNECT", "Off", ISS_ON, 0, 0}, }; | 
|---|
| 146 |  | 
|---|
| 147 | static 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 | /*******************************/ | 
|---|
| 154 | static IText TemmaVersionT[]                    = {{"VERSION", "Version", 0, 0, 0, 0}}; | 
|---|
| 155 | static 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 | /*******************************/ | 
|---|
| 163 | static IText TemmaNoteT[]                       = {{"Note", "", 0, 0, 0, 0}, {"Feedback", "", 0, 0,0 ,0}}; | 
|---|
| 164 | static ITextVectorProperty TemmaNoteTP          = { mydev, "Temma Driver", "", MAIN_GROUP, IP_RO, 0, IPS_OK, TemmaNoteT, NARRAY(TemmaNoteT), "", 0}; | 
|---|
| 165 |  | 
|---|
| 166 | /*******************************/ | 
|---|
| 167 | /* Port names text property */ | 
|---|
| 168 | /*******************************/ | 
|---|
| 169 | static IText PortT[]                    = {{"PORT", "Port", 0, 0, 0, 0}}; | 
|---|
| 170 | static 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 | /*******************************/ | 
|---|
| 177 | static 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 | }; | 
|---|
| 181 | static 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 | /*******************************/ | 
|---|
| 188 | static 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 | }; | 
|---|
| 192 | static 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) */ | 
|---|
| 198 | static 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 |  | 
|---|
| 203 | static 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 */ | 
|---|
| 208 | static INumber UTC[] = { | 
|---|
| 209 | {"UTC", "UTC", "%10.6m" , 0.,0.,0.,0., 0, 0, 0}}; | 
|---|
| 210 | INumberVectorProperty Time = { | 
|---|
| 211 | mydev, "TIME_UTC", "UTC Time", DATETIME_GROUP, | 
|---|
| 212 | IP_RW, 0, IPS_IDLE, UTC, NARRAY(UTC), "", 0}; | 
|---|
| 213 |  | 
|---|
| 214 | static INumber STime[] = { | 
|---|
| 215 | {"LST", "Sidereal time", "%10.6m" , | 
|---|
| 216 | 0.,0.,0.,0., 0, 0, 0}}; | 
|---|
| 217 |  | 
|---|
| 218 | INumberVectorProperty SDTime = { | 
|---|
| 219 | mydev, "TIME_LST", "Sidereal Time", | 
|---|
| 220 | DATETIME_GROUP, IP_RW, 0, IPS_IDLE, | 
|---|
| 221 | STime, NARRAY(STime), "", 0}; | 
|---|
| 222 |  | 
|---|
| 223 | static ISwitch OnCoordSetS[] = { | 
|---|
| 224 | {"SLEW", "Goto", ISS_OFF, 0, 0 }, | 
|---|
| 225 | {"SYNC", "Sync", ISS_ON, 0 , 0}, | 
|---|
| 226 | {"TRACK", "Track", ISS_OFF, 0, 0 }}; | 
|---|
| 227 |  | 
|---|
| 228 | static 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 |  | 
|---|
| 235 | static ISwitch abortSlewS[] = { | 
|---|
| 236 | {"ABORT", "Abort", ISS_OFF, 0, 0 }}; | 
|---|
| 237 | static 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 */ | 
|---|
| 243 | static 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 |  | 
|---|
| 247 | static INumberVectorProperty geoNum = { | 
|---|
| 248 | mydev, "GEOGRAPHIC_COORD", "Geographic Location", | 
|---|
| 249 | DATETIME_GROUP, IP_RW, 0., IPS_IDLE, | 
|---|
| 250 | geo, NARRAY(geo), "", 0}; | 
|---|
| 251 |  | 
|---|
| 252 | #endif | 
|---|