Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DustCover open/close #2152

Merged
merged 3 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/filter_wheel/filter_simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FilterSim : public INDI::FilterWheel
virtual bool initProperties() override;
virtual bool updateProperties() override;
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
const char *getDefaultName();
virtual const char *getDefaultName() override;

bool Connect() override;
bool Disconnect() override;
Expand Down
69 changes: 23 additions & 46 deletions drivers/focuser/alluna_tcs2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,40 +403,6 @@ bool AllunaTCS2::ISNewSwitch(const char * dev, const char * name, ISState * stat
return true;
}

// Cover Switch?
// if (!strcmp(name, ParkCapSP.name))
// {
// // Find out which state is requested by the client
// const char *actionName = IUFindOnSwitchName(states, names, n);
// // Do nothing, if state is already what it should be
// int currentCoverIndex = IUFindOnSwitchIndex(&ParkCapSP);
// if (!strcmp(actionName, ParkCapS[currentCoverIndex].name))
// {
// DEBUGF(INDI::Logger::DBG_SESSION, "Cover is already %s", ParkCapS[currentCoverIndex].label);
// ParkCapSP.s = IPS_IDLE;
// IDSetSwitch(&ParkCapSP, NULL);
// return true;
// }

// // Otherwise, let us update the switch state
// IUUpdateSwitch(&ParkCapSP, states, names, n);
// currentCoverIndex = IUFindOnSwitchIndex(&ParkCapSP);
// if ( setDustCover() )
// {
// isCoverMoving = true;
// DEBUGF(INDI::Logger::DBG_SESSION, "Cover is now %s", ParkCapS[currentCoverIndex].label);
// ParkCapSP.s = IPS_OK;
// IDSetSwitch(&ParkCapSP, NULL);
// return true;
// }
// else
// {
// DEBUG(INDI::Logger::DBG_SESSION, "Cannot get lock, try again");
// ParkCapSP.s = IPS_ALERT;
// IDSetSwitch(&ParkCapSP, NULL);
// }
// }

// Climate Control Switch?
if (ClimateControlSP.isNameMatch(name))
{
Expand Down Expand Up @@ -679,10 +645,10 @@ void AllunaTCS2::TimerHit()
IDSetNumber(&FocusAbsPosNP, nullptr);
break;
case 'I': // starting to focus
LOG_INFO("TimerHit: starting to focus");
LOG_DEBUG("TimerHit: starting to focus");
break;
case 'J': // end of focusing
LOG_INFO("TimetHit: end of focusing");
LOG_DEBUG("TimetHit: end of focusing");
isFocuserMoving = false;
FocusAbsPosNP.s = IPS_OK;
IDSetNumber(&FocusAbsPosNP, nullptr);
Expand All @@ -697,14 +663,15 @@ void AllunaTCS2::TimerHit()
receiveDone();
ParkCapSP.setState(IPS_OK);
ParkCapSP.apply();
getDustCover();
break;
default: // unexpected output
LOGF_INFO("TimerHit: unexpected response (%s)", res);
LOGF_DEBUG("TimerHit: unexpected response (%s)", res);
}
}
else
{
LOGF_INFO("TimerHit: unexpected response (%s)", res);
LOGF_DEBUG("TimerHit: unexpected response (%s)", res);
}
actionInProgress = isFocuserMoving || isCoverMoving;
}
Expand Down Expand Up @@ -844,33 +811,43 @@ bool AllunaTCS2::getDustCover()
ParkCapSP[CAP_UNPARK].setState((value == 1) ? ISS_ON : ISS_OFF);
ParkCapSP[CAP_PARK ].setState((value != 1) ? ISS_ON : ISS_OFF);
ParkCapSP.setState(IPS_OK);
ParkCapSP.apply();

return true;
}

IPState AllunaTCS2::ParkCap()
{
if (ParkCapSP[CAP_PARK].getState() == ISS_OFF)
if (ParkCapSP[CAP_PARK].getState() == ISS_ON)
{
if (setDustCover()) // toggle state of dust cover
LOG_DEBUG("Toggle");
if (setDustCover()) { // toggle state of dust cover
isCoverMoving = true;
return IPS_BUSY;
}
else
return IPS_ALERT;
}
getDustCover();

// Cover already parked, nothing to do
return IPS_OK;
}

IPState AllunaTCS2::UnParkCap()
{
if (ParkCapSP[CAP_UNPARK].getState() == ISS_OFF)
LOGF_DEBUG("UnParkCap called, state is %d %d", ParkCapSP[CAP_PARK].getState(), ParkCapSP[CAP_UNPARK].getState());
if (ParkCapSP[CAP_UNPARK].getState() == ISS_ON)
{
if (setDustCover()) // toggle state of dust cover
LOG_DEBUG("Toggle");
if (setDustCover()) { // toggle state of dust cover
isCoverMoving = true;
return IPS_BUSY;
}
else
return IPS_ALERT;
}
getDustCover();

// Cover already unparked, nothing to do
return IPS_OK;
Expand Down Expand Up @@ -898,7 +875,7 @@ bool AllunaTCS2::getStepping()

// Set limits as per documentation
FocusAbsPosN[0].max = (steppingMode == MICRO) ? 22400 : 1400; // 22400 in microstep mode, 1400 in speedstep mode
LOGF_INFO("readStepping: set max position to %d", (int)FocusAbsPosN[0].max);
LOGF_DEBUG("readStepping: set max position to %d", (int)FocusAbsPosN[0].max);
return true;
}

Expand All @@ -908,8 +885,8 @@ bool AllunaTCS2::setStepping(SteppingMode mode)
char cmd[DRIVER_LEN] = {0};
steppingMode = mode;
value = (mode == SPEED) ? 0 : 1;
LOGF_INFO("Setting stepping mode to: %s", (mode == SPEED) ? "SPEED" : "micro");
LOGF_INFO("Setting stepping mode to: %d", value);
LOGF_DEBUG("Setting stepping mode to: %s", (mode == SPEED) ? "SPEED" : "micro");
LOGF_DEBUG("Setting stepping mode to: %d", value);
snprintf(cmd, DRIVER_LEN, "SetFocuserMode %d\n", value);
return sendCommand(cmd);
}
Expand Down Expand Up @@ -1044,7 +1021,7 @@ bool AllunaTCS2::getFanPower()

if (value != (int)FanPowerNP[0].value)
{
LOGF_INFO("FanPower read to be %d", value);
LOGF_DEBUG("FanPower read to be %d", value);
FanPowerNP[0].value = (double)value;
FanPowerNP.setState(IPS_OK);
FanPowerNP.apply();
Expand Down
Loading