Skip to content

Commit

Permalink
Merge pull request #27 from kamgolabek/master
Browse files Browse the repository at this point in the history
Loading situations file from disk.
  • Loading branch information
vranki authored Apr 4, 2018
2 parents 1ae0ec1 + c6a4a9b commit 223c3cc
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ external programs through an easy-to-use TCP protocol.
* Support for different dataref types: int, float, double, int[], float[], data
* Simulate key and button presses
* Execute commands
* Load situations
* Free & open source under GPLv3
* Client libraries available for Qt (c++), Java and C#

Expand Down Expand Up @@ -246,6 +247,11 @@ provide a way to lookup keys or buttons by name.

Command identifiers are strings that look like datarefs.


### Situations ###
* ** sit {situationFileLocation} ** situation file location relative to XPlane root folder <br />
(e.g., sit Output/situations/SampleSit.sit )

### Other ###

* **disconnect** Disconnect the TCP socket.
Expand Down Expand Up @@ -382,6 +388,7 @@ Original Author:
Contributors:
- Dan Krusi <dan.krusi@nerves.ch>
- Bob Gates
- Kamil Gołąbek <kamgolabek@gmail.com>

Use GitHub's issue tracker to report bugs or feature requests.

Expand Down
14 changes: 14 additions & 0 deletions extplane-plugin/xplaneplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,20 @@ QString XPlanePlugin::refNameWithoutModifiers(QString &original)
return original;
}

/**
* @brief XPlanePlugin::loadSituation
* @param name : situation file location -
* relative to XPlane root folder, e.g. Output/situations/XXX.sit
*/
bool XPlanePlugin::loadSituation(QString sitFileLocation){
int ret = XPLMLoadDataFile(xplm_DataFile_Situation, sitFileLocation.toLatin1().data());
if(ret == 1){
return true;
}else {
return false;
}
}


void XPlanePlugin::pluginStop() {
DEBUG;
Expand Down
1 change: 1 addition & 0 deletions extplane-plugin/xplaneplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class XPlanePlugin : public QObject, public DataRefProvider {
virtual void buttonRelease(int buttonid);
virtual void changeDataRef(DataRef *ref);
virtual void command(QString &name, extplaneCommandType type);
virtual bool loadSituation(QString sitFileLocation);

public slots:
void setFlightLoopInterval(float newInterval);
Expand Down
2 changes: 2 additions & 0 deletions extplane-server/datarefprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class DataRefProvider {
virtual void buttonRelease(int buttonid)=0;
// Run a named command
virtual void command(QString &name, extplaneCommandType type)=0;
//Load situation file from disk, relatively to XPlane root folder
virtual bool loadSituation(QString sitFileLocation)=0;
};

#endif // DATAREFPROVIDER_H
6 changes: 6 additions & 0 deletions extplane-server/tcpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ void TcpClient::readClient() {
} else {
INFO << "Invalid cmd command";
}
} else if(command == "sit"){
if(subLine.size() == 2) {
_refProvider->loadSituation(subLine.value(1));
} else {
INFO << "Invalid sit command";
}
} else {
INFO << "Unknown command " << command;
}
Expand Down
3 changes: 3 additions & 0 deletions extplane-transformer/datasources/flightgeardatasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ void FlightGearDataSource::buttonRelease(int buttonid)
void FlightGearDataSource::command(QString &name, extplaneCommandType type)
{}

bool FlightGearDataSource::loadSituation(QString sitFileLocation)
{}

void FlightGearDataSource::sessionOpened()
{
setNetworkError(QString());
Expand Down
1 change: 1 addition & 0 deletions extplane-transformer/datasources/flightgeardatasource.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class FlightGearDataSource : public DataSource
void buttonPress(int buttonid);
void buttonRelease(int buttonid);
void command(QString &name, extplaneCommandType type);
bool loadSituation(QString sitFileLocation);

private slots:
void sessionOpened();
Expand Down

0 comments on commit 223c3cc

Please sign in to comment.