kopia lustrzana https://github.com/PianetaRadio/CatRadio
rodzic
1273184597
commit
bf2b4455ae
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
** This file is part of the CatRadio project.
|
||||||
|
** Copyright 2022 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
|
||||||
|
**
|
||||||
|
** 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, either 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 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 "dialogcommand.h"
|
||||||
|
#include "ui_dialogcommand.h"
|
||||||
|
|
||||||
|
#include "rig.h"
|
||||||
|
|
||||||
|
DialogCommand::DialogCommand(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::DialogCommand)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogCommand::~DialogCommand()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCommand::on_pushButton_send_clicked()
|
||||||
|
{
|
||||||
|
//int rig_send_raw(rig, unsigned char *send, int send_len, unsigned char *reply, int reply_len, unsigned char term);
|
||||||
|
//send contains the raw command data
|
||||||
|
//send_len is the # of bytes to send
|
||||||
|
//If reply is NULL no answer is expected
|
||||||
|
//reply should be as long as need for any reply
|
||||||
|
//term is the command termination char -- could be semicolon, CR, or 0xfd for Icom rigs
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCommand::on_pushButton_close_clicked()
|
||||||
|
{
|
||||||
|
this->close();
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
** This file is part of the CatRadio project.
|
||||||
|
** Copyright 2022 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
|
||||||
|
**
|
||||||
|
** 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, either 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 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 DIALOGCOMMAND_H
|
||||||
|
#define DIALOGCOMMAND_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DialogCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DialogCommand : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DialogCommand(QWidget *parent = nullptr);
|
||||||
|
~DialogCommand();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_pushButton_close_clicked();
|
||||||
|
|
||||||
|
void on_pushButton_send_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::DialogCommand *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOGCOMMAND_H
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogCommand</class>
|
||||||
|
<widget class="QDialog" name="DialogCommand">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>140</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Command</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_commandSend">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command Send</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit_commandSend"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="pushButton_send">
|
||||||
|
<property name="text">
|
||||||
|
<string>Send</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_receive">
|
||||||
|
<property name="text">
|
||||||
|
<string>Receive</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit_receive">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QCheckBox" name="checkBox_icom">
|
||||||
|
<property name="text">
|
||||||
|
<string>Icom</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="pushButton_close">
|
||||||
|
<property name="text">
|
||||||
|
<string>Close</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -21,6 +21,7 @@
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "dialogconfig.h"
|
#include "dialogconfig.h"
|
||||||
#include "dialogsetup.h"
|
#include "dialogsetup.h"
|
||||||
|
#include "dialogcommand.h"
|
||||||
#include "rigdaemon.h"
|
#include "rigdaemon.h"
|
||||||
#include "rigdata.h"
|
#include "rigdata.h"
|
||||||
#include "guidata.h"
|
#include "guidata.h"
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
|
|
||||||
#include <rig.h> //Hamlib
|
#include <rig.h> //Hamlib
|
||||||
|
|
||||||
extern RIG *my_rig; //Defined in rigdaemon.cpp
|
RIG *my_rig;
|
||||||
|
|
||||||
extern rigConnect rigCom;
|
extern rigConnect rigCom;
|
||||||
extern rigSettings rigGet;
|
extern rigSettings rigGet;
|
||||||
|
@ -61,6 +62,8 @@ FILE* debugFile;
|
||||||
QThread workerThread; //
|
QThread workerThread; //
|
||||||
RigDaemon *rigDaemon = new RigDaemon;
|
RigDaemon *rigDaemon = new RigDaemon;
|
||||||
|
|
||||||
|
QDialog *command = nullptr;
|
||||||
|
|
||||||
|
|
||||||
//***** MainWindow *****
|
//***** MainWindow *****
|
||||||
|
|
||||||
|
@ -99,7 +102,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
//* Thread for RigDaemon
|
//* Thread for RigDaemon
|
||||||
rigDaemon->moveToThread(&workerThread); //
|
rigDaemon->moveToThread(&workerThread); //
|
||||||
connect(&workerThread, &QThread::finished, rigDaemon, &QObject::deleteLater);
|
connect(&workerThread, &QThread::finished, rigDaemon, &QObject::deleteLater);
|
||||||
connect(timer, &QTimer::timeout, rigDaemon, &RigDaemon::rigUpdate);
|
connect(timer, &QTimer::timeout, this, &MainWindow::rigUpdate);
|
||||||
connect(rigDaemon, &RigDaemon::resultReady, this, &MainWindow::on_rigDaemonResultReady);
|
connect(rigDaemon, &RigDaemon::resultReady, this, &MainWindow::on_rigDaemonResultReady);
|
||||||
workerThread.start();
|
workerThread.start();
|
||||||
|
|
||||||
|
@ -604,6 +607,10 @@ void MainWindow::guiUpdate()
|
||||||
else if (rigGet.toneType == 4) ui->comboBox_toneFreq->setCurrentText(QString::number(rigGet.tone)); //DCS
|
else if (rigGet.toneType == 4) ui->comboBox_toneFreq->setCurrentText(QString::number(rigGet.tone)); //DCS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::rigUpdate()
|
||||||
|
{
|
||||||
|
rigDaemon->rigUpdate(my_rig);
|
||||||
|
}
|
||||||
|
|
||||||
//* RigDaemon handle results
|
//* RigDaemon handle results
|
||||||
void MainWindow::on_rigDaemonResultReady()
|
void MainWindow::on_rigDaemonResultReady()
|
||||||
|
@ -678,23 +685,25 @@ void MainWindow::on_pushButton_Connect_toggled(bool checked)
|
||||||
|
|
||||||
if (checked && rigCom.connected == 0)
|
if (checked && rigCom.connected == 0)
|
||||||
{
|
{
|
||||||
retcode = rigDaemon->rigConnect(); //Open Rig connection
|
int retcode;
|
||||||
|
|
||||||
if (retcode != RIG_OK) //Connection error
|
my_rig = rigDaemon->rigConnect(&retcode); //Open Rig connection
|
||||||
{
|
|
||||||
rigCom.connected = 0;
|
if (retcode != RIG_OK) //Connection error
|
||||||
connectMsg = "Connection error: ";
|
{
|
||||||
connectMsg.append(rigerror(retcode));
|
rigCom.connected = 0;
|
||||||
ui->pushButton_Connect->setChecked(false); //Uncheck the button
|
connectMsg = "Connection error: ";
|
||||||
}
|
connectMsg.append(rigerror(retcode));
|
||||||
else //Rig connected
|
ui->pushButton_Connect->setChecked(false); //Uncheck the button
|
||||||
{
|
}
|
||||||
rigCom.connected = 1;
|
else //Rig connected
|
||||||
guiInit();
|
{
|
||||||
connectMsg = "Connected to ";
|
rigCom.connected = 1;
|
||||||
connectMsg.append(my_rig->caps->model_name);
|
guiInit();
|
||||||
if (rigCap.onoff == 0 || rigGet.onoff == RIG_POWER_ON || rigGet.onoff == RIG_POWER_UNKNOWN) timer->start(rigCom.rigRefresh);
|
connectMsg = "Connected to ";
|
||||||
}
|
connectMsg.append(my_rig->caps->model_name);
|
||||||
|
if (rigCap.onoff == 0 || rigGet.onoff == RIG_POWER_ON || rigGet.onoff == RIG_POWER_UNKNOWN) timer->start(rigCom.rigRefresh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (rigCom.connected) //Button unchecked
|
else if (rigCom.connected) //Button unchecked
|
||||||
{
|
{
|
||||||
|
@ -1432,6 +1441,22 @@ void MainWindow::on_action_Setup_triggered()
|
||||||
ui->lineEdit_vfoSub->setMode(guiConf.vfoDisplayMode);
|
ui->lineEdit_vfoSub->setMode(guiConf.vfoDisplayMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionCommand_triggered()
|
||||||
|
{
|
||||||
|
//DialogCommand command;
|
||||||
|
//command.setModal(true);
|
||||||
|
//command.exec();
|
||||||
|
|
||||||
|
if (!command)
|
||||||
|
{
|
||||||
|
command = new DialogCommand(this);
|
||||||
|
}
|
||||||
|
command->setModal(false);
|
||||||
|
command->show();
|
||||||
|
command->raise();
|
||||||
|
command->activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_action_AboutCatRadio_triggered()
|
void MainWindow::on_action_AboutCatRadio_triggered()
|
||||||
{
|
{
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void guiUpdate();
|
void guiUpdate();
|
||||||
|
void rigUpdate(); //Slot for QTimer
|
||||||
void on_rigDaemonResultReady(); //Slot for rigDaemon resultReady
|
void on_rigDaemonResultReady(); //Slot for rigDaemon resultReady
|
||||||
void on_vfoDisplayMainValueChanged(int value); //Slot for vfoDisplay Main valueChanged
|
void on_vfoDisplayMainValueChanged(int value); //Slot for vfoDisplay Main valueChanged
|
||||||
void on_vfoDisplaySubValueChanged(int value); //Slot for vfoDisplay Sub valueChanged
|
void on_vfoDisplaySubValueChanged(int value); //Slot for vfoDisplay Sub valueChanged
|
||||||
|
@ -203,6 +204,8 @@ private slots:
|
||||||
|
|
||||||
void on_checkBox_micMonitor_toggled(bool checked);
|
void on_checkBox_micMonitor_toggled(bool checked);
|
||||||
|
|
||||||
|
void on_actionCommand_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QTimer *timer;
|
QTimer *timer;
|
||||||
|
|
|
@ -2058,13 +2058,19 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="action_CatRadioHomepage"/>
|
<addaction name="action_CatRadioHomepage"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_RadioInfo"/>
|
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_AboutCatRadio"/>
|
<addaction name="action_AboutCatRadio"/>
|
||||||
<addaction name="action_AboutHamLib"/>
|
<addaction name="action_AboutHamLib"/>
|
||||||
<addaction name="action_AboutQT"/>
|
<addaction name="action_AboutQT"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuUtility">
|
||||||
|
<property name="title">
|
||||||
|
<string>Utility</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionCommand"/>
|
||||||
|
</widget>
|
||||||
<addaction name="menu_Config"/>
|
<addaction name="menu_Config"/>
|
||||||
|
<addaction name="menuUtility"/>
|
||||||
<addaction name="menu_Help"/>
|
<addaction name="menu_Help"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
@ -2098,9 +2104,9 @@
|
||||||
<string>CatRadio homepage</string>
|
<string>CatRadio homepage</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_RadioInfo">
|
<action name="actionCommand">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Radio Info</string>
|
<string>Command</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -28,9 +28,6 @@
|
||||||
|
|
||||||
#include <rig.h>
|
#include <rig.h>
|
||||||
|
|
||||||
|
|
||||||
RIG *my_rig;
|
|
||||||
|
|
||||||
extern rigConnect rigCom;
|
extern rigConnect rigCom;
|
||||||
extern rigSettings rigGet;
|
extern rigSettings rigGet;
|
||||||
extern rigSettings rigSet;
|
extern rigSettings rigSet;
|
||||||
|
@ -46,11 +43,9 @@ RigDaemon::RigDaemon(QObject *parent) : QObject(parent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int RigDaemon::rigConnect()
|
RIG *RigDaemon::rigConnect(int *retcode)
|
||||||
{
|
{
|
||||||
int retcode;
|
RIG *my_rig = rig_init(rigCom.rigModel); //Allocate rig handle
|
||||||
|
|
||||||
my_rig = rig_init(rigCom.rigModel); //Allocate rig handle
|
|
||||||
|
|
||||||
if (!my_rig) //Wrong Rig number
|
if (!my_rig) //Wrong Rig number
|
||||||
{
|
{
|
||||||
|
@ -61,7 +56,8 @@ int RigDaemon::rigConnect()
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
|
||||||
return -1; //RIG_EINVAL, Invalid parameter
|
*retcode = RIG_EINVAL; //RIG_EINVAL, Invalid parameter
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -89,20 +85,19 @@ int RigDaemon::rigConnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = rig_open(my_rig);
|
*retcode = rig_open(my_rig);
|
||||||
|
|
||||||
if (retcode != RIG_OK) return retcode; //Rig not connected
|
if (*retcode != RIG_OK) return nullptr; //Rig not connected
|
||||||
else //Rig connected
|
else //Rig connected
|
||||||
{
|
{
|
||||||
if (my_rig->caps->get_powerstat != NULL) rig_get_powerstat(my_rig, &rigGet.onoff);
|
if (my_rig->caps->get_powerstat != NULL) rig_get_powerstat(my_rig, &rigGet.onoff);
|
||||||
else rigGet.onoff = RIG_POWER_UNKNOWN;
|
else rigGet.onoff = RIG_POWER_UNKNOWN;
|
||||||
return 0;
|
return my_rig;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigDaemon::rigUpdate()
|
void RigDaemon::rigUpdate(RIG *my_rig)
|
||||||
{
|
{
|
||||||
int retcode;
|
int retcode;
|
||||||
value_t retvalue;
|
value_t retvalue;
|
||||||
|
@ -305,7 +300,6 @@ void RigDaemon::rigUpdate()
|
||||||
if (retcode == RIG_OK)
|
if (retcode == RIG_OK)
|
||||||
{
|
{
|
||||||
rigGet.band = rigSet.band;
|
rigGet.band = rigSet.band;
|
||||||
|
|
||||||
indexCmd = 21;
|
indexCmd = 21;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,10 @@ class RigDaemon : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RigDaemon(QObject *parent = nullptr);
|
explicit RigDaemon(QObject *parent = nullptr);
|
||||||
int rigConnect();
|
RIG *rigConnect(int *retcode);
|
||||||
|
void rigUpdate(RIG *my_rig);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void rigUpdate();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void resultReady();
|
void resultReady();
|
||||||
|
|
Ładowanie…
Reference in New Issue