26 static std::unique_ptr<ActiveFocuser> activeFocuser(
new ActiveFocuser());
28 #define DRIVER_NAME "ActiveFocuser"
29 #define DRIVER_VERSION_MAJOR 1
30 #define DRIVER_VERSION_MINOR 0
32 #define VENDOR_ID 0x20E1
33 #define PRODUCT_ID 0x0002
97 return hid_handle !=
nullptr;
117 hid_handle =
nullptr;
150 IUFillText(&HardwareVersionN[0],
"Version infos",
"",
"1.04");
154 std::stringstream softwareVersionStream;
157 IUFillText(&SoftwareVersionN[0],
"Version infos",
"", softwareVersionStream.str().c_str());
163 IUFillNumber(&AirTemperatureN[0],
"AIR TEMPERATURE",
"Celsius",
"%6.2f", -50., 70., 0., 0.);
167 IUFillNumber(&TubeTemperatureN[0],
"TUBE TEMPERATURE",
"Celsius",
"%6.2f", -50., 70., 0., 0.);
171 IUFillNumber(&MirrorTemperatureN[0],
"MIRROR TEMPERATURE",
"Celsius",
"%6.2f", -50., 70., 0., 0.);
173 "Mirror Temperature",
180 IUFillSwitchVector(&FanSP, FanS, 2,
getDeviceName(),
"FAN_STATE",
"Fan",
MAIN_CONTROL_TAB,
IP_RW,
ISR_1OFMANY, 60,
265 if (strcmp(FanSP.
name, name) == 0)
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;
#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
Initilize properties initial state and value. The child class must implement this function.
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
bool Disconnect() override
Disconnect from device.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
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
Process the client newSwitch command.
const char * getDefaultName() override
const char * getDeviceName() const
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.
INumberVectorProperty FocusSpeedNP
INumberVectorProperty FocusAbsPosNP
INumberVectorProperty FocusRelPosNP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
INumberVectorProperty FocusMaxPosNP
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
void setSupportedConnections(const uint8_t &value)
setConnection Set Focuser connection mode. Child class should call this in the constructor before Foc...
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,...)
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
void IUUpdateMinMax(const INumberVectorProperty *nvp)
Function to update the min and max elements of a number in the client.
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)