Instrument Neutral Distributed Interface INDI  1.9.5
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 
34 class FocusSim : public INDI::Focuser
35 {
36  public:
37  FocusSim();
38  virtual ~FocusSim() override = default;
39 
40  const char *getDefaultName() override;
41 
42  void ISGetProperties(const char *dev) override;
43  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
44  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
45 
46  protected:
47 
48  bool initProperties() override;
49  bool updateProperties() override;
50 
51  bool Connect() override;
52  bool Disconnect() override;
53 
54  virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
55  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
56  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
57  virtual bool SetFocuserSpeed(int speed) override;
58 
59  virtual bool SetFocuserBacklash(int32_t steps) override;
60  virtual bool SetFocuserBacklashEnabled(bool enabled) override;
61 
62  private:
63  double internalTicks { 0 };
64  double initTicks { 0 };
65 
66  // Seeing in arcseconds
67  INumberVectorProperty SeeingNP;
68  INumber SeeingN[1];
69 
70  // FWHM to be used by CCD driver to draw 'fuzzy' stars
71  INumberVectorProperty FWHMNP;
72  INumber FWHMN[1];
73 
74  // Temperature in celcius degrees
75  INumberVectorProperty TemperatureNP;
76  INumber TemperatureN[1];
77 
78  // Current mode of Focus simulator for testing purposes
79  enum
80  {
81  MODE_ALL,
82  MODE_ABSOLUTE,
83  MODE_RELATIVE,
84  MODE_TIMER,
85  MODE_COUNT
86  };
87  ISwitchVectorProperty ModeSP;
88  ISwitch ModeS[MODE_COUNT];
89 };
FocusSim
The FocusSim class provides a simple Focuser simulator that can simulator the following devices:
Definition: focus_simulator.h:34
IPState
IPState
Property state.
Definition: indiapi.h:158
ISwitch
One switch descriptor.
FocusSim::SetFocuserBacklash
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: focus_simulator.cpp:317
INumber
One number descriptor.
FocusSim::~FocusSim
virtual ~FocusSim() override=default
FocusSim::updateProperties
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: focus_simulator.cpp:121
indifocuser.h
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
FocusSim::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: focus_simulator.cpp:267
FocusSim::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: focus_simulator.cpp:297
FocusSim::ISGetProperties
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
Definition: focus_simulator.cpp:68
FocusSim::Connect
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: focus_simulator.cpp:43
FocusSim::getDefaultName
const char * getDefaultName() override
Definition: focus_simulator.cpp:60
FocusSim::FocusSim
FocusSim()
Definition: focus_simulator.cpp:35
name
const char * name
Definition: indiserver.c:116
FocusSim::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: focus_simulator.cpp:192
FocusSim::Disconnect
bool Disconnect() override
Disconnect from device.
Definition: focus_simulator.cpp:52
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
FocusSim::MoveFocuser
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.
Definition: focus_simulator.cpp:222
ISState
ISState
Switch state.
Definition: indiapi.h:148
FocusSim::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: focus_simulator.cpp:144
INDI::Focuser
Definition: indifocuser.h:43
FocusSim::SetFocuserSpeed
virtual bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
Definition: focus_simulator.cpp:308
FocusSim::SetFocuserBacklashEnabled
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
Definition: focus_simulator.cpp:326
FocusSim::initProperties
bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: focus_simulator.cpp:82
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365