30static 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";
65 TempTrackDirSP.
load();
68 StartSavedPositionSP.
load();
87 TempCompNP[0].
fill(
"TEMPCOMP",
"step/10 degC",
"%4.2f", -5000, 5000, 1, 65);
100 TempTrackDirSP[MODE_TDIR_BOTH].
fill(
"Both",
"Both",
ISS_ON);
101 TempTrackDirSP[MODE_TDIR_IN].
fill(
"In",
"In",
ISS_ON);
102 TempTrackDirSP[MODE_TDIR_OUT].
fill(
"Out",
"Out",
ISS_ON);
107 StartSavedPositionSP[MODE_SAVED_ON].
fill(
"Yes",
"Yes",
ISS_ON);
108 StartSavedPositionSP[MODE_SAVED_OFF].
fill(
"No",
"No",
ISS_OFF);
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')
185 TempTrackDirSP.
update(states, names, n);
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 #");
223 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_tdir_measd);
226 if (MFOC_tdir_measd == tdir)
235 TempTrackDirSP.
apply();
243 StartSavedPositionSP.
update(states, names, n);
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 #");
275 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_svstart_measd);
279 if (MFOC_svstart_measd == svstart)
288 StartSavedPositionSP.
apply();
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);
353bool 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";
364 TempCompNP.
update(values, names, n);
365 tc_int = TempCompNP[0].getValue();
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();
441 else targetTicks += ticks;
467uint32_t lacerta_mfoc::GetAbsFocuserPosition()
469 char MFOC_cmd[32] =
": Q #";
470 char MFOC_res[32] = {0};
471 char MFOC_res_type[32] =
"0";
472 int MFOC_pos_measd = 0;
474 int nbytes_written = 0;
484 sscanf(MFOC_res,
"%s %d", MFOC_res_type, &MFOC_pos_measd);
487 while(strcmp(MFOC_res_type,
"P") != 0 && count < 100);
490 LOGF_DEBUG(
"current position: %d", MFOC_pos_measd);
492 return static_cast<uint32_t
>(MFOC_pos_measd);
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
INDI::PropertyNumber FocusMaxPosNP
INDI::PropertyNumber FocusBacklashNP
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 bool saveConfigItems(FILE *fp) override
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...
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool load()
load Attempt to load property values from configuration file.
void save(FILE *f) const
save Save property to configuration file.
bool isNameMatch(const char *otherName) const
bool update(const double values[], const char *const names[], int n)
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)
int findOnSwitchIndex() const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
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 bool SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
const char * getDefaultName() override
void ISGetProperties(const char *dev) override
Handles client requests for property definitions for this device or all devices. Delegates to the bas...
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
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
virtual bool saveConfigItems(FILE *fp) override
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.
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)
#define MFOC_POSMAX_HARDWARE
#define FOCUSMFOC_TIMEOUT
#define MFOC_POSMIN_HARDWARE