Skip to content

Commit

Permalink
Update CCD simulator property SimulateBayerSP
Browse files Browse the repository at this point in the history
  • Loading branch information
naheedsa committed Feb 7, 2024
1 parent 0583a75 commit cc74fcf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
24 changes: 12 additions & 12 deletions drivers/ccd/ccd_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ bool CCDSim::initProperties()
"Settings", SIMULATOR_TAB, IP_RW, 60, IPS_IDLE);

// RGB Simulation
IUFillSwitch(&SimulateBayerS[INDI_ENABLED], "INDI_ENABLED", "Enabled", ISS_OFF);
IUFillSwitch(&SimulateBayerS[INDI_DISABLED], "INDI_DISABLED", "Disabled", ISS_ON);
IUFillSwitchVector(&SimulateBayerSP, SimulateBayerS, 2, getDeviceName(), "SIMULATE_BAYER", "Bayer", SIMULATOR_TAB, IP_RW,
SimulateBayerSP[INDI_ENABLED].fill("INDI_ENABLED", "Enabled", ISS_OFF);
SimulateBayerSP[INDI_DISABLED].fill("INDI_DISABLED", "Disabled", ISS_ON);
SimulateBayerSP.fill(getDeviceName(), "SIMULATE_BAYER", "Bayer", SIMULATOR_TAB, IP_RW,
ISR_1OFMANY, 60, IPS_IDLE);

// Simulate focusing
Expand Down Expand Up @@ -265,7 +265,7 @@ void CCDSim::ISGetProperties(const char * dev)
defineProperty(&SimulatorSettingsNP);
defineProperty(&EqPENP);
defineProperty(&FocusSimulationNP);
defineProperty(&SimulateBayerSP);
defineProperty(SimulateBayerSP);
defineProperty(&CrashSP);
}

Expand Down Expand Up @@ -1151,15 +1151,15 @@ bool CCDSim::ISNewSwitch(const char * dev, const char * name, ISState * states,
if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
{
// Simulate RGB
if (!strcmp(name, SimulateBayerSP.name))
if (SimulateBayerSP.isNameMatch(name))
{
IUUpdateSwitch(&SimulateBayerSP, states, names, n);
int index = IUFindOnSwitchIndex(&SimulateBayerSP);
SimulateBayerSP.update(states, names, n);
int index = SimulateBayerSP.findOnSwitchIndex();
if (index == -1)
{
SimulateBayerSP.s = IPS_ALERT;
SimulateBayerSP.setState(IPS_ALERT);
LOG_INFO("Cannot determine whether RGB simulation should be switched on or off.");
IDSetSwitch(&SimulateBayerSP, nullptr);
SimulateBayerSP.apply();
return false;
}

Expand All @@ -1168,8 +1168,8 @@ bool CCDSim::ISNewSwitch(const char * dev, const char * name, ISState * states,

SimulateBayerS[INDI_ENABLED].s = m_SimulateBayer ? ISS_ON : ISS_OFF;
SimulateBayerS[INDI_DISABLED].s = m_SimulateBayer ? ISS_OFF : ISS_ON;
SimulateBayerSP.s = IPS_OK;
IDSetSwitch(&SimulateBayerSP, nullptr);
SimulateBayerSP.setState(IPS_OK);
SimulateBayerSP.apply();

return true;
}
Expand Down Expand Up @@ -1400,7 +1400,7 @@ bool CCDSim::saveConfigItems(FILE * fp)
ResolutionSP.save(fp);

// Bayer
IUSaveConfigSwitch(fp, &SimulateBayerSP);
SimulateBayerSP.save(fp);

// Focus simulation
IUSaveConfigNumber(fp, &FocusSimulationNP);
Expand Down
8 changes: 7 additions & 1 deletion drivers/ccd/ccd_simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ class CCDSim : public INDI::CCD, public INDI::FilterInterface
INumberVectorProperty SimulatorSettingsNP;
INumber SimulatorSettingsN[SIM_N];

ISwitchVectorProperty SimulateBayerSP;
INDI::PropertySwitch SimulateBayerSP {2};
enum
{
INDI_ENABLED,
INDI_DISABLED
};

ISwitch SimulateBayerS[2];

// We are going to snoop these from focuser
Expand Down

0 comments on commit cc74fcf

Please sign in to comment.