26static std::unique_ptr<ActiveFocuser> activeFocuser(
new ActiveFocuser());
28#define DRIVER_NAME "ActiveFocuser"
29#define DRIVER_VERSION_MAJOR 1
30#define DRIVER_VERSION_MINOR 1
32#define VENDOR_ID 0x20E1
33#define PRODUCT_ID 0x0002
97 return hid_handle !=
nullptr;
117 hid_handle =
nullptr;
150 HardwareVersionNP[0].
fill(
"Version infos",
"",
"1.04");
154 std::stringstream softwareVersionStream;
157 SoftwareVersionNP[0].
fill(
"Version infos",
"", softwareVersionStream.str().c_str());
163 AirTemperatureNP[0].
fill(
"AIR TEMPERATURE",
"Celsius",
"%6.2f", -50., 70., 0., 0.);
167 TubeTemperatureNP[0].
fill(
"TEMPERATURE",
"Celsius",
"%6.2f", -50., 70., 0., 0.);
171 MirrorTemperatureNP[0].
fill(
"MIRROR TEMPERATURE",
"Celsius",
"%6.2f", -50., 70., 0., 0.);
173 "Mirror Temperature",
268 FanSP.
update(states, names, n);
276 const unsigned char data[3] = {0x01,
279 hid_write(hid_handle, data,
sizeof(data));
285 IDLog(
"Connection failed");
296 const unsigned char data[3] = {0x01,
299 hid_write(hid_handle, data,
sizeof(data));
305 IDLog(
"Connection failed");
346 hid_write(hid_handle, data,
sizeof(data));
362 IDLog(
"Connection failed");
373 internalTicks = targetTicks;
392 for (
int i = 0; i < 4; ++i)
394 auto num = (targetTicks >> 8 * (3 - i) & 255);
398 hid_write(hid_handle, data,
sizeof(data));
428 int relativeTicks = ((dir ==
FOCUS_INWARD ? ticks : -ticks));
430 double newTicks = internalTicks + relativeTicks;
457 HardwareVersionNP.
apply();
465 AirTemperatureNP.
apply();
467 TubeTemperatureNP.
apply();
469 MirrorTemperatureNP.
apply();
474 FanSP.
apply(
nullptr);
479 FanSP.
apply(
nullptr);
#define DRIVER_VERSION_MINOR
#define DRIVER_VERSION_MAJOR
static Poller * GetInstance(hid_device &hid_handle)
static double GetTubeTemperature()
static int GetCurrentPositionStep()
static char * GetHardwareRevision()
static double GetMirrorTemperature()
static double GetAirTemperature()
static bool GetIsMoving()
static const std::map< Commands, unsigned char > CommandsMap
IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
void ISGetProperties(const char *dev) override
Handles client requests for property definitions for this device or all devices. Delegates to the bas...
bool Disconnect() override
Disconnect from device.
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 MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
bool AbortFocuser() override
AbortFocuser all focus motion.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
const char * getDefaultName() override
void setDefaultPollingPeriod(uint32_t msec)
setDefaultPollingPeriod Change the default polling period to call TimerHit() function in the driver.
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
INDI::PropertyNumber FocusRelPosNP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
INDI::PropertyNumber FocusSpeedNP
INDI::PropertyNumber FocusMaxPosNP
INDI::PropertyNumber FocusAbsPosNP
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
virtual void ISGetProperties(const char *dev) override
Handles client requests for property definitions for this device or all devices. Delegates to the bas...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
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...
INDI::PropertyNumber PresetNP
void setSupportedConnections(const uint8_t &value)
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isNameMatch(const char *otherName) const
void setPermission(IPerm permission)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
bool update(const ISState states[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number.
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 HID_API_EXPORT hid_close(hid_device *dev)
Close a HID device.
int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock)
Set the device handle to be non-blocking.
int HID_API_EXPORT hid_exit(void)
Finalize the HIDAPI library.
void IDLog(const char *fmt,...)