From 3b827988bdef0c2917396f4d6c38454c54304af9 Mon Sep 17 00:00:00 2001 From: Ville Ranki Date: Mon, 9 Dec 2019 17:58:41 +0200 Subject: [PATCH] Fix get command if ref already subscribed, document get --- README.md | 3 ++- extplane-server/tcpclient.cpp | 8 ++++---- extplane-server/tcpserver.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fc0d931..a683196 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A plugin for X-Plane and other simulators that allows commanding the simulation from external programs through an easy-to-use TCP protocol. -Current version 1002 +Current version 1003 (set in tcpserver.h, if you make changes!) ## Supported simulators ## @@ -211,6 +211,7 @@ Commands and replies are sent as text strings as defined below. * **sub {dataref}:[modifiers] [accuracy]** Subscribe to dataref, with optional accuracy. * **unsub {dataref}** Unsubscribe dataref. * **set {dataref} {value}** Set dataref to value. Dataref must be subscribed first. +* **get {dataref}** Get dataref value once, then unsubscribe. With accuracy you can decide how much the dataref's value can change before a update is sent. Set it to as large value as possible diff --git a/extplane-server/tcpclient.cpp b/extplane-server/tcpclient.cpp index 63401af..99e29bd 100644 --- a/extplane-server/tcpclient.cpp +++ b/extplane-server/tcpclient.cpp @@ -109,15 +109,15 @@ void TcpClient::readClient() { _refValueB[ref] = qobject_cast(ref)->value(); } INFO << "Subscribed to " << ref->name() << ", accuracy " << accuracy << ", type " << ref->typeString() << ", valid " << ref->isValid(); - if(ref->isValid()) { - sendRef(ref); // Force update - } - if(command == "get") ref->setUnsubscribeAfterChange(); } } else { // Ref already subscribed - update accuracy INFO << "Updating " << refName << " accuracy to " << accuracy; ref->setAccuracy(accuracy); } + if(ref->isValid()) { + sendRef(ref); // Force update + } + if(command == "get") ref->setUnsubscribeAfterChange(); } else { extplaneWarning(QString("Invalid sub command")); } diff --git a/extplane-server/tcpserver.h b/extplane-server/tcpserver.h index e782eda..ab49e2d 100644 --- a/extplane-server/tcpserver.h +++ b/extplane-server/tcpserver.h @@ -14,7 +14,7 @@ // Network protocol, currently always 1 #define EXTPLANE_PROTOCOL 1 // Feature revision, every time we add a new feature or bug fix, this should be incremented so that clients can know how old the plugin is -#define EXTPLANE_VERSION 1002 +#define EXTPLANE_VERSION 1003 #define EXTPLANE_STRINGIFY(s) __EXTPLANE_STRINGIFY(s) #define __EXTPLANE_STRINGIFY(s) #s