41static std::unique_ptr<PegasusUPB> upb(
new PegasusUPB());
48 lastSensorData.reserve(21);
49 lastPowerData.reserve(4);
50 lastStepperData.reserve(4);
51 lastDewAggData.reserve(1);
74 RebootSP[0].fill(
"REBOOT",
"Reboot Device",
ISS_OFF);
79 PowerConsumptionNP[CONSUMPTION_AVG_AMPS].fill(
"CONSUMPTION_AVG_AMPS",
"Avg. Amps",
"%4.2f", 0, 999, 100, 0);
80 PowerConsumptionNP[CONSUMPTION_AMP_HOURS].fill(
"CONSUMPTION_AMP_HOURS",
"Amp Hours",
"%4.2f", 0, 999, 100, 0);
81 PowerConsumptionNP[CONSUMPTION_WATT_HOURS].fill(
"CONSUMPTION_WATT_HOURS",
"Watt Hours",
"%4.2f", 0, 999, 100, 0);
82 PowerConsumptionNP.fill(
getDeviceName(),
"POWER_CONSUMPTION",
"Consumption",
86 PowerOnBootSP[POWER_PORT_1].fill(
"POWER_PORT_1",
"Port 1",
ISS_ON);
87 PowerOnBootSP[POWER_PORT_2].fill(
"POWER_PORT_2",
"Port 2",
ISS_ON);
88 PowerOnBootSP[POWER_PORT_3].fill(
"POWER_PORT_3",
"Port 3",
ISS_ON);
89 PowerOnBootSP[POWER_PORT_4].fill(
"POWER_PORT_4",
"Port 4",
ISS_ON);
93 OverCurrentLP[POWER_PORT_1].fill(
"POWER_PORT_1",
"Port 1",
IPS_OK);
94 OverCurrentLP[POWER_PORT_2].fill(
"POWER_PORT_2",
"Port 2",
IPS_OK);
95 OverCurrentLP[POWER_PORT_3].fill(
"POWER_PORT_3",
"Port 3",
IPS_OK);
96 OverCurrentLP[POWER_PORT_4].fill(
"POWER_PORT_4",
"Port 4",
IPS_OK);
97 OverCurrentLP[DEW_A].fill(
"DEW_A",
"Dew A",
IPS_OK);
98 OverCurrentLP[DEW_B].fill(
"DEW_B",
"Dew B",
IPS_OK);
99 OverCurrentLP[DEW_C].fill(
"DEW_C",
"Dew C",
IPS_OK);
107 AutoDewAggNP[AUTO_DEW_AGG].fill(
"AUTO_DEW_AGG_VALUE",
"Auto Dew Agg (50-250)",
"%.2f", 50, 250, 20, 0);
116 FocuserSettingsNP[SETTING_MAX_SPEED].fill(
"SETTING_MAX_SPEED",
"Max Speed",
"%.f", 0, 900, 100, 400);
122 FirmwareTP[FIRMWARE_VERSION].fill(
"VERSION",
"Version",
"NA");
123 FirmwareTP[FIRMWARE_UPTIME].fill(
"UPTIME",
"Uptime (h)",
"NA");
124 FirmwareTP.fill(
getDeviceName(),
"FIRMWARE_INFO",
"Firmware", FIRMWARE_TAB,
IP_RO, 60,
129 addParameter(
"WEATHER_TEMPERATURE",
"Temperature (C)", -15, 35, 15);
130 addParameter(
"WEATHER_HUMIDITY",
"Humidity %", 0, 100, 15);
131 addParameter(
"WEATHER_DEWPOINT",
"Dew Point (C)", 0, 100, 15);
138 serialConnection->registerHandshake([&]()
181 setupComplete =
true;
209 setupComplete =
false;
217 return "Pegasus UPB";
223bool PegasusUPB::Handshake()
225 char response[PEGASUS_LEN] = {0};
227 PortFD = serialConnection->getPortFD();
233 snprintf(response, PEGASUS_LEN,
"UPB2_OK");
238 int tty_rc = 0, nbytes_written = 0;
239 char command[PEGASUS_LEN] = {0};
240 tcflush(PortFD, TCIOFLUSH);
241 strncpy(command,
"P#\n", PEGASUS_LEN);
246 LOGF_ERROR(
"Serial write error: %s", errorMessage);
256 tcflush(PortFD, TCIOFLUSH);
259 tty_rc =
tty_nread_section(PortFD, response, PEGASUS_LEN, stopChar, 1, &nbytes_read);
266 LOGF_ERROR(
"Serial read error: %s", errorMessage);
271 cleanupResponse(response);
272 tcflush(PortFD, TCIOFLUSH);
278 setupComplete =
false;
281 lastSensorData.clear();
282 lastPowerData.clear();
283 lastStepperData.clear();
284 lastDewAggData.clear();
286 version = strstr(response,
"UPB2_OK") ?
UPB_V2 :
UPB_V1;
307 const char *usbLabels[] = {
"USB3 Port 1",
"USB3 Port 2",
"USB3 Port 3",
"USB3 Port 4",
"USB2 Port 5",
"USB2 Port 6"};
323 if (RebootSP.isNameMatch(name))
332 if (PowerOnBootSP.isNameMatch(name))
337 PowerOnBootSP.update(states, names,
n);
339 PowerOnBootSP.apply();
344 if (strstr(name,
"FOCUS"))
356 return DefaultDevice::ISNewSwitch(dev, name, states, names,
n);
367 if (AutoDewAggNP.isNameMatch(name))
373 if (setAutoDewAgg(values[0]))
375 AutoDewAggNP[0].setValue(values[0]);
376 AutoDewAggNP.setState(
IPS_OK);
383 AutoDewAggNP.apply();
388 if (FocuserSettingsNP.isNameMatch(name))
394 if (setFocuserMaxSpeed(values[0]))
396 FocuserSettingsNP[0].setValue(values[0]);
397 FocuserSettingsNP.setState(
IPS_OK);
404 FocuserSettingsNP.apply();
408 if (strstr(name,
"FOCUS_"))
411 if (strstr(name,
"WEATHER_"))
421 std::vector<double> volts(values, values +
n);
422 for (
auto &volt : volts)
423 volt = std::clamp(std::round(volt), 3.0, 12.0);
454bool PegasusUPB::sendCommand(
const char *
cmd,
char * res)
456 int nbytes_read = 0, nbytes_written = 0, tty_rc = 0;
461 if (!strcmp(
cmd,
"PS"))
463 strncpy(res,
"PS:1111:12", PEGASUS_LEN);
465 else if (!strcmp(
cmd,
"PA"))
467 strncpy(res,
"UPB2:12.0:0.9:10:24.8:37:9.1:1111:111111:153:153:0:0:0:0:0:70:0:0:0000000:0", PEGASUS_LEN);
469 else if (!strcmp(
cmd,
"PC"))
471 strncpy(res,
"0.40:0.00:0.03:26969", PEGASUS_LEN);
473 else if (!strcmp(
cmd,
"SA"))
475 strncpy(res,
"3000:0:0:10", PEGASUS_LEN);
477 else if (!strcmp(
cmd,
"SS"))
479 strncpy(res,
"999", PEGASUS_LEN);
481 else if (!strcmp(
cmd,
"PD"))
483 strncpy(res,
"210", PEGASUS_LEN);
485 else if (!strcmp(
cmd,
"PV"))
487 strncpy(res,
"Sim v1.0", PEGASUS_LEN);
491 snprintf(res, PEGASUS_LEN,
"%s",
cmd);
497 for (
int i = 0; i < 2; i++)
499 char command[PEGASUS_LEN] = {0};
500 tcflush(PortFD, TCIOFLUSH);
501 snprintf(command, PEGASUS_LEN,
"%s\n",
cmd);
507 tcflush(PortFD, TCIOFLUSH);
515 tcflush(PortFD, TCIOFLUSH);
517 cleanupResponse(res);
535 return setUSBPortEnabled(port, enabled);
543 char cmd[PEGASUS_LEN] = {0}, res[PEGASUS_LEN] = {0};
544 snprintf(
cmd, PEGASUS_LEN,
"SM:%u", targetTicks);
545 if (sendCommand(
cmd, res))
547 m_FocusTarget =
static_cast<int32_t
>(targetTicks);
548 m_FocusIdlePolls = 0;
568 char res[PEGASUS_LEN] = {0};
569 if (sendCommand(
"SH", res))
571 return (!strcmp(res,
"SH"));
582 char cmd[PEGASUS_LEN] = {0}, res[PEGASUS_LEN] = {0};
583 snprintf(
cmd, PEGASUS_LEN,
"SR:%d", enabled ? 1 : 0);
584 if (sendCommand(
cmd, res))
586 return (!strcmp(res,
cmd));
597 char cmd[PEGASUS_LEN] = {0};
598 snprintf(
cmd, PEGASUS_LEN,
"SC:%u", ticks);
599 return sendCommand(
cmd,
nullptr);
609 char cmd[PEGASUS_LEN] = {0}, res[PEGASUS_LEN] = {0};
610 snprintf(
cmd, PEGASUS_LEN,
"SB:%d", steps);
611 return sendCommand(
cmd, res) && !strcmp(
cmd, res);
617bool PegasusUPB::setFocuserMaxSpeed(uint16_t maxSpeed)
620 char cmd[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
621 snprintf(
cmd, PEGASUS_LEN,
"SS:%d", maxSpeed);
622 return sendCommand(
cmd, res);
632 if (enabled && steps <= 0)
641bool PegasusUPB::setPowerEnabled(uint8_t port,
bool enabled)
643 char cmd[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
644 snprintf(
cmd, PEGASUS_LEN,
"P%d:%d", port, enabled ? 1 : 0);
645 if (sendCommand(
cmd, res))
647 return (!strcmp(res,
cmd));
656bool PegasusUPB::setPowerLEDEnabled(
bool enabled)
658 char cmd[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
659 snprintf(
cmd, PEGASUS_LEN,
"PL:%d", enabled ? 1 : 0);
660 if (sendCommand(
cmd, res))
662 return (!strcmp(res,
cmd));
671bool PegasusUPB::setAutoDewEnabled(
bool enabled)
673 char cmd[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
674 snprintf(
cmd, PEGASUS_LEN,
"PD:%d", enabled ? 1 : 0);
675 if (sendCommand(
cmd, res))
677 return (!strcmp(res,
cmd));
686bool PegasusUPB::setAutoDewAgg(uint8_t value)
688 char cmd[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0}, expected[PEGASUS_LEN] = {0};
689 snprintf(
cmd, PEGASUS_LEN,
"PD:%03d", value);
690 snprintf(expected, PEGASUS_LEN,
"PD:%d", value);
691 if (sendCommand(
cmd, res))
693 return (!strcmp(res, expected));
701bool PegasusUPB::setAdjustableOutput(uint8_t voltage)
703 char cmd[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
704 snprintf(
cmd, PEGASUS_LEN,
"P8:%d", voltage);
705 if (sendCommand(
cmd, res))
707 return (!strcmp(res,
cmd));
716bool PegasusUPB::setPowerOnBoot()
718 char cmd[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
719 snprintf(
cmd, PEGASUS_LEN,
"PE:%d%d%d%d", PowerOnBootSP[POWER_PORT_1].getState() ==
ISS_ON ? 1 : 0,
720 PowerOnBootSP[POWER_PORT_2].getState() ==
ISS_ON ? 1 : 0,
721 PowerOnBootSP[POWER_PORT_3].getState() ==
ISS_ON ? 1 : 0,
722 PowerOnBootSP[POWER_PORT_4].getState() ==
ISS_ON ? 1 : 0);
723 if (sendCommand(
cmd, res))
725 return (!strcmp(res,
"PE:1"));
734bool PegasusUPB::getPowerOnBoot()
736 char res[PEGASUS_LEN] = {0};
737 if (sendCommand(
"PS", res))
739 std::vector<std::string> result = split(res,
":");
740 if (result.size() != 3)
742 LOGF_WARN(
"Received wrong number (%i) of power on boot data (%s). Retrying...", result.size(), res);
746 const char *status = result[1].c_str();
747 PowerOnBootSP[POWER_PORT_1].setState((status[0] ==
'1') ?
ISS_ON :
ISS_OFF);
748 PowerOnBootSP[POWER_PORT_2].setState((status[1] ==
'1') ?
ISS_ON :
ISS_OFF);
749 PowerOnBootSP[POWER_PORT_3].setState((status[2] ==
'1') ?
ISS_ON :
ISS_OFF);
750 PowerOnBootSP[POWER_PORT_4].setState((status[3] ==
'1') ?
ISS_ON :
ISS_OFF);
773bool PegasusUPB::setDewPWM(uint8_t
id, uint8_t value)
775 char cmd[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0}, expected[PEGASUS_LEN] = {0};
776 snprintf(
cmd, PEGASUS_LEN,
"P%d:%03d",
id, value);
777 snprintf(expected, PEGASUS_LEN,
"P%d:%d",
id, value);
778 if (sendCommand(
cmd, res))
780 return (!strcmp(res, expected));
789bool PegasusUPB::setUSBHubEnabled(
bool enabled)
791 char cmd[PEGASUS_LEN] = {0}, expected[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
792 snprintf(
cmd, PEGASUS_LEN,
"PU:%d", enabled ? 1 : 0);
793 snprintf(expected, PEGASUS_LEN,
"PU:%d", enabled ? 0 : 1);
794 if (sendCommand(
cmd, res))
796 return (!strcmp(res, expected));
805bool PegasusUPB::setUSBPortEnabled(uint8_t port,
bool enabled)
807 char cmd[PEGASUS_LEN] = {0}, expected[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
808 snprintf(
cmd, PEGASUS_LEN,
"U%d:%d", port + 1, enabled ? 1 : 0);
809 snprintf(expected, PEGASUS_LEN,
"U%d:%d", port + 1, enabled ? 1 : 0);
810 if (sendCommand(
cmd, res))
812 return (!strcmp(res, expected));
821bool PegasusUPB::toggleAutoDewV2(
size_t port,
bool enabled)
823 char cmd[PEGASUS_LEN] = {0}, expected[PEGASUS_LEN] = {0},
res[PEGASUS_LEN] = {0};
832 if (port == 0) dewA_on = enabled;
833 else if (port == 1) dewB_on = enabled;
834 else if (port == 2) dewC_on = enabled;
836 if (!dewA_on && !dewB_on && !dewC_on)
838 else if (dewA_on && dewB_on && dewC_on)
840 else if (dewA_on && dewB_on)
842 else if (dewA_on && dewC_on)
844 else if (dewB_on && dewC_on)
853 snprintf(
cmd, PEGASUS_LEN,
"PD:%d", value);
854 snprintf(expected, PEGASUS_LEN,
"PD:%d", value);
855 if (sendCommand(
cmd, res))
857 return (!strcmp(res, expected));
901 catch (
const std::exception &e)
903 LOGF_WARN(
"Failed to parse the device status: %s", e.what());
912bool PegasusUPB::sendFirmware()
914 char res[PEGASUS_LEN] = {0};
915 if (sendCommand(
"PV", res))
918 FirmwareTP[FIRMWARE_VERSION].setText(res);
929bool PegasusUPB::sensorUpdated(
const std::vector<std::string> &result, uint8_t start, uint8_t end)
931 if (lastSensorData.empty())
934 for (uint8_t index = start; index <=
end; index++)
936 if (index >= lastSensorData.size() or result[index] != lastSensorData[index])
946bool PegasusUPB::stepperUpdated(
const std::vector<std::string> &result, uint8_t index)
948 if (lastStepperData.empty())
951 return index >= lastStepperData.size() or result[index] != lastStepperData[index];
957bool PegasusUPB::getSensorData()
959 char res[PEGASUS_LEN] = {0};
960 if (sendCommand(
"PA", res))
962 std::vector<std::string> result = split(res,
":");
963 if ( (version ==
UPB_V1 && result.size() != 19) ||
964 (version ==
UPB_V2 && result.size() != 21))
966 LOGF_WARN(
"Received wrong number (%i) of detailed sensor data (%s). Retrying...", result.size(), res);
970 if (result == lastSensorData)
979 if (sensorUpdated(result, 0, 2))
987 if (sensorUpdated(result, 4, 6))
996 const char * portStatus = result[7].c_str();
1005 if (sensorUpdated(result, 7, 7))
1009 const char * usb_status = result[8].c_str();
1016 if (sensorUpdated(result, 8, 8))
1025 if (sensorUpdated(result, 8, 8))
1039 const size_t dewChannels = (version ==
UPB_V1) ? 2 : 3;
1042 const double duty = std::stod(result[index + i]);
1046 if (sensorUpdated(result, index, version ==
UPB_V1 ? index + 1 : index + 2))
1051 bool dewChannelChanged =
false;
1054 auto newState = (std::stoi(result[index]) > 0) ?
ISS_ON :
ISS_OFF;
1058 dewChannelChanged =
true;
1063 auto newState = (std::stoi(result[index + 1]) > 0) ?
ISS_ON :
ISS_OFF;
1067 dewChannelChanged =
true;
1072 auto newState = (std::stoi(result[index + 2]) > 0) ?
ISS_ON :
ISS_OFF;
1076 dewChannelChanged =
true;
1079 if (dewChannelChanged)
1082 index = (version ==
UPB_V1) ? 11 : 12;
1084 const double ampDivision = (version ==
UPB_V1) ? 400.0 : 480.0;
1095 if (sensorUpdated(result, index, index + 3))
1098 index = (version ==
UPB_V1) ? 15 : 16;
1106 if (sensorUpdated(result, index, version ==
UPB_V1 ? index + 1 : index + 2))
1109 index = (version ==
UPB_V1) ? 17 : 19;
1113 if (sensorUpdated(result, index, index))
1115 const char * over_curent = result[index].c_str();
1116 OverCurrentLP[POWER_PORT_1].setState((over_curent[0] ==
'0') ?
IPS_OK :
IPS_ALERT);
1117 OverCurrentLP[POWER_PORT_2].setState((over_curent[1] ==
'0') ?
IPS_OK :
IPS_ALERT);
1118 OverCurrentLP[POWER_PORT_3].setState((over_curent[2] ==
'0') ?
IPS_OK :
IPS_ALERT);
1119 OverCurrentLP[POWER_PORT_4].setState((over_curent[3] ==
'0') ?
IPS_OK :
IPS_ALERT);
1122 OverCurrentLP[DEW_A].setState((over_curent[4] ==
'0') ?
IPS_OK :
IPS_ALERT);
1123 OverCurrentLP[DEW_B].setState((over_curent[5] ==
'0') ?
IPS_OK :
IPS_ALERT);
1124 OverCurrentLP[DEW_C].setState((over_curent[6] ==
'0') ?
IPS_OK :
IPS_ALERT);
1127 OverCurrentLP.setState(strchr(over_curent,
'1') ?
IPS_ALERT :
IPS_OK);
1128 OverCurrentLP.apply();
1131 index = (version ==
UPB_V1) ? 18 : 20;
1137 if (sensorUpdated(result, index, index))
1146 if (sensorUpdated(result, index, index))
1148 int value = std::stoi(result[index]);
1203 lastSensorData = result;
1213bool PegasusUPB::getPowerData()
1215 char res[PEGASUS_LEN] = {0};
1216 if (sendCommand(
"PC", res))
1218 std::vector<std::string> result = split(res,
":");
1220 if (result.size() < 3)
1222 LOGF_WARN(
"Received wrong number (%i) of power sensor data (%s). Retrying...", result.size(), res);
1226 if (result == lastPowerData)
1229 PowerConsumptionNP[CONSUMPTION_AVG_AMPS].setValue(std::stod(result[0]));
1230 PowerConsumptionNP[CONSUMPTION_AMP_HOURS].setValue(std::stod(result[1]));
1231 PowerConsumptionNP[CONSUMPTION_WATT_HOURS].setValue(std::stod(result[2]));
1232 PowerConsumptionNP.setState(
IPS_OK);
1233 PowerConsumptionNP.apply();
1235 if (result.size() == 4)
1239 std::chrono::milliseconds uptime(std::stol(result[3]));
1240 using dhours = std::chrono::duration<double, std::ratio<3600>>;
1241 std::stringstream ss;
1242 ss << std::fixed << std::setprecision(3) << dhours(uptime).count();
1243 FirmwareTP[FIRMWARE_UPTIME].setText(ss.str().c_str());
1248 FirmwareTP[FIRMWARE_UPTIME].setText(
"NA");
1249 LOGF_DEBUG(
"Failed to process uptime: %s", result[3].c_str());
1255 lastPowerData = result;
1265bool PegasusUPB::getStepperData()
1267 char res[PEGASUS_LEN] = {0};
1268 if (sendCommand(
"SA", res))
1270 std::vector<std::string> result = split(res,
":");
1271 if (result.size() != 4)
1273 LOGF_WARN(
"Received wrong number (%i) of stepper sensor data (%s). Retrying...", result.size(), res);
1279 if (result == lastStepperData && !moving)
1282 const int position = std::stoi(result[0]);
1284 focusMotorRunning = (std::stoi(result[1]) == 1);
1288 if (moving && !focusMotorRunning && (position == m_FocusTarget || ++m_FocusIdlePolls >= FOCUS_IDLE_POLLS))
1292 LOGF_ERROR(
"The focuser stopped at %d instead of %d.", position, m_FocusTarget);
1300 if (focusMotorRunning)
1301 m_FocusIdlePolls = 0;
1302 if (stepperUpdated(result, 0))
1309 if (stepperUpdated(result, 2))
1314 const int backlash = std::stoi(result[3]);
1315 if (stepperUpdated(result, 3))
1317 const bool wasOn = lastStepperData.size() > 3 && lastStepperData[3] !=
"0";
1326 else if (wasOn || lastStepperData.empty())
1334 lastStepperData = result;
1340bool PegasusUPB::getDewAggData()
1342 char res[PEGASUS_LEN] = {0};
1343 if (sendCommand(
"DA", res))
1345 std::vector<std::string> result = split(res,
":");
1346 if (result.size() != 2)
1348 LOGF_WARN(
"Received wrong number (%i) of dew aggresiveness data (%s). Retrying...", result.size(), res);
1352 if (result == lastDewAggData)
1355 AutoDewAggNP[0].setValue(std::stod(result[1]));
1356 AutoDewAggNP.setState(
IPS_OK);
1357 AutoDewAggNP.apply();
1359 lastDewAggData = result;
1367bool PegasusUPB::reboot()
1369 return sendCommand(
"PF",
nullptr);
1375std::vector<std::string> PegasusUPB::split(
const std::string &input,
const std::string ®ex)
1378 std::regex re(regex);
1379 std::sregex_token_iterator
1380 first{input.begin(), input.end(), re, -1},
1382 return {first, last};
1388bool PegasusUPB::setupParams()
1396 char res[PEGASUS_LEN] = {0};
1397 if (sendCommand(
"SS", res))
1401 uint32_t
value = std::stol(res);
1402 if (value == UINT16_MAX)
1404 LOGF_WARN(
"Invalid maximum speed detected: %u. Please set maximum speed appropriate for your motor focus type (0-900)",
1410 FocuserSettingsNP[SETTING_MAX_SPEED].setValue(value);
1411 FocuserSettingsNP.setState(
IPS_OK);
1416 LOGF_WARN(
"Failed to process focuser max speed: %s", res);
1427void PegasusUPB::cleanupResponse(
char *response)
1429 std::string s(response);
1430 s.erase(std::remove_if(s.begin(), s.end(),
1433 return std::isspace(x);
1435 snprintf(response, PEGASUS_LEN,
"%s", s.c_str());
1444 return setPowerEnabled(port + 1, enabled);
1451 auto pwmValue =
static_cast<uint8_t
>(dutyCycle / 100.0 * 255.0);
1452 return setDewPWM(port + 5, enabled ? pwmValue : 0);
1461 LOG_WARN(
"The adjustable output cannot be switched off; it always supplies 3 to 12 V.");
1464 return setAdjustableOutput(
static_cast<uint8_t
>(std::lround(std::clamp(voltage, 3.0, 12.0))));
1470 if (!enabled && version ==
UPB_V2)
1471 LOG_WARN(
"With the LED off, the stepper motor output sleeps on UPB v2 boards from revision C on.");
1472 return setPowerLEDEnabled(enabled);
1481 return setAutoDewEnabled(enabled);
1487 return toggleAutoDewV2(port, enabled);
1496 char cmd[PEGASUS_LEN] = {0}, res[PEGASUS_LEN] = {0};
1497 snprintf(
cmd, PEGASUS_LEN,
"PZ:1");
1498 if (sendCommand(
cmd, res) && !strcmp(
cmd, res))
1500 LOG_INFO(
"All power outputs switched on (PZ:1). The UPB has no power cycle command.");
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
const char * getDeviceName() const
virtual bool updateProperties()
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
void registerConnection(Connection::Interface *newConnection)
registerConnection Add new connection plugin to the existing connection pool. The connection type sha...
bool isConfigLoading() const
isConfigLoading Check if driver configuration is currently in the process of getting loaded.
void setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
friend class WeatherInterface
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)
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
virtual bool initProperties()
Initialize properties initial state and value. The child class must implement this function.
bool isSimulation() const
friend class FocuserInterface
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process the client newNumber command.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
friend class PowerInterface
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
INDI::PropertyNumber FocusRelPosNP
INDI::PropertySwitch FocusReverseSP
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
void initProperties(const char *groupName)
Initialize focuser properties. It is recommended to call this function within initProperties() of you...
bool saveConfigItems(FILE *fp)
saveConfigItems save focuser properties defined in the interface in config file
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process focus number properties.
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process focus switch properties.
INDI::PropertySwitch FocusBacklashSP
INDI::PropertyNumber FocusBacklashNP
INDI::PropertyNumber FocusAbsPosNP
INDI::PropertySwitch DewChannelsSP
@ POWER_HAS_VOLTAGE_SENSOR
@ POWER_HAS_OVERALL_CURRENT
@ POWER_HAS_PER_PORT_CURRENT
bool saveConfigItems(FILE *fp)
saveConfigItems Save power properties in config file
INDI::PropertySwitch AutoDewSP
INDI::PropertyNumber VariableChannelVoltsNP
void SetCapability(uint32_t cap)
SetPowerCapability sets the Power capabilities. All capabilities must be initialized.
INDI::PropertyNumber PowerSensorsNP
INDI::PropertyNumber PowerChannelCurrentNP
INDI::PropertyNumber DewChannelCurrentNP
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process Power number properties.
void initProperties(const char *groupName, size_t nPowerPorts=0, size_t nDewPorts=0, size_t nVariablePorts=0, size_t nAutoDewPorts=0, size_t nUSBPorts=0)
Initialize Power properties. It is recommended to call this function within initProperties() of your ...
bool processText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process Power text properties.
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process Power switch properties.
INDI::PropertySwitch PowerChannelsSP
INDI::PropertySwitch USBPortSP
INDI::PropertyNumber DewChannelDutyCycleNP
INDI::PropertyText USBPortLabelsTP
bool updateProperties()
updateProperties Define or Delete Power properties based on the connection status of the base device
INDI::PropertySwitch VariableChannelsSP
void addParameter(std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning, bool flipWarning=false)
Add a physical weather measurable parameter to the weather driver.
bool setCriticalParameter(std::string name)
setCriticalParameter Set parameter that is considered critical to the operation of the observatory....
bool syncCriticalParameters()
Synchronize and update the state of all critical parameters.
void setParameterValue(std::string name, double value)
setParameterValue Update weather parameter value
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process weather number properties.
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save parameters ranges in the config file.
INDI::PropertyNumber ParametersNP
void initProperties(const char *statusGroup, const char *paramsGroup)
Initialize focuser properties. It is recommended to call this function within initProperties() of you...
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
INDI::PropertyLight critialParametersLP
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
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....
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool SetVariablePort(size_t port, bool enabled, double voltage) override
SetVariablePort Set variable voltage port.
virtual bool SetPowerPort(size_t port, bool enabled) override
Power Interface Implementations.
virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle) override
SetDewPort Set DEW/Dew port duty cycle.
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
virtual bool SetLEDEnabled(bool enabled) override
SetLEDEnabled Enable/disable power LEDs.
virtual bool SetUSBPort(size_t port, bool enabled) override
SetUSBPort Set USB port on/off.
virtual bool CyclePower() override
CyclePower Cycle power to all ports.
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
const char * getDefaultName() override
virtual bool SetAutoDewEnabled(size_t port, bool enabled) override
SetAutoDewEnabled Enable/disable automatic dew control.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * FOCUS_TAB
FOCUS_TAB Where all the properties for focuser are located.
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
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.
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_INFO(fmt,...)
#define LOGF_WARN(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)
Namespace to encapsulate INDI client, drivers, and mediator classes.
*brief create JSON pointer *sa reference_tokens end()