49 static std::unique_ptr<DomeScript> scope_script(
new DomeScript());
58 return (
const char *)
"Dome Scripting Gateway";
65 #if defined(__APPLE__)
106 if (strcmp(name, ScriptsTP.
name) == 0)
117 bool DomeScript::RunScript(
int script, ...)
120 strncpy(tmp, ScriptsT[script].text,
sizeof(tmp));
122 char **args = (
char **)malloc(
MAXARGS *
sizeof(
char *));
128 char *pp = strstr(p,
" ");
136 va_start(ap, script);
139 char *pp = va_arg(ap,
char *);
146 snprintf(path,
sizeof(path),
"%s/%s", ScriptsT[0].text, tmp);
148 if (access(path, F_OK | X_OK) != 0)
156 snprintf(dbg,
sizeof(dbg),
"execvp('%s'", path);
157 for (
int i = 0; args[i]; i++)
160 strcat(dbg, args[i]);
163 strcat(dbg,
", nullptr)");
182 waitpid(pid, &status, 0);
183 LOGF_DEBUG(
"Script %s returned %d", ScriptsT[script].text, status);
211 char tmpfile[] =
"/tmp/indi_dome_script_status_XXXXXX";
212 int fd = mkstemp(tmpfile);
215 LOGF_ERROR(
"Temp file %s creation for status script failed, %s", tmpfile, strerror(
errno));
223 int parked = 0, shutter = 0;
225 FILE *file = fopen(tmpfile,
"r");
226 int rc = fscanf(file,
"%d %d %f", &parked, &shutter, &az);
237 LOG_INFO(
"Park successfully executed");
246 LOG_INFO(
"Unpark successfully executed");
266 LOG_INFO(
"Shutter was successfully closed");
276 LOG_INFO(
"Shutter was successfully opened");
285 if (!
isParked() && TimeSinceUpdate++ > 4)
314 LOG_INFO(
"Successfully disconnected");
358 snprintf(_az, 16,
"%f",
round(az * 10) / 10);
359 bool status = RunScript(
SCRIPT_GOTO, _az,
nullptr);
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual const char * getDefaultName() override
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
virtual bool Abort() override
Abort all dome motion.
bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Move the Dome in a particular direction.
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
virtual IPState MoveAbs(double az) override
Move the Dome to an absolute azimuth.
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual IPState ControlShutter(ShutterOperation operation) override
Open or Close shutter.
virtual bool Disconnect() override
Disconnect from device.
const char * getDeviceName() const
void setDefaultPollingPeriod(uint32_t msec)
setDefaultPollingPeriod Change the default polling period to call TimerHit() function in the driver.
virtual bool loadConfig(bool silent=false, const char *property=nullptr)
Load the last saved configuration file.
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
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.
bool isParked()
isParked is dome currently parked?
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
ShutterState m_ShutterState
void SetAxis1Park(double value)
SetRAPark Set current AZ parking position. The data park file (stored in ~/.indi/ParkData....
void UpdateMountCoords()
updateCoords updates the horizontal coordinates (Az & Alt) of the mount from the snooped RA,...
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 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 * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
Implementations for common driver routines.
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
void IUSaveConfigText(FILE *fp, const ITextVectorProperty *tvp)
Add a text vector property value to the configuration file.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n)
Update all text members in a text vector property.
void IDSetText(const ITextVectorProperty *tvp, 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,...)
double round(double value, int decimal_places)