Instrument Neutral Distributed Interface INDI  2.0.2
activefocuser_utils.h
Go to the documentation of this file.
1 /*
2  ActiveFocuser driver for Takahashi CCA-250 and Mewlon-250/300CRS
3 
4  Driver written by Alvin FREY <https://afrey.fr> for Optique Unterlinden and Takahashi Europe
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 */
21 
22 #pragma once
23 
24 #include <map>
25 #include <string>
26 #include <hidapi.h>
27 #include <mutex>
28 #include <future>
29 #include <cstring>
30 #include <chrono>
31 #include <cmath>
32 #include <memory>
33 #include <indifocuser.h>
34 #include "activefocuser.h"
35 
37 {
38 
39  public :
40 
41  typedef enum
42  {
52  DUMMY
54 
55  static const std::map<Commands, unsigned char> CommandsMap;
56 
57  class Parser
58  {
59  public :
60  static int Get32(const unsigned char *buffer, int position);
61  static int Get16(const unsigned char *buffer, int position);
62  static double TicksToMillimeters(int ticks);
63  static int MillimetersToTicks(double millimeters);
64  static void PrintFrame(const unsigned char *buffer);
65  static void PrintBasicDeviceData(const unsigned char *buffer);
66  private:
67  Parser() = delete;
68  ~Parser() = delete;
69  void operator=(const Parser &) = delete;
70 
71  };
72 
73  class Poller
74  {
75  public:
76  static Poller *GetInstance(hid_device &hid_handle);
77  bool IsRunning;
78  bool Start();
79  bool Stop();
80  protected:
81  Poller(hid_device &hid_handle) : hid_handle_(hid_handle) {}
82  ~Poller() {}
84  private:
85  Poller(Poller &other) = delete;
86  void operator=(const Poller &) = delete;
87  static Poller *pinstance_;
88  static std::mutex mutex_;
89  };
90 
92  {
93 
94  public:
95  static int GetCurrentPositionStep();
96  static void SetCurrentPositionStep(int currentPositionStep);
97  static double GetCurrentPosition();
98  static void SetCurrentPosition(double currentPosition);
99  static void SetIsOrigin(bool isOrigin);
100  static bool GetIsMoving();
101  static void SetIsMoving(bool isMoving);
102  static bool GetIsFanOn();
103  static void SetIsFanOn(bool isFanOn);
104  static bool GetIsHold();
105  static void SetIsHold(bool isHold);
106  static char * GetHardwareRevision();
107  static void SetHardwareRevision(char * hardwareRevision);
108  static int GetImmpp();
109  static void SetImmpp(int immpp);
110  static int GetSpan();
111  static void SetSpan(int span);
112  static double GetMmpp();
113  static void SetMmpp(double mmpp);
114  static double GetAirTemperature();
115  static void SetAirTemperature(double airTemperature);
116  static double GetTubeTemperature();
117  static void SetTubeTemperature(double tubeTemperature);
118  static double GetMirrorTemperature();
119  static void SetMirrorTemperature(double mirrorTemperature);
120  private:
121  SystemState() = delete;
122  ~SystemState() = delete;
123  void operator=(const SystemState &) = delete;
124 
125  bool GetIsOrigin();
126  };
127 
128  private:
129  ActiveFocuserUtils() = delete;
130  ~ActiveFocuserUtils() = delete;
131  void operator=(const ActiveFocuserUtils &) = delete;
132 
133 };
static void PrintBasicDeviceData(const unsigned char *buffer)
static int Get32(const unsigned char *buffer, int position)
static double TicksToMillimeters(int ticks)
static int MillimetersToTicks(double millimeters)
static void PrintFrame(const unsigned char *buffer)
static int Get16(const unsigned char *buffer, int position)
Poller(hid_device &hid_handle)
static Poller * GetInstance(hid_device &hid_handle)
static void SetAirTemperature(double airTemperature)
static void SetIsOrigin(bool isOrigin)
static void SetTubeTemperature(double tubeTemperature)
static void SetHardwareRevision(char *hardwareRevision)
static void SetMirrorTemperature(double mirrorTemperature)
static void SetIsFanOn(bool isFanOn)
static void SetCurrentPositionStep(int currentPositionStep)
static void SetCurrentPosition(double currentPosition)
static void SetIsMoving(bool isMoving)
static void SetIsHold(bool isHold)
static const std::map< Commands, unsigned char > CommandsMap
std::vector< uint8_t > buffer
#define currentPosition
Definition: robofocus.cpp:37