TwiceAsNice  2019-02-18
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
SkywatcherAPI Class Referenceabstract

#include <skywatcherAPI.h>

Inheritance diagram for SkywatcherAPI:
Inheritance graph
Collaboration diagram for SkywatcherAPI:
Collaboration graph

Public Types

enum  AXISID { AXIS1 = 0, AXIS2 = 1 }
 
enum  PositiveRotationSense_t { CLOCKWISE, ANTICLOCKWISE }
 
enum  MountType {
  EQ6 = 0x00, HEQ5 = 0x01, EQ5 = 0x02, EQ3 = 0x03,
  GT = 0x80, MF = 0x81, _114GT = 0x82, DOB = 0x90
}
 

Public Member Functions

 SkywatcherAPI ()
 
virtual ~SkywatcherAPI ()=default
 
unsigned long BCDstr2long (std::string &String)
 
unsigned long Highstr2long (std::string &String)
 
bool CheckIfDCMotor ()
 
bool IsVirtuosoMount () const
 Check if the current mount is a Virtuoso (AltAz) More...
 
bool IsMerlinMount () const
 Check if the current mount is a Merlin (AltAz) More...
 
long DegreesPerSecondToClocksTicksPerMicrostep (AXISID Axis, double DegreesPerSecond)
 Convert a slewing rate in degrees per second into the required clock ticks per microstep setting. More...
 
long DegreesToMicrosteps (AXISID Axis, double AngleInDegrees)
 Convert angle in degrees to microsteps. More...
 
bool GetEncoder (AXISID Axis)
 Set the CurrentEncoders status variable to the current encoder value in microsteps for the specified axis. More...
 
bool GetHighSpeedRatio (AXISID Axis)
 Set the HighSpeedRatio status variable to the ratio between high and low speed stepping modes. More...
 
bool GetMicrostepsPerRevolution (AXISID Axis)
 Set the MicrostepsPerRevolution status variable to the number of microsteps for a 360 degree revolution of the axis. More...
 
bool GetMicrostepsPerWormRevolution (AXISID Axis)
 Set the MicrostepsPermWormRevolution status variable to the number of microsteps for a 360 degree revolution of the worm gear. More...
 
bool GetMotorBoardVersion (AXISID Axis)
 
PositiveRotationSense_t GetPositiveRotationDirection (AXISID Axis)
 Returns the rotation direction for a positive step on the designated axis. More...
 
bool GetStatus (AXISID Axis)
 
bool GetStepperClockFrequency (AXISID Axis)
 Set the StepperClockFrequency status variable to fixed PIC timer interrupt frequency (ticks per second). More...
 
bool InitializeMC ()
 
bool InitMount (bool recover)
 Initialize the communication to the mount. More...
 
bool InstantStop (AXISID Axis)
 Bring the axis to an immediate halt. More...
 
void Long2BCDstr (long Number, std::string &String)
 
double MicrostepsToDegrees (AXISID Axis, long Microsteps)
 Convert microsteps to angle in degrees. More...
 
double MicrostepsToRadians (AXISID Axis, long Microsteps)
 Convert microsteps to angle in radians. More...
 
void PrepareForSlewing (AXISID Axis, double Speed)
 
long RadiansPerSecondToClocksTicksPerMicrostep (AXISID Axis, double RadiansPerSecond)
 Convert a slewing rate in radians per second into the required clock ticks per microstep setting. More...
 
long RadiansToMicrosteps (AXISID Axis, double AngleInRadians)
 Convert angle in radians to microsteps. More...
 
bool SetEncoder (AXISID Axis, long Microsteps)
 Set axis encoder to the specified value. More...
 
bool SetGotoTargetOffset (AXISID Axis, long OffsetInMicrosteps)
 Set the goto target offset per the specified axis. More...
 
bool SetMotionMode (AXISID Axis, char Func, char Direction)
 Set the motion mode per the specified axis. More...
 
void SetSerialPort (int port)
 Set the serail port to be usb for mount communication. More...
 
bool SetClockTicksPerMicrostep (AXISID Axis, long ClockTicksPerMicrostep)
 Set the PIC internal divider variable which determines how many clock interrupts have to occur between each microstep. More...
 
bool SetSlewModeDeccelerationRampLength (AXISID Axis, long Microsteps)
 Set the length of the deccelaration ramp for Slew mode. More...
 
