30 static std::unique_ptr<lacerta_mfoc> Lacerta_mfoc(
new lacerta_mfoc());
33 #define FOCUSMFOC_TIMEOUT 1000
35 #define MFOC_POSMAX_HARDWARE 250000
36 #define MFOC_POSMIN_HARDWARE 300
51 return "Lacerta MFOC";
87 IUFillNumber(&TempCompN[0],
"TEMPCOMP",
"step/10 degC",
"%4.2f", -5000, 5000, 1, 65);
150 char MFOC_cmd[32] =
": Q #";
151 char MFOC_res[32] = {0};
152 char MFOC_res_type[32] =
"0";
153 int MFOC_pos_measd = 0;
154 int nbytes_written = 0;
163 sscanf(MFOC_res,
"%s %d", MFOC_res_type, &MFOC_pos_measd);
165 if (MFOC_res_type[0] ==
'P')
183 if (strcmp(TempTrackDirSP.
name, name) == 0)
188 char MFOC_cmd[32] =
": I ";
189 char MFOC_res[32] = {0};
191 int nbytes_written = 0;
192 int MFOC_tdir_measd = 0;
193 char MFOC_res_type[32] =
"0";
199 strcat(MFOC_cmd,
"0 #");
204 strcat(MFOC_cmd,
"1 #");
209 strcat(MFOC_cmd,
"2 #");
214 IDSetSwitch(&TempTrackDirSP,
"Unknown mode index %d", index);
223 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_tdir_measd);
226 if (MFOC_tdir_measd == tdir)
241 if (strcmp(StartSavedPositionSP.
name, name) == 0)
246 char MFOC_cmd[32] =
": F ";
247 char MFOC_res[32] = {0};
249 int nbytes_written = 0;
250 int MFOC_svstart_measd = 0;
251 char MFOC_res_type[32] =
"0";
257 strcat(MFOC_cmd,
"1 #");
262 strcat(MFOC_cmd,
"0 #");
267 IDSetSwitch(&StartSavedPositionSP,
"Unknown mode index %d", index);
275 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_svstart_measd);
279 if (MFOC_svstart_measd == svstart)
281 StartSavedPositionSP.
s =
IPS_OK;
306 if (strcmp(name,
"TEMPCOMP_SETTINGS") == 0)
308 return SetTempComp(values, names, n);
323 char MFOC_cmd[32] =
": B ";
324 char MFOC_res[32] = {0};
326 int nbytes_written = 0;
327 int MFOC_tdir_measd = 0;
329 char bl_char[32] = {0};
330 char MFOC_res_type[32] =
"0";
334 sprintf(bl_char,
"%d", steps);
335 strcat(bl_char,
" #");
336 strcat(MFOC_cmd, bl_char);
344 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_tdir_measd);
353 bool lacerta_mfoc::SetTempComp(
double values[],
char *names[],
int n)
355 char MFOC_cmd[32] =
": D ";
356 char MFOC_res[32] = {0};
358 int nbytes_written = 0;
359 int MFOC_tc_measd = 0;
361 char tc_char[32] = {0};
362 char MFOC_res_type[32] =
"0";
365 tc_int = TempCompN[0].value;
366 sprintf(tc_char,
"%d", tc_int);
367 strcat(tc_char,
" #");
368 strcat(MFOC_cmd, tc_char);
376 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_tc_measd);
387 char MFOC_cmd[32] =
": G ";
388 char MFOC_res[32] = {0};
390 int nbytes_written = 0;
391 int MFOC_pm_measd = 0;
392 char pm_char[32] = {0};
393 char MFOC_res_type[32] =
"0";
395 sprintf(pm_char,
"%d", ticks);
396 strcat(pm_char,
" #");
397 strcat(MFOC_cmd, pm_char);
405 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_pm_measd);
416 char MFOC_cmd[32] =
": M ";
417 char abs_pos_char[32] = {0};
418 int nbytes_written = 0;
421 sprintf(abs_pos_char,
"%d", targetTicks);
422 strcat(abs_pos_char,
" #");
423 strcat(MFOC_cmd, abs_pos_char);
429 GetAbsFocuserPosition();
464 uint32_t lacerta_mfoc::GetAbsFocuserPosition()
466 char MFOC_cmd[32] =
": Q #";
467 char MFOC_res[32] = {0};
468 char MFOC_res_type[32] =
"0";
469 int MFOC_pos_measd = 0;
471 int nbytes_written = 0;
481 sscanf(MFOC_res,
"%s %d", MFOC_res_type, &MFOC_pos_measd);
484 while(strcmp(MFOC_res_type,
"P") != 0 && count < 100);
487 LOGF_DEBUG(
"current position: %d", MFOC_pos_measd);
489 return static_cast<uint32_t
>(MFOC_pos_measd);
const char * getDeviceName() const
virtual bool loadConfig(bool silent=false, const char *property=nullptr)
Load the last saved configuration file.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
INumberVectorProperty FocusAbsPosNP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
INumber FocusBacklashN[1]
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
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.
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool Handshake() override
perform handshake with device to check communication
const char * getDefaultName() override
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 SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
Implementations for common driver routines.
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.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
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 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,...)
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
#define LOGF_DEBUG(fmt,...)
#define MFOC_POSMAX_HARDWARE
#define FOCUSMFOC_TIMEOUT
#define MFOC_POSMIN_HARDWARE