31#include <libnova/julian_day.h>
32#include <libnova/sidereal_time.h>
33#include <libnova/transform.h>
43#define DOME_SLAVING_TAB "Slaving"
44#define DOME_COORD_THRESHOLD \
53Dome::Dome() : ParkDataFileName(GetHomeDirectory() +
"/.indi/ParkData.xml")
69 ParkdataXmlRoot =
nullptr;
73 m_ShutterParkTimer.setInterval(SHUTTER_PARK_POLL_INTERVAL);
74 m_ShutterParkTimer.callOnTimeout(std::bind(&Dome::checkShutterParkSequence,
this));
92std::string Dome::GetHomeDirectory()
const
95 const char * HomeDir = getenv(
"HOME");
100 HomeDir = getpwuid(getuid())->pw_dir;
102 return (HomeDir ? std::string(HomeDir) :
"");
113 PresetNP[0].fill(
"Preset 1",
"",
"%6.2f", 0, 360.0, 1.0, 0);
114 PresetNP[1].fill(
"Preset 2",
"",
"%6.2f", 0, 360.0, 1.0, 0);
115 PresetNP[2].fill(
"Preset 3",
"",
"%6.2f", 0, 360.0, 1.0, 0);
173 DomeSpeedNP[0].fill(
"DOME_SPEED_VALUE",
"RPM",
"%6.2f", 0.0, 10, 0.1, 1.0);
177 DomeSyncNP[0].fill(
"DOME_SYNC_VALUE",
"Az",
"%.2f", 0.0, 360, 10, 0.0);
187 DomeAbsPosNP[0].fill(
"DOME_ABSOLUTE_POSITION",
"Degrees",
"%6.2f", 0.0, 360.0, 1.0, 0.0);
191 DomeRelPosNP[0].fill(
"DOME_RELATIVE_POSITION",
"Degrees",
"%6.2f", -180, 180.0, 10.0, 0.0);
199 DomeParamNP[0].fill(
"AUTOSYNC_THRESHOLD",
"Autosync threshold (deg)",
"%6.2f", 0.0, 360.0, 1.0, 0.5);
216 DomeBacklashNP[0].fill(
"DOME_BACKLASH_VALUE",
"Steps",
"%.f", 0, 1e6, 100, 0);
236 controller->initProperties();
252 return callHandshake();
262 return callHandshake();
280 controller->ISGetProperties(dev);
341 cancelShutterParkSequence();
392 controller->updateProperties();
437 LOGF_INFO(
"Dome slaving differential threshold updated to %.2f degrees.",
DomeParamNP[0].getValue());
443 auto newSpeed = values[0];
449 auto newPos = values[0];
455 auto newPos = values[0];
483 LOG_WARN(
"Dome backlash must be enabled first.");
487 auto steps =
static_cast<uint32_t
>(values[0]);
519 LOG_ERROR(
"Please unpark before issuing any motion commands.");
531 LOGF_INFO(
"Moving to Preset %d (%.2f degrees).", index + 1,
PresetNP[index].getValue());
550 LOGF_WARN(
"Dome will now be synced to mount azimuth position if the differential threshold exceeds %.2f degrees.",
554 m_MountUpdateTimer.start(HORZ_UPDATE_TIMER);
558 LOG_WARN(
"Dome is no longer synced to mount azimuth position.");
560 m_MountUpdateTimer.stop();
577 LOG_WARN(
"Dome shall be synced assuming OTA situated east of the pier");
581 LOG_WARN(
"Dome shall be synced assuming OTA situated west of the pier");
585 LOG_WARN(
"Dome shall be synced from pier side as reported by the mount.");
589 LOG_WARN(
"Dome shall be synced for OTA pier side derived from Hour Angle.");
593 LOG_WARN(
"Dome shall be synced by ignoring pier side as in a fork mount.");
607 for (
int i = 0; i <
n; i++)
621 auto current_direction =
DomeMotionSP.findOnSwitchIndex();
623 if (current_direction < 0)
637 else if (
AbortSP.isNameMatch(name))
648 for (
int i = 0; i <
n; i++)
656 if (m_ShutterParkSequence != SHUTTER_SEQUENCE_NONE && !m_ShutterParkShutterDone)
659 if (operation != sequenceOperation)
661 LOGF_WARN(
"Manual shutter command overrides the shutter park policy. Dome %s will not wait for the shutter.",
662 m_ShutterParkSequence == SHUTTER_SEQUENCE_PARK ?
"parking" :
"unparking");
663 m_ShutterParkShutterDone =
true;
664 m_ShutterParkShutterFailed =
false;
669 checkShutterParkSequence();
677 else if (
ParkSP.isNameMatch(name))
680 for (
int i = 0; i <
n; i++)
684 if (
ParkSP[0].isNameMatch(names[i]))
715 if (sp->isNameMatch(
"PARK_CURRENT"))
719 else if (sp->isNameMatch(
"PARK_DEFAULT"))
723 else if (sp->isNameMatch(
"PARK_WRITE_DATA"))
727 LOG_INFO(
"Saved Park Status/Position.");
729 LOG_WARN(
"Can not save Park Status/Position.");
740 else if (!strcmp(name, AutoParkSP.name))
746 if (AutoParkS[0].s ==
ISS_ON)
747 LOG_WARN(
"Warning: Auto park is enabled. If weather conditions are in the "
748 "danger zone, the dome will be automatically parked. Only enable this "
749 "option is parking the dome at any time will not cause damage to any "
767 LOG_INFO(
"Mount Policy set to: Mount ignored. Dome can park regardless of mount parking state.");
769 LOG_WARN(
"Mount Policy set to: Mount locks. This prevents the dome from parking when mount is unparked.");
799 LOGF_INFO(
"Dome backlash is %s.", (enabled ?
"enabled" :
"disabled"));
806 LOG_ERROR(
"Failed to set trigger Dome backlash.");
815 controller->ISNewSwitch(dev, name, states, names,
n);
824bool Dome::ISNewText(
const char * dev,
const char * name,
char * texts[],
char * names[],
int n)
848 controller->ISNewText(dev, name, texts, names,
n);
865 int rc_ra = -1, rc_de = -1;
866 double ra = std::numeric_limits<double>::quiet_NaN(), de = std::numeric_limits<double>::quiet_NaN();
873 if (!strcmp(elemName,
"RA"))
875 else if (!strcmp(elemName,
"DEC"))
881 if (rc_ra == 0 && rc_de == 0 && !std::isnan(
ra) && !std::isnan(de))
888 if (
ra == 0 && de == 0)
899 LOGF_DEBUG(
"Calling Update mount to anticipate goto target: %g - DEC: %g",
903 UseHourAngle =
false;
912 int rc_ra = -1, rc_de = -1;
913 double ra = std::numeric_limits<double>::quiet_NaN(), de = std::numeric_limits<double>::quiet_NaN();
919 if (!strcmp(elemName,
"RA"))
921 else if (!strcmp(elemName,
"DEC"))
925 if (rc_ra == 0 && rc_de == 0 && !std::isnan(
ra) && !std::isnan(de))
932 if (
ra == 0 && de == 0)
935 char RAStr[64] = {0}, DEStr[64] = {0};
939 LOGF_DEBUG(
"Snooped RA %s DEC %s", RAStr, DEStr);
974 if (!strcmp(elemName,
"LONG"))
983 else if (!strcmp(elemName,
"LAT"))
999 bool prevState = IsLocked;
1004 if ((!strcmp(elemName,
"PARK") && !strcmp(
pcdataXMLEle(ep),
"On")))
1005 IsMountParked =
true;
1006 else if ((!strcmp(elemName,
"UNPARK") && !strcmp(
pcdataXMLEle(ep),
"On")))
1007 IsMountParked =
false;
1009 if (IsLocked && !strcmp(elemName,
"PARK") && !strcmp(
pcdataXMLEle(ep),
"On"))
1011 else if (!IsLocked && !strcmp(elemName,
"UNPARK") && !strcmp(
pcdataXMLEle(ep),
"On"))
1015 LOGF_INFO(
"Telescope status changed. Lock is set to: %s", IsLocked ?
"locked" :
"unlocked");
1023 if (!strcmp(
"WEATHER_STATUS", propName))
1034 if (AutoParkS[0].s ==
ISS_ON)
1036 LOG_WARN(
"Weather conditions in the danger zone! Parking dome...");
1041 LOG_WARN(
"Weather conditions in the danger zone! AutoPark is disabled. Please park the dome!");
1046 LOG_WARN(
"Weather conditions in the danger zone! Close the dome immediately!");
1059 if (!strcmp(elemName,
"PIER_EAST") && !strcmp(
pcdataXMLEle(ep),
"On"))
1061 else if (!strcmp(elemName,
"PIER_WEST") && !strcmp(
pcdataXMLEle(ep),
"On"))
1068 controller->ISSnoopDevice(root);
1079 LOG_ERROR(
"Dome does not support backlash compensation.");
1121 controller->saveConfigItems(fp);
1129void Dome::triggerSnoop(
const char * driverName,
const char * snoopedProp)
1131 LOGF_DEBUG(
"Active Snoop, driver: %s, property: %s", driverName, snoopedProp);
1148 static_cast<Dome *
>(context)->processButton(button_n, state);
1154void Dome::processButton(
const char * button_n,
ISState state)
1161 if (!strcmp(button_n,
"Dome CW"))
1168 else if (!strcmp(button_n,
"Dome CCW"))
1175 else if (!strcmp(button_n,
"Dome Abort"))
1221 LOG_WARN(
"Unknown shutter status.");
1228 checkShutterParkSequence();
1236 if (m_ShutterParkSequence != SHUTTER_SEQUENCE_NONE)
1239 if ((value ==
DOME_PARKED && m_ShutterParkSequence == SHUTTER_SEQUENCE_PARK) ||
1240 (value ==
DOME_UNPARKED && m_ShutterParkSequence == SHUTTER_SEQUENCE_UNPARK))
1242 shutterParkMotionDone();
1247 cancelShutterParkSequence();
1368 point3D MountCenter, OptCenter, OptVector, DomeIntersect;
1375 LOG_WARN(
"Geographic coordinates are not yet defined, triggering snoop...");
1379 double JD = ln_get_julian_from_sys();
1381 char lstStr[64], latStr[64], lonStr[64];
1382 fs_sexa(lstStr, LST, 2, 3600);
1387 LOGF_DEBUG(
"Coords - LST: %s, Lat: %s, Lon: %s", lstStr, latStr, lonStr);
1395 char raStr[64], decStr[64], haStr[64];
1398 fs_sexa(haStr, hourAngle, 2, 3600);
1402 char mountAzStr[64], mountAltStr[64];
1407 LOGF_DEBUG(
"Mount - RA: %s, Dec: %s, HA: %s --> Az: %s, Alt: %s", raStr, decStr, haStr, mountAzStr, mountAltStr);
1411 double effectiveHourAngle = hourAngle;
1412 const double poleThresholdDec = 89.0;
1416 const double POLE_AZIMUTH_DEVIATION_THRESHOLD = 30.0;
1419 auto performCalculations = [&](
double currentEffectiveHourAngle)
1423 int otaSideSelection =
OTASideSP.findOnSwitchIndex();
1430 double haForSide = nearPole ? currentEffectiveHourAngle : hourAngle;
1433 if (haForSide > 0.1 && haForSide < 11.9)
1455 fs_sexa(effHaStr, currentEffectiveHourAngle, 2, 3600);
1456 LOGF_DEBUG(
"Geom - Mount(E:%.2f,N:%.2f,Up:%.2f) OTA(SideSel:%d, SideUsed:%d, Off:%.2f, EffHA:%s) -> OptCenter(X:%.3f,Y:%.3f,Z:%.3f) OptVec(X:%.3f,Y:%.3f,Z:%.3f)",
1457 MountCenter.
x, MountCenter.
y, MountCenter.
z,
1459 OptCenter.
x, OptCenter.
y, OptCenter.
z,
1460 OptVector.
x, OptVector.
y, OptVector.
z);
1467 LOGF_DEBUG(
"Intersection mu1 < 0, using mu2 (%.3f)", mu2);
1471 DomeIntersect.
x = OptCenter.
x + mu1 * (OptVector.
x );
1472 DomeIntersect.
y = OptCenter.
y + mu1 * (OptVector.
y );
1473 DomeIntersect.
z = OptCenter.
z + mu1 * (OptVector.
z );
1474 LOGF_DEBUG(
"Intersection - Point(X:%.3f, Y:%.3f, Z:%.3f) Dist: %.3f", DomeIntersect.
x, DomeIntersect.
y, DomeIntersect.
z,
1478 Az = atan2(DomeIntersect.
x, DomeIntersect.
y) * 180.0 /
M_PI;
1490 if ((std::abs(DomeIntersect.
x) > 0.00001) || (std::abs(DomeIntersect.
y) > 0.00001))
1491 Alt = 180 * atan(DomeIntersect.
z / sqrt((DomeIntersect.
x * DomeIntersect.
x) + (DomeIntersect.
y * DomeIntersect.
y))) /
M_PI;
1500 minAz =
range360(Az - HalfApertureChordAngle);
1501 maxAz =
range360(Az + HalfApertureChordAngle);
1514 bool success = performCalculations(effectiveHourAngle);
1517 if (nearPole && success)
1519 double initialAz = Az;
1522 diff = 360.0 - diff;
1524 if (diff > POLE_AZIMUTH_DEVIATION_THRESHOLD)
1526 LOGF_DEBUG(
"Near pole, initial Az (%.2f) deviates from mount Az (%.2f) by %.2f degrees. Attempting alternative effectiveHourAngle.",
1530 effectiveHourAngle = (effectiveHourAngle == 0.0) ? 12.0 : 0.0;
1531 success = performCalculations(effectiveHourAngle);
1535 LOGF_DEBUG(
"Re-calculated Az (%.2f) with alternative effectiveHourAngle (%.2f).", Az, effectiveHourAngle);
1539 LOG_WARN(
"Re-calculation with alternative effectiveHourAngle failed.");
1547 char currentAzStr[64], targetAzStr[64], targetAltStr[64], minAzStr[64], maxAzStr[64];
1549 fs_sexa(targetAzStr, Az, 2, 3600);
1550 fs_sexa(targetAltStr, Alt, 2, 3600);
1551 fs_sexa(minAzStr, minAz, 2, 3600);
1552 fs_sexa(maxAzStr, maxAz, 2, 3600);
1553 LOGF_DEBUG(
"Result - Current Az:%s , Target Az: %s, Alt: %s --> Range Min: %s, Max: %s", currentAzStr, targetAzStr,
1554 targetAltStr, minAzStr, maxAzStr);
1559 LOG_WARN(
"Optical axis does not intersect dome sphere.");
1569 a = dp.
x * dp.
x + dp.
y * dp.
y + dp.
z * dp.
z;
1570 b = 2 * (dp.
x * p1.
x + dp.
y * p1.
y + dp.
z * p1.
z);
1572 c = c + p1.
x * p1.
x + p1.
y * p1.
y + p1.
z * p1.
z;
1574 bb4ac = b * b - 4 * a * c;
1575 if ((fabs(a) < 0.0000001) || (bb4ac < 0))
1582 mu1 = (-b + sqrt(bb4ac)) / (2 * a);
1583 mu2 = (-b - sqrt(bb4ac)) / (2 * a);
1591 double cosf, sinf, cosq, sinq;
1594 q =
M_PI * (90 - Lat) / 180;
1595 f = -
M_PI * (180 + Ah * 15) / 180;
1603 OP.
x = (dOpticalAxis * cosf + MountCenter.
x);
1604 OP.
y = (dOpticalAxis * sinf * cosq + MountCenter.
y);
1605 OP.
z = (dOpticalAxis * sinf * sinq + MountCenter.
z);
1614 q =
M_PI * Alt / 180;
1615 f =
M_PI * Az / 180;
1616 OV.
x = cos(q) * sin(f);
1617 OV.
y = cos(q) * cos(f);
1625 return 1.0 / sin(x);
1630 return 1.0 / cos(x);
1637 sinh_value = cos(lat) * cos(HA) * cos(
dec) + sin(lat) * sin(
dec);
1639 if (sinh_value >= 0.0)
1669 if (IsMountParked ==
false)
1682 if (AutoSyncWarning ==
false)
1684 LOG_WARN(
"Cannot perform autosync with dome parked. Please unpark to enable autosync operation.");
1685 AutoSyncWarning =
true;
1691 AutoSyncWarning =
false;
1692 double targetAz = 0, targetAlt = 0, minAz = 0, maxAz = 0;
1694 res =
GetTargetAz(targetAz, targetAlt, minAz, maxAz);
1697 LOGF_DEBUG(
"GetTargetAz failed %g", targetAz);
1701 double diff = std::abs(targetAz -
DomeAbsPosNP[0].getValue());
1703 diff = 360.0 - diff;
1708 LOGF_DEBUG(
"Dome synced to position %.2f degrees.", targetAz);
1710 LOGF_DEBUG(
"Dome is syncing to position %.2f degrees...", targetAz);
1712 LOG_ERROR(
"Dome failed to sync to new requested position.");
1733 return "Shutter is open.";
1735 return "Shutter is closed.";
1737 return "Shutter is moving.";
1739 return "Shutter has errors.";
1742 return "Shutter status is unknown.";
1772void Dome::SyncParkStatus(
bool isparked)
1774 IsParked = isparked;
1792 if (m_ShutterParkSequence != SHUTTER_SEQUENCE_NONE)
1795 if (isparked == (m_ShutterParkSequence == SHUTTER_SEQUENCE_PARK))
1797 shutterParkMotionDone();
1802 cancelShutterParkSequence();
1805 SyncParkStatus(isparked);
1819 LOGF_INFO(
"InitPark: No Park data in file %s: %s", ParkDataFileName.c_str(), loadres);
1820 SyncParkStatus(
false);
1828 LOGF_DEBUG(
"InitPark Axis1 %.2f", Axis1ParkPosition);
1843const char * Dome::LoadParkXML()
1852 bool devicefound =
false;
1855 ParkstatusXml =
nullptr;
1856 ParkdeviceXml =
nullptr;
1857 ParkpositionXml =
nullptr;
1858 ParkpositionAxis1Xml =
nullptr;
1860 if (wordexp(ParkDataFileName.c_str(), &wexp, 0))
1863 return "Badly formed filename.";
1866 if (!(fp = fopen(wexp.we_wordv[0],
"r")))
1869 return strerror(
errno);
1875 if (ParkdataXmlRoot)
1882 if (!ParkdataXmlRoot)
1886 return "Not a park data file";
1892 if (strcmp(
tagXMLEle(parkxml),
"device"))
1898 if (ap && (!strcmp(
valuXMLAtt(ap), ParkDeviceName)))
1907 return "No park data found for this device";
1909 ParkdeviceXml = parkxml;
1910 ParkstatusXml =
findXMLEle(parkxml,
"parkstatus");
1914 ParkpositionXml =
findXMLEle(parkxml,
"parkposition");
1915 ParkpositionAxis1Xml =
findXMLEle(ParkpositionXml,
"axis1position");
1917 if (ParkpositionAxis1Xml ==
nullptr)
1919 return "Park position invalid or missing.";
1922 else if (ParkstatusXml ==
nullptr)
1923 return "Park status invalid or missing.";
1932 const char * result = LoadParkXML();
1933 if (result !=
nullptr)
1942 double axis1Pos = std::numeric_limits<double>::quiet_NaN();
1944 int rc = sscanf(
pcdataXMLEle(ParkpositionAxis1Xml),
"%lf", &axis1Pos);
1947 return "Unable to parse Park Position Axis 1.";
1950 if (std::isnan(axis1Pos) ==
false)
1952 Axis1ParkPosition = axis1Pos;
1956 return "Failed to parse Park Position.";
1963 if (LoadParkXML() !=
nullptr)
1964 LOG_DEBUG(
"Failed to refresh parking data.");
1971 if (wordexp(ParkDataFileName.c_str(), &wexp, 0))
1974 LOGF_INFO(
"WriteParkData: can not write file %s: Badly formed filename.",
1975 ParkDataFileName.c_str());
1979 if (!(fp = fopen(wexp.we_wordv[0],
"w")))
1982 LOGF_INFO(
"WriteParkData: can not write file %s: %s", ParkDataFileName.c_str(),
1987 if (!ParkdataXmlRoot)
1988 ParkdataXmlRoot =
addXMLEle(
nullptr,
"parkdata");
1992 ParkdeviceXml =
addXMLEle(ParkdataXmlRoot,
"device");
1993 addXMLAtt(ParkdeviceXml,
"name", ParkDeviceName);
1997 ParkstatusXml =
addXMLEle(ParkdeviceXml,
"parkstatus");
2000 if (!ParkpositionXml)
2001 ParkpositionXml =
addXMLEle(ParkdeviceXml,
"parkposition");
2002 if (!ParkpositionAxis1Xml)
2003 ParkpositionAxis1Xml =
addXMLEle(ParkpositionXml,
"axis1position");
2006 editXMLEle(ParkstatusXml, (IsParked ?
"true" :
"false"));
2010 snprintf(pcdata,
sizeof(pcdata),
"%lf", Axis1ParkPosition);
2023 return Axis1ParkPosition;
2028 return Axis1DefaultParkPosition;
2033 Axis1ParkPosition = value;
2040 Axis1DefaultParkPosition = value;
2050 LOG_WARN(
"Please unpark the dome before issuing any motion commands.");
2058 LOG_WARN(
"Please stop dome before issuing any further motion commands.");
2062 auto current_direction =
DomeMotionSP.findOnSwitchIndex();
2087 LOG_ERROR(
"Dome does not support relative motion.");
2093 LOG_ERROR(
"Please unpark before issuing any motion commands.");
2101 LOG_WARN(
"Please stop dome before issuing any further motion commands.");
2114 LOGF_INFO(
"Dome moved %.2f degrees %s.", azDiff, (azDiff > 0) ?
"clockwise" :
"counter clockwise");
2128 LOGF_INFO(
"Dome moved %.2f degrees %s.", azDiff, (azDiff > 0) ?
"clockwise" :
"counter clockwise");
2146 LOG_WARN(
"Dome failed to move to new requested position.");
2155 LOG_ERROR(
"Dome does not support MoveAbs(). MoveAbs() must be implemented in the child class.");
2161 LOG_ERROR(
"Please unpark before issuing any motion commands.");
2169 LOG_WARN(
"Please stop dome before issuing any further motion commands.");
2177 LOGF_ERROR(
"Error: requested azimuth angle %.2f is out of range.", az);
2188 LOGF_INFO(
"Dome moved to position %.2f degrees azimuth.", az);
2197 LOGF_INFO(
"Dome is moving to position %.2f degrees azimuth...", az);
2211 LOG_INFO(
"Dome failed to move to new requested position.");
2219 LOG_WARN(
"Syncing is not supported.");
2227 LOG_ERROR(
"Dome does not support abort.");
2235 const bool sequenceParking = (m_ShutterParkSequence == SHUTTER_SEQUENCE_PARK);
2236 const bool sequenceUnparking = (m_ShutterParkSequence == SHUTTER_SEQUENCE_UNPARK);
2237 const bool sequenceMotionDone = m_ShutterParkMotionDone;
2238 cancelShutterParkSequence();
2248 if (parking || unparking)
2276 ((sequenceParking || sequenceUnparking) &&
ParkSP.getState() ==
IPS_BUSY))
2298 LOG_ERROR(
"Dome does not support variable speed.");
2319 LOG_ERROR(
"Dome does not have shutter control.");
2345 LOGF_INFO(
"Shutter is %s...", (operation == 0 ?
"opening" :
"closing"));
2351 LOGF_INFO(
"Shutter failed to %s.", (operation == 0 ?
"open" :
"close"));
2361 LOG_ERROR(
"Dome does not support parking.");
2382 LOG_INFO(
"Cannot Park Dome when mount is locking. See: Mount Policy in options tab.");
2387 cancelShutterParkSequence();
2391 if (
HasShutter() && !m_ShutterParkPolicyHandledByDriver &&
2394 LOG_INFO(
"Closing shutter on park...");
2395 m_ShutterParkSequence = SHUTTER_SEQUENCE_PARK;
2396 m_ShutterParkCommandSent =
true;
2400 cancelShutterParkSequence();
2401 LOG_ERROR(
"Failed to close shutter. Dome park aborted.");
2407 m_ShutterParkTimer.start();
2420 if (m_ShutterParkSequence == SHUTTER_SEQUENCE_PARK)
2439 cancelShutterParkSequence();
2443 return ParkSP.getState();
2450 LOG_ERROR(
"Dome does not support parking.");
2458 LOG_INFO(
"Dome already unparked.");
2463 cancelShutterParkSequence();
2469 const bool openShutter =
HasShutter() && !m_ShutterParkPolicyHandledByDriver &&
2472 m_ShutterParkSequence = SHUTTER_SEQUENCE_UNPARK;
2478 cancelShutterParkSequence();
2485 if (openShutter && m_ShutterParkSequence == SHUTTER_SEQUENCE_UNPARK)
2487 LOG_INFO(
"Opening shutter on unpark...");
2488 m_ShutterParkCommandSent =
true;
2491 LOG_ERROR(
"Failed to open shutter on unpark.");
2492 m_ShutterParkShutterFailed =
true;
2495 m_ShutterParkTimer.start();
2504 cancelShutterParkSequence();
2510 if (m_ShutterParkSequence == SHUTTER_SEQUENCE_UNPARK)
2517 return ParkSP.getState();
2520bool Dome::isShutterAt(ShutterOperation operation)
const
2525bool Dome::isShutterKnownAt(ShutterOperation operation)
const
2533void Dome::cancelShutterParkSequence()
2535 m_ShutterParkTimer.stop();
2536 m_ShutterParkSequence = SHUTTER_SEQUENCE_NONE;
2537 m_ShutterParkCommandSent =
false;
2538 m_ShutterParkMotionDone =
false;
2539 m_ShutterParkShutterDone =
false;
2540 m_ShutterParkShutterFailed =
false;
2543void Dome::shutterParkMotionDone()
2545 if (m_ShutterParkMotionDone)
2548 m_ShutterParkMotionDone =
true;
2551 if (m_ShutterParkSequence == SHUTTER_SEQUENCE_PARK)
2571 checkShutterParkSequence();
2573 if (m_ShutterParkSequence == SHUTTER_SEQUENCE_PARK)
2574 LOG_INFO(
"Dome reached park position. Waiting for shutter to close...");
2575 else if (m_ShutterParkSequence == SHUTTER_SEQUENCE_UNPARK)
2576 LOG_INFO(
"Dome is unparked. Waiting for shutter to open...");
2579void Dome::checkShutterParkSequence()
2581 if (m_ShutterParkSequence == SHUTTER_SEQUENCE_NONE)
2584 const bool parking = (m_ShutterParkSequence == SHUTTER_SEQUENCE_PARK);
2586 if (m_ShutterParkCommandSent && !m_ShutterParkShutterDone && !m_ShutterParkShutterFailed)
2591 m_ShutterParkShutterDone =
true;
2594 LOGF_ERROR(
"Shutter failed to %s.", parking ?
"close" :
"open");
2595 m_ShutterParkShutterFailed =
true;
2599 if (!m_ShutterParkMotionDone || !(m_ShutterParkShutterDone || m_ShutterParkShutterFailed))
2602 const bool failed = m_ShutterParkShutterFailed;
2603 cancelShutterParkSequence();
2610 LOG_ERROR(
"Dome park failed: shutter is not closed.");
2621 LOG_ERROR(
"Dome is unparked but shutter failed to open.");
2630 LOG_WARN(
"Parking is not supported.");
2636 LOG_WARN(
"Parking is not supported.");
2645bool Dome::callHandshake()
2647 if (domeConnection > 0)
2660 return domeConnection;
2667 if (value == 0 || (mask & value) == 0)
2669 LOGF_ERROR(
"Invalid connection mode %d", value);
2673 domeConnection = value;
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
The TCP class manages connection with devices over the network via TCP/IP. Upon successful connection...
const char * getDeviceName() const
INDI::PropertyText getText(const char *name) const
The Controller class provides functionality to access a controller (e.g. joystick) input and send it ...
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process the client newSwitch command.
void registerConnection(Connection::Interface *newConnection)
registerConnection Add new connection plugin to the existing connection pool. The connection type sha...
virtual void ISGetProperties(const char *dev)
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool ISSnoopDevice(XMLEle *root)
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
void setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool initProperties()
Initialize properties initial state and value. The child class must implement this function.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process the client newNumber command.
Connection::Interface * getActiveConnection()
void addDebugControl()
Add Debug control to the driver.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
INDI::PropertySwitch PresetGotoSP
INDI::IHorizontalCoordinates mountHoriztonalCoords
Connection::TCP * tcpConnection
virtual IPState UnPark()
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
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
INDI::PropertySwitch ParkOptionSP
const char * GetShutterStatusString(ShutterState status)
getShutterStatusString
INDI::IEquatorialCoordinates mountEquatorialCoords
bool CheckHorizon(double HA, double dec, double lat)
CheckHorizon Returns true if telescope points above horizon.
INDI::PropertyNumber DomeRelPosNP
bool isParked()
isParked is dome currently parked?
INDI::PropertyNumber DomeParamNP
bool OpticalCenter(point3D MountCenter, double dOpticalAxis, double Lat, double Ah, point3D &OP)
OpticalCenter This function calculates the distance from the optical axis to the Dome center.
INDI::PropertyNumber ParkPositionNP
virtual bool SetSpeed(double rpm)
SetSpeed Set Dome speed. This does not initiate motion, it sets the speed for the next motion command...
virtual bool Sync(double az)
Sync sets the dome current azimuth as the supplied azimuth position.
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,...
ShutterOperation
Shutter operation command.
IPState getMountState() const
void SetAxis1ParkDefault(double steps)
SetAxis1Park Set default AZ parking position.
INDI::PropertySwitch AbortSP
INDI::PropertyNumber DomeSpeedNP
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
INDI::PropertyNumber DomeMeasurementsNP
virtual void UpdateAutoSync()
UpdateAutoSync This function calculates the target dome azimuth from the mount's target coordinates g...
INDI::PropertyNumber DomeBacklashNP
virtual IPState MoveRel(double azDiff)
Move the Dome to an relative position.
bool isLocked()
isLocked, is the dome currently locked?
virtual void ActiveDevicesUpdated()
INDI::PropertySwitch ParkSP
virtual bool SetBacklash(int32_t steps)
SetBacklash Set the dome backlash compensation value.
double GetAxis1ParkDefault()
virtual IPState Park()
Goto Park Position. The park position is an absolute azimuth value.
const char * LoadParkData()
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.
virtual bool SetDefaultPark()
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
bool Intersection(point3D p1, point3D p2, double r, double &mu1, double &mu2)
Intersection Calculate the intersection of a ray and a sphere. The line segment is defined from p1 to...
virtual bool SetBacklashEnabled(bool enabled)
SetBacklashEnabled Enables or disables the dome backlash compensation.
virtual IPState MoveAbs(double az)
Move the Dome to an absolute azimuth.
INDI::PropertySwitch DomeMotionSP
IGeographicCoordinates observer
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
static void buttonHelper(const char *button_n, ISState state, void *context)
INDI::PropertySwitch DomeBacklashSP
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
virtual bool SetCurrentPark()
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
void setShutterState(const ShutterState &value)
bool OpticalVector(double Az, double Alt, point3D &OV)
OpticalVector This function calculates a second point for determining the optical axis.
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
INDI::PropertySwitch MountPolicySP
void SetParkDataType(DomeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
INDI::PropertySwitch DomeAutoSyncSP
INDI::PropertySwitch DomeShutterSP
DomeParkData parkDataType
virtual bool Handshake()
perform handshake with device to check communication
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual IPState ControlShutter(ShutterOperation operation)
Open or Close shutter.
INDI::PropertyText ActiveDeviceTP
INDI::PropertySwitch OTASideSP
bool GetTargetAz(double &Az, double &Alt, double &minAz, double &maxAz)
GetTargetAz.
INDI::PropertyNumber DomeSyncNP
uint8_t getDomeConnection() const
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation)
Move the Dome in a particular direction.
INDI::PropertyNumber PresetNP
virtual bool Abort()
Abort all dome motion.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * SITE_TAB
SITE_TAB Where all site information setting are located.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
int fs_sexa(char *out, double a, int w, int fracbase)
Converts a sexagesimal number to a string. sprint the variable a in sexagesimal format into out[].
double get_local_hour_angle(double sideral_time, double ra)
get_local_hour_angle Returns local hour angle of an object
Implementations for common driver routines.
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sidereal time given longitude and system clock.
int crackIPState(const char *str, IPState *ip)
Extract property state (Idle, OK, Busy, Alert) from the supplied string.
#define DOME_COORD_THRESHOLD
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
void IDSnoopDevice(const char *snooped_device, const char *snooped_property)
Function a Driver calls to snoop on another Device. Snooped messages will then arrive via ISSnoopDevi...
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_INFO(fmt,...)
#define DEBUG(priority, msg)
Macro to print log messages. Example of usage of the Logger: DEBUG(DBG_DEBUG, "hello " << "world");.
#define LOGF_WARN(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,...)
const char * findXMLAttValu(XMLEle *ep, const char *name)
Find an XML element's attribute value.
XMLEle * nextXMLEle(XMLEle *ep, int init)
Iterate an XML element for a list of nesetd XML elements.
XMLAtt * findXMLAtt(XMLEle *ep, const char *name)
Find an XML attribute within an XML element.
LilXML * newLilXML()
Create a new lilxml parser.
char * tagXMLEle(XMLEle *ep)
Return the tag of an XML element.
XMLEle * addXMLEle(XMLEle *parent, const char *tag)
add an element with the given tag to the given element. parent can be NULL to make a new root.
XMLEle * findXMLEle(XMLEle *ep, const char *tag)
Find an XML element within an XML element.
char * valuXMLAtt(XMLAtt *ap)
Return the value of an XML attribute.
void editXMLEle(XMLEle *ep, const char *pcdata)
set the pcdata of the given element
void prXMLEle(FILE *fp, XMLEle *ep, int level)
Print an XML element.
void delXMLEle(XMLEle *ep)
delXMLEle Delete XML element.
char * pcdataXMLEle(XMLEle *ep)
Return the pcdata of an XML element.
void delLilXML(LilXML *lp)
Delete a lilxml parser.
XMLAtt * addXMLAtt(XMLEle *ep, const char *name, const char *valu)
Add an XML attribute to an existing XML element.
XMLEle * readXMLFile(FILE *fp, LilXML *lp, char ynot[])
Handy wrapper to read one xml file.
Namespace to encapsulate INDI client, drivers, and mediator classes.
void EquatorialToHorizontal(IEquatorialCoordinates *object, IGeographicCoordinates *observer, double JD, IHorizontalCoordinates *position)
EquatorialToHorizontal Calculate horizontal coordinates from equatorial coordinates.