lx200v24-h -------------------------------------------------------------------------------------- #ifndef HERKULES_H #define HERKULES_H #pragma once #include #include #include #include #include #include #include #define LX200_TIMEOUT 5 /* FD timeout in seconds */ #define RB_MAX_LEN 64 #define TCS_TIMEOUT 1 /* 50ms? */ #define TCS_COMMAND_BUFFER_LENGTH 32 #define TCS_RESPONSE_BUFFER_LENGTH 32 enum TDirection { LX200_NORTH, LX200_WEST, LX200_EAST, LX200_SOUTH, LX200_ALL }; enum TSlew { LX200_SLEW_MAX, LX200_SLEW_FIND, LX200_SLEW_CENTER, LX200_SLEW_GUIDE }; enum TFormat { LX200_SHORT_FORMAT, LX200_LONG_FORMAT, LX200_LONGER_FORMAT }; // Herkules specific tabs extern const char *INFO_TAB; class LX200Herkules : public LX200Telescope { public: enum TrackMode { TRACK_SIDEREAL = 0, //=Telescope::TelescopeTrackMode::TRACK_SIDEREAL, TRACK_SOLAR = 1, //=Telescope::TelescopeTrackMode::TRACK_SOLAR, TRACK_LUNAR = 2, //=Telescope::TelescopeTrackMode::TRACK_LUNAR, TRACK_NONE = 3 }; enum MotorsState { MOTORS_OFF = 0, MOTORS_DEC_ONLY = 1, MOTORS_RA_ONLY = 2, MOTORS_ON = 3 }; TrackMode CurrentTrackMode {TRACK_SIDEREAL}; MotorsState CurrentMotorsState {MOTORS_OFF}; TelescopeSlewRate CurrentSlewRate {SLEW_MAX}; LX200Herkules(); virtual const char *getDefaultName() override; virtual bool Handshake() override; virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override; virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override; virtual bool updateProperties() override; virtual bool initProperties() override; virtual void ISGetProperties(const char *dev)override; // helper functions virtual bool receive(char* buffer, int* bytes, int wait = TCS_TIMEOUT); virtual bool receive(char* buffer, int* bytes, char end, int wait = TCS_TIMEOUT); virtual void flush(); virtual bool transmit(const char* buffer); virtual bool SetTrackMode(uint8_t mode) override; protected: // parking position ISwitchVectorProperty MountSetParkSP; ISwitch MountSetParkS[1]; // Speed definitions INumber SystemSlewSpeedP[1]; INumberVectorProperty SystemSlewSpeedNP; int controller_format { LX200_LONG_FORMAT }; // override LX200Generic virtual void getBasicData() override; virtual bool ReadScopeStatus() override; virtual bool Park() override; virtual void SetParked(bool isparked); virtual bool UnPark() override; virtual bool saveConfigItems(FILE *fp) override; virtual bool Goto(double ra, double dec) override; virtual bool Connect() override; virtual bool Disconnect() override; // Herkules stuff bool setParkPosition(ISState *states, char *names[], int n); bool getSystemSlewSpeed (int *xx); bool setSystemSlewSpeed (int xx); // scope status virtual bool ParseMotionState(char* state); // location virtual bool sendScopeLocation(); double LocalSiderealTime(double longitude); bool setLocalSiderealTime(double longitude); virtual bool updateLocation(double latitude, double longitude, double elevation) override; virtual bool getSiteLatitude(double *siteLat); virtual bool getSiteLongitude(double *siteLong); virtual bool getLST_String(char* input); bool getTrackFrequency(double *value); virtual bool getEqCoordinates(double *ra, double *dec); // queries to the scope interface. Wait for specified end character virtual bool sendQuery(const char* cmd, char* response, char end, int wait = TCS_TIMEOUT); // Wait for default "#' character virtual bool sendQuery(const char* cmd, char* response, int wait = TCS_TIMEOUT); virtual bool getFirmwareInfo(); virtual bool setSiteLatitude(double Lat); virtual bool setSiteLongitude(double Long); virtual bool getScopeAlignmentStatus(); virtual bool getMotorStatus(int *xSpeed, int *ySpeed); virtual bool getParkHomeStatus (char* status); virtual bool setMountGotoHome(); virtual bool setMountParkPosition(); // meridian flip virtual bool syncSideOfPier(); bool checkLX200Format(); // Guide Commands virtual IPState GuideNorth(uint32_t ms) override; virtual IPState GuideSouth(uint32_t ms) override; virtual IPState GuideEast(uint32_t ms) override; virtual IPState GuideWest(uint32_t ms) override; virtual bool SetSlewRate(int index) override; virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec) override; virtual bool SetTrackEnabled(bool enabled) override; virtual bool SetTrackRate(double raRate, double deRate) override; // NSWE Motion Commands virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override; virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override; virtual bool Sync(double ra, double dec) override; bool setObjectCoords(double ra, double dec); virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override; virtual bool setLocalTime24(uint8_t hour, uint8_t minute, uint8_t second) override; virtual bool setUTCOffset(double offset) override; virtual bool getLocalTime(char *timeString) override; virtual bool getLocalDate(char *dateString) override; virtual bool getUTFOffset(double *offset) override; // Abort ALL motion virtual bool Abort() override; int MoveTo(int direction); bool setSlewMode(int slewMode); }; inline bool LX200Herkules::sendQuery(const char* cmd, char* response, int wait) { return sendQuery(cmd, response, '#', wait); } inline bool LX200Herkules::receive(char* buffer, int* bytes, int wait) { return receive(buffer, bytes, '#', wait); } #endif // Herkules_V24 ------------------------------------------------------------------------------------- lx200v24.cpp ------------------------------------------------------------------------------------- #include "lx200v24.h" #include #include #include #include #ifndef _WIN32 #include #endif #include #include #include "config.h" // Unique pointers static std::unique_ptr telescope; const char *INFO_TAB = "TCS"; void ISInit() { static int isInit = 0; if (isInit) return; isInit = 1; if (telescope.get() == nullptr) { LX200Herkules* myScope = new LX200Herkules(); telescope.reset(myScope); } } void ISGetProperties(const char *dev) { ISInit(); telescope->ISGetProperties(dev); } void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) { ISInit(); telescope->ISNewSwitch(dev, name, states, names, n); } void ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) { ISInit(); telescope->ISNewText(dev, name, texts, names, n); } void ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) { ISInit(); telescope->ISNewNumber(dev, name, values, names, n); } void ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) { INDI_UNUSED(dev); INDI_UNUSED(name); INDI_UNUSED(sizes); INDI_UNUSED(blobsizes); INDI_UNUSED(blobs); INDI_UNUSED(formats); INDI_UNUSED(names); INDI_UNUSED(n); } void ISSnoopDevice(XMLEle *root) { //ISInit(); telescope->ISSnoopDevice(root); // focuser->ISSnoopDevice(root); } /************************************************** *** LX200 Generic Implementation / Constructor ***************************************************/ LX200Herkules::LX200Herkules() { LOG_DEBUG(__FUNCTION__); setVersion(HERKULES_VERSION_MAJOR, HERKULES_VERSION_MINOR); DBG_SCOPE = INDI::Logger::DBG_DEBUG; /* TCS has no location and no time * TELESCOPE_HAS_TIME * TELESCOPE_HAS_LOCATION * * TCS has * Pulseguiding? * Alignmenttype? */ setLX200Capability(LX200_HAS_PULSE_GUIDING ); SetTelescopeCapability(TELESCOPE_CAN_PARK | TELESCOPE_CAN_SYNC | TELESCOPE_CAN_GOTO | TELESCOPE_CAN_ABORT | TELESCOPE_HAS_TRACK_MODE | TELESCOPE_CAN_CONTROL_TRACK | TELESCOPE_HAS_PIER_SIDE, 4); } ... and so on .... ---------------------------------------------------------------------------------------