105 int rc = writeCmd(
"GINF");
109 std::string response;
110 rc = readStatus(response);
114 LOGF_DEBUG(
"Initial response: %s", response.c_str());
117 if (response[0] !=
'V')
120 parseGINF(response.c_str());
158int DDW::writeCmd(
const char *
cmd)
160 int nbytes_written = 0, rc = -1;
166 LOGF_ERROR(
"Error writing command: %s. Cmd: %s", errstr,
cmd);
171int DDW::readStatus(std::string &status)
173 int nbytes_read = 0, rc = -1;
177 char response[256] = { 0 };
189void DDW::parseGINF(
const char *response)
245 int num = sscanf(response,
"V%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &version,
246 &dticks, &homepos, &coast, &azimuth, &slave, &shutter, &dsr, &home, &htick_cclk, &htick_clk,
247 &upins, &weatherAge, &windDir, &windSpd, &
temperature, &
humidity, &wetness, &snow, &windPeak,
248 &scopeAzimuth, &deadzone, &offset);
253 ticksPerRev = dticks;
254 homeAz = 360.0 * homepos / ticksPerRev;
256 DomeAbsPosNP[0].setValue(360.0 * azimuth / ticksPerRev);
293 char response[256] = { 0 };
296 if (rc !=
TTY_OK || nr != 1)
330 sscanf(response,
"P%d", &tick);
356 sscanf(response,
"Z%d", &tick);
374 auto prevState = cmdState;
381 if(prevState == SHUTTER_OPERATION)
395 if(prevState == MOVING)
399 LOGF_DEBUG(
"Performing pending goto to %f", gotoTarget);
415 LOGF_ERROR(
"Unknown response character %c", response[0]);
429 if (cmdState == MOVING)
431 LOG_DEBUG(
"Dome already moving, latching the new move command");
436 else if (cmdState != IDLE)
438 LOG_ERROR(
"Dome needs to be idle to issue moves");
443 int rounded =
round(az);
445 snprintf(
cmd,
sizeof(
cmd),
"G%03d", rounded);
456 if (cmdState != IDLE)
458 LOG_ERROR(
"Dome needs to be idle to issue park");
474 if (cmdState != IDLE)
476 LOG_ERROR(
"Dome needs to be idle to issue unpark");
492 if (cmdState != IDLE)
494 LOG_ERROR(
"Dome needs to be idle for shutter operations");
500 cmdState = SHUTTER_OPERATION;
501 if (writeCmd(
"GOPN") !=
TTY_OK)
507 cmdState = SHUTTER_OPERATION;
508 if (writeCmd(
"GCLS") !=
TTY_OK)
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
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....
INDI::PropertyNumber FirmwareVersionNP
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual IPState ControlShutter(ShutterOperation operation) override
Open or Close shutter.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
virtual IPState MoveAbs(double az) override
Move the Dome to an absolute azimuth.
virtual bool Abort() override
Abort all dome motion.
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual const char * getDefaultName() override
void setPollingPeriodRange(uint32_t minimum, uint32_t maximum)
setPollingPeriodRange Set the range permitted by the polling range in milliseconds
void setDefaultPollingPeriod(uint32_t msec)
setDefaultPollingPeriod Change the default polling period to call TimerHit() function in the driver.
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
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.
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.
void setDomeConnection(const uint8_t &value)
setDomeConnection Set Dome connection mode. Child class should call this in the constructor before Do...
INDI::PropertySwitch ShutterParkPolicySP
void SetAxis1Park(double value)
SetRAPark Set current AZ parking position. The data park file (stored in ~/.indi/ParkData....
ShutterOperation
Shutter operation command.
void SetAxis1ParkDefault(double steps)
SetAxis1Park Set default AZ parking position.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
INDI::PropertyNumber DomeAbsPosNP
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
void setShutterState(const ShutterState &value)
void setDomeState(const DomeState &value)
void SetShutterParkPolicyHandledByDriver(bool enabled)
SetShutterParkPolicyHandledByDriver By default, INDI::Dome applies the shutter park policy (DOME_SHUT...
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
Connection::Serial * serialConnection
void SetParkDataType(DomeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
ShutterState getShutterState() const
DomeState getDomeState() const
std::unique_ptr< DDW > ddw(new DDW())
const char * INFO_TAB
INFO_TAB Where all the properties for general information 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.
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Implementations for common driver routines.
#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,...)
double round(double value, int decimal_places)