From a61aead38c72ac7cdd2cfa555617d05cb181c46f Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 23 Nov 2014 20:38:30 -0800 Subject: [PATCH] New LinkManager::[connect|disconnect]Link usage --- src/comm/MAVLinkSimulationLink.cc | 34 ++----------------------------- src/comm/MAVLinkSimulationLink.h | 15 +++++++++----- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/src/comm/MAVLinkSimulationLink.cc b/src/comm/MAVLinkSimulationLink.cc index 1bced51fc..ea0c2258b 100644 --- a/src/comm/MAVLinkSimulationLink.cc +++ b/src/comm/MAVLinkSimulationLink.cc @@ -853,7 +853,7 @@ void MAVLinkSimulationLink::readBytes() * @return True if connection has been disconnected, false if connection * couldn't be disconnected. **/ -bool MAVLinkSimulationLink::disconnect() +bool MAVLinkSimulationLink::_disconnect(void) { if(isConnected()) @@ -877,7 +877,7 @@ bool MAVLinkSimulationLink::disconnect() * @return True if connection has been established, false if connection * couldn't be established. **/ -bool MAVLinkSimulationLink::connect() +bool MAVLinkSimulationLink::_connect(void) { _isConnected = true; emit connected(); @@ -892,36 +892,6 @@ bool MAVLinkSimulationLink::connect() return true; } -/** - * Connect the link. - * - * @param connect true connects the link, false disconnects it - * @return True if connection has been established, false if connection - * couldn't be established. - **/ -void MAVLinkSimulationLink::connectLink() -{ - this->connect(); -} - -/** - * Connect the link. - * - * @param connect true connects the link, false disconnects it - * @return True if connection has been established, false if connection - * couldn't be established. - **/ -bool MAVLinkSimulationLink::connectLink(bool connect) -{ - _isConnected = connect; - - if(connect) { - this->connect(); - } - - return true; -} - /** * Check if connection is active. * diff --git a/src/comm/MAVLinkSimulationLink.h b/src/comm/MAVLinkSimulationLink.h index b360d37df..1c35a69fc 100644 --- a/src/comm/MAVLinkSimulationLink.h +++ b/src/comm/MAVLinkSimulationLink.h @@ -54,8 +54,6 @@ public: void run(); void requestReset() { } - bool connect(); - bool disconnect(); // Extensive statistics for scientific purposes qint64 getConnectionSpeed() const; @@ -70,14 +68,17 @@ public: int getParityType() const; int getDataBitsType() const; int getStopBitsType() const; + + // These are left unimplemented in order to cause linker errors which indicate incorrect usage of + // connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager. + bool connect(void); + bool disconnect(void); public slots: void writeBytes(const char* data, qint64 size); void readBytes(); /** @brief Mainloop simulating the mainloop of the MAV */ virtual void mainloop(); - bool connectLink(bool connect); - void connectLink(); void sendMAVLinkMessage(const mavlink_message_t* msg); @@ -129,7 +130,11 @@ protected: signals: void valueChanged(int uasId, QString curve, double value, quint64 usec); void messageReceived(const mavlink_message_t& message); - + +private: + // From LinkInterface + virtual bool _connect(void); + virtual bool _disconnect(void); }; #endif // MAVLINKSIMULATIONLINK_H -- 2.22.0