Skip to content

Commit

Permalink
Update SnapCap driver to use common abort capability from DustCapInte…
Browse files Browse the repository at this point in the history
…rface instead of doing it manually. (#2136)
  • Loading branch information
jpaana authored Oct 10, 2024
1 parent 3c35e75 commit c2530d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
21 changes: 4 additions & 17 deletions drivers/auxiliary/snapcap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
Copyright(c) 2017-2023 Jarno Paananen. All right reserved.
Copyright(c) 2017-2024 Jarno Paananen. All right reserved.
Based on Flip Flat driver by:
Expand Down Expand Up @@ -45,7 +45,7 @@ std::unique_ptr<SnapCap> snapcap(new SnapCap());

SnapCap::SnapCap() : LightBoxInterface(this), DustCapInterface(this)
{
setVersion(1, 3);
setVersion(1, 4);
}

SnapCap::~SnapCap()
Expand All @@ -69,15 +69,11 @@ bool SnapCap::initProperties()
FirmwareTP[0].fill("VERSION", "Version", nullptr);
FirmwareTP.fill(getDeviceName(), "FIRMWARE", "Firmware", MAIN_CONTROL_TAB, IP_RO, 60, IPS_IDLE);

// Abort and force open/close buttons
AbortSP[0].fill("ABORT", "Abort", ISS_OFF);
AbortSP.fill(getDeviceName(), "ABORT", "Abort", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);

ForceSP[0].fill("OFF", "Off", ISS_ON);
ForceSP[1].fill("ON", "On", ISS_OFF);
ForceSP.fill(getDeviceName(), "FORCE", "Force movement", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);

DI::initProperties(MAIN_CONTROL_TAB);
DI::initProperties(MAIN_CONTROL_TAB, CAN_ABORT);
LI::initProperties(MAIN_CONTROL_TAB, CAN_DIM);

LightIntensityNP[0].setMin(0);
Expand Down Expand Up @@ -136,7 +132,6 @@ bool SnapCap::updateProperties()
}
defineProperty(StatusTP);
defineProperty(FirmwareTP);
defineProperty(AbortSP);
defineProperty(ForceSP);

getStartupData();
Expand All @@ -149,7 +144,6 @@ bool SnapCap::updateProperties()
}
deleteProperty(StatusTP);
deleteProperty(FirmwareTP);
deleteProperty(AbortSP);
deleteProperty(ForceSP);
}

Expand Down Expand Up @@ -220,13 +214,6 @@ bool SnapCap::ISNewSwitch(const char *dev, const char *name, ISState *states, ch
if (!dev || strcmp(dev, getDeviceName()))
return false;

if (AbortSP.isNameMatch(name))
{
AbortSP.reset();
AbortSP.setState(Abort());
AbortSP.apply();
return true;
}
if (ForceSP.isNameMatch(name))
{
ForceSP.update(states, names, n);
Expand Down Expand Up @@ -368,7 +355,7 @@ IPState SnapCap::UnParkCap()
return IPS_ALERT;
}

IPState SnapCap::Abort()
IPState SnapCap::AbortCap()
{
if (isSimulation())
{
Expand Down
11 changes: 4 additions & 7 deletions drivers/auxiliary/snapcap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
Copyright(c) 2017-2023 Jarno Paananen. All right reserved.
Copyright(c) 2017-2024 Jarno Paananen. All right reserved.
Driver for SnapCap dust cap / flat panel
Expand Down Expand Up @@ -84,6 +84,7 @@ class SnapCap : public INDI::DefaultDevice, public INDI::LightBoxInterface, publ
// From Dust Cap
virtual IPState ParkCap() override;
virtual IPState UnParkCap() override;
virtual IPState AbortCap() override;

// From Light Box
virtual bool SetLightBoxBrightness(uint16_t value) override;
Expand All @@ -100,17 +101,12 @@ class SnapCap : public INDI::DefaultDevice, public INDI::LightBoxInterface, publ

bool sendCommand(const char *command, char *response);

IPState Abort();

// Status
INDI::PropertyText StatusTP{3};

// Firmware version
INDI::PropertyText FirmwareTP{1};

// Abort
INDI::PropertySwitch AbortSP{1};

// Force open & close
INDI::PropertySwitch ForceSP{2};

Expand All @@ -128,4 +124,5 @@ class SnapCap : public INDI::DefaultDevice, public INDI::LightBoxInterface, publ

private:
bool callHandshake();
uint8_t dustcapConnection = CONNECTION_SERIAL | CONNECTION_TCP;};
uint8_t dustcapConnection = CONNECTION_SERIAL | CONNECTION_TCP;
};

0 comments on commit c2530d1

Please sign in to comment.