Instrument Neutral Distributed Interface INDI  2.0.2
focus_simulator.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2012 Jasem Mutlaq. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7  .
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12  .
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 *******************************************************************************/
18 
19 #pragma once
20 
21 #include "indifocuser.h"
22 #include "indipropertynumber.h"
23 
35 class FocusSim : public INDI::Focuser
36 {
37  public:
38  FocusSim();
39  virtual ~FocusSim() override = default;
40 
41  const char *getDefaultName() override;
42 
43  void ISGetProperties(const char *dev) override;
44  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
45  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
46 
47  protected:
48 
49  bool initProperties() override;
50  bool updateProperties() override;
51 
52  bool Connect() override;
53  bool Disconnect() override;
54 
55  virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
56  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
57  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
58  virtual bool SetFocuserSpeed(int speed) override;
59 
60  virtual bool SetFocuserBacklash(int32_t steps) override;
61  virtual bool SetFocuserBacklashEnabled(bool enabled) override;
62 
63  virtual bool saveConfigItems(FILE *fp) override;
64 
65  private:
66  double internalTicks { 0 };
67  double initTicks { 0 };
68 
69  // Seeing in arcseconds
70  INumberVectorProperty SeeingNP;
71  INumber SeeingN[1];
72 
73  // FWHM to be used by CCD driver to draw 'fuzzy' stars
74  INumberVectorProperty FWHMNP;
75  INumber FWHMN[1];
76 
77  // Temperature in celcius degrees
78  INumberVectorProperty TemperatureNP;
79  INumber TemperatureN[1];
80 
81  INDI::PropertyNumber DelayNP {1};
82 
83  // Current mode of Focus simulator for testing purposes
84  enum
85  {
86  MODE_ALL,
87  MODE_ABSOLUTE,
88  MODE_RELATIVE,
89  MODE_TIMER,
90  MODE_COUNT
91  };
92  ISwitchVectorProperty ModeSP;
93  ISwitch ModeS[MODE_COUNT];
94 };
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 ~FocusSim() override=default
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.
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367