39#define SIM_SHUTTER_TIMER 5.0
40#define SIM_FLAP_TIMER 5.0
41#define SIM_DOME_HI_SPEED 5.0
42#define SIM_DOME_LO_SPEED 0.5
125 return (
const char *)
"Baader Dome";
165 LOG_INFO(
"Dome is already calibrated.");
182 LOG_INFO(
"Starting calibration procedure...");
196 LOG_ERROR(
"Calibration failure due to dome motion failure.");
217 if (prevStatus == FlapDome)
237 LOGF_INFO(
"Flap is %s", (FlapDome == 0 ?
"open" :
"closed"));
246 LOGF_INFO(
"Flap is %s", (FlapDome == 0 ?
"opening" :
"closing"));
252 LOGF_INFO(
"Flap failed to %s", (FlapDome == 0 ?
"open" :
"close"));
266 int nbytes_written = 0, nbytes_read = 0, rc = -1;
273 tcflush(
PortFD, TCIOFLUSH);
278 LOGF_ERROR(
"d#getflap Ack error: %s.", errstr);
286 strncpy(resp,
"d#flapclo",
DOME_BUF);
296 resp[nbytes_read] =
'\0';
300 rc = sscanf(resp,
"d#%s",
status);
313 int nbytes_written = 0, nbytes_read = 0, rc = -1;
318 tcflush(
PortFD, TCIOFLUSH);
323 LOGF_ERROR(
"d#getshut UpdateShutterStatus error: %s.", errstr);
332 strncpy(resp,
"d#shutclo",
DOME_CMD + 1);
334 strncpy(resp,
"d#shutope",
DOME_CMD + 1);
336 strncpy(resp,
"d#shutrun",
DOME_CMD + 1);
342 LOGF_ERROR(
"UpdateShutterStatus error: %s.", errstr);
346 resp[nbytes_read] =
'\0';
350 rc = sscanf(resp,
"d#shut%s",
status);
357 if (strcmp(
status,
"ope") == 0)
365 else if (strcmp(
status,
"clo") == 0)
373 else if (strcmp(
status,
"run") == 0)
382 LOGF_ERROR(
"Unknown Shutter status: %s.", resp);
394 int nbytes_written = 0, nbytes_read = 0, rc = -1;
397 unsigned short domeAz = 0;
399 tcflush(
PortFD, TCIOFLUSH);
404 LOGF_ERROR(
"d#getazim UpdatePosition error: %s.", errstr);
421 LOGF_ERROR(
"UpdatePosition error: %s.", errstr);
425 resp[nbytes_read] =
'\0';
429 rc = sscanf(resp,
"d#azr%hu", &domeAz);
455 rc = sscanf(resp,
"d#azi%hu", &domeAz);
472 domeAz = (mountAz) * 10.0 - 1800;
474 if (mountAz >= 0 && mountAz <= 179.9)
482 return ((
unsigned short)(domeAz));
492 mountAz = ((double)(domeAz + 1800)) / 10.0;
499 else if (mountAz < 0)
530 currentPosition += speed;
533 currentPosition -= speed;
539 currentPosition += speed;
543 currentPosition -= speed;
554 LOG_INFO(
"Dome reached requested azimuth angle.");
570 LOG_INFO(
"Calibration stage 1 complete. Starting stage 2...");
586 LOG_INFO(
"Dome reached initial position.");
630 int nbytes_written = 0, nbytes_read = 0, rc = -1;
637 LOG_WARN(
"Dome is not calibrated. Please calibrate dome before issuing any commands.");
645 tcflush(
PortFD, TCIOFLUSH);
658 strncpy(resp,
"d#gotmess",
DOME_CMD + 1);
668 resp[nbytes_read] =
'\0';
672 if (strcmp(resp,
"d#gotmess") == 0)
709 int nbytes_written = 0, nbytes_read = 0, rc = -1;
714 memset(
cmd, 0,
sizeof(
cmd));
727 tcflush(
PortFD, TCIOFLUSH);
741 strncpy(resp,
"d#gotmess",
DOME_CMD + 1);
747 LOGF_ERROR(
"ControlDomeShutter error: %s.", errstr);
751 resp[nbytes_read] =
'\0';
755 if (strcmp(resp,
"d#gotmess") == 0)
781 return "Flap is open.";
784 return "Flap is closed.";
787 return "Flap is in motion.";
791 return "Flap status is unknown.";
801 int nbytes_written = 0, nbytes_read = 0, rc = -1;
806 memset(
cmd, 0,
sizeof(
cmd));
819 tcflush(
PortFD, TCIOFLUSH);
833 strncpy(resp,
"d#gotmess",
DOME_CMD + 1);
839 LOGF_ERROR(
"ControlDomeFlap error: %s.", errstr);
843 resp[nbytes_read] =
'\0';
847 if (strcmp(resp,
"d#gotmess") == 0)
860 int nbytes_written = 0, nbytes_read = 0, rc = -1;
865 tcflush(
PortFD, TCIOFLUSH);
870 LOGF_ERROR(
"d#getflap UpdateflapStatus error: %s.", errstr);
879 strncpy(resp,
"d#flapclo",
DOME_CMD + 1);
881 strncpy(resp,
"d#flapope",
DOME_CMD + 1);
883 strncpy(resp,
"d#flaprun",
DOME_CMD + 1);
889 LOGF_ERROR(
"UpdateflapStatus error: %s.", errstr);
893 resp[nbytes_read] =
'\0';
897 rc = sscanf(resp,
"d#flap%s",
status);
904 if (strcmp(
status,
"ope") == 0)
912 else if (strcmp(
status,
"clo") == 0)
920 else if (strcmp(
status,
"run") == 0)
941 int nbytes_written = 0, nbytes_read = 0, rc = -1;
948 tcflush(
PortFD, TCIOFLUSH);
953 LOGF_ERROR(
"%s SaveEncoderPosition error: %s.",
cmd, errstr);
961 strncpy(resp,
"d#gotmess",
DOME_CMD + 1);
967 LOGF_ERROR(
"SaveEncoderPosition error: %s.", errstr);
971 resp[nbytes_read] =
'\0';
975 return strcmp(resp,
"d#gotmess") == 0;
#define SIM_SHUTTER_TIMER
#define SIM_DOME_HI_SPEED
std::unique_ptr< BaaderDome > baaderDome(new BaaderDome())
#define SIM_DOME_LO_SPEED
int ControlDomeFlap(FlapOperation operation)
virtual IPState MoveAbs(double az) override
Move the Dome to an absolute azimuth.
bool UpdateShutterStatus()
bool SaveEncoderPosition()
CalibrationStage calibrationStage
unsigned short MountAzToDomeAz(double mountAz)
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
const char * GetFlapStatusString(FlapStatus status)
double calibrationTarget1
INDI::PropertySwitch DomeFlapSP
double calibrationTarget2
virtual const char * getDefaultName() override
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual IPState ControlShutter(ShutterOperation operation) override
Open or Close shutter.
ShutterState simShutterStatus
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool Abort() override
Abort all dome motion.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
ShutterOperation targetShutter
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
virtual IPState MoveRel(double azDiff) override
Move the Dome to an relative position.
INDI::PropertySwitch CalibrateSP
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
double DomeAzToMountAz(unsigned short domeAz)
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.
bool isSimulation() const
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
void SetDomeCapability(uint32_t cap)
SetDomeCapability set the dome capabilities. All capabilities must be initialized.
const char * GetShutterStatusString(ShutterState status)
getShutterStatusString
INDI::PropertyNumber DomeRelPosNP
INDI::PropertyNumber DomeParamNP
ShutterState m_ShutterState
void SetAxis1Park(double value)
SetRAPark Set current AZ parking position. The data park file (stored in ~/.indi/ParkData....
void SetAxis1ParkDefault(double steps)
SetAxis1Park Set default AZ parking position.
ShutterOperation
Shutter operation command.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
@ DOME_HAS_VARIABLE_SPEED
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
INDI::PropertyNumber DomeAbsPosNP
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
INDI::PropertySwitch DomeMotionSP
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
void setDomeState(const DomeState &value)
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
void SetParkDataType(DomeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
INDI::PropertySwitch DomeShutterSP
DomeState getDomeState() const
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isNameMatch(const char *otherName) const
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)
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Implementations for common driver routines.
#define LOGF_INFO(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)