Skip to content

Commit 3b82798

Browse files
committed
Fix get command if ref already subscribed, document get
1 parent b1eaa25 commit 3b82798

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
A plugin for X-Plane and other simulators that allows commanding the simulation from
44
external programs through an easy-to-use TCP protocol.
55

6-
Current version 1002
6+
Current version 1003 (set in tcpserver.h, if you make changes!)
77

88
## Supported simulators ##
99

@@ -211,6 +211,7 @@ Commands and replies are sent as text strings as defined below.
211211
* **sub {dataref}:[modifiers] [accuracy]** Subscribe to dataref, with optional accuracy.
212212
* **unsub {dataref}** Unsubscribe dataref.
213213
* **set {dataref} {value}** Set dataref to value. Dataref must be subscribed first.
214+
* **get {dataref}** Get dataref value once, then unsubscribe.
214215

215216
With accuracy you can decide how much the dataref's value can
216217
change before a update is sent. Set it to as large value as possible

extplane-server/tcpclient.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ void TcpClient::readClient() {
109109
_refValueB[ref] = qobject_cast<DataDataRef*>(ref)->value();
110110
}
111111
INFO << "Subscribed to " << ref->name() << ", accuracy " << accuracy << ", type " << ref->typeString() << ", valid " << ref->isValid();
112-
if(ref->isValid()) {
113-
sendRef(ref); // Force update
114-
}
115-
if(command == "get") ref->setUnsubscribeAfterChange();
116112
}
117113
} else { // Ref already subscribed - update accuracy
118114
INFO << "Updating " << refName << " accuracy to " << accuracy;
119115
ref->setAccuracy(accuracy);
120116
}
117+
if(ref->isValid()) {
118+
sendRef(ref); // Force update
119+
}
120+
if(command == "get") ref->setUnsubscribeAfterChange();
121121
} else {
122122
extplaneWarning(QString("Invalid sub command"));
123123
}

extplane-server/tcpserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Network protocol, currently always 1
1515
#define EXTPLANE_PROTOCOL 1
1616
// 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
17-
#define EXTPLANE_VERSION 1002
17+
#define EXTPLANE_VERSION 1003
1818

1919
#define EXTPLANE_STRINGIFY(s) __EXTPLANE_STRINGIFY(s)
2020
#define __EXTPLANE_STRINGIFY(s) #s

0 commit comments

Comments
 (0)