Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/migrate-t…
Browse files Browse the repository at this point in the history
…elescope
  • Loading branch information
naheedsa committed Aug 28, 2024
2 parents 422c82a + 394bbc3 commit 03fc9ec
Show file tree
Hide file tree
Showing 10 changed files with 586 additions and 236 deletions.
29 changes: 27 additions & 2 deletions drivers/dome/universal_ror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ bool UniversalROR::initProperties()
InputTP.fill(getDeviceName(), "INPUT_INDEX", "Input Indexes", OPTIONS_TAB, IP_RW, 60, IPS_IDLE);
InputTP.load();

// Limit Switch Indicators
LimitSwitchLP[FullyOpened].fill("FULLY_OPENED", "Fully Opened", IPS_IDLE);
LimitSwitchLP[FullyClosed].fill("FULLY_CLOSED", "Fully Closed", IPS_IDLE);
LimitSwitchLP.fill(getDeviceName(), "LIMIT_SWITCHES", "Limit Switches", MAIN_CONTROL_TAB, IPS_IDLE);

// Output Indexes
OutputTP[OpenRoof].fill("OPEN_ROOF", "Open Roof", "Comma separated indexes");
OutputTP[CloseRoof].fill("CLOSE_ROOF", "Close Roof", "Comma separated indexes");
Expand Down Expand Up @@ -88,10 +93,22 @@ bool UniversalROR::setupParms()
////////////////////////////////////////////////////////////////////////////////
bool UniversalROR::Connect()
{
// Check if client is initialized and connected
if (!m_Client || !m_Client->isConnected())
{
LOG_ERROR("ROR Client is not connected. Specify the input and output drivers in Options tab.");
return false;
// If the client is already initialized, let's connect server again
if (m_Client)
m_Client->connectServer();
// Otherwise need to initialize the client again completely
else
ActiveDevicesUpdated();

// Check again if that worked.
if (!m_Client || !m_Client->isConnected())
{
LOG_ERROR("ROR Client is not connected. Specify the input and output drivers in Options tab.");
return false;
}

}

Expand All @@ -105,6 +122,8 @@ bool UniversalROR::Connect()
////////////////////////////////////////////////////////////////////////////////
bool UniversalROR::Disconnect()
{
m_InputFullyOpened.clear();
m_InputFullyClosed.clear();
return true;
}

Expand Down Expand Up @@ -170,11 +189,13 @@ bool UniversalROR::updateProperties()

defineProperty(InputTP);
defineProperty(OutputTP);
defineProperty(LimitSwitchLP);
}
else
{
deleteProperty(InputTP);
deleteProperty(OutputTP);
deleteProperty(LimitSwitchLP);
}

return true;
Expand Down Expand Up @@ -354,10 +375,14 @@ void UniversalROR::ActiveDevicesUpdated()
m_Client->setFullyClosedCallback([&](bool on)
{
m_FullClosedLimitSwitch = on;
LimitSwitchLP[FullyClosed].setState(on ? IPS_OK : IPS_IDLE);
LimitSwitchLP.apply();
});
m_Client->setFullyOpenedCallback([&](bool on)
{
m_FullOpenLimitSwitch = on;
LimitSwitchLP[FullyOpened].setState(on ? IPS_OK : IPS_IDLE);
LimitSwitchLP.apply();
});
m_Client->watchDevice(input.c_str());
m_Client->watchDevice(output.c_str());
Expand Down
1 change: 1 addition & 0 deletions drivers/dome/universal_ror.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class UniversalROR : public INDI::Dome
bool m_FullOpenLimitSwitch {false}, m_FullClosedLimitSwitch {false};

INDI::PropertyText InputTP {2};
INDI::PropertyLight LimitSwitchLP {2};
enum
{
FullyOpened,
Expand Down
9 changes: 9 additions & 0 deletions drivers/dome/universal_ror_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ void UniversalRORClient::newProperty(INDI::Property property)
updateProperty(property);
}

///////////////////////////////////////////////////////////////////////////////////////////
///
///////////////////////////////////////////////////////////////////////////////////////////
void UniversalRORClient::serverDisconnected(int exitCode)
{
INDI_UNUSED(exitCode);
m_InputReady = m_OutputReady = false;
}

///////////////////////////////////////////////////////////////////////////////////////////
/// Check if any of the relevant digital inputs are for the fully opened or closed states
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions drivers/dome/universal_ror_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class UniversalRORClient : public INDI::BaseClient
virtual void newDevice(INDI::BaseDevice dp) override;
virtual void newProperty(INDI::Property property) override;
virtual void updateProperty(INDI::Property property) override;
virtual void serverDisconnected(int exitCode) override;

private:
std::string m_Input, m_Output;
Expand Down
25 changes: 25 additions & 0 deletions drivers/telescope/lx200_OnStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5474,3 +5474,28 @@ IPState LX200_OnStep::ExecuteHomeAction(TelescopeHomeAction action)

return IPS_ALERT;
}

bool LX200_OnStep::Handshake()
{
if (checkConnection())
{
return true;
}

/* OnStepX has a tendency to start up in an unresponsive state
* due to grabage in the serial buffer. Try to reset it by sending
* the :GVP# command repeatedly.
*
* First sending should result in a '0' response, the second in
* 'OnStep' so the 2nd sending should return with a failure.
*/
if(sendOnStepCommand(":GVP#"))
{
if(!sendOnStepCommand(":GVP#"))
{
return checkConnection();
}
}

return false;
}
4 changes: 1 addition & 3 deletions drivers/telescope/lx200_OnStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class LX200_OnStep : public LX200Generic, public INDI::WeatherInterface, public
virtual bool updateProperties() override;
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
virtual bool Handshake() override;

protected:
virtual void getBasicData() override;
Expand Down Expand Up @@ -506,7 +507,4 @@ class LX200_OnStep : public LX200Generic, public INDI::WeatherInterface, public
private:
int currentCatalog;
int currentSubCatalog;



};
Loading

0 comments on commit 03fc9ec

Please sign in to comment.