kopia lustrzana https://gitlab.com/eliggett/wfview
Add option of popup alert
rodzic
373b670482
commit
3e149ee742
|
@ -320,7 +320,7 @@ void commHandler::openPort()
|
|||
qInfo(logSerial()) << "Could not open serial port " << portName << " , please restart.";
|
||||
isConnected = false;
|
||||
serialError = true;
|
||||
emit haveSerialPortError(portName, "Could not open port. Please restart.");
|
||||
emit havePortError(errorType(portName, "Could not open port. Please restart."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <QTime>
|
||||
#include <QTimer>
|
||||
|
||||
#include "wfviewtypes.h"
|
||||
|
||||
// This class abstracts the comm port in a useful way and connects to
|
||||
// the command creator and command parser.
|
||||
|
||||
|
@ -39,7 +41,7 @@ signals:
|
|||
void haveTextMessage(QString message); // status, debug only
|
||||
void sendDataOutToPort(const QByteArray &writeData); // not used
|
||||
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
|
||||
void haveSerialPortError(const QString port, const QString error);
|
||||
void havePortError(errorType err);
|
||||
void haveStatusUpdate(const QString text);
|
||||
|
||||
private:
|
||||
|
|
|
@ -90,7 +90,7 @@ void pttyHandler::openPort()
|
|||
qInfo(logSerial()) << "Could not open pseudo terminal port, please restart.";
|
||||
isConnected = false;
|
||||
serialError = true;
|
||||
emit haveSerialPortError(portName, "Could not open pseudo terminal port. Please restart.");
|
||||
emit havePortError(errorType(portName, "Could not open pseudo terminal port. Please restart."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <QtSerialPort/QSerialPort>
|
||||
|
||||
#include "rigidentities.h"
|
||||
#include "wfviewtypes.h"
|
||||
|
||||
// This class abstracts the comm port in a useful way and connects to
|
||||
// the command creator and command parser.
|
||||
|
@ -34,7 +35,7 @@ private slots:
|
|||
signals:
|
||||
void haveTextMessage(QString message); // status, debug only
|
||||
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
|
||||
void haveSerialPortError(const QString port, const QString error);
|
||||
void havePortError(errorType err);
|
||||
void haveStatusUpdate(const QString text);
|
||||
|
||||
private:
|
||||
|
|
|
@ -86,8 +86,8 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu
|
|||
// data from the rig to the ptty:
|
||||
connect(comm, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray)));
|
||||
|
||||
connect(comm, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString)));
|
||||
connect(ptty, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString)));
|
||||
connect(comm, SIGNAL(havePortError(errorType)), this, SLOT(handlePortError(errorType)));
|
||||
connect(ptty, SIGNAL(havePortError(errotType)), this, SLOT(handlePortError(errorType)));
|
||||
|
||||
connect(this, SIGNAL(getMoreDebug()), comm, SLOT(debugThis()));
|
||||
connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis()));
|
||||
|
@ -164,12 +164,12 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud
|
|||
connect(udp, SIGNAL(haveBaudRate(quint32)), this, SLOT(receiveBaudRate(quint32)));
|
||||
|
||||
// Connect for errors/alerts
|
||||
connect(udp, SIGNAL(haveNetworkError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString)));
|
||||
connect(udp, SIGNAL(haveNetworkError(errorType)), this, SLOT(handlePortError(errorType)));
|
||||
connect(udp, SIGNAL(haveNetworkStatus(networkStatus)), this, SLOT(handleStatusUpdate(networkStatus)));
|
||||
connect(udp, SIGNAL(haveNetworkAudioLevels(networkAudioLevels)), this, SLOT(handleNetworkAudioLevels(networkAudioLevels)));
|
||||
|
||||
|
||||
connect(ptty, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString)));
|
||||
connect(ptty, SIGNAL(havePortError(errorType)), this, SLOT(handlePortError(errorType)));
|
||||
connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis()));
|
||||
|
||||
connect(this, SIGNAL(discoveredRigID(rigCapabilities)), ptty, SLOT(receiveFoundRigID(rigCapabilities)));
|
||||
|
@ -232,14 +232,14 @@ void rigCommander::process()
|
|||
// new thread enters here. Do nothing but do check for errors.
|
||||
if(comm!=Q_NULLPTR && comm->serialError)
|
||||
{
|
||||
emit haveSerialPortError(rigSerialPort, QString("Error from commhandler. Check serial port."));
|
||||
emit havePortError(errorType(rigSerialPort, QString("Error from commhandler. Check serial port.")));
|
||||
}
|
||||
}
|
||||
|
||||
void rigCommander::handleSerialPortError(const QString port, const QString errorText)
|
||||
void rigCommander::handlePortError(errorType err)
|
||||
{
|
||||
qInfo(logRig()) << "Error using port " << port << " message: " << errorText;
|
||||
emit haveSerialPortError(port, errorText);
|
||||
qInfo(logRig()) << "Error using port " << err.device << " message: " << err.message;
|
||||
emit havePortError(err);
|
||||
}
|
||||
|
||||
void rigCommander::handleStatusUpdate(const networkStatus status)
|
||||
|
|
|
@ -227,7 +227,7 @@ public slots:
|
|||
// UDP:
|
||||
void handleNewData(const QByteArray& data);
|
||||
void receiveAudioData(const audioPacket& data);
|
||||
void handleSerialPortError(const QString port, const QString errorText);
|
||||
void handlePortError(errorType err);
|
||||
void changeLatency(const quint16 value);
|
||||
void dataFromServer(QByteArray data);
|
||||
void receiveBaudRate(quint32 baudrate);
|
||||
|
@ -249,7 +249,7 @@ public slots:
|
|||
signals:
|
||||
// Communication:
|
||||
void commReady();
|
||||
void haveSerialPortError(const QString port, const QString errorText);
|
||||
void havePortError(errorType err);
|
||||
void haveStatusUpdate(const networkStatus status);
|
||||
void haveNetworkAudioLevels(const networkAudioLevels l);
|
||||
void dataForComm(const QByteArray &outData);
|
||||
|
|
|
@ -29,6 +29,7 @@ servermain::servermain(const QString settingsFile)
|
|||
qRegisterMetaType<QList<radio_cap_packet>>();
|
||||
qRegisterMetaType<networkStatus>();
|
||||
qRegisterMetaType<codecType>();
|
||||
qRegisterMetaType<errorType>();
|
||||
|
||||
setDefPrefs();
|
||||
|
||||
|
@ -119,7 +120,7 @@ void servermain::makeRig()
|
|||
connect(radio->rigThread, SIGNAL(finished()), radio->rig, SLOT(deleteLater()));
|
||||
radio->rigThread->start();
|
||||
// Rig status and Errors:
|
||||
connect(radio->rig, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(receiveSerialPortError(QString, QString)));
|
||||
connect(radio->rig, SIGNAL(havePortError(errorType)), this, SLOT(receivePortError(errorType)));
|
||||
connect(radio->rig, SIGNAL(haveStatusUpdate(networkStatus)), this, SLOT(receiveStatusUpdate(networkStatus)));
|
||||
|
||||
// Rig comm setup:
|
||||
|
@ -328,7 +329,7 @@ void servermain::receiveFoundRigID(rigCapabilities rigCaps)
|
|||
return;
|
||||
}
|
||||
|
||||
void servermain::receiveSerialPortError(QString port, QString errorText)
|
||||
void servermain::receivePortError(errorType err)
|
||||
{
|
||||
qInfo(logSystem()) << "servermain: received serial port error for port: " << port << " with message: " << errorText;
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ private slots:
|
|||
void receivePTTstatus(bool pttOn);
|
||||
|
||||
void receiveFoundRigID(rigCapabilities rigCaps);
|
||||
void receiveSerialPortError(QString port, QString errorText);
|
||||
void receivePortError(errorType err);
|
||||
void receiveBaudRate(quint32 baudrate);
|
||||
|
||||
void handlePttLimit();
|
||||
|
@ -305,6 +305,7 @@ Q_DECLARE_METATYPE(enum meterKind)
|
|||
Q_DECLARE_METATYPE(enum spectrumMode)
|
||||
Q_DECLARE_METATYPE(rigstate*)
|
||||
Q_DECLARE_METATYPE(codecType)
|
||||
Q_DECLARE_METATYPE(errorType)
|
||||
|
||||
|
||||
#endif // WFMAIN_H
|
||||
|
|
|
@ -325,12 +325,12 @@ void udpHandler::dataReceived()
|
|||
if (in->type != 0x01) {
|
||||
if (in->error == 0xffffffff && !streamOpened)
|
||||
{
|
||||
emit haveNetworkError(radioIP.toString(), "Connection failed, wait a few minutes or reboot the radio.");
|
||||
emit haveNetworkError(errorType(true, radioIP.toString(), "Connection failed\ntry rebooting the radio."));
|
||||
qInfo(logUdp()) << this->metaObject()->className() << ": Connection failed, wait a few minutes or reboot the radio.";
|
||||
}
|
||||
else if (in->error == 0x00000000 && in->disc == 0x01)
|
||||
{
|
||||
emit haveNetworkError(radioIP.toString(), "Got radio disconnected.");
|
||||
emit haveNetworkError(errorType(radioIP.toString(), "Got radio disconnected."));
|
||||
qInfo(logUdp()) << this->metaObject()->className() << ": Got radio disconnected.";
|
||||
if (streamOpened) {
|
||||
// Close stream connections but keep connection open to the radio.
|
||||
|
@ -395,7 +395,7 @@ void udpHandler::dataReceived()
|
|||
{
|
||||
if (rxSetup.codec >= 0x40 || txSetup.codec >= 0x40)
|
||||
{
|
||||
emit haveNetworkError(QString("UDP"), QString("Opus codec not supported, forcing LPCM16"));
|
||||
emit haveNetworkError(errorType(QString("UDP"), QString("Opus codec not supported, forcing LPCM16")));
|
||||
if (rxSetup.codec >= 0x40)
|
||||
rxSetup.codec = 0x04;
|
||||
if (txSetup.codec >= 0x40)
|
||||
|
@ -406,7 +406,7 @@ void udpHandler::dataReceived()
|
|||
|
||||
if (in->error == 0xfeffffff)
|
||||
{
|
||||
status.message = "Invalid Username/Password";
|
||||
emit haveNetworkError(errorType(true, radioIP.toString(), "Invalid Username/Password"));
|
||||
qInfo(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password";
|
||||
}
|
||||
else if (!isAuthenticated)
|
||||
|
|
|
@ -62,7 +62,7 @@ public slots:
|
|||
signals:
|
||||
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
|
||||
void haveAudioData(audioPacket data); // emit this when we have data, connect to rigcommander
|
||||
void haveNetworkError(QString, QString);
|
||||
void haveNetworkError(errorType);
|
||||
void haveChangeLatency(quint16 value);
|
||||
void haveSetVolume(unsigned char value);
|
||||
void haveNetworkStatus(networkStatus);
|
||||
|
|
16
wfmain.cpp
16
wfmain.cpp
|
@ -74,6 +74,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
|
|||
qRegisterMetaType<networkStatus>();
|
||||
qRegisterMetaType<networkAudioLevels>();
|
||||
qRegisterMetaType<codecType>();
|
||||
qRegisterMetaType<errorType>();
|
||||
|
||||
haveRigCaps = false;
|
||||
|
||||
|
@ -493,7 +494,7 @@ void wfmain::makeRig()
|
|||
rigThread->start();
|
||||
|
||||
// Rig status and Errors:
|
||||
connect(rig, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(receiveSerialPortError(QString, QString)));
|
||||
connect(rig, SIGNAL(havePortError(errorType)), this, SLOT(receivePortError(errorType)));
|
||||
connect(rig, SIGNAL(haveStatusUpdate(networkStatus)), this, SLOT(receiveStatusUpdate(networkStatus)));
|
||||
connect(rig, SIGNAL(haveNetworkAudioLevels(networkAudioLevels)), this, SLOT(receiveNetworkAudioLevels(networkAudioLevels)));
|
||||
connect(rig, SIGNAL(requestRadioSelection(QList<radio_cap_packet>)), this, SLOT(radioSelection(QList<radio_cap_packet>)));
|
||||
|
@ -673,11 +674,16 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
|
|||
return;
|
||||
}
|
||||
|
||||
void wfmain::receiveSerialPortError(QString port, QString errorText)
|
||||
void wfmain::receivePortError(errorType err)
|
||||
{
|
||||
qInfo(logSystem()) << "wfmain: received serial port error for port: " << port << " with message: " << errorText;
|
||||
ui->statusBar->showMessage(QString("ERROR: using port ").append(port).append(": ").append(errorText), 10000);
|
||||
|
||||
if (err.alert) {
|
||||
QMessageBox::critical(this, err.device, err.message, QMessageBox::Ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
qInfo(logSystem()) << "wfmain: received error for device: " << err.device << " with message: " << err.message;
|
||||
ui->statusBar->showMessage(QString("ERROR: using device ").append(err.device).append(": ").append(err.message), 10000);
|
||||
}
|
||||
// TODO: Dialog box, exit, etc
|
||||
}
|
||||
|
||||
|
|
3
wfmain.h
3
wfmain.h
|
@ -296,7 +296,7 @@ private slots:
|
|||
void receiveAntennaSel(unsigned char ant, bool rx);
|
||||
void receiveRigID(rigCapabilities rigCaps);
|
||||
void receiveFoundRigID(rigCapabilities rigCaps);
|
||||
void receiveSerialPortError(QString port, QString errorText);
|
||||
void receivePortError(errorType err);
|
||||
void receiveStatusUpdate(networkStatus status);
|
||||
void receiveNetworkAudioLevels(networkAudioLevels l);
|
||||
void handlePlotClick(QMouseEvent *);
|
||||
|
@ -1076,6 +1076,7 @@ Q_DECLARE_METATYPE(QList<radio_cap_packet>)
|
|||
Q_DECLARE_METATYPE(QList<spotData>)
|
||||
Q_DECLARE_METATYPE(rigstate*)
|
||||
Q_DECLARE_METATYPE(codecType)
|
||||
Q_DECLARE_METATYPE(errorType)
|
||||
|
||||
//void (*wfmain::logthistext)(QString text) = NULL;
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ Global
|
|||
{326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|x64.Build.0 = Debug|x64
|
||||
{326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x64.ActiveCfg = Release|x64
|
||||
{326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x64.Build.0 = Release|x64
|
||||
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|Win32.Build.0 = Release|Win32
|
||||
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|x64.ActiveCfg = Release|x64
|
||||
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -45,6 +45,17 @@ struct timekind {
|
|||
bool isMinus;
|
||||
};
|
||||
|
||||
struct errorType {
|
||||
errorType(bool alert, QString message) : alert(alert), message(message) {};
|
||||
errorType(bool alert, QString device, QString message) : alert(alert), device(device), message(message) {};
|
||||
errorType(QString device, QString message) : alert(false), device(device), message(message) {};
|
||||
errorType(QString message) : alert(false), message(message) {};
|
||||
|
||||
bool alert;
|
||||
QString device;
|
||||
QString message;
|
||||
};
|
||||
|
||||
enum audioType {qtAudio,portAudio,rtAudio};
|
||||
enum codecType { LPCM, PCMU, OPUS };
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue