Skip to content

Commit

Permalink
Add support to close shutter on parking
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Apr 20, 2019
1 parent 68ae2fa commit 3fc7943
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/indi-nexdome/CMakeLists.txt
Expand Up @@ -6,7 +6,7 @@ LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake_modules/"
include(GNUInstallDirs)

set(INDI_NEXDOME_VERSION_MAJOR 1)
set(INDI_NEXDOME_VERSION_MINOR 2)
set(INDI_NEXDOME_VERSION_MINOR 3)

find_package(INDI REQUIRED)
find_package(ZLIB REQUIRED)
Expand Down
34 changes: 31 additions & 3 deletions 3rdparty/indi-nexdome/nex_dome.cpp
Expand Up @@ -136,9 +136,16 @@ bool NexDome::initProperties()
///////////////////////////////////////////////////////////////////////////////
/// Dome Reversal
///////////////////////////////////////////////////////////////////////////////
IUFillSwitch(&ReversedS[0], "Disable", "", ISS_OFF);
IUFillSwitch(&ReversedS[1], "Enable", "", ISS_OFF);
IUFillSwitchVector(&ReversedSP, ReversedS, 2, getDeviceName(), "DOME_REVERSED", "Reversed", SITE_TAB, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
IUFillSwitch(&ReversedS[DISABLED], "Disable", "", ISS_ON);
IUFillSwitch(&ReversedS[ENABLED], "Enable", "", ISS_OFF);
IUFillSwitchVector(&ReversedSP, ReversedS, 2, getDeviceName(), "DOME_REVERSED", "Reversed", SITE_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);

///////////////////////////////////////////////////////////////////////////////
/// Close Shutter on Park?
///////////////////////////////////////////////////////////////////////////////
IUFillSwitch(&CloseShutterOnParkS[DISABLED], "Disable", "", ISS_ON);
IUFillSwitch(&CloseShutterOnParkS[ENABLED], "Enable", "", ISS_OFF);
IUFillSwitchVector(&CloseShutterOnParkSP, CloseShutterOnParkS, 2, getDeviceName(), "DOME_CLOSE_SHUTTER_ON_PARK", "Close Shutter on Park", SITE_TAB, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);

return true;
}
Expand Down Expand Up @@ -175,6 +182,8 @@ bool NexDome::updateProperties()
defineNumber(&BatteryLevelNP);
defineText(&FirmwareVersionTP);
defineSwitch(&ReversedSP);
if (HasShutter())
defineSwitch(&CloseShutterOnParkSP);
}
else
{
Expand All @@ -185,6 +194,8 @@ bool NexDome::updateProperties()
deleteProperty(BatteryLevelNP.name);
deleteProperty(FirmwareVersionTP.name);
deleteProperty(ReversedSP.name);
if (HasShutter())
deleteProperty(CloseShutterOnParkSP.name);
}

return true;
Expand Down Expand Up @@ -271,6 +282,17 @@ bool NexDome::ISNewSwitch(const char *dev, const char *name, ISState *states, ch

IDSetSwitch(&ReversedSP, nullptr);
}

///////////////////////////////////////////////////////////////////////////////
/// Close Shutter on Park
///////////////////////////////////////////////////////////////////////////////
if (!strcmp(name, CloseShutterOnParkSP.name))
{
IUUpdateSwitch(&CloseShutterOnParkSP, states, names, n);
CloseShutterOnParkSP.s = IPS_OK;
IDSetSwitch(&CloseShutterOnParkSP, nullptr);
return true;
}
}
return INDI::Dome::ISNewSwitch(dev, name, states, names, n);
}
Expand Down Expand Up @@ -802,7 +824,12 @@ IPState NexDome::Park()
IDSetNumber(&BatteryLevelNP, nullptr);
return IPS_ALERT;
}

MoveAbs(GetAxis1Park());

if (HasShutter() && IUFindOnSwitchIndex(&CloseShutterOnParkSP) == ENABLED)
ControlShutter(ShutterOperation::SHUTTER_CLOSE);

return IPS_BUSY;
}

Expand Down Expand Up @@ -964,6 +991,7 @@ bool NexDome::saveConfigItems(FILE * fp)
INDI::Dome::saveConfigItems(fp);

IUSaveConfigSwitch(fp, &ReversedSP);
IUSaveConfigSwitch(fp, &CloseShutterOnParkSP);

return true;
}
9 changes: 9 additions & 0 deletions 3rdparty/indi-nexdome/nex_dome.h
Expand Up @@ -61,6 +61,12 @@ class NexDome : public INDI::Dome
/// Properties
/////////////////////////////////////////////////////////////////////////////

enum
{
DISABLED,
ENABLED
};

ISwitchVectorProperty HomeSP;
ISwitch HomeS[1];

Expand All @@ -82,6 +88,9 @@ class NexDome : public INDI::Dome
ISwitchVectorProperty ReversedSP;
ISwitch ReversedS[2];

ISwitchVectorProperty CloseShutterOnParkSP;
ISwitch CloseShutterOnParkS[2];

private:
///////////////////////////////////////////////////////////////////////////////
/// Utility Functions
Expand Down

0 comments on commit 3fc7943

Please sign in to comment.