Instrument Neutral Distributed Interface INDI 2.2.5
smartfocus.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2015,2020 Camiel Severijns. 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
24{
25 public:
26 SmartFocus();
27
28 const char *getDefaultName() override;
29
30 bool initProperties() override;
31 bool updateProperties() override;
32
33 virtual bool Handshake() override;
34
35 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
36 //virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) override;
37
38 virtual bool AbortFocuser() override;
39 virtual IPState MoveAbsFocuser(uint32_t targetPosition) override;
40 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
41 virtual void TimerHit() override;
42
43 typedef unsigned short Position;
44 protected:
45 virtual bool saveConfigItems(FILE *fp) override;
46
47 private:
48 typedef unsigned char Flags;
49
50 enum State
51 {
52 Idle,
53 MovingTo,
54 MovingIn,
55 MovingOut
56 };
57
58 enum StatusFlags
59 {
60 STATUS_SERIAL_FRAMING_ERROR = 0,
61 STATUS_SERIAL_OVERRUN_ERROR,
62 STATUS_MOTOR_ENCODE_ERROR,
63 STATUS_AT_ZERO_POSITION,
64 STATUS_AT_MAX_POSITION,
65 STATUS_NUM_FLAGS
66 };
67
68 enum FlagBits
69 {
70 SerFramingError = 0x02,
71 SerOverrunError = 0x04,
72 MotorEncoderError = 0x08,
73 AtZeroPosition = 0x40,
74 AtMaxPosition = 0x80
75 };
76
77 bool SFacknowledge();
78 bool SFisIdle() const
79 {
80 return (state == Idle);
81 }
82 bool SFisMoving() const
83 {
84 return !SFisIdle();
85 }
86 Position SFgetPosition();
87 Flags SFgetFlags();
88 void SFgetState();
89
90 bool send(const char *command, const size_t nbytes, const char *from, const bool log_error = true);
91 bool recv(char *respons, const size_t nbytes, const char *from, const bool log_error = true);
92
93 Position position { 0 };
94 State state { Idle };
95 int timer_id { 0 };
96
97 ILight FlagsL[5];
99 INumber MotionErrorN[1];
100 INumberVectorProperty MotionErrorNP;
101};
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
const char * getDefaultName() override
virtual IPState MoveAbsFocuser(uint32_t targetPosition) override
MoveFocuser the focuser to an absolute position.
bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool saveConfigItems(FILE *fp) override
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
unsigned short Position
Definition smartfocus.h:43
bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
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...
IPState
Property state.
Definition indiapi.h:158
State
Definition lilxml.cpp:74
One light descriptor.
One number descriptor.
Light vector property descriptor.
Definition indiapi.h:415
Number vector property descriptor.
Definition indiapi.h:317