27static std::unique_ptr<FocusSim> focusSim(
new FocusSim());
60 return "Focuser Simulator";
84 SeeingNP[0].
fill(
"SIM_SEEING",
"arcseconds",
"%4.2f", 0, 60, 0, 3.5);
88 FWHMNP[0].
fill(
"SIM_FWHM",
"arcseconds",
"%4.2f", 0, 60, 0, 7.5);
91 TemperatureNP[0].
fill(
"TEMPERATURE",
"Celsius",
"%6.2f", -50., 70., 0., 0.);
95 DelayNP[0].
fill(
"DELAY_VALUE",
"Value (uS)",
"%.f", 0, 60000, 100, 100);
99 ModeSP[MODE_ABSOLUTE].
fill(
"Absolute",
"Absolute",
ISS_OFF);
100 ModeSP[MODE_RELATIVE].
fill(
"Relative",
"Relative",
ISS_OFF);
101 ModeSP[MODE_TIMER].
fill(
"Timer",
"Timer",
ISS_OFF);
105 initTicks = sqrt(FWHMNP[0].getValue() - SeeingNP[0].getValue()) / 0.75;
154 ModeSP.
update(states, names, n);
200 if (strcmp(name,
"SEEING_SETTINGS") == 0)
203 SeeingNP.
update(values, names, n);
209 if (strcmp(name,
"FOCUS_TEMPERATURE") == 0)
212 TemperatureNP.
update(values, names, n);
214 TemperatureNP.
apply();
221 DelayNP.
update(values, names, n);
240 double targetTicks = ((dir ==
FOCUS_INWARD) ? -1 : 1) * (speed * duration);
242 internalTicks += targetTicks;
244 if (mode == MODE_ALL)
248 internalTicks -= targetTicks;
249 LOG_ERROR(
"Cannot move focuser in this direction any further.");
255 usleep(duration * 1000);
257 double ticks = initTicks + (internalTicks - mid) / 5000.0;
259 FWHMNP[0].setValue(0.5625 * ticks * ticks + SeeingNP[0].getValue());
261 LOGF_DEBUG(
"TIMER Current internal ticks: %g FWHM ticks: %g FWHM: %g", internalTicks, ticks,
262 FWHMNP[0].getValue());
264 if (mode == MODE_ALL)
270 if (FWHMNP[0].getValue() < SeeingNP[0].getValue())
271 FWHMNP[0].setValue(SeeingNP[0].getValue());
285 internalTicks = targetTicks;
288 double ticks = initTicks + (targetTicks - mid) / 5000.0;
291 usleep(std::abs((targetTicks -
FocusAbsPosNP[0].getValue()) * DelayNP[0].getValue()));
295 FWHMNP[0].setValue(0.5625 * ticks * ticks + SeeingNP[0].getValue());
297 LOGF_DEBUG(
"ABS Current internal ticks: %g FWHM ticks: %g FWHM: %g", internalTicks, ticks,
298 FWHMNP[0].getValue());
300 if (FWHMNP[0].getValue() < SeeingNP[0].getValue())
301 FWHMNP[0].setValue(SeeingNP[0].getValue());
The FocusSim class provides a simple Focuser simulator that can simulator the following devices:
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
void ISGetProperties(const char *dev) override
Handles client requests for property definitions for this device or all devices. Delegates to the bas...
bool Disconnect() override
Disconnect from device.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
const char * getDefaultName() override
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override
MoveFocuser the focuser in a particular direction with a specific speed for a finite duration.
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool saveConfigItems(FILE *fp) override
bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
virtual bool loadConfig(bool silent=false, const char *property=nullptr)
Load the last saved configuration file.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
@ FOCUSER_HAS_VARIABLE_SPEED
INDI::PropertyNumber FocusSpeedNP
INDI::PropertyNumber FocusAbsPosNP
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
virtual bool saveConfigItems(FILE *fp) override
virtual void ISGetProperties(const char *dev) override
Handles client requests for property definitions for this device or all devices. Delegates to the bas...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
void save(FILE *f) const
save Save property to configuration file.
const char * getName() const
bool isNameMatch(const char *otherName) const
bool update(const double values[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
bool update(const ISState states[], const char *const names[], int n)
int findOnSwitchIndex() const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...