102 int rc = writeCmd(
"GINF");
106 std::string response;
107 rc = readStatus(response);
111 LOGF_DEBUG(
"Initial response: %s", response.c_str());
114 if (response[0] !=
'V')
117 parseGINF(response.c_str());
155 int DDW::writeCmd(
const char *
cmd)
157 int nbytes_written = 0, rc = -1;
163 LOGF_ERROR(
"Error writing command: %s. Cmd: %s", errstr,
cmd);
168 int DDW::readStatus(std::string &status)
170 int nbytes_read = 0, rc = -1;
174 char response[256] = { 0 };
186 void DDW::parseGINF(
const char *response)
242 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,
243 &dticks, &homepos, &coast, &azimuth, &slave, &shutter, &dsr, &home, &htick_cclk, &htick_clk,
244 &upins, &weatherAge, &windDir, &windSpd, &temperature, &humidity, &wetness, &snow, &windPeak,
245 &scopeAzimuth, &deadzone, &offset);
250 ticksPerRev = dticks;
251 homeAz = 360.0 * homepos / ticksPerRev;
253 DomeAbsPosN[0].value = 360.0 * azimuth / ticksPerRev;
290 char response[256] = { 0 };
293 if (rc !=
TTY_OK || nr != 1)
327 sscanf(response,
"P%d", &tick);
353 sscanf(response,
"Z%d", &tick);
371 auto prevState = cmdState;
378 if(prevState == SHUTTER_OPERATION)
392 if(prevState == MOVING)
396 LOGF_DEBUG(
"Performing pending goto to %f", gotoTarget);
412 LOGF_ERROR(
"Unknown response character %c", response[0]);
426 if (cmdState == MOVING)
428 LOG_DEBUG(
"Dome already moving, latching the new move command");
433 else if (cmdState != IDLE)
435 LOG_ERROR(
"Dome needs to be idle to issue moves");
440 int rounded =
round(az);
442 snprintf(
cmd,
sizeof(
cmd),
"G%03d", rounded);
453 if (cmdState != IDLE)
455 LOG_ERROR(
"Dome needs to be idle to issue park");
475 if (cmdState != IDLE)
477 LOG_ERROR(
"Dome needs to be idle to issue unpark");
493 if (cmdState != IDLE)
495 LOG_ERROR(
"Dome needs to be idle for shutter operations");
501 cmdState = SHUTTER_OPERATION;
502 if (writeCmd(
"GOPN") !=
TTY_OK)
508 cmdState = SHUTTER_OPERATION;
509 if (writeCmd(
"GCLS") !=
TTY_OK)
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
virtual bool initProperties() override
Initilize 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
const char * getDeviceName() const
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...
void SetAxis1Park(double value)
SetRAPark Set current AZ parking position. The data park file (stored in ~/.indi/ParkData....
ISwitch ShutterParkPolicyS[2]
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
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
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)
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
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
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.
void IDSetNumber(const INumberVectorProperty *nvp, const char *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,...)
double round(double value, int decimal_places)