bool SetSlewToModeDeccelerationRampLength (AXISID Axis, long Microsteps)
 Set the length of the deccelaration ramp for SlewTo mode. More...
 
bool SetSwitch (bool OnOff)
 Set the camera control switch to the given state. More...
 
void Slew (AXISID Axis, double SpeedInRadiansPerSecond, bool IgnoreSilentMode=true)
 Start the axis slewing at the given rate. More...
 
void SlewTo (AXISID Axis, long OffsetInMicrosteps, bool verbose=true)
 Slew to the given offset and stop. More...
 
bool SlowStop (AXISID Axis)
 Bring the axis to slow stop in the distance specified by SetSlewModeDeccelerationRampLength. More...
 
bool StartMotion (AXISID Axis)
 Start the axis slewing in the prevously selected mode. More...
 
bool TalkWithAxis (AXISID Axis, char Command, std::string &cmdDataStr, std::string &responseStr)
 
bool IsInMotion (AXISID Axis)
 Check if an axis is moving. More...
 

Public Attributes

unsigned long MCVersion { 0 }
 
unsigned long MountCode { 0 }
 
bool IsDCMotor { false }
 
bool SilentSlewMode { true }
 
long MicrostepsPerRevolution [2]
 
long StepperClockFrequency [2]
 
long HighSpeedRatio [2]
 
long MicrostepsPerWormRevolution [2]
 
double RadiansPerMicrostep [2]
 
double MicrostepsPerRadian [2]
 
double DegreesPerMicrostep [2]
 
double MicrostepsPerDegree [2]
 
long LowSpeedGotoMargin [2]
 
long LastSlewToTarget [2]
 
long CurrentEncoders [2]
 Current encoder values (microsteps). More...
 
long PolarisPositionEncoders [2]
 Polaris position (initial) encoder values (microsteps). More...
 
long ZeroPositionEncoders [2]
 Zero position encoder values (microsteps). More...
 
AXISSTATUS AxesStatus [2]
 
double SlewingSpeed [2]
 
INDI::TelescopepChildTelescope { nullptr }
 

Static Public Attributes

static constexpr double SIDEREALRATE { (2 * M_PI / 86164.09065) }
 
static constexpr double MAX_SPEED { 500.0 }
 
static constexpr double LOW_SPEED_MARGIN { 128.0 * SIDEREALRATE }
 

Protected Attributes

unsigned int DBG_SCOPE { 0 }
 

Private Types

enum  TTY_ERROR {
  TTY_OK = 0, TTY_READ_ERROR = -1, TTY_WRITE_ERROR = -2, TTY_SELECT_ERROR = -3,
  TTY_TIME_OUT = -4, TTY_PORT_FAILURE = -5, TTY_PARAM_ERROR = -6, TTY_ERRNO = -7
}
 

Private Member Functions

virtual int skywatcher_tty_read (int fd, char *buf, int nbytes, int timeout, int *nbytes_read)=0
 
virtual int skywatcher_tty_write (int fd, const char *buffer, int nbytes, int *nbytes_written)=0
 

Private Attributes

int MyPortFD { 0 }
 

Member Enumeration Documentation

◆ AXISID

Enumerator
AXIS1 
AXIS2 

◆ MountType

Enumerator
EQ6 
HEQ5 
EQ5 
EQ3 
GT 
MF 
_114GT 
DOB 

◆ PositiveRotationSense_t

Enumerator
CLOCKWISE 
ANTICLOCKWISE 

◆ TTY_ERROR

Enumerator
TTY_OK 
TTY_READ_ERROR 
TTY_WRITE_ERROR 
TTY_SELECT_ERROR 
TTY_TIME_OUT 
TTY_PORT_FAILURE 
TTY_PARAM_ERROR 
TTY_ERRNO 

Constructor & Destructor Documentation

◆ SkywatcherAPI()

SkywatcherAPI::SkywatcherAPI ( )

◆ ~SkywatcherAPI()

virtual SkywatcherAPI::~SkywatcherAPI ( )
virtualdefault

Member Function Documentation

◆ BCDstr2long()

unsigned long SkywatcherAPI::BCDstr2long ( std::string &  String)

◆ CheckIfDCMotor()

bool SkywatcherAPI::CheckIfDCMotor ( )

◆ DegreesPerSecondToClocksTicksPerMicrostep()

