@@ -19,11 +19,11 @@ ExtPlaneClient::ExtPlaneClient(QObject *parent, QString name, bool simulated) :
1919 _instance = this ;
2020}
2121
22- void ExtPlaneClient::createClient ()
23- {
22+ void ExtPlaneClient::createClient () {
2423 if (m_connection) return ; // Already created
2524 connect (&m_simulatedExtplaneConnection, &ExtPlaneConnection::connectionMessage, this , &ExtPlaneClient::setConnectionMessage);
2625 connect (&m_extplaneConnection, &ExtPlaneConnection::connectionMessage, this , &ExtPlaneClient::setConnectionMessage);
26+ connect (&m_extplaneConnection, &ExtPlaneConnection::extplaneWarning, this , &ExtPlaneClient::extplaneWarning);
2727 qDebug () << Q_FUNC_INFO << " simulated:" << m_simulated;
2828 if (m_simulated) {
2929 m_simulatedExtplaneConnection.registerClient (this );
@@ -55,16 +55,28 @@ ClientDataRef* ExtPlaneClient::subscribeDataRef(QString name, double accuracy) {
5555 ClientDataRef *ref = m_connection->subscribeDataRef (name, accuracy);
5656 connect (ref, &ClientDataRef::changed, this , &ExtPlaneClient::cdrChanged);
5757 connect (ref, &ClientDataRef::destroyed, this , &ExtPlaneClient::refDestroyed);
58+ ref->setClient (this );
5859 m_dataRefs.append (ref);
5960 return ref;
6061}
6162
63+
64+ void ExtPlaneClient::unsubscribeDataRefByName (QString name) {
65+ qDebug () << Q_FUNC_INFO << " Warning: this functions is deprecated and will be removed. Used with ref" << name;
66+ for (ClientDataRef *ref : m_dataRefs) {
67+ if (ref->name () == name) {
68+ m_dataRefs.removeOne (ref);
69+ m_connection->unsubscribeDataRef (ref);
70+ return ;
71+ }
72+ }
73+ }
74+
6275void ExtPlaneClient::refDestroyed (QObject* refqo) {
6376 m_dataRefs.removeOne (static_cast <ClientDataRef*>(refqo));
6477}
6578
66- void ExtPlaneClient::setConnectionMessage (QString msg)
67- {
79+ void ExtPlaneClient::setConnectionMessage (QString msg) {
6880 m_connectionMessage = msg;
6981 emit connectionMessageChanged (m_connectionMessage);
7082}
@@ -86,9 +98,9 @@ void ExtPlaneClient::cdrChanged(ClientDataRef *ref) {
8698 }
8799}
88100
89- void ExtPlaneClient::unsubscribeDataRef (QString name ) {
101+ void ExtPlaneClient::unsubscribeDataRef (ClientDataRef *refToUnsubscribe ) {
90102 for (ClientDataRef *ref : m_dataRefs) {
91- if (ref->name () == name) {
103+ if (ref->name () == refToUnsubscribe-> name () ) {
92104 m_dataRefs.removeOne (ref);
93105 m_connection->unsubscribeDataRef (ref);
94106 return ;
@@ -161,7 +173,7 @@ void ExtPlaneClient::setSimulated(bool simulated) {
161173 return ;
162174
163175 while (!m_dataRefs.isEmpty ())
164- unsubscribeDataRef (m_dataRefs.first ()-> name () );
176+ unsubscribeDataRef (m_dataRefs.first ());
165177
166178 qDebug () << Q_FUNC_INFO << simulated;
167179
@@ -186,7 +198,3 @@ void ExtPlaneClient::setSimulated(bool simulated) {
186198void ExtPlaneClient::valueSet (ClientDataRef *ref) {
187199 m_connection->setValue (ref->name (), ref->value ());
188200}
189-
190- void ExtPlaneClient::unsubscribed (ClientDataRef *ref) {
191- unsubscribeDataRef (ref->name ());
192- }
0 commit comments