Skip to content

Commit

Permalink
Add capability to crash generic ccd
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Dec 26, 2023
1 parent 8cad1c3 commit db98fc8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
23 changes: 23 additions & 0 deletions examples/generic-ccd/generic_ccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ bool GenericCCD::initProperties()
uint32_t cap = CCD_CAN_ABORT | CCD_CAN_BIN | CCD_CAN_SUBFRAME | CCD_HAS_COOLER | CCD_HAS_SHUTTER | CCD_HAS_ST4_PORT;
SetCCDCapability(cap);

// Simulate Crash
IUFillSwitch(&CrashS[0], "CRASH", "Crash driver", ISS_OFF);
IUFillSwitchVector(&CrashSP, CrashS, 1, getDeviceName(), "CCD_SIMULATE_CRASH", "Crash", OPTIONS_TAB, IP_WO,
ISR_ATMOST1, 0, IPS_IDLE);

// Add configuration for Debug
addDebugControl();

Expand All @@ -114,6 +119,7 @@ bool GenericCCD::updateProperties()
{
// Let's get parameters now from CCD
setupParams();
defineProperty(&CrashSP);
SetTimer(getCurrentPollingPeriod());
}

Expand Down Expand Up @@ -658,3 +664,20 @@ IPState GenericCCD::GuideWest(uint32_t ms)

return IPS_OK;
}

///////////////////////////////////////////////////////////////////////////////////////
/// Crash simulation
///////////////////////////////////////////////////////////////////////////////////////
bool GenericCCD::ISNewSwitch(const char * dev, const char * name, ISState * states, char * names[], int n)
{
if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
{
if (strcmp(name, CrashSP.name) == 0)
{
abort();
}
}

return INDI::CCD::ISNewSwitch(dev, name, states, names, n);
}

36 changes: 20 additions & 16 deletions examples/generic-ccd/generic_ccd.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,38 @@ class GenericCCD : public INDI::CCD
GenericCCD(DEVICE device, const char *name);
virtual ~GenericCCD();

const char *getDefaultName();
const char *getDefaultName() override;

bool initProperties();
bool updateProperties();
bool initProperties() override;
bool updateProperties() override;

bool Connect();
bool Disconnect();
bool Connect() override;
bool Disconnect() override;

int SetTemperature(double temperature);
bool StartExposure(float duration);
bool AbortExposure();
int SetTemperature(double temperature) override;
bool StartExposure(float duration) override;
bool AbortExposure() override;

protected:
void TimerHit();
virtual bool UpdateCCDFrame(int x, int y, int w, int h);
virtual bool UpdateCCDBin(int binx, int biny);
virtual bool UpdateCCDFrameType(INDI::CCDChip::CCD_FRAME fType);
void TimerHit() override;
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
virtual bool UpdateCCDFrame(int x, int y, int w, int h) override;
virtual bool UpdateCCDBin(int binx, int biny) override;
virtual bool UpdateCCDFrameType(INDI::CCDChip::CCD_FRAME fType) override;

// Guide Port
virtual IPState GuideNorth(uint32_t ms);
virtual IPState GuideSouth(uint32_t ms);
virtual IPState GuideEast(uint32_t ms);
virtual IPState GuideWest(uint32_t ms);
virtual IPState GuideNorth(uint32_t ms) override;
virtual IPState GuideSouth(uint32_t ms) override;
virtual IPState GuideEast(uint32_t ms) override;
virtual IPState GuideWest(uint32_t ms) override;

private:
DEVICE device;
char m_Name[MAXINDINAME];

ISwitchVectorProperty CrashSP;
ISwitch CrashS[1];

INDI::ElapsedTimer m_ElapsedTimer;
double ExposureRequest;
double TemperatureRequest;
Expand Down

0 comments on commit db98fc8

Please sign in to comment.