Instrument Neutral Distributed Interface INDI 2.2.5
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
27#ifdef _USE_SYSTEM_HIDAPILIB
28#include <hidapi/hidapi.h>
29#else
30#include <indi_hidapi.h>
31#endif
32
33#include <mutex>
34#include <future>
35#include <cstring>
36#include <chrono>
37#include <cmath>
38#include <memory>
39#include <indifocuser.h>
40#include "activefocuser.h"
41
43{
44
45 public :
46
60
61 static const std::map<Commands, unsigned char> CommandsMap;
62
63 class Parser
64 {
65 public :
66 static int Get32(const unsigned char *buffer, int position);
67 static int Get16(const unsigned char *buffer, int position);
68 static double TicksToMillimeters(int ticks);
69 static int MillimetersToTicks(double millimeters);
70 static void PrintFrame(const unsigned char *buffer);
71 static void PrintBasicDeviceData(const unsigned char *buffer);
72 private:
73 Parser() = delete;
74 ~Parser() = delete;
75 void operator=(const Parser &) = delete;
76
77 };
78
79 class Poller
80 {
81 public:
82 static Poller *GetInstance(hid_device &hid_handle);
84 bool Start();
85 bool Stop();
86 protected:
87 Poller(hid_device &hid_handle) : hid_handle_(hid_handle) {}
90 private:
91 Poller(Poller &other) = delete;
92 void operator=(const Poller &) = delete;
93 static Poller *pinstance_;
94 static std::mutex mutex_;
95 };
96
98 {
99
100 public:
101 static int GetCurrentPositionStep();
102 static void SetCurrentPositionStep(int currentPositionStep);
103 static double GetCurrentPosition();
104 static void SetCurrentPosition(double currentPosition);
105 static void SetIsOrigin(bool isOrigin);
106 static bool GetIsMoving();
107 static void SetIsMoving(bool isMoving);
108 static bool GetIsFanOn();
109 static void SetIsFanOn(bool isFanOn);
110 static bool GetIsHold();
111 static void SetIsHold(bool isHold);
112 static char * GetHardwareRevision();
113 static void SetHardwareRevision(char * hardwareRevision);
114 static int GetImmpp();
115 static void SetImmpp(int immpp);
116 static int GetSpan();
117 static void SetSpan(int span);
118 static double GetMmpp();
119 static void SetMmpp(double mmpp);
120 static double GetAirTemperature();
121 static void SetAirTemperature(double airTemperature);
122 static double GetTubeTemperature();
123 static void SetTubeTemperature(double tubeTemperature);
124 static double GetMirrorTemperature();
125 static void SetMirrorTemperature(double mirrorTemperature);
126 private:
127 SystemState() = delete;
128 ~SystemState() = delete;
129 void operator=(const SystemState &) = delete;
130
131 bool GetIsOrigin();
132 };
133
134 private:
135 ActiveFocuserUtils() = delete;
136 ~ActiveFocuserUtils() = delete;
137 void operator=(const ActiveFocuserUtils &) = delete;
138
139};
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 const std::map< Commands, unsigned char > CommandsMap