Browse Source
Add support for X/Y coordinates. Add coordinate precision setting. Automatically scan for serial port changes. Refactor so each protocol is implemented in a separate class. Add start of DFM protocol.chirpmodem-v8.0.0
31 changed files with 2846 additions and 470 deletions
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QRegularExpression> |
||||
|
||||
#include "maincore.h" |
||||
#include "channel/channelwebapiutils.h" |
||||
|
||||
#include "gs232controllerreport.h" |
||||
#include "controllerprotocol.h" |
||||
#include "gs232protocol.h" |
||||
#include "spidprotocol.h" |
||||
#include "rotctrldprotocol.h" |
||||
#include "dfmprotocol.h" |
||||
|
||||
ControllerProtocol::ControllerProtocol() : |
||||
m_device(nullptr), |
||||
m_lastAzimuth(-1.0f), |
||||
m_lastElevation(-1.0f), |
||||
m_msgQueueToFeature(nullptr) |
||||
{ |
||||
} |
||||
|
||||
ControllerProtocol::~ControllerProtocol() |
||||
{ |
||||
} |
||||
|
||||
void ControllerProtocol::setAzimuth(float azimuth) |
||||
{ |
||||
setAzimuthElevation(azimuth, m_lastElevation); |
||||
m_lastAzimuth = azimuth; |
||||
} |
||||
|
||||
void ControllerProtocol::setAzimuthElevation(float azimuth, float elevation) |
||||
{ |
||||
m_lastAzimuth = azimuth; |
||||
m_lastElevation = elevation; |
||||
} |
||||
|
||||
void ControllerProtocol::applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force) |
||||
{ |
||||
if (force) { |
||||
m_settings = settings; |
||||
} else { |
||||
m_settings.applySettings(settingsKeys, settings); |
||||
} |
||||
} |
||||
|
||||
void ControllerProtocol::sendMessage(Message *message) |
||||
{ |
||||
m_msgQueueToFeature->push(message); |
||||
} |
||||
|
||||
void ControllerProtocol::reportAzEl(float az, float el) |
||||
{ |
||||
m_msgQueueToFeature->push(GS232ControllerReport::MsgReportAzAl::create(az, el)); |
||||
} |
||||
|
||||
void ControllerProtocol::reportError(const QString &message) |
||||
{ |
||||
m_msgQueueToFeature->push(GS232Controller::MsgReportWorker::create(message)); |
||||
} |
||||
|
||||
void ControllerProtocol::getPosition(float& latitude, float& longitude) |
||||
{ |
||||
if (!m_settings.m_track) |
||||
{ |
||||
// When not tracking, use My Position from preferences
|
||||
// although this precludes having different antennas at different positions
|
||||
latitude = MainCore::instance()->getSettings().getLatitude(); |
||||
longitude = MainCore::instance()->getSettings().getLongitude(); |
||||
} |
||||
else |
||||
{ |
||||
// When tracking, get position from Star Tracker / Sat Tracker
|
||||
QRegularExpression re("([FTR])(\\d+):(\\d+)"); |
||||
QRegularExpressionMatch match = re.match(m_settings.m_source); |
||||
if (match.hasMatch()) |
||||
{ |
||||
QString kind = match.captured(1); |
||||
int setIndex = match.captured(2).toInt(); |
||||
int index = match.captured(3).toInt(); |
||||
if (kind == 'F') |
||||
{ |
||||
double lat, lon; |
||||
bool latOk = ChannelWebAPIUtils::getFeatureSetting(setIndex, index, "latitude", lat); |
||||
bool lonOk = ChannelWebAPIUtils::getFeatureSetting(setIndex, index, "longitude", lon); |
||||
if (latOk && lonOk) |
||||
{ |
||||
latitude = (float)lat; |
||||
longitude = (float)lon; |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "ControllerProtocol::getPosition - Failed to get position from source: " << m_settings.m_source; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
double lat, lon; |
||||
bool latOk = ChannelWebAPIUtils::getChannelSetting(setIndex, index, "latitude", lat); |
||||
bool lonOk = ChannelWebAPIUtils::getChannelSetting(setIndex, index, "longitude", lon); |
||||
if (latOk && lonOk) |
||||
{ |
||||
latitude = (float)lat; |
||||
longitude = (float)lon; |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "ControllerProtocol::getPosition - Failed to get position from source: " << m_settings.m_source; |
||||
} |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "ControllerProtocol::getPosition - Couldn't parse source: " << m_settings.m_source; |
||||
} |
||||
} |
||||
//qDebug() << "ControllerProtocol::getPosition: " << latitude << longitude;
|
||||
} |
||||
|
||||
ControllerProtocol *ControllerProtocol::create(GS232ControllerSettings::Protocol protocol) |
||||
{ |
||||
switch (protocol) |
||||
{ |
||||
case GS232ControllerSettings::GS232: |
||||
return new GS232Protocol(); |
||||
break; |
||||
case GS232ControllerSettings::SPID: |
||||
return new SPIDProtocol(); |
||||
break; |
||||
case GS232ControllerSettings::ROTCTLD: |
||||
return new RotCtrlDProtocol(); |
||||
break; |
||||
case GS232ControllerSettings::DFM: |
||||
return new DFMProtocol(); |
||||
break; |
||||
default: |
||||
return nullptr; |
||||
} |
||||
} |
||||
|
||||
|
||||
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_CONTROLLERPROTOCOL_H_ |
||||
#define INCLUDE_FEATURE_CONTROLLERPROTOCOL_H_ |
||||
|
||||
#include <QIODevice> |
||||
|
||||
#include "util/messagequeue.h" |
||||
#include "gs232controllersettings.h" |
||||
#include "gs232controller.h" |
||||
|
||||
class ControllerProtocol |
||||
{ |
||||
public: |
||||
ControllerProtocol(); |
||||
virtual ~ControllerProtocol(); |
||||
virtual void setAzimuth(float azimuth); |
||||
virtual void setAzimuthElevation(float azimuth, float elevation) = 0; |
||||
virtual void readData() = 0; |
||||
virtual void update() = 0; |
||||
void setDevice(QIODevice *device) { m_device = device; } |
||||
virtual void applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force); |
||||
void setMessageQueue(MessageQueue *messageQueue) { m_msgQueueToFeature = messageQueue; } |
||||
void sendMessage(Message *message); |
||||
void reportAzEl(float az, float el); |
||||
void reportError(const QString &message); |
||||
void getPosition(float& latitude, float& longitude); |
||||
|
||||
static ControllerProtocol *create(GS232ControllerSettings::Protocol protocol); |
||||
|
||||
protected: |
||||
QIODevice *m_device; |
||||
GS232ControllerSettings m_settings; |
||||
float m_lastAzimuth; |
||||
float m_lastElevation; |
||||
|
||||
private: |
||||
MessageQueue *m_msgQueueToFeature; |
||||
}; |
||||
|
||||
#endif // INCLUDE_FEATURE_CONTROLLERPROTOCOL_H_
|
||||
|
||||
@ -0,0 +1,239 @@
@@ -0,0 +1,239 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QDebug> |
||||
|
||||
#include "util/astronomy.h" |
||||
|
||||
#include "dfmprotocol.h" |
||||
|
||||
MESSAGE_CLASS_DEFINITION(DFMProtocol::MsgReportDFMStatus, Message) |
||||
|
||||
DFMProtocol::DFMProtocol() : |
||||
m_packetCnt(0) |
||||
{ |
||||
// Call periodicTask() every 500ms
|
||||
connect(&m_timer, &QTimer::timeout, this, &DFMProtocol::periodicTask); |
||||
m_timer.start(500); |
||||
} |
||||
|
||||
DFMProtocol::~DFMProtocol() |
||||
{ |
||||
m_timer.stop(); |
||||
} |
||||
|
||||
void DFMProtocol::setAzimuthElevation(float azimuth, float elevation) |
||||
{ |
||||
// This gets position from source plugin in track is enabled (E.g. Star Tracker / Satellite tracker)
|
||||
// or My Position preference, if not tracking
|
||||
float latitude, longitude; |
||||
getPosition(latitude, longitude); |
||||
|
||||
// Convert az/el to RA/Dec
|
||||
AzAlt aa; |
||||
aa.az = azimuth; |
||||
aa.alt = elevation; |
||||
QDateTime dt = QDateTime::currentDateTime(); |
||||
RADec rd = Astronomy::azAltToRaDec(aa, latitude, longitude, dt); |
||||
// Save as target
|
||||
m_targetRA = rd.ra; |
||||
m_targetDec = rd.dec; |
||||
|
||||
// Call parent method to save m_lastAzimuth and m_lastElevation
|
||||
ControllerProtocol::setAzimuthElevation(azimuth, elevation); |
||||
} |
||||
|
||||
// Handle data received from LCU
|
||||
// Packets are of the form #L,L,f,f,..,f;
|
||||
void DFMProtocol::readData() |
||||
{ |
||||
char c; |
||||
while (m_device->getChar(&c)) |
||||
{ |
||||
if (c == '#') |
||||
{ |
||||
// Start packet
|
||||
m_rxBuffer = QString(c); |
||||
} |
||||
else if (c == ';') |
||||
{ |
||||
// End packet
|
||||
m_rxBuffer.append(c); |
||||
|
||||
// Only process if we have valid packet
|
||||
if (m_rxBuffer.startsWith('#')) |
||||
{ |
||||
parseLCUResponse(m_rxBuffer); |
||||
m_rxBuffer = ""; |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "DFMProtocol::readData - Ignoring partial packet: " << m_rxBuffer; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
m_rxBuffer.append(c); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void DFMProtocol::parseLCUResponse(const QString& packet) |
||||
{ |
||||
qDebug() << "DFMProtocol::parseLCUResponse - " << packet; |
||||
|
||||
// Check packet starts with expected header
|
||||
if (!packet.startsWith("#L,L,")) |
||||
{ |
||||
qDebug() << "DFMProtocol::readData - Ignoring non LCU packet: " << m_rxBuffer; |
||||
return; |
||||
} |
||||
|
||||
// Strip off header and footer
|
||||
QString strippedPacket = packet.mid(5, packet.length() - 6); |
||||
|
||||
// Convert packet to list of strings
|
||||
QStringList dataStrings = strippedPacket.split(","); |
||||
|
||||
// Extract values we are interested in
|
||||
DFMStatus status; |
||||
|
||||
int statl = (int)dataStrings[1].toFloat(); |
||||
status.m_initialized = statl & 1; |
||||
status.m_brakesOn = (statl >> 1) & 1; |
||||
status.m_trackOn = (statl >> 2) & 1; |
||||
status.m_slewEnabled = (statl >> 3) & 1; |
||||
status.m_lubePumpsOn = (statl >> 4) & 1; |
||||
status.m_approachingSWLimit = (statl >> 5) & 1; |
||||
status.m_finalSWLimit = (statl >> 6) & 1; |
||||
status.m_slewing = (statl >> 7) & 1; |
||||
|
||||
int stath = (int)dataStrings[2].toFloat(); |
||||
status.m_setting = stath & 1; |
||||
status.m_haltMotorsIn = (stath >> 1) & 1; |
||||
status.m_excomSwitchOn = (stath >> 2) & 1; |
||||
status.m_servoPackAlarm = (stath >> 3) & 1; |
||||
status.m_targetOutOfRange = (stath >> 4) & 1; |
||||
status.m_cosdecOn = (stath >> 5) & 1; |
||||
status.m_rateCorrOn = (stath >> 6) & 1; |
||||
status.m_drivesOn = (stath >> 7) & 1; |
||||
|
||||
int statlh = (int)dataStrings[3].toFloat(); |
||||
status.m_pumpsReady = statlh & 1; |
||||
// Bit 1 unknown
|
||||
status.m_minorPlus = (statlh >> 2) & 1; |
||||
status.m_minorMinus = (statlh >> 3) & 1; |
||||
status.m_majorPlus = (statlh >> 4) & 1; |
||||
status.m_majorMinus = (statlh >> 5) & 1; |
||||
status.m_nextObjectActive = (statlh >> 6) & 1; |
||||
status.m_auxTrackRate = (statlh >> 7) & 1; |
||||
|
||||
status.m_siderealTime = dataStrings[5].toFloat(); |
||||
status.m_universalTime = dataStrings[6].toFloat(); |
||||
|
||||
status.m_currentHA = dataStrings[7].toFloat(); |
||||
status.m_currentRA = dataStrings[8].toFloat(); |
||||
status.m_currentDec = dataStrings[9].toFloat(); |
||||
|
||||
status.m_currentX = dataStrings[20].toFloat(); |
||||
status.m_currentY = dataStrings[21].toFloat(); |
||||
|
||||
status.m_siderealRateX = dataStrings[30].toFloat(); |
||||
status.m_siderealRateY = dataStrings[31].toFloat(); |
||||
|
||||
status.m_torqueX = dataStrings[34].toFloat(); |
||||
status.m_torqueY = dataStrings[35].toFloat(); |
||||
|
||||
status.m_controller = (DFMStatus::Controller)dataStrings[38].toInt(); |
||||
|
||||
status.m_rateX = dataStrings[39].toFloat(); |
||||
status.m_rateY = dataStrings[40].toFloat(); |
||||
|
||||
// Display status in GUI
|
||||
sendMessage(MsgReportDFMStatus::create(status)); |
||||
|
||||
// Convert current X/Y to Az/El
|
||||
AzAlt aa = Astronomy::xy85ToAzAlt(status.m_currentX, status.m_currentY); |
||||
float az = aa.az; |
||||
float el = aa.alt; |
||||
reportAzEl(az, el); |
||||
|
||||
// If this is the second LCU packet, we send a commmand
|
||||
m_packetCnt++; |
||||
if (m_packetCnt == 2) |
||||
{ |
||||
m_packetCnt = 0; |
||||
sendCommand(); |
||||
} |
||||
} |
||||
|
||||
void DFMProtocol::sendCommand() |
||||
{ |
||||
// TODO: Use m_lastAzimuth/m_lastElevation or m_targetRA/m_targetDec to calculate position commands
|
||||
|
||||
// Send a command to the LCU
|
||||
int cmdId = 98; |
||||
int handPaddle = 0; |
||||
int frontPanel = (m_settings.m_dfmDrivesOn << 2) |
||||
| (m_settings.m_dfmTrackOn << 3) |
||||
| (m_settings.m_dfmLubePumpsOn << 4) |
||||
| (m_settings.m_dfmBrakesOn << 7); |
||||
|
||||
QString cmd = QString("#M,R,%1,%2.000000,%3.000000;").arg(cmdId).arg(handPaddle).arg(frontPanel); |
||||
m_device->write(cmd.toLatin1()); |
||||
|
||||
qDebug() << "DFMProtocol::sendCommand - " << cmd; |
||||
} |
||||
|
||||
// Request current Az/El
|
||||
void DFMProtocol::update() |
||||
{ |
||||
// This is called periodically for protocols that need to send a command to get current az/el
|
||||
// However, for this protocol, we might not need to do anything here,
|
||||
// if we're continually calling reportAzEl() in response to packets received from the LCU.
|
||||
//sendCommand();
|
||||
} |
||||
|
||||
void DFMProtocol::periodicTask() |
||||
{ |
||||
// Just as an example, this will be called every 500ms. Can be removed if not needed
|
||||
} |
||||
|
||||
// This is called when new settings are available from GUI (or API).
|
||||
void DFMProtocol::applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force) |
||||
{ |
||||
if (settingsKeys.contains("dfmTrackOn") || force) |
||||
{ |
||||
// Do something with settings.m_dfmTrackOn if needed
|
||||
} |
||||
if (settingsKeys.contains("dfmLubePumpsOn") || force) |
||||
{ |
||||
// Do something with settings.m_dfmLubePumpsOn if needed
|
||||
} |
||||
if (settingsKeys.contains("dfmBrakesOn") || force) |
||||
{ |
||||
// Do something with settings.m_dfmBreaksOn if needed
|
||||
} |
||||
if (settingsKeys.contains("dfmDrivesOn") || force) |
||||
{ |
||||
// Do something with settings.m_dfmDrivesOn if needed
|
||||
} |
||||
|
||||
// Call parent method to set m_settings to settings
|
||||
ControllerProtocol::applySettings(settings, settingsKeys, force); |
||||
} |
||||
|
||||
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_DFMPROTOCOL_H_ |
||||
#define INCLUDE_FEATURE_DFMPROTOCOL_H_ |
||||
|
||||
#include <QTimer> |
||||
|
||||
#include "util/message.h" |
||||
#include "controllerprotocol.h" |
||||
|
||||
class DFMProtocol : public QObject, public ControllerProtocol |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
|
||||
struct DFMStatus { |
||||
// STATL
|
||||
bool m_initialized; |
||||
bool m_brakesOn; |
||||
bool m_trackOn; |
||||
bool m_slewEnabled; |
||||
bool m_lubePumpsOn; |
||||
bool m_approachingSWLimit; |
||||
bool m_finalSWLimit; |
||||
bool m_slewing; |
||||
// STATH
|
||||
bool m_setting; |
||||
bool m_haltMotorsIn; |
||||
bool m_excomSwitchOn; |
||||
bool m_servoPackAlarm; |
||||
bool m_targetOutOfRange; |
||||
bool m_cosdecOn; |
||||
bool m_rateCorrOn; |
||||
bool m_drivesOn; |
||||
// STATLH
|
||||
bool m_pumpsReady; |
||||
bool m_minorPlus; |
||||
bool m_minorMinus; |
||||
bool m_majorPlus; |
||||
bool m_majorMinus; |
||||
bool m_nextObjectActive; |
||||
bool m_auxTrackRate; |
||||
// Other status information
|
||||
float m_currentHA; |
||||
float m_currentRA; |
||||
float m_currentDec; |
||||
float m_currentX; |
||||
float m_currentY; |
||||
enum Controller {NONE, OCU, LCU, MCU} m_controller; |
||||
float m_torqueX; |
||||
float m_torqueY; |
||||
float m_rateX; |
||||
float m_rateY; |
||||
float m_siderealRateX; |
||||
float m_siderealRateY; |
||||
float m_siderealTime; |
||||
float m_universalTime; |
||||
}; |
||||
|
||||
// Message from DFMProtocol to the GUI, with status information to display
|
||||
class MsgReportDFMStatus : public Message { |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
DFMStatus getDFMStatus() const { return m_dfmStatus; } |
||||
|
||||
static MsgReportDFMStatus* create(const DFMStatus& dfmStatus) |
||||
{ |
||||
return new MsgReportDFMStatus(dfmStatus); |
||||
} |
||||
private: |
||||
DFMStatus m_dfmStatus; |
||||
|
||||
MsgReportDFMStatus(const DFMStatus& dfmStatus) : |
||||
Message(), |
||||
m_dfmStatus(dfmStatus) |
||||
{ |
||||
} |
||||
}; |
||||
|
||||
DFMProtocol(); |
||||
~DFMProtocol(); |
||||
void setAzimuthElevation(float azimuth, float elevation) override; |
||||
void readData() override; |
||||
void update() override; |
||||
void applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force) override; |
||||
|
||||
private: |
||||
void parseLCUResponse(const QString& packet); |
||||
void sendCommand(); |
||||
|
||||
QTimer m_timer; |
||||
|
||||
QString m_rxBuffer; |
||||
int m_packetCnt; |
||||
|
||||
float m_targetRA; |
||||
float m_targetDec; |
||||
|
||||
private slots: |
||||
void periodicTask(); |
||||
}; |
||||
|
||||
#endif // INCLUDE_FEATURE_DFMPROTOCOL_H_
|
||||
|
||||
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "util/units.h" |
||||
|
||||
#include "dfmstatusdialog.h" |
||||
|
||||
DFMStatusDialog::DFMStatusDialog(QWidget* parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::DFMStatusDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
// Make checkboxes read-only
|
||||
ui->trackOn->setAttribute(Qt::WA_TransparentForMouseEvents); |
||||
ui->driveOn->setAttribute(Qt::WA_TransparentForMouseEvents); |
||||
ui->brakesOn->setAttribute(Qt::WA_TransparentForMouseEvents); |
||||
ui->pumpsOn->setAttribute(Qt::WA_TransparentForMouseEvents); |
||||
ui->controller->setAttribute(Qt::WA_TransparentForMouseEvents); |
||||
} |
||||
|
||||
void DFMStatusDialog::displayStatus(const DFMProtocol::DFMStatus& dfmStatus) |
||||
{ |
||||
ui->currentHA->setText(QString::number(dfmStatus.m_currentHA, 'f')); |
||||
ui->currentRA->setText(QString::number(dfmStatus.m_currentRA, 'f')); |
||||
ui->currentDec->setText(QString::number(dfmStatus.m_currentDec, 'f')); |
||||
|
||||
ui->st->setText(Units::decimalHoursToHoursMinutesAndSeconds(dfmStatus.m_siderealTime)); |
||||
ui->ut->setText(Units::decimalHoursToHoursMinutesAndSeconds(dfmStatus.m_universalTime)); |
||||
|
||||
ui->currentX->setText(QString::number(dfmStatus.m_currentX, 'f')); |
||||
ui->currentY->setText(QString::number(dfmStatus.m_currentY, 'f')); |
||||
ui->siderealRateX->setText(QString::number(dfmStatus.m_siderealRateX, 'f')); |
||||
ui->siderealRateY->setText(QString::number(dfmStatus.m_siderealRateY, 'f')); |
||||
ui->rateX->setText(QString::number(dfmStatus.m_rateX, 'f')); |
||||
ui->rateY->setText(QString::number(dfmStatus.m_rateY, 'f')); |
||||
ui->torqueX->setText(QString::number(dfmStatus.m_torqueX, 'f')); |
||||
ui->torqueY->setText(QString::number(dfmStatus.m_torqueY, 'f')); |
||||
|
||||
ui->trackOn->setChecked(dfmStatus.m_trackOn); |
||||
ui->driveOn->setChecked(dfmStatus.m_drivesOn); |
||||
ui->brakesOn->setChecked(dfmStatus.m_brakesOn); |
||||
ui->pumpsOn->setChecked(dfmStatus.m_pumpsReady); // ?
|
||||
ui->controller->setCurrentIndex((int)dfmStatus.m_controller); |
||||
} |
||||
|
||||
DFMStatusDialog::~DFMStatusDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void DFMStatusDialog::accept() |
||||
{ |
||||
QDialog::accept(); |
||||
} |
||||
|
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_DFMSTATUSSDIALOG_H |
||||
#define INCLUDE_DFMSTATUSSDIALOG_H |
||||
|
||||
#include "ui_dfmstatusdialog.h" |
||||
#include "dfmprotocol.h" |
||||
|
||||
class DFMStatusDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit DFMStatusDialog(QWidget* parent = 0); |
||||
~DFMStatusDialog(); |
||||
void displayStatus(const DFMProtocol::DFMStatus& dfmStatus); |
||||
|
||||
private slots: |
||||
void accept(); |
||||
|
||||
private: |
||||
Ui::DFMStatusDialog* ui; |
||||
}; |
||||
|
||||
#endif // INCLUDE_DFMSTATUSSDIALOG_H
|
||||
|
||||
@ -0,0 +1,413 @@
@@ -0,0 +1,413 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>DFMStatusDialog</class> |
||||
<widget class="QDialog" name="DFMStatusDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>474</width> |
||||
<height>488</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>DFM Status</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox"> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="6" column="0" colspan="3"> |
||||
<widget class="QGroupBox" name="statusGroup"> |
||||
<property name="title"> |
||||
<string>Status</string> |
||||
</property> |
||||
<layout class="QFormLayout" name="formLayout"> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="trackOnLabel"> |
||||
<property name="text"> |
||||
<string>Track</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QCheckBox" name="trackOn"> |
||||
<property name="focusPolicy"> |
||||
<enum>Qt::NoFocus</enum> |
||||
</property> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
<property name="checkable"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="driverOnLabel"> |
||||
<property name="text"> |
||||
<string>Drives</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QCheckBox" name="driveOn"> |
||||
<property name="focusPolicy"> |
||||
<enum>Qt::NoFocus</enum> |
||||
</property> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
<property name="checkable"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="brakesOnLabel"> |
||||
<property name="text"> |
||||
<string>Brakes</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QCheckBox" name="brakesOn"> |
||||
<property name="focusPolicy"> |
||||
<enum>Qt::NoFocus</enum> |
||||
</property> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
<property name="checkable"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="pumpsOnLabel"> |
||||
<property name="text"> |
||||
<string>Pumps</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="QCheckBox" name="pumpsOn"> |
||||
<property name="mouseTracking"> |
||||
<bool>true</bool> |
||||
</property> |
||||
<property name="focusPolicy"> |
||||
<enum>Qt::NoFocus</enum> |
||||
</property> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
<property name="checkable"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="1"> |
||||
<widget class="QComboBox" name="controller"> |
||||
<item> |
||||
<property name="text"> |
||||
<string>None</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>OCU</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>LCU</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>MCU</string> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="0"> |
||||
<widget class="QLabel" name="controllerLabel"> |
||||
<property name="text"> |
||||
<string>Controller</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item row="8" column="2"> |
||||
<spacer name="verticalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>20</width> |
||||
<height>40</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item row="2" column="0" colspan="2"> |
||||
<widget class="QGroupBox" name="antennaPositionGroup"> |
||||
<property name="title"> |
||||
<string>Antenna Position</string> |
||||
</property> |
||||
<layout class="QFormLayout" name="formLayout_2"> |
||||
<item row="2" column="1"> |
||||
<widget class="QLineEdit" name="currentRA"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="currentRALabel"> |
||||
<property name="text"> |
||||
<string>RA</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="currentDecLabel"> |
||||
<property name="text"> |
||||
<string>Dec</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="QLineEdit" name="currentDec"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="currentHALabel"> |
||||
<property name="text"> |
||||
<string>HA</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QLineEdit" name="currentHA"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="2"> |
||||
<widget class="QGroupBox" name="dateTimeGroup"> |
||||
<property name="title"> |
||||
<string>Date/Time</string> |
||||
</property> |
||||
<layout class="QFormLayout" name="formLayout_3"> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="stLabel"> |
||||
<property name="text"> |
||||
<string>ST</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="utLabel"> |
||||
<property name="text"> |
||||
<string>UT</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QLineEdit" name="st"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QLineEdit" name="ut"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="0" colspan="3"> |
||||
<widget class="QGroupBox" name="xyStatus"> |
||||
<property name="title"> |
||||
<string>X/Y Status</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout_2"> |
||||
<item row="4" column="1"> |
||||
<widget class="QLineEdit" name="torqueX"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QLineEdit" name="currentX"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="0"> |
||||
<widget class="QLabel" name="torqueXYLabel"> |
||||
<property name="text"> |
||||
<string>Torque</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="QLineEdit" name="rateX"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="2"> |
||||
<widget class="QLineEdit" name="torqueY"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="2"> |
||||
<widget class="QLineEdit" name="currentY"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="rateXYLabel"> |
||||
<property name="text"> |
||||
<string>Rate</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QLabel" name="xColumnLabel"> |
||||
<property name="text"> |
||||
<string>X</string> |
||||
</property> |
||||
<property name="alignment"> |
||||
<set>Qt::AlignCenter</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="currentXYLabel"> |
||||
<property name="text"> |
||||
<string>Antenna</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="2"> |
||||
<widget class="QLabel" name="yColumnLabel"> |
||||
<property name="text"> |
||||
<string>Y</string> |
||||
</property> |
||||
<property name="alignment"> |
||||
<set>Qt::AlignCenter</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="2"> |
||||
<widget class="QLineEdit" name="rateY"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="siderealRateXYLabel"> |
||||
<property name="text"> |
||||
<string>Sidereal Rate</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QLineEdit" name="siderealRateX"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="2"> |
||||
<widget class="QLineEdit" name="siderealRateY"> |
||||
<property name="readOnly"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Close</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>DFMStatusDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>DFMStatusDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||