Skip to content

Commit

Permalink
Fix get command if ref already subscribed, document get
Browse files Browse the repository at this point in the history
  • Loading branch information
vranki committed Dec 9, 2019
1 parent b1eaa25 commit 3b82798
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions extplane-server/tcpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ void TcpClient::readClient() {
_refValueB[ref] = qobject_cast<DataDataRef*>(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"));
}
Expand Down
2 changes: 1 addition & 1 deletion extplane-server/tcpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3b82798

Please sign in to comment.