long SkywatcherAPI::DegreesPerSecondToClocksTicksPerMicrostep ( AXISID  Axis,
double  DegreesPerSecond 
)

Convert a slewing rate in degrees per second into the required clock ticks per microstep setting.

Parameters
[in]Axis- The axis to use.
[in]DegreesPerSecond- Slewing rate in degrees per second
Returns
Clock ticks per microstep for the requested rate

◆ DegreesToMicrosteps()

long SkywatcherAPI::DegreesToMicrosteps ( AXISID  Axis,
double  AngleInDegrees 
)

Convert angle in degrees to microsteps.

Parameters
[in]Axis- The axis to use.
[in]AngleInRadians- the angle in degrees.
Returns
the number of microsteps

◆ GetEncoder()

bool SkywatcherAPI::GetEncoder ( AXISID  Axis)

Set the CurrentEncoders status variable to the current encoder value in microsteps for the specified axis.

Returns
false failure

◆ GetHighSpeedRatio()

bool SkywatcherAPI::GetHighSpeedRatio ( AXISID  Axis)

Set the HighSpeedRatio status variable to the ratio between high and low speed stepping modes.

◆ GetMicrostepsPerRevolution()

bool SkywatcherAPI::GetMicrostepsPerRevolution ( AXISID  Axis)

Set the MicrostepsPerRevolution status variable to the number of microsteps for a 360 degree revolution of the axis.

Parameters
[in]Axis- The axis to use.
Returns
false failure

◆ GetMicrostepsPerWormRevolution()

bool SkywatcherAPI::GetMicrostepsPerWormRevolution ( AXISID  Axis)

Set the MicrostepsPermWormRevolution status variable to the number of microsteps for a 360 degree revolution of the worm gear.

Parameters
[in]Axis- The axis to use.
Returns
false failure

◆ GetMotorBoardVersion()

bool SkywatcherAPI::GetMotorBoardVersion ( AXISID  Axis)

◆ GetPositiveRotationDirection()

SkywatcherAPI::PositiveRotationSense_t SkywatcherAPI::GetPositiveRotationDirection ( AXISID  Axis)

Returns the rotation direction for a positive step on the designated axis.

Parameters
[in]Axis- The axis to use.
Returns
The rotation sense clockwise or anticlockwise.

Rotation directions are given looking down the axis towards the motorised pier for an altitude or declination axis. Or down the pier towards the mount base for an azimuth or right ascension axis

◆ GetStatus()

bool SkywatcherAPI::GetStatus ( AXISID  Axis)

◆ GetStepperClockFrequency()

bool SkywatcherAPI::GetStepperClockFrequency ( AXISID  Axis)

Set the StepperClockFrequency status variable to fixed PIC timer interrupt frequency (ticks per second).

Returns
false failure

◆ Highstr2long()

unsigned long SkywatcherAPI::Highstr2long ( std::string &  String)

◆ InitializeMC()

bool SkywatcherAPI::InitializeMC ( )

◆ InitMount()

bool SkywatcherAPI::InitMount ( bool  recover)

Initialize the communication to the mount.

Parameters
[in]recover- The connection is recovering
Returns
True if successful otherwise false

◆ InstantStop()

bool SkywatcherAPI::InstantStop ( AXISID  Axis)

Bring the axis to an immediate halt.

N.B. This command could cause damage to the mount or telescope and should not normally be used except for emergency stops.

Parameters
[in]Axis- The axis to use.
Returns
false failure

◆ IsInMotion()

bool SkywatcherAPI::IsInMotion ( AXISID  Axis)

Check if an axis is moving.

Parameters
[in]Axis- The axis to check.
Returns
True if the axis is moving otherwise false.

◆ IsMerlinMount()

bool SkywatcherAPI::IsMerlinMount ( ) const

Check if the current mount is a Merlin (AltAz)

Returns
True if the current mount is Merlin otherwise false.

◆ IsVirtuosoMount()

bool SkywatcherAPI::IsVirtuosoMount ( ) const

Check if the current mount is a Virtuoso (AltAz)

Returns
True if the current mount is Virtuoso otherwise false.

◆ Long2BCDstr()

void SkywatcherAPI::Long2BCDstr ( long  Number,
std::string &  String 
)

◆ MicrostepsToDegrees()

double SkywatcherAPI::MicrostepsToDegrees ( AXISID  Axis,
long  Microsteps 
)

Convert microsteps to angle in degrees.

