Skip to content

Commit

Permalink
Migrate rest of INDI::Telescope legacy properties
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Aug 30, 2024
1 parent 79af635 commit c6f3eb2
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 119 deletions.
2 changes: 1 addition & 1 deletion drivers/telescope/ioptronHC8406.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ bool ioptronHC8406::ReadScopeStatus()
if (isSlewComplete())
{
nanosleep(&timeout, nullptr); //Wait until :MS# finish
if (IUFindSwitch(&CoordSP, "SYNC")->s == ISS_ON || IUFindSwitch(&CoordSP, "SLEW")->s == ISS_ON)
if (CoordSP.isSwitchOn("SYNC") || CoordSP.isSwitchOn("SLEW"))
{
TrackState = SCOPE_IDLE;
LOG_WARN("Slew is complete. IDLE");
Expand Down
29 changes: 7 additions & 22 deletions drivers/telescope/lx200_OnStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ bool LX200_OnStep::initProperties()
SlewRateSP[8].fill("8", "Half-Max", ISS_OFF);
SlewRateSP[9].fill("9", "Max", ISS_OFF);
SlewRateSP.fill(getDeviceName(), "TELESCOPE_SLEW_RATE", "Slew Rate", MOTION_TAB,
IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
IP_RW, ISR_1OFMANY, 0, IPS_IDLE);

IUFillNumber(&MaxSlewRateN[0], "maxSlew", "Rate", "%f", 0.0, 9.0, 1.0, 5.0); //2.0, 9.0, 1.0, 9.0
IUFillNumberVector(&MaxSlewRateNP, MaxSlewRateN, 1, getDeviceName(), "Max slew Rate", "", MOTION_TAB,
Expand Down Expand Up @@ -809,7 +809,7 @@ bool LX200_OnStep::ISNewNumber(const char *dev, const char *name, double values[
if (strstr(name, "ROTATOR_"))
return RI::processNumber(dev, name, values, names, n);

if (strcmp(name, "EQUATORIAL_EOD_COORD") == 0)
if (EqNP.isNameMatch(name))
//Replace this from inditelescope so it doesn't change state
//Most of this needs to be handled by our updates, or it breaks things
{
Expand Down Expand Up @@ -843,37 +843,22 @@ bool LX200_OnStep::ISNewNumber(const char *dev, const char *name, double values[
// Check if it can sync
if (Telescope::CanSync())
{
ISwitch *sw;
sw = IUFindSwitch(&CoordSP, "SYNC");
if ((sw != nullptr) && (sw->s == ISS_ON))
auto oneSwitch = CoordSP.findWidgetByName("SYNC");
if (oneSwitch && oneSwitch->getState() == ISS_ON)
{
rc = Sync(ra, dec);
// if (rc)
// EqNP.s = lastEqState = IPS_OK;
// else
// EqNP.s = lastEqState = IPS_ALERT;
// IDSetNumber(&EqNP, nullptr);
return rc;
return Sync(ra, dec);
}
}

// Remember Track State
// RememberTrackState = TrackState;
// Issue GOTO
rc = Goto(ra, dec);
if (rc)
{
// EqNP.s = lastEqState = IPS_BUSY;
// Now fill in target co-ords, so domes can start turning
TargetNP[AXIS_RA].setValue(ra);
TargetNP[AXIS_DE].setValue(dec);
TargetNP.apply();
}
else
{
// EqNP.s = lastEqState = IPS_ALERT;
}
// IDSetNumber(&EqNP, nullptr);
}
return rc;
}
Expand Down Expand Up @@ -2382,7 +2367,7 @@ bool LX200_OnStep::ReadScopeStatus()
}
break;
}
if (EqNP[AXIS_RA].getValue() != currentRA || EqNP[AXIS_DE].getValue() != currentDEC)
if (EqNP[AXIS_RA].getValue() != currentRA || EqNP[AXIS_DE].getValue() != currentDEC)
{
#ifdef DEBUG_TRACKSTATE
LOG_DEBUG("EqNP coordinates updated");
Expand Down Expand Up @@ -4982,7 +4967,7 @@ void LX200_OnStep::slewError(int slewCode)
default:
LOG_ERROR("OnStep slew/syncError: Not in range of values that should be returned! INVALID, Something went wrong!");
}
EqNP.setState(IPS_ALERT);
EqNP.setState(IPS_ALERT);
EqNP.apply();
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/telescope/lx200ap_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void LX200AstroPhysicsV2::initRateLabels()
SlewRateSP[3].fill("600", "600x", ISS_OFF);
SlewRateSP[4].fill("1200", "1200x", ISS_OFF);
SlewRateSP.fill(getDeviceName(), "TELESCOPE_SLEW_RATE", "Slew Rate", MOTION_TAB, IP_RW,
ISR_1OFMANY, 0, IPS_IDLE);
ISR_1OFMANY, 0, IPS_IDLE);

// Slew speed when performing regular GOTO
IUFillSwitch(&APSlewSpeedS[0], "600", "600x", ISS_ON);
Expand Down Expand Up @@ -584,7 +584,7 @@ bool LX200AstroPhysicsV2::ISNewNumber(const char *dev, const char *name, double
double ra = lst - HourangleCoordsN[0].value;
double dec = HourangleCoordsN[1].value;
bool success = false;
if ((ISS_ON == IUFindSwitch(&CoordSP, "TRACK")->s) || (ISS_ON == IUFindSwitch(&CoordSP, "SLEW")->s))
if (CoordSP.isSwitchOn("TRACK") || CoordSP.isSwitchOn("SLEW"))
{
success = Goto(ra, dec);
}
Expand Down Expand Up @@ -2203,7 +2203,7 @@ bool LX200AstroPhysicsV2::MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command
ISState states[] = { ISS_OFF, ISS_OFF, ISS_OFF, ISS_OFF };
states[rememberSlewRate] = ISS_ON;
const char *names[] = { SlewRateSP[0].getName(), SlewRateSP[1].getName(),
SlewRateSP[2].getName(), SlewRateSP[3].getName()
SlewRateSP[2].getName(), SlewRateSP[3].getName()
};
ISNewSwitch(SlewRateSP.getDeviceName(), SlewRateSP.getName(), states, const_cast<char **>(names), 4);
rememberSlewRate = -1;
Expand All @@ -2221,7 +2221,7 @@ bool LX200AstroPhysicsV2::MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command
ISState states[] = { ISS_OFF, ISS_OFF, ISS_OFF, ISS_OFF };
states[rememberSlewRate] = ISS_ON;
const char *names[] = { SlewRateSP[0].getName(), SlewRateSP[1].getName(),
SlewRateSP[2].getName(), SlewRateSP[3].getName()
SlewRateSP[2].getName(), SlewRateSP[3].getName()
};
ISNewSwitch(SlewRateSP.getDeviceName(), SlewRateSP.getName(), states, const_cast<char **>(names), 4);
rememberSlewRate = -1;
Expand Down
4 changes: 2 additions & 2 deletions drivers/telescope/pmc8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool PMC8::updateProperties()
defineProperty(&FirmwareTP);

// do not support park position
deleteProperty(ParkPositionNP.name);
deleteProperty(ParkPositionNP);
deleteProperty(ParkOptionSP);
}
else
Expand Down Expand Up @@ -1394,7 +1394,7 @@ void PMC8::mountSim()
switch (TrackState)
{
case SCOPE_IDLE:
currentRA += (TrackRateNP[AXIS_RA].getValue() / 3600.0 * dt) / 15.0;
currentRA += (TrackRateNP[AXIS_RA].getValue() / 3600.0 * dt) / 15.0;
currentRA = range24(currentRA);
break;

Expand Down
10 changes: 5 additions & 5 deletions drivers/telescope/skywatcherAPIMount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,7 @@ bool SkywatcherAPIMount::ISNewNumber(const char *dev, const char *name, double v
}
if ((ra >= 0) && (ra <= 24) && (dec >= -90) && (dec <= 90))
{
ISwitch *sw = IUFindSwitch(&CoordSP, "SYNC");

if (sw != nullptr && sw->s == ISS_ON && isParked())
if (CoordSP.isSwitchOn("SYNC") && isParked())
{
return Sync(ra, dec);
}
Expand Down Expand Up @@ -516,7 +514,8 @@ bool SkywatcherAPIMount::Goto(double ra, double dec)

DEBUGF(INDI::AlignmentSubsystem::DBG_ALIGNMENT, "GOTO RA %lf DEC %lf", ra, dec);

if (IUFindSwitch(&CoordSP, "TRACK")->s == ISS_ON || IUFindSwitch(&CoordSP, "SLEW")->s == ISS_ON)
auto onSwitch = CoordSP.findOnSwitch();
if (onSwitch && (onSwitch->isNameMatch("TRACK") || onSwitch->isNameMatch("SLEW")))
{
char RAStr[32], DecStr[32];
fs_sexa(RAStr, ra, 2, 3600);
Expand Down Expand Up @@ -840,7 +839,8 @@ bool SkywatcherAPIMount::ReadScopeStatus()
return Goto(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination);
}

if (ISS_ON == IUFindSwitch(&CoordSP, "TRACK")->s)
auto onSwitch = CoordSP.findOnSwitch();
if (onSwitch && (onSwitch->isNameMatch("TRACK")))
{
// Goto has finished start tracking
TrackState = SCOPE_TRACKING;
Expand Down
6 changes: 3 additions & 3 deletions drivers/telescope/telescope_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ bool ScopeSim::initProperties()
SlewRateSP[SLEW_FIND].fill("SLEW_FIND", "Find", ISS_OFF);
SlewRateSP[SLEW_MAX].fill("SLEW_MAX", "Max", ISS_ON);
SlewRateSP.fill(getDeviceName(), "TELESCOPE_SLEW_RATE", "Slew Rate", MOTION_TAB,
IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
IP_RW, ISR_1OFMANY, 0, IPS_IDLE);

// Add Tracking Modes, the order must match the order of the TelescopeTrackMode enum
AddTrackMode("TRACK_SIDEREAL", "Sidereal", true);
Expand Down Expand Up @@ -168,8 +168,8 @@ bool ScopeSim::updateProperties()

alignment.latitude = Angle(LocationNP[LOCATION_LATITUDE].getValue());
alignment.longitude = Angle(LocationNP[LOCATION_LONGITUDE].getValue());
currentRA = (alignment.lst() - Angle(ParkPositionN[AXIS_RA].value, Angle::ANGLE_UNITS::HOURS)).Hours();
currentDEC = ParkPositionN[AXIS_DE].value;
currentRA = (alignment.lst() - Angle(ParkPositionNP[AXIS_RA].getValue(), Angle::ANGLE_UNITS::HOURS)).Hours();
currentDEC = ParkPositionNP[AXIS_DE].getValue();
Sync(currentRA, currentDEC);

}
Expand Down
7 changes: 3 additions & 4 deletions examples/tutorial_seven/simple_telescope_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool ScopeSim::Goto(double ra, double dec)
DEBUGF(DBG_SIMULATOR, "Goto - Celestial reference frame target right ascension %lf(%lf) declination %lf",
ra * 360.0 / 24.0, ra, dec);

if (ISS_ON == IUFindSwitch(&CoordSP, "TRACK")->s)
if (CoordSP.isSwitchOn("TRACK"))
{
char RAStr[32], DecStr[32];
fs_sexa(RAStr, ra, 2, 3600);
Expand Down Expand Up @@ -588,7 +588,7 @@ void ScopeSim::TimerHit()
case SCOPE_SLEWING:
if ((STOPPED == AxisStatusRA) && (STOPPED == AxisStatusDEC))
{
if (ISS_ON == IUFindSwitch(&CoordSP, "TRACK")->s)
if (CoordSP.isSwitchOn("TRACK"))
{
// Goto has finished start tracking
DEBUG(DBG_SIMULATOR, "TimerHit - Goto finished start tracking");
Expand All @@ -601,8 +601,7 @@ void ScopeSim::TimerHit()
break;
}
}
else
break;
break;

case SCOPE_TRACKING:
{
Expand Down
Loading

0 comments on commit c6f3eb2

Please sign in to comment.