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 #include <unistd.h>
00025
00026 #include "lx200autostar.h"
00027 #include "lx200driver.h"
00028
00029 #define FirmwareGroup "Firmware data"
00030
00031
00032 extern LX200Generic *telescope;
00033 extern int MaxReticleFlashRate;
00034 extern ITextVectorProperty Time;
00035 extern INumberVectorProperty SDTime;
00036 extern INumberVectorProperty eqNum;
00037 extern ISwitchVectorProperty ParkSP;
00038 extern ISwitchVectorProperty PowerSP;
00039
00040 static IText VersionT[] ={{ "Date", "", 0, 0, 0, 0} ,
00041 { "Time", "", 0, 0, 0, 0} ,
00042 { "Number", "", 0, 0, 0 ,0} ,
00043 { "Full", "", 0, 0, 0, 0} ,
00044 { "Name", "" ,0 ,0 ,0 ,0}};
00045
00046 static ITextVectorProperty VersionInfo = {mydev, "Firmware Info", "", FirmwareGroup, IP_RO, 0, IPS_IDLE, VersionT, NARRAY(VersionT), "" ,0};
00047
00048 void changeLX200AutostarDeviceName(const char *newName)
00049 {
00050 strcpy(VersionInfo.device, newName);
00051 }
00052
00053 LX200Autostar::LX200Autostar() : LX200Generic()
00054 {
00055
00056
00057
00058
00059 }
00060
00061
00062 void LX200Autostar::ISGetProperties (const char *dev)
00063 {
00064
00065 if (dev && strcmp (thisDevice, dev))
00066 return;
00067
00068 LX200Generic::ISGetProperties(dev);
00069
00070 IDDefText (&VersionInfo, NULL);
00071
00072 }
00073
00074 void LX200Autostar::ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
00075 {
00076
00077 if (strcmp (dev, thisDevice))
00078 return;
00079
00080
00081 n=n;
00082
00083 LX200Generic::ISNewText (dev, name, texts, names, n);
00084
00085 }
00086
00087
00088 void LX200Autostar::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
00089 {
00090 LX200Generic::ISNewNumber (dev, name, values, names, n);
00091 }
00092
00093 void LX200Autostar::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
00094 {
00095
00096 if (!strcmp(name, ParkSP.name))
00097 {
00098 if (checkPower(&ParkSP))
00099 return;
00100
00101 ParkSP.s = IPS_IDLE;
00102
00103 if (eqNum.s == IPS_BUSY)
00104 {
00105 abortSlew();
00106
00107
00108 usleep(200000);
00109 }
00110
00111 slewToPark();
00112
00113 ParkSP.s = IPS_OK;
00114 eqNum.s = IPS_IDLE;
00115 PowerSP.s = IPS_IDLE;
00116 PowerSP.sp[0].s = ISS_OFF;
00117 PowerSP.sp[1].s = ISS_ON;
00118 IDSetNumber(&eqNum, NULL);
00119 IDSetSwitch(&ParkSP, "The telescope is slewing to park position. Turn off the telescope after park is complete. Disconnecting...");
00120 IDSetSwitch(&PowerSP, NULL);
00121 return;
00122 }
00123
00124 LX200Generic::ISNewSwitch (dev, name, states, names, n);
00125
00126 }
00127
00128 void LX200Autostar::ISPoll ()
00129 {
00130
00131 LX200Generic::ISPoll();
00132
00133 }
00134
00135 void LX200Autostar::getBasicData()
00136 {
00137
00138 VersionInfo.tp[0].text = new char[64];
00139 getVersionDate(VersionInfo.tp[0].text);
00140 VersionInfo.tp[1].text = new char[64];
00141 getVersionTime(VersionInfo.tp[1].text);
00142 VersionInfo.tp[2].text = new char[64];
00143 getVersionNumber(VersionInfo.tp[2].text);
00144 VersionInfo.tp[3].text = new char[128];
00145 getFullVersion(VersionInfo.tp[3].text);
00146 VersionInfo.tp[4].text = new char[128];
00147 getProductName(VersionInfo.tp[4].text);
00148
00149 IDSetText(&VersionInfo, NULL);
00150
00151
00152 LX200Generic::getBasicData();
00153
00154 }