Parameters
[in]Axis- The axis to use.
[in]Microsteps
Returns
the angle in degrees

◆ MicrostepsToRadians()

double SkywatcherAPI::MicrostepsToRadians ( AXISID  Axis,
long  Microsteps 
)

Convert microsteps to angle in radians.

Parameters
[in]Axis- The axis to use.
[in]Microsteps
Returns
the angle in radians

◆ PrepareForSlewing()

void SkywatcherAPI::PrepareForSlewing ( AXISID  Axis,
double  Speed 
)

◆ RadiansPerSecondToClocksTicksPerMicrostep()

long SkywatcherAPI::RadiansPerSecondToClocksTicksPerMicrostep ( AXISID  Axis,
double  RadiansPerSecond 
)

Convert a slewing rate in radians per second into the required clock ticks per microstep setting.

Parameters
[in]Axis- The axis to use.
[in]DegreesPerSecond- Slewing rate in degrees per second
Returns
Clock ticks per microstep for the requested rate

◆ RadiansToMicrosteps()

long SkywatcherAPI::RadiansToMicrosteps ( AXISID  Axis,
double  AngleInRadians 
)

Convert angle in radians to microsteps.

Parameters
[in]Axis- The axis to use.
[in]AngleInRadians- the angle in radians.
Returns
the number of microsteps

◆ SetClockTicksPerMicrostep()

bool SkywatcherAPI::SetClockTicksPerMicrostep ( AXISID  Axis,
long  ClockTicksPerMicrostep 
)

Set the PIC internal divider variable which determines how many clock interrupts have to occur between each microstep.

◆ SetEncoder()

bool SkywatcherAPI::SetEncoder ( AXISID  Axis,
long  Microsteps 
)

Set axis encoder to the specified value.

Parameters
[in]Axis- The axis to use.
[in]Microsteps- the value in microsteps.
Returns
false failure

◆ SetGotoTargetOffset()

bool SkywatcherAPI::SetGotoTargetOffset ( AXISID  Axis,
long  OffsetInMicrosteps 
)

Set the goto target offset per the specified axis.

Parameters
[in]Axis- The axis to use.
[in]OffsetInMicrosteps- the value to use
Returns
false failure

◆ SetMotionMode()

bool SkywatcherAPI::SetMotionMode ( AXISID  Axis,
char  Func,
char  Direction 
)

Set the motion mode per the specified axis.

Func - 0 High speed slew to mode (goto) Func - 1 Low speed slew mode Func - 2 Low speed slew to mode (goto) Func - 3 High speed slew mode.

Parameters
[in]Axis- The axis to use.
[in]Func- the slewing mode
  • 0 = High speed SlewTo mode
  • 1 = Low speed Slew mode
  • 2 = Low speed SlewTo mode
  • 3 = High Speed Slew mode
[in]Direction- the direction to slew in
  • 0 = Forward
  • 1 = Reverse
Returns
false failure

◆ SetSerialPort()

void SkywatcherAPI::SetSerialPort ( int  port)
inline

Set the serail port to be usb for mount communication.

Parameters
[in]port- an open file descriptor for the port to use.

◆ SetSlewModeDeccelerationRampLength()

bool SkywatcherAPI::SetSlewModeDeccelerationRampLength ( AXISID  Axis,
long  Microsteps 
)

Set the length of the deccelaration ramp for Slew mode.

Parameters
[in]Axis- The axis to use.
[in]Microsteps- the length of the decceleration ramp in microsteps.
Returns
false failure

◆ SetSlewToModeDeccelerationRampLength()

bool SkywatcherAPI::SetSlewToModeDeccelerationRampLength ( AXISID  Axis,
long  Microsteps 
)

Set the length of the deccelaration ramp for SlewTo mode.

Parameters
[in]Axis- The axis to use.
[in]Microsteps- the length of the decceleration ramp in microsteps.
Returns
false failure

◆ SetSwitch()

bool SkywatcherAPI::SetSwitch ( bool  OnOff)

Set the camera control switch to the given state.

Parameters
[in]OnOff- the state requested.

◆ skywatcher_tty_read()

virtual int SkywatcherAPI::skywatcher_tty_read ( int  fd,
char *  buf,
int  nbytes,
int  timeout,
int *  nbytes_read 
)
privatepure virtual

◆ skywatcher_tty_write()

