00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <string.h>
00024
00025 #include "lx200classic.h"
00026 #include "lx200driver.h"
00027
00028 extern LX200Generic *telescope;
00029 extern INumberVectorProperty eqNum;
00030 extern ITextVectorProperty Time;
00031 extern int MaxReticleFlashRate;
00032
00033 #define BASIC_GROUP "Main Control"
00034 #define LIBRARY_GROUP "Library"
00035 #define MOVE_GROUP "Movement Control"
00036
00037 static IText ObjectText[] = {{"objectText", "Info", 0, 0, 0, 0}};
00038 static ITextVectorProperty ObjectInfo = {mydev, "Object Info", "", BASIC_GROUP, IP_RO, 0, IPS_IDLE, ObjectText, NARRAY(ObjectText), "", 0};
00039
00040
00041 static ISwitch StarCatalogS[] = {{"STAR", "", ISS_ON, 0, 0}, {"SAO", "", ISS_OFF, 0, 0}, {"GCVS", "", ISS_OFF, 0, 0}};
00042 static ISwitch DeepSkyCatalogS[] = {{"NGC", "", ISS_ON, 0, 0}, {"IC", "", ISS_OFF, 0, 0}, {"UGC", "", ISS_OFF, 0, 0}, {"Caldwell", "", ISS_OFF, 0, 0}, {"Arp", "", ISS_OFF, 0, 0}, {"Abell", "", ISS_OFF, 0, 0}, {"Messier", "", ISS_OFF, 0, 0}};
00043 static ISwitch SolarS[] = { {"Select", "Select item...", ISS_ON, 0, 0}, {"1", "Mercury", ISS_OFF,0 , 0}, {"2", "Venus", ISS_OFF, 0, 0}, {"3", "Moon", ISS_OFF, 0, 0}, {"4", "Mars", ISS_OFF, 0, 0}, {"5", "Jupiter", ISS_OFF, 0, 0}, {"6", "Saturn", ISS_OFF, 0, 0}, {"7", "Uranus", ISS_OFF, 0, 0}, {"8", "Neptune", ISS_OFF, 0, 0}, {"9", "Pluto", ISS_OFF, 0 ,0}};
00044
00045 static ISwitchVectorProperty StarCatalogSw = { mydev, "Star Catalogs", "", LIBRARY_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE, StarCatalogS, NARRAY(StarCatalogS), "", 0};
00046 static ISwitchVectorProperty DeepSkyCatalogSw= { mydev, "Deep Sky Catalogs", "", LIBRARY_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE, DeepSkyCatalogS, NARRAY(DeepSkyCatalogS), "", 0};
00047 static ISwitchVectorProperty SolarSw = { mydev, "SOLAR_SYSTEM", "Solar System", LIBRARY_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE, SolarS, NARRAY(SolarS), "", 0};
00048
00049 static INumber ObjectN[] = { "ObjectN", "Number", "%g", 1., 10000., 1., 0., 0, 0, 0};
00050 static INumberVectorProperty ObjectNo= { mydev, "Object Number", "", LIBRARY_GROUP, IP_RW, 0, IPS_IDLE, ObjectN, NARRAY(ObjectN), "", 0 };
00051
00052 static INumber MaxSlew[] = {{"maxSlew", "Rate", "%g", 2.0, 9.0, 1.0, 9., 0, 0 ,0}};
00053 static INumberVectorProperty MaxSlewRate = { mydev, "Max slew Rate", "", MOVE_GROUP, IP_RW, 0, IPS_IDLE, MaxSlew, NARRAY(MaxSlew), "", 0};
00054
00055 static INumber altLimit[] = {
00056 {"minAlt", "min Alt", "%+03f", -90., 90., 0., 0., 0, 0, 0},
00057 {"maxAlt", "max Alt", "%+03f", -90., 90., 0., 0., 0, 0, 0}};
00058 static INumberVectorProperty elevationLimit = { mydev, "altLimit", "Slew elevation Limit", BASIC_GROUP, IP_RW, 0, IPS_IDLE, altLimit, NARRAY(altLimit), "", 0};
00059
00060 void changeLX200ClassicDeviceName(const char *newName)
00061 {
00062 strcpy(ObjectInfo.device, newName);
00063 strcpy(SolarSw.device, newName);
00064 strcpy(StarCatalogSw.device, newName);
00065 strcpy(DeepSkyCatalogSw.device, newName);
00066 strcpy(ObjectNo.device, newName);
00067 strcpy(MaxSlewRate.device , newName );
00068 strcpy(elevationLimit.device , newName );
00069 }
00070
00071 LX200Classic::LX200Classic() : LX200Generic()
00072 {
00073 ObjectInfo.tp[0].text = new char[128];
00074 strcpy(ObjectInfo.tp[0].text, "");
00075
00076 currentCatalog = LX200_STAR_C;
00077 currentSubCatalog = 0;
00078
00079 }
00080
00081
00082 void LX200Classic::ISGetProperties (const char *dev)
00083 {
00084
00085 if (dev && strcmp (thisDevice, dev))
00086 return;
00087
00088 LX200Generic::ISGetProperties(dev);
00089
00090 IDDefNumber (&elevationLimit, NULL);
00091 IDDefText (&ObjectInfo, NULL);
00092 IDDefSwitch (&SolarSw, NULL);
00093 IDDefSwitch (&StarCatalogSw, NULL);
00094 IDDefSwitch (&DeepSkyCatalogSw, NULL);
00095 IDDefNumber (&ObjectNo, NULL);
00096 IDDefNumber (&MaxSlewRate, NULL);
00097
00098 }
00099
00100 void LX200Classic::ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
00101 {
00102
00103 if (strcmp (dev, thisDevice))
00104 return;
00105
00106 LX200Generic::ISNewText (dev, name, texts, names, n);
00107 }
00108
00109
00110 void LX200Classic::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
00111 {
00112 int err=0;
00113
00114
00115 if (strcmp (dev, thisDevice))
00116 return;
00117
00118 if ( !strcmp (name, ObjectNo.name) )
00119 {
00120 if (checkPower(&ObjectNo))
00121 return;
00122
00123 selectCatalogObject( currentCatalog, (int) values[0]);
00124
00125 getLX200RA(&eqNum.np[0].value);
00126 getLX200DEC(&eqNum.np[1].value);
00127
00128 ObjectNo.s = eqNum.s = IPS_OK;
00129 IDSetNumber(&ObjectNo , "Object updated");
00130 IDSetNumber(&eqNum, NULL);
00131
00132 if (getObjectInfo(ObjectText[0].text) < 0)
00133 IDMessage(thisDevice, "Getting object info failed.");
00134 else
00135 IDSetText (&ObjectInfo, NULL);
00136
00137 handleCoordSet();
00138
00139 return;
00140 }
00141
00142 if ( !strcmp (name, MaxSlewRate.name) )
00143 {
00144
00145 if (checkPower(&MaxSlewRate))
00146 return;
00147
00148 if ( ( err = setMaxSlewRate( (int) values[0]) < 0) )
00149 {
00150 handleError(&MaxSlewRate, err, "Setting maximum slew rate");
00151 return;
00152 }
00153 MaxSlewRate.s = IPS_OK;
00154 MaxSlewRate.np[0].value = values[0];
00155 IDSetNumber(&MaxSlewRate, NULL);
00156 return;
00157 }
00158
00159
00160
00161 if (!strcmp (name, elevationLimit.name))
00162 {
00163
00164 double minAlt = 0, maxAlt = 0;
00165 int i, nset;
00166
00167 if (checkPower(&elevationLimit))
00168 return;
00169
00170 for (nset = i = 0; i < n; i++)
00171 {
00172 INumber *altp = IUFindNumber (&elevationLimit, names[i]);
00173 if (altp == &altLimit[0])
00174 {
00175 minAlt = values[i];
00176 nset += minAlt >= -90.0 && minAlt <= 90.0;
00177 } else if (altp == &altLimit[1])
00178 {
00179 maxAlt = values[i];
00180 nset += maxAlt >= -90.0 && maxAlt <= 90.0;
00181 }
00182 }
00183 if (nset == 2)
00184 {
00185
00186 if ( ( err = setMinElevationLimit( (int) minAlt) < 0) )
00187 {
00188 handleError(&elevationLimit, err, "Setting elevation limit");
00189 }
00190 setMaxElevationLimit( (int) maxAlt);
00191 elevationLimit.np[0].value = minAlt;
00192 elevationLimit.np[1].value = maxAlt;
00193 elevationLimit.s = IPS_OK;
00194 IDSetNumber (&elevationLimit, NULL);
00195 } else
00196 {
00197 elevationLimit.s = IPS_IDLE;
00198 IDSetNumber(&elevationLimit, "elevation limit missing or invalid");
00199 }
00200
00201 return;
00202 }
00203
00204 LX200Generic::ISNewNumber (dev, name, values, names, n);
00205 }
00206
00207 void LX200Classic::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
00208 {
00209
00210 int index=0;
00211
00212
00213 if (strcmp (dev, thisDevice))
00214 return;
00215
00216
00217 if (!strcmp (name, StarCatalogSw.name))
00218 {
00219 if (checkPower(&StarCatalogSw))
00220 return;
00221
00222 IUResetSwitches(&StarCatalogSw);
00223 IUUpdateSwitches(&StarCatalogSw, states, names, n);
00224 index = getOnSwitch(&StarCatalogSw);
00225
00226 currentCatalog = LX200_STAR_C;
00227
00228 if (selectSubCatalog(currentCatalog, index))
00229 {
00230 currentSubCatalog = index;
00231 StarCatalogSw.s = IPS_OK;
00232 IDSetSwitch(&StarCatalogSw, NULL);
00233 }
00234 else
00235 {
00236 StarCatalogSw.s = IPS_IDLE;
00237 IDSetSwitch(&StarCatalogSw, "Catalog unavailable");
00238 }
00239 return;
00240 }
00241
00242
00243 if (!strcmp (name, DeepSkyCatalogSw.name))
00244 {
00245 if (checkPower(&DeepSkyCatalogSw))
00246 return;
00247
00248 IUResetSwitches(&DeepSkyCatalogSw);
00249 IUUpdateSwitches(&DeepSkyCatalogSw, states, names, n);
00250 index = getOnSwitch(&DeepSkyCatalogSw);
00251
00252 if (index == LX200_MESSIER_C)
00253 {
00254 currentCatalog = index;
00255 DeepSkyCatalogSw.s = IPS_OK;
00256 IDSetSwitch(&DeepSkyCatalogSw, NULL);
00257 return;
00258 }
00259 else
00260 currentCatalog = LX200_DEEPSKY_C;
00261
00262 if (selectSubCatalog(currentCatalog, index))
00263 {
00264 currentSubCatalog = index;
00265 DeepSkyCatalogSw.s = IPS_OK;
00266 IDSetSwitch(&DeepSkyCatalogSw, NULL);
00267 }
00268 else
00269 {
00270 DeepSkyCatalogSw.s = IPS_IDLE;
00271 IDSetSwitch(&DeepSkyCatalogSw, "Catalog unavailable");
00272 }
00273 return;
00274 }
00275
00276
00277 if (!strcmp (name, SolarSw.name))
00278 {
00279
00280 if (checkPower(&SolarSw))
00281 return;
00282
00283 IUResetSwitches(&SolarSw);
00284 IUUpdateSwitches(&SolarSw, states, names, n);
00285 index = getOnSwitch(&SolarSw);
00286
00287
00288 if (index == 0)
00289 {
00290 SolarSw.s = IPS_IDLE;
00291 IDSetSwitch(&SolarSw, NULL);
00292 return;
00293 }
00294
00295 selectSubCatalog ( LX200_STAR_C, LX200_STAR);
00296 selectCatalogObject( LX200_STAR_C, index + 900);
00297
00298 ObjectNo.s = IPS_OK;
00299 SolarSw.s = IPS_OK;
00300
00301 getObjectInfo(ObjectInfo.tp[0].text);
00302 IDSetNumber(&ObjectNo , "Object updated.");
00303 IDSetSwitch(&SolarSw, NULL);
00304
00305 if (currentCatalog == LX200_STAR_C || currentCatalog == LX200_DEEPSKY_C)
00306 selectSubCatalog( currentCatalog, currentSubCatalog);
00307
00308 getObjectRA(&targetRA);
00309 getObjectDEC(&targetDEC);
00310
00311 handleCoordSet();
00312
00313 return;
00314 }
00315
00316 LX200Generic::ISNewSwitch (dev, name, states, names, n);
00317
00318 }
00319
00320 void LX200Classic::ISPoll ()
00321 {
00322
00323 LX200Generic::ISPoll();
00324
00325 }
00326
00327 void LX200Classic::getBasicData()
00328 {
00329
00330
00331 LX200Generic::getBasicData();
00332
00333 }