37 #define DOME_TIMEOUT 3
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)
263 int nbytes_written = 0, nbytes_read = 0, rc = -1;
270 tcflush(
PortFD, TCIOFLUSH);
275 LOGF_ERROR(
"d#getflap Ack error: %s.", errstr);
283 strncpy(resp,
"d#flapclo",
DOME_BUF);
293 resp[nbytes_read] =
'\0';
297 rc = sscanf(resp,
"d#%s",
status);
310 int nbytes_written = 0, nbytes_read = 0, rc = -1;
315 tcflush(
PortFD, TCIOFLUSH);
320 LOGF_ERROR(
"d#getshut UpdateShutterStatus error: %s.", errstr);
329 strncpy(resp,
"d#shutclo",
DOME_CMD + 1);
331 strncpy(resp,
"d#shutope",
DOME_CMD + 1);
333 strncpy(resp,
"d#shutrun",
DOME_CMD + 1);
339 LOGF_ERROR(
"UpdateShutterStatus error: %s.", errstr);
343 resp[nbytes_read] =
'\0';
347 rc = sscanf(resp,
"d#shut%s",
status);
354 if (strcmp(
status,
"ope") == 0)
362 else if (strcmp(
status,
"clo") == 0)
370 else if (strcmp(
status,
"run") == 0)
379 LOGF_ERROR(
"Unknown Shutter status: %s.", resp);
391 int nbytes_written = 0, nbytes_read = 0, rc = -1;
394 unsigned short domeAz = 0;
396 tcflush(
PortFD, TCIOFLUSH);
401 LOGF_ERROR(
"d#getazim UpdatePosition error: %s.", errstr);
418 LOGF_ERROR(
"UpdatePosition error: %s.", errstr);
422 resp[nbytes_read] =
'\0';
426 rc = sscanf(resp,
"d#azr%hu", &domeAz);
452 rc = sscanf(resp,
"d#azi%hu", &domeAz);
469 domeAz = (mountAz) * 10.0 - 1800;
471 if (mountAz >= 0 && mountAz <= 179.9)
479 return ((
unsigned short)(domeAz));
489 mountAz = ((double)(domeAz + 1800)) / 10.0;
496 else if (mountAz < 0)
552 LOG_INFO(
"Dome reached requested azimuth angle.");
568 LOG_INFO(
"Calibration stage 1 complete. Starting stage 2...");
577 "Calibration stage 2 complete. Returning to initial position %g...",
calibrationStart);
585 LOG_INFO(
"Dome reached initial position.");
629 int nbytes_written = 0, nbytes_read = 0, rc = -1;
636 LOG_WARN(
"Dome is not calibrated. Please calibrate dome before issuing any commands.");
644 tcflush(
PortFD, TCIOFLUSH);
657 strncpy(resp,
"d#gotmess",
DOME_CMD + 1);
667 resp[nbytes_read] =
'\0';
671 if (strcmp(resp,
"d#gotmess") == 0)
716 int nbytes_written = 0, nbytes_read = 0, rc = -1;
721 memset(
cmd, 0,
sizeof(
cmd));
734 tcflush(
PortFD, TCIOFLUSH);
748 strncpy(resp,
"d#gotmess",
DOME_CMD + 1);
754 LOGF_ERROR(
"ControlDomeShutter error: %s.", errstr);
758 resp[nbytes_read] =
'\0';
762 if (strcmp(resp,
"d#gotmess") == 0)
788 return "Flap is open.";
791 return "Flap is closed.";
794 return "Flap is in motion.";
798 return "Flap status is unknown.";
808 int nbytes_written = 0, nbytes_read = 0, rc = -1;
813 memset(
cmd, 0,
sizeof(
cmd));
826 tcflush(
PortFD, TCIOFLUSH);
840 strncpy(resp,
"d#gotmess",
DOME_CMD + 1);
846 LOGF_ERROR(
"ControlDomeFlap error: %s.", errstr);
850 resp[nbytes_read] =
'\0';
854 if (strcmp(resp,
"d#gotmess") == 0)
867 int nbytes_written = 0, nbytes_read = 0, rc = -1;
872 tcflush(
PortFD, TCIOFLUSH);
877 LOGF_ERROR(
"d#getflap UpdateflapStatus error: %s.", errstr);
886 strncpy(resp,
"d#flapclo",
DOME_CMD + 1);
888 strncpy(resp,
"d#flapope",
DOME_CMD + 1);
890 strncpy(resp,
"d#flaprun",
DOME_CMD + 1);
896 LOGF_ERROR(
"UpdateflapStatus error: %s.", errstr);
900 resp[nbytes_read] =
'\0';
904 rc = sscanf(resp,
"d#flap%s",
status);
911 if (strcmp(
status,
"ope") == 0)
919 else if (strcmp(
status,
"clo") == 0)
927 else if (strcmp(
status,
"run") == 0)
948 int nbytes_written = 0, nbytes_read = 0, rc = -1;
955 tcflush(
PortFD, TCIOFLUSH);
960 LOGF_ERROR(
"%s SaveEncoderPosition error: %s.",
cmd, errstr);
968 strncpy(resp,
"d#gotmess",
DOME_CMD + 1);
974 LOGF_ERROR(
"SaveEncoderPosition error: %s.", errstr);
978 resp[nbytes_read] =
'\0';
982 return strcmp(resp,
"d#gotmess") == 0;
#define SIM_SHUTTER_TIMER
#define SIM_DOME_HI_SPEED
#define SIM_DOME_LO_SPEED
std::unique_ptr< BaaderDome > baaderDome(new BaaderDome())
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
ISwitchVectorProperty 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
Initilize 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.
ISwitchVectorProperty CalibrateSP
virtual IPState MoveRel(double azDiff) override
Move the Dome to an relative position.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
double DomeAzToMountAz(unsigned short domeAz)
const char * getDeviceName() const
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.
@ DOME_HAS_VARIABLE_SPEED
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
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
Initilize properties initial state and value. The child class must implement this function.
INumberVectorProperty DomeAbsPosNP
ISwitchVectorProperty DomeShutterSP
virtual 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.
INumberVectorProperty DomeRelPosNP
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.
DomeState getDomeState() const
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
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Implementations for common driver routines.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
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 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,...)
#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,...)
#define DEBUGF(priority, msg,...)