27 static std::unique_ptr<FocusSim> focusSim(
new FocusSim());
59 return "Focuser Simulator";
83 IUFillNumber(&SeeingN[0],
"SIM_SEEING",
"arcseconds",
"%4.2f", 0, 60, 0, 3.5);
87 IUFillNumber(&FWHMN[0],
"SIM_FWHM",
"arcseconds",
"%4.2f", 0, 60, 0, 7.5);
90 IUFillNumber(&TemperatureN[0],
"TEMPERATURE",
"Celsius",
"%6.2f", -50., 70., 0., 0.);
94 DelayNP[0].
fill(
"DELAY_VALUE",
"Value (uS)",
"%.f", 0, 60000, 100, 100);
104 initTicks = sqrt(FWHMN[0].value - SeeingN[0].value) / 0.75;
151 if (strcmp(ModeSP.
name, name) == 0)
177 IDSetSwitch(&ModeSP,
"Unknown mode index %d", index);
198 if (strcmp(name,
"SEEING_SETTINGS") == 0)
207 if (strcmp(name,
"FOCUS_TEMPERATURE") == 0)
219 DelayNP.
update(values, names, n);
238 double targetTicks = ((dir ==
FOCUS_INWARD) ? -1 : 1) * (speed * duration);
240 internalTicks += targetTicks;
242 if (mode == MODE_ALL)
246 internalTicks -= targetTicks;
247 LOG_ERROR(
"Cannot move focuser in this direction any further.");
253 usleep(duration * 1000);
255 double ticks = initTicks + (internalTicks - mid) / 5000.0;
257 FWHMN[0].value = 0.5625 * ticks * ticks + SeeingN[0].value;
259 LOGF_DEBUG(
"TIMER Current internal ticks: %g FWHM ticks: %g FWHM: %g", internalTicks, ticks,
262 if (mode == MODE_ALL)
268 if (FWHMN[0].value < SeeingN[0].value)
269 FWHMN[0].value = SeeingN[0].value;
283 internalTicks = targetTicks;
286 double ticks = initTicks + (targetTicks - mid) / 5000.0;
289 usleep(std::abs((targetTicks -
FocusAbsPosN[0].value) * DelayNP[0].getValue()));
293 FWHMN[0].value = 0.5625 * ticks * ticks + SeeingN[0].value;
295 LOGF_DEBUG(
"ABS Current internal ticks: %g FWHM ticks: %g FWHM: %g", internalTicks, ticks,
298 if (FWHMN[0].value < SeeingN[0].value)
299 FWHMN[0].value = SeeingN[0].value;
The FocusSim class provides a simple Focuser simulator that can simulator the following devices:
bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
bool Disconnect() override
Disconnect from device.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
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
Process the client newSwitch command.
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
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
const char * getDeviceName() const
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.
INumberVectorProperty FocusAbsPosNP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
@ FOCUSER_HAS_VARIABLE_SPEED
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
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)
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,...
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...