30 for (
int i = 0; i < 4; ++i)
32 num = num << 8 |
buffer[position + i];
62 std::stringstream outputStream;
64 for (
int i = 0; i < (int)
sizeof(
buffer); i++)
66 outputStream << std::hex << (int)
buffer[i];
69 IDLog(
"%s\r\n", outputStream.str().c_str());
76 std::stringstream sst;
78 sst <<
"Current device (v " <<
86 IDLog(
"%s\r\n", sst.str().c_str());
93 std::mutex ActiveFocuserUtils::Poller::mutex_;
107 std::lock_guard<std::mutex> lock(mutex_);
108 if (pinstance_ ==
nullptr)
120 while (
futureObjSender.wait_for(std::chrono::milliseconds(1000)) == std::future_status::timeout)
129 IDLog(
"Unable to write \r\n");
138 while (
futureObj.wait_for(std::chrono::milliseconds(1)) == std::future_status::timeout)
141 unsigned char buf[256];
152 std::stringstream ssVersion;
171 IDLog(
"Unable to read \r\n");
187 IDLog(
"Poller started\r\n");
202 IDLog(
"Poller stopped\r\n");
212 static int CurrentPositionStep;
213 static double CurrentPosition;
214 static bool IsOrigin;
217 static bool IsMoving;
218 static char * HardwareRevision;
222 static double AirTemperature;
223 static double TubeTemperature;
224 static double MirrorTemperature;
230 return CurrentPositionStep;
235 CurrentPositionStep = currentPositionStep;
240 return CurrentPosition;
248 bool ActiveFocuserUtils::SystemState::GetIsOrigin()
290 return HardwareRevision;
295 HardwareRevision = hardwareRevision;
330 return AirTemperature;
335 AirTemperature = airTemperature;
340 return TubeTemperature;
345 TubeTemperature = tubeTemperature;
350 return MirrorTemperature;
355 MirrorTemperature = mirrorTemperature;
362 {ActiveFocuserUtils::Commands::ZERO, 0x03},
363 {ActiveFocuserUtils::Commands::RELEASE, 0x04},
364 {ActiveFocuserUtils::Commands::FREE, 0x06},
365 {ActiveFocuserUtils::Commands::AUTO, 0x07},
366 {ActiveFocuserUtils::Commands::MOVE, 0x09},
367 {ActiveFocuserUtils::Commands::STOP, 0x0A},
368 {ActiveFocuserUtils::Commands::FAN_ON, 0x0B},
369 {ActiveFocuserUtils::Commands::FAN_OFF, 0x0C},
370 {ActiveFocuserUtils::Commands::RESET, 0x7E},
371 {ActiveFocuserUtils::Commands::DUMMY, 0xFF},
std::future< void > futureObjSender
void threaded_poller(std::future< void > futureObj)
std::future< void > futureObj
std::promise< void > exitSignal
void threaded_sender(std::future< void > futureObjSender)
unsigned char poller_buffer[60]
std::promise< void > exitSignalSender
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)
static Poller * GetInstance(hid_device &hid_handle)
static void SetAirTemperature(double airTemperature)
static void SetIsOrigin(bool isOrigin)
static void SetTubeTemperature(double tubeTemperature)
static void SetImmpp(int immpp)
static double GetTubeTemperature()
static int GetCurrentPositionStep()
static void SetHardwareRevision(char *hardwareRevision)
static void SetMirrorTemperature(double mirrorTemperature)
static void SetSpan(int span)
static char * GetHardwareRevision()
static void SetMmpp(double mmpp)
static double GetCurrentPosition()
static double GetMirrorTemperature()
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 double GetAirTemperature()
static bool GetIsMoving()
static const std::map< Commands, unsigned char > CommandsMap
int HID_API_EXPORT hid_read(hid_device *dev, unsigned char *data, size_t length)
Read an Input report from a HID device.
int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length)
Write an Output report to a HID device.
void IDLog(const char *fmt,...)
std::vector< uint8_t > buffer
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values