virtual int SkywatcherAPI::skywatcher_tty_write ( int  fd,
const char *  buffer,
int  nbytes,
int *  nbytes_written 
)
privatepure virtual

◆ Slew()

void SkywatcherAPI::Slew ( AXISID  Axis,
double  SpeedInRadiansPerSecond,
bool  IgnoreSilentMode = true 
)

Start the axis slewing at the given rate.

Parameters
[in]Axis- The axis to use.
[in]SpeedInRadiansPerSecond- the slewing speed
[in]IgnoreSilentMode- ignore the silent mode even if set

◆ SlewTo()

void SkywatcherAPI::SlewTo ( AXISID  Axis,
long  OffsetInMicrosteps,
bool  verbose = true 
)

Slew to the given offset and stop.

Parameters
[in]Axis- The axis to use.
[in]OffsetInMicrosteps- The number of microsteps to
[in]verbose- Verbose mode slew from the current axis position.

◆ SlowStop()

bool SkywatcherAPI::SlowStop ( AXISID  Axis)

Bring the axis to slow stop in the distance specified by SetSlewModeDeccelerationRampLength.

Parameters
[in]Axis- The axis to use.
Returns
false failure

◆ StartMotion()

bool SkywatcherAPI::StartMotion ( AXISID  Axis)

Start the axis slewing in the prevously selected mode.

Parameters
[in]Axis- The axis to use.
Returns
false failure

◆ TalkWithAxis()

bool SkywatcherAPI::TalkWithAxis ( AXISID  Axis,
char  Command,
std::string &  cmdDataStr,
std::string &  responseStr 
)

Member Data Documentation

◆ AxesStatus

AXISSTATUS SkywatcherAPI::AxesStatus[2]

◆ CurrentEncoders

long SkywatcherAPI::CurrentEncoders[2]

Current encoder values (microsteps).

◆ DBG_SCOPE

unsigned int SkywatcherAPI::DBG_SCOPE { 0 }
protected

◆ DegreesPerMicrostep

double SkywatcherAPI::DegreesPerMicrostep[2]

◆ HighSpeedRatio

long SkywatcherAPI::HighSpeedRatio[2]

◆ IsDCMotor

bool SkywatcherAPI::IsDCMotor { false }

◆ LastSlewToTarget

long SkywatcherAPI::LastSlewToTarget[2]

◆ LOW_SPEED_MARGIN

constexpr double SkywatcherAPI::LOW_SPEED_MARGIN { 128.0 * SIDEREALRATE }
static

◆ LowSpeedGotoMargin

long SkywatcherAPI::LowSpeedGotoMargin[2]

◆ MAX_SPEED

constexpr double SkywatcherAPI::MAX_SPEED { 500.0 }
static

◆ MCVersion

unsigned long SkywatcherAPI::MCVersion { 0 }

◆ MicrostepsPerDegree

double SkywatcherAPI::MicrostepsPerDegree[2]

◆ MicrostepsPerRadian

double SkywatcherAPI::MicrostepsPerRadian[2]

◆ MicrostepsPerRevolution

long SkywatcherAPI::MicrostepsPerRevolution[2]

◆ MicrostepsPerWormRevolution

long SkywatcherAPI::MicrostepsPerWormRevolution[2]

◆ MountCode

unsigned long SkywatcherAPI::MountCode { 0 }

◆ MyPortFD

int SkywatcherAPI::MyPortFD { 0 }
private

◆ pChildTelescope

INDI::Telescope* SkywatcherAPI::pChildTelescope { nullptr }

◆ PolarisPositionEncoders

long SkywatcherAPI::PolarisPositionEncoders[2]

Polaris position (initial) encoder values (microsteps).

◆ RadiansPerMicrostep

double SkywatcherAPI::RadiansPerMicrostep[2]

◆ SIDEREALRATE

constexpr double SkywatcherAPI::SIDEREALRATE { (2 * M_PI / 86164.09065) }
static

◆ SilentSlewMode

bool SkywatcherAPI::SilentSlewMode { true }

◆ SlewingSpeed

double SkywatcherAPI::SlewingSpeed[2]

◆ StepperClockFrequency

long SkywatcherAPI::StepperClockFrequency[2]

◆ ZeroPositionEncoders

long SkywatcherAPI::ZeroPositionEncoders[2]

Zero position encoder values (microsteps).


The documentation for this class was generated from the following files: