TwiceAsNice
2019-02-18
|
#include <skywatcherAPI.h>
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::Telescope * | pChildTelescope { 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 } |
|
private |
SkywatcherAPI::SkywatcherAPI | ( | ) |
|
virtualdefault |
unsigned long SkywatcherAPI::BCDstr2long | ( | std::string & | String | ) |
bool SkywatcherAPI::CheckIfDCMotor | ( | ) |
long SkywatcherAPI::DegreesPerSecondToClocksTicksPerMicrostep | ( | AXISID | Axis, |
double | DegreesPerSecond | ||
) |
Convert a slewing rate in degrees per second into the required clock ticks per microstep setting.
[in] | Axis | - The axis to use. |
[in] | DegreesPerSecond | - Slewing rate in degrees per second |
Convert angle in degrees to microsteps.
[in] | Axis | - The axis to use. |
[in] | AngleInRadians | - the angle in degrees. |
Set the CurrentEncoders status variable to the current encoder value in microsteps for the specified axis.
Set the HighSpeedRatio status variable to the ratio between high and low speed stepping modes.
Set the MicrostepsPerRevolution status variable to the number of microsteps for a 360 degree revolution of the axis.
[in] | Axis | - The axis to use. |
Set the MicrostepsPermWormRevolution status variable to the number of microsteps for a 360 degree revolution of the worm gear.
[in] | Axis | - The axis to use. |
SkywatcherAPI::PositiveRotationSense_t SkywatcherAPI::GetPositiveRotationDirection | ( | AXISID | Axis | ) |
Returns the rotation direction for a positive step on the designated axis.
[in] | Axis | - The axis to use. |
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
Set the StepperClockFrequency status variable to fixed PIC timer interrupt frequency (ticks per second).
unsigned long SkywatcherAPI::Highstr2long | ( | std::string & | String | ) |
bool SkywatcherAPI::InitializeMC | ( | ) |
Initialize the communication to the mount.
[in] | recover | - The connection is recovering |
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.
[in] | Axis | - The axis to use. |
Check if an axis is moving.
[in] | Axis | - The axis to check. |
bool SkywatcherAPI::IsMerlinMount | ( | ) | const |
Check if the current mount is a Merlin (AltAz)
bool SkywatcherAPI::IsVirtuosoMount | ( | ) | const |
Check if the current mount is a Virtuoso (AltAz)
void SkywatcherAPI::Long2BCDstr | ( | long | Number, |
std::string & | String | ||
) |
Convert microsteps to angle in degrees.
[in] | Axis | - The axis to use. |
[in] | Microsteps |
Convert microsteps to angle in radians.
[in] | Axis | - The axis to use. |
[in] | Microsteps |
void SkywatcherAPI::PrepareForSlewing | ( | AXISID | Axis, |
double | Speed | ||
) |
long SkywatcherAPI::RadiansPerSecondToClocksTicksPerMicrostep | ( | AXISID | Axis, |
double | RadiansPerSecond | ||
) |
Convert a slewing rate in radians per second into the required clock ticks per microstep setting.
[in] | Axis | - The axis to use. |
[in] | DegreesPerSecond | - Slewing rate in degrees per second |
Convert angle in radians to microsteps.
[in] | Axis | - The axis to use. |
[in] | AngleInRadians | - the angle in radians. |
Set the PIC internal divider variable which determines how many clock interrupts have to occur between each microstep.
Set axis encoder to the specified value.
[in] | Axis | - The axis to use. |
[in] | Microsteps | - the value in microsteps. |
Set the goto target offset per the specified axis.
[in] | Axis | - The axis to use. |
[in] | OffsetInMicrosteps | - the value to use |
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.
[in] | Axis | - The axis to use. |
[in] | Func | - the slewing mode
|
[in] | Direction | - the direction to slew in
|
|
inline |
Set the serail port to be usb for mount communication.
[in] | port | - an open file descriptor for the port to use. |
Set the length of the deccelaration ramp for Slew mode.
[in] | Axis | - The axis to use. |
[in] | Microsteps | - the length of the decceleration ramp in microsteps. |
Set the length of the deccelaration ramp for SlewTo mode.
[in] | Axis | - The axis to use. |
[in] | Microsteps | - the length of the decceleration ramp in microsteps. |
Set the camera control switch to the given state.
[in] | OnOff | - the state requested. |
|
privatepure virtual |
Implemented in SkywatcherAPIMount, and SkywatcherAltAzSimple.
|
privatepure virtual |
Implemented in SkywatcherAPIMount, and SkywatcherAltAzSimple.
void SkywatcherAPI::Slew | ( | AXISID | Axis, |
double | SpeedInRadiansPerSecond, | ||
bool | IgnoreSilentMode = true |
||
) |
Start the axis slewing at the given rate.
[in] | Axis | - The axis to use. |
[in] | SpeedInRadiansPerSecond | - the slewing speed |
[in] | IgnoreSilentMode | - ignore the silent mode even if set |
Slew to the given offset and stop.
[in] | Axis | - The axis to use. |
[in] | OffsetInMicrosteps | - The number of microsteps to |
[in] | verbose | - Verbose mode slew from the current axis position. |
Bring the axis to slow stop in the distance specified by SetSlewModeDeccelerationRampLength.
[in] | Axis | - The axis to use. |
Start the axis slewing in the prevously selected mode.
[in] | Axis | - The axis to use. |
bool SkywatcherAPI::TalkWithAxis | ( | AXISID | Axis, |
char | Command, | ||
std::string & | cmdDataStr, | ||
std::string & | responseStr | ||
) |
AXISSTATUS SkywatcherAPI::AxesStatus[2] |
long SkywatcherAPI::CurrentEncoders[2] |
Current encoder values (microsteps).
|
protected |
double SkywatcherAPI::DegreesPerMicrostep[2] |
long SkywatcherAPI::HighSpeedRatio[2] |
long SkywatcherAPI::LastSlewToTarget[2] |
|
static |
long SkywatcherAPI::LowSpeedGotoMargin[2] |
|
static |
unsigned long SkywatcherAPI::MCVersion { 0 } |
double SkywatcherAPI::MicrostepsPerDegree[2] |
double SkywatcherAPI::MicrostepsPerRadian[2] |
long SkywatcherAPI::MicrostepsPerRevolution[2] |
long SkywatcherAPI::MicrostepsPerWormRevolution[2] |
unsigned long SkywatcherAPI::MountCode { 0 } |
|
private |
INDI::Telescope* SkywatcherAPI::pChildTelescope { nullptr } |
long SkywatcherAPI::PolarisPositionEncoders[2] |
Polaris position (initial) encoder values (microsteps).
double SkywatcherAPI::RadiansPerMicrostep[2] |
|
static |
double SkywatcherAPI::SlewingSpeed[2] |
long SkywatcherAPI::StepperClockFrequency[2] |
long SkywatcherAPI::ZeroPositionEncoders[2] |
Zero position encoder values (microsteps).