Commit 9dea5ac9 authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #423 from DonLakeFlyer/LinkInterfaceCleanup

Removed LinkInterface methods which were never being called. Updated var...
parents 651fdd26 bfe8684e
......@@ -80,88 +80,9 @@ public:
* Bit/s, NOT 104'857'600 Bit/s).
*
* @return The nominal data rate of the interface in bit per second, 0 if unknown
* @see getLongTermDataRate() For the mean data rate
* @see getShortTermDataRate() For a the mean data rate of the last seconds
* @see getCurrentDataRate() For the data rate of the last transferred chunk
* @see getMaxDataRate() For the maximum data rate
**/
virtual qint64 getNominalDataRate() const = 0;
/**
* @brief Full duplex support of this interface.
*
* This method returns true if the interface supports full duplex, which implies
* the full datarate when sending and receiving data simultaneously.
*
* @return True if the interface supports full duplex, false otherwise
**/
virtual bool isFullDuplex() const = 0;
/**
* @brief Get the link quality.
*
* The link quality is reported as percent, on a scale from 0 to 100% in 1% increments.
* If this feature is not supported by the interface, a call to this method return -1.
*
* @return The link quality in integer percent or -1 if not supported
**/
virtual int getLinkQuality() const = 0;
/**
* @Brief Get the long term (complete) mean of the data rate
*
* The mean of the total data rate. It is calculated as
* all transferred bits / total link uptime.
*
* @return The mean data rate of the interface in bit per second, 0 if unknown
* @see getNominalDataRate() For the nominal data rate of the interface
* @see getShortTermDataRate() For a the mean data rate of the last seconds
* @see getCurrentDataRate() For the data rate of the last transferred chunk
* @see getMaxDataRate() For the maximum data rate
**/
virtual qint64 getTotalUpstream() = 0;
/**
* @Brief Get the current data rate
*
* The datarate of the last 100 ms
*
* @return The mean data rate of the interface in bit per second, 0 if unknown
* @see getNominalDataRate() For the nominal data rate of the interface
* @see getLongTermDataRate() For the mean data rate
* @see getShortTermDataRate() For a the mean data rate of the last seconds
* @see getMaxDataRate() For the maximum data rate
**/
virtual qint64 getCurrentUpstream() = 0;
/**
* @Brief Get the maximum data rate
*
* The maximum peak data rate.
*
* @return The mean data rate of the interface in bit per second, 0 if unknown
* @see getNominalDataRate() For the nominal data rate of the interface
* @see getLongTermDataRate() For the mean data rate
* @see getShortTermDataRate() For a the mean data rate of the last seconds
* @see getCurrentDataRate() For the data rate of the last transferred chunk
**/
virtual qint64 getMaxUpstream() = 0;
/**
* @Brief Get the total number of bits sent
*
* @return The number of sent bits
**/
virtual qint64 getBitsSent() const = 0;
/**
* @Brief Get the total number of bits received
*
* @return The number of received bits
* @bug Decide if the bits should be counted fromt the instantiation of the interface or if the counter should reset on disconnect.
**/
virtual qint64 getBitsReceived() const = 0;
/**
* @brief Connect this interface logically
*
......
......@@ -1004,68 +1004,4 @@ qint64 MAVLinkSimulationLink::getNominalDataRate() const
{
/* 100 Mbit is reasonable fast and sufficient for all embedded applications */
return 100000000;
}
qint64 MAVLinkSimulationLink::getTotalUpstream()
{
return 0;
//TODO Add functionality here
// @todo Add functionality here
}
qint64 MAVLinkSimulationLink::getShortTermUpstream()
{
return 0;
}
qint64 MAVLinkSimulationLink::getCurrentUpstream()
{
return 0;
}
qint64 MAVLinkSimulationLink::getMaxUpstream()
{
return 0;
}
qint64 MAVLinkSimulationLink::getBitsSent() const
{
return 0;
}
qint64 MAVLinkSimulationLink::getBitsReceived() const
{
return 0;
}
qint64 MAVLinkSimulationLink::getTotalDownstream()
{
return 0;
}
qint64 MAVLinkSimulationLink::getShortTermDownstream()
{
return 0;
}
qint64 MAVLinkSimulationLink::getCurrentDownstream()
{
return 0;
}
qint64 MAVLinkSimulationLink::getMaxDownstream()
{
return 0;
}
bool MAVLinkSimulationLink::isFullDuplex() const
{
/* Full duplex is no problem when running in pure software, but this is a serial simulation */
return false;
}
int MAVLinkSimulationLink::getLinkQuality() const
{
/* The Link quality is always perfect when running in software */
return 100;
}
}
\ No newline at end of file
......@@ -60,16 +60,6 @@ public:
/* Extensive statistics for scientific purposes */
qint64 getNominalDataRate() const;
qint64 getTotalUpstream();
qint64 getShortTermUpstream();
qint64 getCurrentUpstream();
qint64 getMaxUpstream();
qint64 getTotalDownstream();
qint64 getShortTermDownstream();
qint64 getCurrentDownstream();
qint64 getMaxDownstream();
qint64 getBitsSent() const;
qint64 getBitsReceived() const;
QString getName() const;
int getId() const;
......@@ -80,9 +70,6 @@ public:
int getDataBitsType() const;
int getStopBitsType() const;
int getLinkQuality() const;
bool isFullDuplex() const;
public slots:
void writeBytes(const char* data, qint64 size);
void readBytes();
......
......@@ -508,51 +508,4 @@ bool OpalLink::disconnect()
qint64 OpalLink::getNominalDataRate() const
{
return 0; //unknown
}
int OpalLink::getLinkQuality() const
{
return -1; //not supported
}
qint64 OpalLink::getTotalUpstream()
{
statisticsMutex.lock();
qint64 totalUpstream = bitsSentTotal / ((MG::TIME::getGroundTimeNow() - connectionStartTime) / 1000);
statisticsMutex.unlock();
return totalUpstream;
}
qint64 OpalLink::getTotalDownstream()
{
statisticsMutex.lock();
qint64 totalDownstream = bitsReceivedTotal / ((MG::TIME::getGroundTimeNow() - connectionStartTime) / 1000);
statisticsMutex.unlock();
return totalDownstream;
}
qint64 OpalLink::getCurrentUpstream()
{
return 0; //unknown
}
qint64 OpalLink::getMaxUpstream()
{
return 0; //unknown
}
qint64 OpalLink::getBitsSent() const
{
return bitsSentTotal;
}
qint64 OpalLink::getBitsReceived() const
{
return bitsReceivedTotal;
}
bool OpalLink::isFullDuplex() const
{
return false;
}
}
\ No newline at end of file
......@@ -79,14 +79,6 @@ public:
qint64 getNominalDataRate() const;
bool isFullDuplex() const;
int getLinkQuality() const;
qint64 getTotalUpstream();
qint64 getTotalDownstream();
qint64 getCurrentUpstream();
qint64 getMaxUpstream();
qint64 getBitsSent() const;
qint64 getBitsReceived() const;
bool connect();
......@@ -124,15 +116,8 @@ protected:
int id;
bool connectState;
quint64 bitsSentTotal;
quint64 bitsSentCurrent;
quint64 bitsSentMax;
quint64 bitsReceivedTotal;
quint64 bitsReceivedCurrent;
quint64 bitsReceivedMax;
quint64 connectionStartTime;
QMutex statisticsMutex;
QMutex receiveDataMutex;
void setName(QString name);
......
......@@ -208,7 +208,6 @@ void SerialLink::run()
// qDebug() << "rx of length " << QString::number(readData.length());
m_bytesRead += readData.length();
m_bitsReceivedTotal += readData.length() * 8;
linkErrorCount = 0;
}
}
......@@ -278,9 +277,6 @@ void SerialLink::writeBytes(const char* data, qint64 size)
m_transmitBuffer.append(byteArray);
}
// Increase write counter
m_bitsSentTotal += size * 8;
// Extra debug logging
// qDebug() << byteArray->toHex();
} else {
......@@ -321,7 +317,6 @@ void SerialLink::readBytes()
// fprintf(stderr,"%02x ", v);
// }
// fprintf(stderr,"\n");
m_bitsReceivedTotal += numBytes * 8;
}
}
m_dataMutex.unlock();
......@@ -420,7 +415,6 @@ bool SerialLink::hardwareConnect()
this, SLOT(linkError(SerialLinkPortError_t)));
// port->setCommTimeouts(QSerialPort::CtScheme_NonBlockingRead);
m_connectionStartTime = MG::TIME::getGroundTimeNow();
if (!m_port->open(QIODevice::ReadWrite)) {
emit communicationUpdate(getName(),"Error opening port: " + m_port->errorString());
......@@ -532,62 +526,6 @@ qint64 SerialLink::getNominalDataRate() const
return dataRate;
}
qint64 SerialLink::getTotalUpstream()
{
m_statisticsMutex.lock();
return m_bitsSentTotal / ((MG::TIME::getGroundTimeNow() - m_connectionStartTime) / 1000);
m_statisticsMutex.unlock();
}
qint64 SerialLink::getCurrentUpstream()
{
return 0; // TODO
}
qint64 SerialLink::getMaxUpstream()
{
return 0; // TODO
}
qint64 SerialLink::getBitsSent() const
{
return m_bitsSentTotal;
}
qint64 SerialLink::getBitsReceived() const
{
return m_bitsReceivedTotal;
}
qint64 SerialLink::getTotalDownstream()
{
m_statisticsMutex.lock();
return m_bitsReceivedTotal / ((MG::TIME::getGroundTimeNow() - m_connectionStartTime) / 1000);
m_statisticsMutex.unlock();
}
qint64 SerialLink::getCurrentDownstream()
{
return 0; // TODO
}
qint64 SerialLink::getMaxDownstream()
{
return 0; // TODO
}
bool SerialLink::isFullDuplex() const
{
/* Serial connections are always half duplex */
return false;
}
int SerialLink::getLinkQuality() const
{
/* This feature is not supported with this interface */
return -1;
}
QString SerialLink::getPortName() const
{
return m_portName;
......
......@@ -97,14 +97,6 @@ public:
/* Extensive statistics for scientific purposes */
qint64 getNominalDataRate() const;
qint64 getTotalUpstream();
qint64 getCurrentUpstream();
qint64 getMaxUpstream();
qint64 getTotalDownstream();
qint64 getCurrentDownstream();
qint64 getMaxDownstream();
qint64 getBitsSent() const;
qint64 getBitsReceived() const;
void loadSettings();
void writeSettings();
......@@ -112,8 +104,6 @@ public:
void run();
void run2();
int getLinkQuality() const;
bool isFullDuplex() const;
int getId() const;
signals: //[TODO] Refactor to Linkinterface
......@@ -161,16 +151,6 @@ protected:
int m_timeout;
int m_id;
quint64 m_bitsSentTotal;
quint64 m_bitsSentShortTerm;
quint64 m_bitsSentCurrent;
quint64 m_bitsSentMax;
quint64 m_bitsReceivedTotal;
quint64 m_bitsReceivedShortTerm;
quint64 m_bitsReceivedCurrent;
quint64 m_bitsReceivedMax;
quint64 m_connectionStartTime;
QMutex m_statisticsMutex;
QMutex m_dataMutex;
QMutex m_writeMutex;
QList<QString> m_ports;
......
......@@ -224,7 +224,6 @@ bool TCPLink::hardwareConnect(void)
}
socketIsConnected = true;
connectionStartTime = QGC::groundTimeUsecs()/1000;
emit connected(true);
return true;
......@@ -232,6 +231,7 @@ bool TCPLink::hardwareConnect(void)
void TCPLink::socketError(QAbstractSocket::SocketError socketError)
{
Q_UNUSED(socketError);
emit communicationError(getName(), "Error on socket: " + socket->errorString());
}
......@@ -265,61 +265,4 @@ void TCPLink::setName(QString name)
qint64 TCPLink::getNominalDataRate() const
{
return 54000000; // 54 Mbit
}
qint64 TCPLink::getTotalUpstream()
{
statisticsMutex.lock();
qint64 totalUpstream = bitsSentTotal / ((QGC::groundTimeUsecs()/1000 - connectionStartTime) / 1000);
statisticsMutex.unlock();
return totalUpstream;
}
qint64 TCPLink::getCurrentUpstream()
{
return 0; // TODO
}
qint64 TCPLink::getMaxUpstream()
{
return 0; // TODO
}
qint64 TCPLink::getBitsSent() const
{
return bitsSentTotal;
}
qint64 TCPLink::getBitsReceived() const
{
return bitsReceivedTotal;
}
qint64 TCPLink::getTotalDownstream()
{
statisticsMutex.lock();
qint64 totalDownstream = bitsReceivedTotal / ((QGC::groundTimeUsecs()/1000 - connectionStartTime) / 1000);
statisticsMutex.unlock();
return totalDownstream;
}
qint64 TCPLink::getCurrentDownstream()
{
return 0; // TODO
}
qint64 TCPLink::getMaxDownstream()
{
return 0; // TODO
}
bool TCPLink::isFullDuplex() const
{
return true;
}
int TCPLink::getLinkQuality() const
{
/* This feature is not supported with this interface */
return -1;
}
}
\ No newline at end of file
......@@ -71,19 +71,9 @@ public:
/* Extensive statistics for scientific purposes */
qint64 getNominalDataRate() const;
qint64 getTotalUpstream();
qint64 getCurrentUpstream();
qint64 getMaxUpstream();
qint64 getTotalDownstream();
qint64 getCurrentDownstream();
qint64 getMaxDownstream();
qint64 getBitsSent() const;
qint64 getBitsReceived() const;
void run();
int getLinkQuality() const;
bool isFullDuplex() const;
int getId() const;
public slots:
......@@ -105,14 +95,6 @@ protected:
QTcpSocket* socket;
bool socketIsConnected;
quint64 bitsSentTotal;
quint64 bitsSentCurrent;
quint64 bitsSentMax;
quint64 bitsReceivedTotal;
quint64 bitsReceivedCurrent;
quint64 bitsReceivedMax;
quint64 connectionStartTime;
QMutex statisticsMutex;
QMutex dataMutex;
void setName(QString name);
......
......@@ -344,7 +344,6 @@ bool UDPLink::hardwareConnect(void)
emit connected(connectState);
if (connectState) {
emit connected();
connectionStartTime = QGC::groundTimeUsecs()/1000;
}
return connectState;
}
......@@ -380,61 +379,4 @@ void UDPLink::setName(QString name)
qint64 UDPLink::getNominalDataRate() const
{
return 54000000; // 54 Mbit
}
qint64 UDPLink::getTotalUpstream()
{
statisticsMutex.lock();
qint64 totalUpstream = bitsSentTotal / ((QGC::groundTimeUsecs()/1000 - connectionStartTime) / 1000);
statisticsMutex.unlock();
return totalUpstream;
}
qint64 UDPLink::getCurrentUpstream()
{
return 0; // TODO
}
qint64 UDPLink::getMaxUpstream()
{
return 0; // TODO
}
qint64 UDPLink::getBitsSent() const
{
return bitsSentTotal;
}
qint64 UDPLink::getBitsReceived() const
{
return bitsReceivedTotal;
}
qint64 UDPLink::getTotalDownstream()
{
statisticsMutex.lock();
qint64 totalDownstream = bitsReceivedTotal / ((QGC::groundTimeUsecs()/1000 - connectionStartTime) / 1000);
statisticsMutex.unlock();
return totalDownstream;
}
qint64 UDPLink::getCurrentDownstream()
{
return 0; // TODO
}
qint64 UDPLink::getMaxDownstream()
{
return 0; // TODO
}
bool UDPLink::isFullDuplex() const
{
return true;
}
int UDPLink::getLinkQuality() const
{
/* This feature is not supported with this interface */
return -1;
}
}
\ No newline at end of file
......@@ -73,19 +73,9 @@ public:
/* Extensive statistics for scientific purposes */
qint64 getNominalDataRate() const;
qint64 getTotalUpstream();
qint64 getCurrentUpstream();
qint64 getMaxUpstream();
qint64 getTotalDownstream();
qint64 getCurrentDownstream();
qint64 getMaxDownstream();
qint64 getBitsSent() const;
qint64 getBitsReceived() const;
void run();
int getLinkQuality() const;
bool isFullDuplex() const;
int getId() const;
public slots:
......@@ -118,14 +108,6 @@ protected:
QList<QHostAddress> hosts;
QList<quint16> ports;
quint64 bitsSentTotal;
quint64 bitsSentCurrent;
quint64 bitsSentMax;
quint64 bitsReceivedTotal;
quint64 bitsReceivedCurrent;
quint64 bitsReceivedMax;
quint64 connectionStartTime;
QMutex statisticsMutex;
QMutex dataMutex;
void setName(QString name);
......
......@@ -123,42 +123,6 @@ qint64 XbeeLink::getNominalDataRate() const
{
return this->m_baudRate;
}
bool XbeeLink::isFullDuplex() const
{
return false;
}
int XbeeLink::getLinkQuality() const
{
return -1; // TO DO:
}
qint64 XbeeLink::getTotalUpstream()
{
return 0; // TO DO:
}
qint64 XbeeLink::getCurrentUpstream()
{
return 0; // TO DO:
}
qint64 XbeeLink::getMaxUpstream()
{
return 0; // TO DO:
}
qint64 XbeeLink::getBitsSent() const
{
return 0; // TO DO:
}
qint64 XbeeLink::getBitsReceived() const
{
return 0; // TO DO:
}
bool XbeeLink::hardwareConnect()
{
emit tryConnectBegin(true);
......
......@@ -35,13 +35,6 @@ public: // virtual functions from LinkInterface
QString getName() const;
bool isConnected() const;
qint64 getNominalDataRate() const;
bool isFullDuplex() const;
int getLinkQuality() const;
qint64 getTotalUpstream();
qint64 getCurrentUpstream();
qint64 getMaxUpstream();
qint64 getBitsSent() const;
qint64 getBitsReceived() const;
bool connect();
bool disconnect();
qint64 bytesAvailable();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment