Skip to content

Commit

Permalink
Updates to DDW driver (indilib#1344)
Browse files Browse the repository at this point in the history
- restrict to serial connection as the controller only support that to avoid confusion
- if dome is currently moving when a new command to move arrives (from slaving or similar), latch the command and issue the goto after current one completes
- the state of DomeAbsPosNP was set to IPS_OK too early in a few places causing client to think move is over, corrected those so the state stays IPS_BUSY correctly until the move is actually finished
  • Loading branch information
jpaana authored and karlrees committed Mar 24, 2021
1 parent 6853b30 commit 6535e30
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
37 changes: 30 additions & 7 deletions drivers/dome/ddw_dome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ DDW::DDW()
{
setVersion(1, 0);
SetDomeCapability(DOME_CAN_ABORT | DOME_CAN_ABS_MOVE | DOME_CAN_PARK | DOME_HAS_SHUTTER);
setDomeConnection(CONNECTION_SERIAL);
}

bool DDW::initProperties()
Expand Down Expand Up @@ -153,6 +154,9 @@ bool DDW::Handshake()
return false;

parseGINF(response.c_str());
cmdState = IDLE;
DomeAbsPosNP.s = IPS_OK;
IDSetNumber(&DomeAbsPosNP, nullptr);
return true;
}

Expand Down Expand Up @@ -296,8 +300,6 @@ void DDW::parseGINF(const char *response)
homeAz = 360.0 * homepos / ticksPerRev;

DomeAbsPosN[0].value = 360.0 * azimuth / ticksPerRev;
DomeAbsPosNP.s = IPS_OK;
IDSetNumber(&DomeAbsPosNP, nullptr);

DomeShutterSP.s = IPS_OK;
IUResetSwitch(&DomeShutterSP);
Expand Down Expand Up @@ -371,7 +373,6 @@ void DDW::TimerHit()

// Update current position
DomeAbsPosN[0].value = 359.0 * tick / ticksPerRev;
DomeAbsPosNP.s = IPS_OK;
IDSetNumber(&DomeAbsPosNP, nullptr);
break;
}
Expand Down Expand Up @@ -418,23 +419,38 @@ void DDW::TimerHit()
{
// First phase of parking done, now move to park position
cmdState = IDLE;
MoveAbs(GetAxis1Park());
DomeAbsPosNP.s = MoveAbs(GetAxis1Park());
}
else
{
SetParked(true);
cmdState = IDLE;
DomeAbsPosNP.s = IPS_OK;
}
break;
case DOME_UNPARKING:
SetParked(false);
cmdState = IDLE;
break;
default:
if(gotoPending && cmdState == MOVING)
{
cmdState = IDLE; // Set state so move goes through
MoveAbs(gotoTarget);
gotoPending = false;
}
else
{
cmdState = IDLE;
// Movement now over
DomeAbsPosNP.s = IPS_OK;
}
break;
}
cmdState = IDLE;
IDSetNumber(&DomeAbsPosNP, nullptr);
break;
default:
LOGF_ERROR("Unknown respose character %c", response[0]);
LOGF_ERROR("Unknown response character %c", response[0]);
break;
}
}
Expand All @@ -448,7 +464,14 @@ IPState DDW::MoveAbs(double az)
{
LOGF_DEBUG("MoveAbs (%f)", az);

if (cmdState != IDLE)
if (cmdState == MOVING)
{
LOG_DEBUG("Dome already moving, latching the new move command");
gotoTarget = az;
gotoPending = true;
return IPS_BUSY;
}
else if (cmdState != IDLE)
{
LOG_ERROR("Dome needs to be idle to issue moves");
return IPS_ALERT;
Expand Down
3 changes: 3 additions & 0 deletions drivers/dome/ddw_dome.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class DDW : public INDI::Dome

int fwVersion{ -1 };

double gotoTarget { 0 };
bool gotoPending { false };

enum
{
IDLE,
Expand Down

0 comments on commit 6535e30

Please sign in to comment.