diff --git a/README.md b/README.md
index fb6c379..6b70259 100644
--- a/README.md
+++ b/README.md
@@ -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#
@@ -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
+ (e.g., sit Output/situations/SampleSit.sit )
+
### Other ###
* **disconnect** Disconnect the TCP socket.
@@ -382,6 +388,7 @@ Original Author:
Contributors:
- Dan Krusi
- Bob Gates
+- Kamil Gołąbek
Use GitHub's issue tracker to report bugs or feature requests.
diff --git a/extplane-plugin/xplaneplugin.cpp b/extplane-plugin/xplaneplugin.cpp
index ea44c24..5b60915 100644
--- a/extplane-plugin/xplaneplugin.cpp
+++ b/extplane-plugin/xplaneplugin.cpp
@@ -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;
diff --git a/extplane-plugin/xplaneplugin.h b/extplane-plugin/xplaneplugin.h
index ea504cd..7584d23 100644
--- a/extplane-plugin/xplaneplugin.h
+++ b/extplane-plugin/xplaneplugin.h
@@ -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);
diff --git a/extplane-server/datarefprovider.h b/extplane-server/datarefprovider.h
index 4a4f004..65497aa 100644
--- a/extplane-server/datarefprovider.h
+++ b/extplane-server/datarefprovider.h
@@ -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
diff --git a/extplane-server/tcpclient.cpp b/extplane-server/tcpclient.cpp
index f91e4e4..7b5a885 100644
--- a/extplane-server/tcpclient.cpp
+++ b/extplane-server/tcpclient.cpp
@@ -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;
}
diff --git a/extplane-transformer/datasources/flightgeardatasource.cpp b/extplane-transformer/datasources/flightgeardatasource.cpp
index 9bb1706..60257dd 100644
--- a/extplane-transformer/datasources/flightgeardatasource.cpp
+++ b/extplane-transformer/datasources/flightgeardatasource.cpp
@@ -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());
diff --git a/extplane-transformer/datasources/flightgeardatasource.h b/extplane-transformer/datasources/flightgeardatasource.h
index c528baa..f6df34d 100644
--- a/extplane-transformer/datasources/flightgeardatasource.h
+++ b/extplane-transformer/datasources/flightgeardatasource.h
@@ -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();