30static std::unique_ptr<lacerta_mfoc_fmc> Lacerta_mfoc_fmc(
new lacerta_mfoc_fmc());
33#define FOCUSMFOC_TIMEOUT 1000
35#define MFOC_POSMAX_HARDWARE 250000
36#define MFOC_POSMIN_HARDWARE 300
55 return "Lacerta MFOC FMC";
69 TempTrackDirSP.
load();
72 StartSavedPositionSP.
load();
87 CurrentHoldingNP[0].
fill(
"CURRHOLD",
"holding current mA",
"%4d", 0, 1200, 1, 160);
92 CurrentMovingNP[0].
fill(
"CURRMOVE",
"moving current mA",
"%4d", 0, 1200, 1, 400);
106 TempTrackDirSP[MODE_TDIR_BOTH].
fill(
"Both",
"Both",
ISS_ON);
107 TempTrackDirSP[MODE_TDIR_IN].
fill(
"In",
"In",
ISS_ON);
108 TempTrackDirSP[MODE_TDIR_OUT].
fill(
"Out",
"Out",
ISS_ON);
113 StartSavedPositionSP[MODE_SAVED_ON].
fill(
"Yes",
"Yes",
ISS_ON);
114 StartSavedPositionSP[MODE_SAVED_OFF].
fill(
"No",
"No",
ISS_OFF);
158 char MFOC_cmd[32] =
": q #";
159 char MFOC_res[32] = {0};
160 char MFOC_res_type[32] =
"0";
162 int MFOC_pos_measd = 0;
163 int nbytes_written = 0;
166 bool device_found =
false;
176 LOGF_ERROR(
"Unknown device or MFOC firmware not compatible with this driver version! Please update firmware! %s",
device);
180 sscanf(MFOC_res,
"%s %s", MFOC_res_type,
device);
182 device_found = strcmp(
device,
"MFOC") == 0 || strcmp(
device,
"FMC") == 0;
191 while (!device_found && count != 10);
198 MFOC_res[nbytes_read] = 0;
201 sscanf(MFOC_res,
"%s %d", MFOC_res_type, &MFOC_pos_measd);
203 if (MFOC_res_type[0] ==
'p')
224 TempTrackDirSP.
update(states, names, n);
227 char MFOC_cmd[32] =
": W ";
228 char MFOC_res[32] = {0};
230 int nbytes_written = 0;
231 int MFOC_tdir_measd = 0;
232 char MFOC_res_type[32] =
"0";
238 strcat(MFOC_cmd,
"0 #");
243 strcat(MFOC_cmd,
"1 #");
248 strcat(MFOC_cmd,
"2 #");
260 LOGF_DEBUG(
"ISNewSwitch: CMD [%s]", MFOC_cmd);
263 MFOC_res[nbytes_read] = 0;
264 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_tdir_measd);
265 LOGF_DEBUG(
"ISNewSwitch: RES [%s]", MFOC_res);
267 if (MFOC_tdir_measd == tdir)
276 TempTrackDirSP.
apply();
283 StartSavedPositionSP.
update(states, names, n);
286 char MFOC_cmd[32] =
": N ";
287 char MFOC_res[32] = {0};
289 int nbytes_written = 0;
290 int MFOC_svstart_measd = 0;
291 char MFOC_res_type[32] =
"0";
297 strcat(MFOC_cmd,
"1 #");
302 strcat(MFOC_cmd,
"0 #");
316 MFOC_res[nbytes_read] = 0;
317 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_svstart_measd);
320 if (MFOC_svstart_measd == svstart)
329 StartSavedPositionSP.
apply();
341 if (strcmp(name,
"TEMPCOMP_SETTINGS") == 0)
343 return SetTempComp(values, names, n);
346 if (strcmp(name,
"CURRHOLD_SETTINGS") == 0)
348 CurrentHoldingNP.
update(values, names, n);
349 if (!SetCurrHold(CurrentHoldingNP[0].getValue()))
352 CurrentHoldingNP.
apply();
356 CurrentHoldingNP.
apply();
360 if (strcmp(name,
"CURRMOVE_SETTINGS") == 0)
362 CurrentMovingNP.
update(values, names, n);
363 if (!SetCurrMove(CurrentMovingNP[0].getValue()))
366 CurrentMovingNP.
apply();
370 CurrentMovingNP.
apply();
384 char MFOC_cmd[32] =
": B ";
385 char MFOC_res[32] = {0};
387 int nbytes_written = 0;
388 int MFOC_tdir_measd = 0;
389 char bl_char[32] = {0};
390 char MFOC_res_type[32] =
"0";
392 sprintf(bl_char,
"%d", steps);
393 strcat(bl_char,
" #");
394 strcat(MFOC_cmd, bl_char);
403 MFOC_res[nbytes_read] = 0;
404 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_tdir_measd);
406 while(strcmp(
"b", MFOC_res_type) != 0);
412bool lacerta_mfoc_fmc::SetCurrHold(
int currHoldValue)
414 char MFOC_cmd[32] =
": E ";
415 char MFOC_res[32] = {0};
417 int nbytes_written = 0;
418 int MFOC_ch_measd = 0;
419 char ch_char[32] = {0};
420 char MFOC_res_type[32] =
"0";
422 sprintf(ch_char,
"%d", currHoldValue);
423 strcat(ch_char,
" #");
424 strcat(MFOC_cmd, ch_char);
432 sscanf(MFOC_res,
"%s %d", MFOC_res_type, &MFOC_ch_measd);
433 MFOC_res[nbytes_read] = 0;
435 while(strcmp(
"e", MFOC_res_type) != 0);
438 LOGF_INFO(
"Holding Current set to %d mA", MFOC_ch_measd);
443bool lacerta_mfoc_fmc::SetCurrMove(
int currMoveValue)
445 char MFOC_cmd[32] =
": F ";
446 char MFOC_res[32] = {0};
448 int nbytes_written = 0;
449 int MFOC_cm_measd = 0;
450 char cm_char[32] = {0};
451 char MFOC_res_type[32] =
"0";
453 sprintf(cm_char,
"%d", currMoveValue);
454 strcat(cm_char,
" #");
455 strcat(MFOC_cmd, cm_char);
463 sscanf(MFOC_res,
"%s %d", MFOC_res_type, &MFOC_cm_measd);
464 MFOC_res[nbytes_read] = 0;
466 while(strcmp(
"f", MFOC_res_type) != 0);
469 LOGF_INFO(
"Moving Current set to %d mA", MFOC_cm_measd);
474bool lacerta_mfoc_fmc::SetTempComp(
double values[],
char *names[],
int n)
476 char MFOC_cmd[32] =
": U ";
477 char MFOC_res[32] = {0};
479 int nbytes_written = 0;
480 int MFOC_tc_measd = 0;
482 char tc_char[32] = {0};
483 char MFOC_res_type[32] =
"0";
487 tc_int = TempCompN[0].value;
488 sprintf(tc_char,
"%d", tc_int);
489 strcat(tc_char,
" #");
490 strcat(MFOC_cmd, tc_char);
499 MFOC_res[nbytes_read] = 0;
500 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_tc_measd);
502 while(strcmp(
"u", MFOC_res_type) != 0);
512 char MFOC_cmd[32] =
": G ";
513 char MFOC_res[32] = {0};
515 int nbytes_written = 0;
516 int MFOC_pm_measd = 0;
517 char pm_char[32] = {0};
518 char MFOC_res_type[32] =
"0";
520 sprintf(pm_char,
"%d", ticks);
521 strcat(pm_char,
" #");
522 strcat(MFOC_cmd, pm_char);
526 IgnoreButLogResponse();
532 MFOC_res[nbytes_read] = 0;
533 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &MFOC_pm_measd);
535 while (strcmp(
"g", MFOC_res_type) != 0);
546 char MFOC_cmd[32] =
": M ";
547 char abs_pos_char[32] = {0};
548 int nbytes_written = 0;
551 sprintf(abs_pos_char,
"%d", targetTicks);
552 strcat(abs_pos_char,
" #");
553 strcat(MFOC_cmd, abs_pos_char);
557 IgnoreButLogResponse();
561 GetAbsFocuserPosition();
574 else targetTicks += ticks;
588 char MFOC_cmd[32] =
": P ";
589 char sync_pos[8] = {0};
591 int nbytes_written = 0;
593 sprintf(sync_pos,
"%d", ticks);
594 strcat(sync_pos,
" #");
595 strcat(MFOC_cmd, sync_pos);
599 IgnoreButLogResponse();
609 char MFOC_cmd[32] =
": H #";
610 char MFOC_res[32] = {0};
611 char MFOC_res_type[32] =
"0";
613 int nbytes_written = 0;
626 MFOC_res[nbytes_read] = 0;
627 sscanf (MFOC_res,
"%s %d", MFOC_res_type, &halt_flag);
629 while(strcmp(MFOC_res_type,
"H") != 0 && count <= 100);
651 CurrentHoldingNP.
save(fp);
652 CurrentMovingNP.
save(fp);
657uint32_t lacerta_mfoc_fmc::GetAbsFocuserPosition()
659 char MFOC_cmd[32] =
": q #";
660 char MFOC_res[32] = {0};
661 char MFOC_res_type[32] =
"0";
662 int MFOC_pos_measd = 0;
664 int nbytes_written = 0;
674 sscanf(MFOC_res,
"%s %d", MFOC_res_type, &MFOC_pos_measd);
677 while(strcmp(MFOC_res_type,
"p") != 0 && count < 100);
679 return static_cast<uint32_t
>(MFOC_pos_measd);
682void lacerta_mfoc_fmc::IgnoreResponse()
689void lacerta_mfoc_fmc::IgnoreButLogResponse()
694 MFOC_res[nbytes_read] = 0;
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)
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 SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
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...
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
void ISGetProperties(const char *dev) override
Handles client requests for property definitions for this device or all devices. Delegates to the bas...
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool saveConfigItems(FILE *fp) override
const char * getDefaultName() override
bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
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...
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * FOCUS_TAB
FOCUS_TAB Where all the properties for focuser 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 IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
#define LOGF_INFO(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)
#define MFOC_POSMAX_HARDWARE
#define FOCUSMFOC_TIMEOUT
#define MFOC_POSMIN_HARDWARE