v1.3.0.0
WASimClient_CLI.h
Go to the documentation of this file.
1/*
2This file is part of the WASimCommander project.
3https://github.com/mpaperno/WASimCommander
4
5COPYRIGHT: (c) Maxim Paperno; All Rights Reserved.
6
7This file may be used under the terms of either the GNU General Public License (GPL)
8or the GNU Lesser General Public License (LGPL), as published by the Free Software
9Foundation, either version 3 of the Licenses, or (at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16Copies of the GNU GPL and LGPL are included with this project
17and are available at <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <iostream>
23#include <stdlib.h>
24#include <string>
25#include <tchar.h>
26#include <msclr/marshal.h>
27#include <msclr/marshal_cppstd.h>
28
29#include "client/WASimClient.h"
30#include "WASimCommander_CLI.h"
31
32/// \file
33
34using namespace System;
35using namespace System::Collections::Generic;
36using namespace System::Runtime::InteropServices;
37using namespace msclr::interop;
38
39/// WASimCommander::CLI::Client namespace.
40/// Implementation of the C++ WASimClient as a C++/CLI .NET "wrapper."
42{
43 using namespace WASimCommander::CLI::Enums;
44 using namespace WASimCommander::CLI::Structs;
45 #define WSE WASimCommander::Enums
46
47 /// C+/CLI wrapper implementation of `WASimCommander::Client::WASimClient`.
48 /// See documentation for the C++ class for most of the details. Only implementation differences are documented here.
49 ///
50 /// This is pretty much a method-for-method version of the C++ version, with parameter types adjusted accordingly,
51 /// and using the CLI versions of relevant data structures and enum types.
52 ///
53 /// The main difference is that callbacks from the C++ version are delivered here as managed Events, with defined delegate types to handle them.
54 /// And unlike the callback system, the events can have multiple subscribers if needed.
55 ///
56 /// \note Events are delivered asyncronously from a separtely running thread. The event handlers should be reentrant since they could be callled at any time. \n
57 /// Typically, interactions with GUI components will not be possible directly from inside the event handlers -- use a `Dispatcher` to marshal GUI interactions
58 /// back to the main thread.
59 public ref class WASimClient
60 {
61 public:
62
63 // Delegates -----------------------------------
64
65 /// \name Event handler delegate types
66 /// \{
67 delegate void ClientEventDelegate(ClientEvent ^); ///< Event delegate for Client events (`OnClientEvent`)
68 delegate void ListResultsDelegate(ListResult ^); ///< Event delegate for delivering list results, eg. of local variables sent from Server (`OnListResults`).
69 delegate void DataDelegate(DataRequestRecord ^); ///< Event delegate for subscription result data (`OnDataReceived`).
70 delegate void LogDelegate(LogRecord ^, LogSource); ///< Event delegate for log entries (from both Client and Server) (`OnLogRecordReceived`).
71 delegate void CommandResultDelegate(Command ^); ///< Event delegate for command responses returned from server (`OnCommandResult`).
72 delegate void ResponseDelegate(Command ^); ///< Event delegate for all Command structures received from server (`OnResponseReceived`).
73 /// \}
74
75 // Events -----------------------------------
76
77 #define DELEGATE_DECL(D) { void add(D^); void remove(D^); }
78 /// <summary> WASimClient events like connection and disconnection. </summary>
80 /// <summary> Delivers list results after a successful `WASimClient.list()` command. </summary>
82 /// <summary> Delivers data value subscription updates as they arrive from the Server. </summary>
83 event DataDelegate ^ OnDataReceived DELEGATE_DECL(DataDelegate);
84 /// <summary>Log records delivered from Client and/or Server. </summary>
85 event LogDelegate ^ OnLogRecordReceived DELEGATE_DECL(LogDelegate);
86 /// <summary> This event is triggered whenever any response to a Command is returned from the Server. Responses are Command objects of `Ack` or `Nak` type. </summary>
88 /// <summary>This event is triggered whenever _any_ Command is received from the server. This is typically `Ack` or `Nak` responses but may also include things list results, pings, or disconnection notices.</summary>
90 #undef DELEGATE_DECL
91
92 /// <summary> Construct a new client with the given ID. The ID must be unique among any other possible clients and cannot be zero. </summary>
93 /// See \refwccc{WASimClient()} for more details.
94 explicit WASimClient(UInt32 clientId);
95 /// <summary> Construct a new client with the given ID and with initial settings read from the file specified in `configFile` (.ini format, see default file for example). </summary>
96 /// The client ID must be unique among any other possible clients and cannot be zero. See \refwccc{WASimClient()} for more details.
97 explicit WASimClient(UInt32 clientId, String ^configFile);
98#if DOXYGEN
99 /// <summary> This class implements a Disposable type object and should be disposed-of appropriately by calling `client.Dispose()` when the instance is no longer needed.
100 /// Any open network connections are automatically closed upon destruction, though it is better to close them yourself before deleting the client. </summary>
101 void Dispose();
102#else
103 ~WASimClient();
104 !WASimClient();
105#endif
106
107 // Status -----------------------------------
108
109 /// \name Network actions, status, and settings
110 /// \{
111
112 /// <summary> Get current connection status of this client. \sa WASimCommander::Client::ClientStatus </summary>
113 ClientStatus status() { return (ClientStatus)m_client->status(); }
114 /// <summary> Returns true if connected to the Simulator (SimConnect). </summary>
115 bool isInitialized() { return m_client->isInitialized(); }
116 /// <summary> Returns true if connected to WASimModule server. </summary>
117 bool isConnected() { return m_client->isConnected(); }
118 /// <summary> Returns version number of the WASimClient. </summary>
119 uint32_t clientVersion() { return m_client->clientVersion(); }
120 /// <summary> Returns version number of the WASimModule server, if known. The version is populated after a successful Ping command or server connection. </summary>
121 uint32_t serverVersion() { return m_client->serverVersion(); }
122
123 // Network actions -----------------------------------
124
125 /// <summary> Connect to the Simulator engine on a local connection. </summary>
126 /// <paramref name='timeout'> (optional) Maximum time to wait for response, in milliseconds. Zero (default) means to use the `defaultTimeout()` value. </paramref>
127 /// \return See \refwccc{connectSimulator(uint32_t)}
128 HR connectSimulator([Optional] Nullable<uint32_t> timeout) { return (HR)m_client->connectSimulator(timeout.HasValue ? timeout.Value : 0); }
129 /// <summary> Connect to the Simulator engine using a specific network configuration ID from a SimConnect.cfg file. The file must be in the same folder as the executable running the Client. </summary>
130 /// <paramref name='networkConfigId'> network configuration ID from a SimConnect.cfg file. The file must be in the same folder as the executable running the Client. </paramref>\n
131 /// <paramref name='timeout'> (optional) Maximum time to wait for response, in milliseconds. Zero (default) means to use the `defaultTimeout()` value. </paramref>
132 /// \return See \refwccc{connectSimulator(int,uint32_t)}
133 HR connectSimulator(int networkConfigId, [Optional] Nullable<uint32_t> timeout) { return (HR)m_client->connectSimulator(networkConfigId, timeout.HasValue ? timeout.Value : 0); }
134 /// See \refwccc{disconnectSimulator()}
136
137 /// See \refwccc{pingServer()}
138 uint32_t pingServer([Optional] Nullable<uint32_t> timeout) { return m_client->pingServer(timeout.HasValue ? timeout.Value : 0); }
139 /// See \refwccc{connectServer()}
140 HR connectServer([Optional] Nullable<uint32_t> timeout) { return (HR)m_client->connectServer(timeout.HasValue ? timeout.Value : 0); }
141 void disconnectServer() { m_client->disconnectServer(); } ///< See \refwccc{disconnectServer()}
142
143 // Settings -----------------------------------
144
145 uint32_t defaultTimeout() { return m_client->defaultTimeout(); } ///< See \refwccc{defaultTimeout()}
146 void setDefaultTimeout(uint32_t ms) { m_client->setDefaultTimeout(ms); } ///< See \refwccc{setDefaultTimeout()}
147 int networkConfigurationId() { return m_client->networkConfigurationId(); } ///< See \refwccc{networkConfigurationId()}
148 void setNetworkConfigurationId(int configId) { m_client->setNetworkConfigurationId(configId); } ///< See \refwccc{setNetworkConfigurationId()}
149
150 /// \}
151 /// \name RPN calculator code execution and reusable events
152 /// \{
153
154 /// <summary> Execute calculator code without result </summary> \sa \refwccc{executeCalculatorCode()}
155 HR executeCalculatorCode(String^ code) { return (HR)m_client->executeCalculatorCode(marshal_as<std::string>(code)); }
156 /// <summary> Execute calculator code with a numeric result type. </summary> \sa \refwccc{executeCalculatorCode()}
157 HR executeCalculatorCode(String^ code, CalcResultType resultType, [Out] double %pfResult);
158 /// <summary> Execute calculator code with a string result type. </summary> \sa \refwccc{executeCalculatorCode()}
159 HR executeCalculatorCode(String^ code, CalcResultType resultType, [Out] String^ %psResult);
160 /// <summary> Execute calculator code with both numeric and string results. </summary> \sa \refwccc{executeCalculatorCode()}
161 HR executeCalculatorCode(String^ code, CalcResultType resultType, [Out] double %pfResult, [Out] String^ %psResult);
162
163 /// \}
164 /// \name Variables accessor methods
165 /// \{
166
167 /// <summary> Get the value of a variable with a numeric result type. This is the most typical use case since most variable types are numeric. </summary> \sa \refwccc{getVariable()}
168 HR getVariable(VariableRequest ^var, [Out] double %pfResult);
169 /// <summary> Get the value of a variable with a string result type. The request is executed as calculator code since that is the only way to get string results. </summary>
170 /// Note that only some 'A', 'C', and 'T' type variables can have a string value type in the first place. \sa \refwccc{getVariable()}
171 HR getVariable(VariableRequest ^var, [Out] String^ %psResult);
172 /// <summary> Get the value of a variable with _either_ a numeric or string result based on the unit type of the requested variable. </summary>
173 /// The request is executed as calculator code since that is the only way to get string results. Unlike `executeCalculatorCode()`, this method will not return a string representation of a numeric value.
174 /// Note that only some 'A', 'C', and 'T' type variables can have a string value type in the first place. \sa \refwccc{getVariable()}
175 HR getVariable(VariableRequest ^var, [Out] double %pfResult, [Out] String^ %psResult); ///< See \refwccc{getVariable()}
176
177 /// See \refwccc{getLocalVariable()}
178 HR getLocalVariable(String ^variableName, [Out] double %pfResult) { return getVariable(gcnew VariableRequest(variableName), pfResult); }
179 /// See \refwccc{getLocalVariable()}
180 HR getLocalVariable(String ^variableName, String ^unitName, [Out] double %pfResult) { return getVariable(gcnew VariableRequest(variableName, false, unitName), pfResult); }
181 /// \sa \refwccc{getOrCreateLocalVariable()}
182 HR getOrCreateLocalVariable(String ^variableName, double defaultValue, [Out] double %pfResult);
183 /// \sa \refwccc{getOrCreateLocalVariable()}
184 HR getOrCreateLocalVariable(String ^variableName, String ^unitName, double defaultValue, [Out] double %pfResult);
185
186 /// See \refwccc{setVariable(const VariableRequest &, double)}
187 HR setVariable(VariableRequest ^var, const double value) { return (HR)m_client->setVariable(var, value); }
188 /// See \refwccc{setVariable(const VariableRequest &, const std::string &)}
189 HR setVariable(VariableRequest ^var, String ^stringValue) { return (HR)m_client->setVariable(var, marshal_as<std::string>(stringValue)); }
190
191 /// See \refwccc{setLocalVariable()}
192 HR setLocalVariable(String ^variableName, const double value) { return (HR)m_client->setLocalVariable(marshal_as<std::string>(variableName), value); }
193 HR setLocalVariable(String ^variableName, String ^unitName, const double value) {
194 return (HR)m_client->setLocalVariable(marshal_as<std::string>(variableName), value, marshal_as<std::string>(unitName));
195 }
196 /// See \refwccc{setOrCreateLocalVariable()}
197 HR setOrCreateLocalVariable(String ^variableName, const double value) { return (HR)m_client->setOrCreateLocalVariable(marshal_as<std::string>(variableName), value); }
198 /// See \refwccc{setOrCreateLocalVariable()}
199 HR setOrCreateLocalVariable(String ^variableName, String ^unitName, const double value) {
200 return (HR)m_client->setOrCreateLocalVariable(marshal_as<std::string>(variableName), value, marshal_as<std::string>(unitName));
201 }
202
203 /// See \refwccc{setSimVarVariable(const std::string &, const std::string &, double)}
204 HR setSimVarVariable(String ^variableName, String ^unitName, const double value) {
205 return (HR)m_client->setSimVarVariable(marshal_as<std::string>(variableName), marshal_as<std::string>(unitName), value);
206 }
207 /// See \refwccc{setSimVarVariable(const std::string &, uint8_t, const std::string &, double)}
208 HR setSimVarVariable(String ^variableName, uint8_t index, String ^unitName, const double value) {
209 return (HR)m_client->setSimVarVariable(marshal_as<std::string>(variableName), index, marshal_as<std::string>(unitName), value);
210 }
211 /// See \refwccc{setSimVarVariable(const std::string &, const std::string &)}
212 HR setSimVarVariable(String ^variableName, String ^stringValue) {
213 return (HR)m_client->setSimVarVariable(marshal_as<std::string>(variableName), marshal_as<std::string>(stringValue));
214 }
215 /// See \refwccc{setSimVarVariable(const std::string &, uint8_t, const std::string &)}
216 HR setSimVarVariable(String ^variableName, uint8_t index, String ^stringValue) {
217 return (HR)m_client->setSimVarVariable(marshal_as<std::string>(variableName), index, marshal_as<std::string>(stringValue));
218 }
219
220 /// \}
221 /// \name Data change subscriptions (variables and calculated results)
222 /// \{
223
224 HR saveDataRequest(DataRequest ^request) { return (HR)m_client->saveDataRequest(request); } ///< See \refwccc{saveDataRequest()} as used with `async = false`
225 HR saveDataRequestAsync(DataRequest ^request) { return (HR)m_client->saveDataRequest(request, true); } ///< See \refwccc{saveDataRequest()} as used with `async = true`
226 HR removeDataRequest(const uint32_t requestId) { return (HR)m_client->removeDataRequest(requestId); } ///< See \refwccc{removeDataRequest()}
227 HR updateDataRequest(uint32_t requestId) { return (HR)m_client->updateDataRequest(requestId); } ///< See \refwccc{updateDataRequest()}
228
229 DataRequestRecord ^dataRequest(uint32_t requestId) { return gcnew DataRequestRecord(m_client->dataRequest(requestId)); } ///< See \refwccc{dataRequest()}
230 array<DataRequestRecord ^> ^dataRequests(); ///< See \refwccc{dataRequests()}
231 array<UInt32> ^dataRequestIdsList(); ///< See \refwccc{dataRequestIdsList()}
232
233 HR setDataRequestsPaused(bool paused) { return (HR)m_client->setDataRequestsPaused(paused); } ///< See \refwccc{setDataRequestsPaused()}
234
235 /// \}
236 /// \name RPN calculator code execution and reusable events
237 /// \{
238
239 HR registerEvent(RegisteredEvent ^eventData) { return (HR)m_client->registerEvent(eventData); } ///< See \refwccc{registerEvent()}
240 HR removeEvent(uint32_t eventId) { return (HR)m_client->removeEvent(eventId); } ///< See \refwccc{removeEvent()}
241 HR transmitEvent(uint32_t eventId) { return (HR)m_client->transmitEvent(eventId); } ///< See \refwccc{transmitEvent()}
242
243 RegisteredEvent ^registeredEvent(uint32_t eventId) { return gcnew RegisteredEvent(m_client->registeredEvent(eventId)); } ///< See \refwccc{registeredEvent()}
244 array<RegisteredEvent ^> ^registeredEvents(); ///< See \refwccc{registeredEvents()}
245
246 /// \}
247 /// \name Simulator Key Events
248 /// \{
249
250 /// See \refwccc{sendKeyEvent(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t) const}
251 HR sendKeyEvent(uint32_t keyEventId, [Optional] Nullable<uint32_t> v1, [Optional] Nullable<uint32_t> v2, [Optional] Nullable<uint32_t> v3, [Optional] Nullable<uint32_t> v4, [Optional] Nullable<uint32_t> v5) {
252 return (HR)m_client->sendKeyEvent(keyEventId, v1.GetValueOrDefault(0), v2.GetValueOrDefault(0), v3.GetValueOrDefault(0), v4.GetValueOrDefault(0), v5.GetValueOrDefault(0));
253 }
254
255 /// See \refwccc{sendKeyEvent(const std::string&, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)}
256 HR sendKeyEvent(String ^keyEventName, [Optional] Nullable<uint32_t> v1, [Optional] Nullable<uint32_t> v2, [Optional] Nullable<uint32_t> v3, [Optional] Nullable<uint32_t> v4, [Optional] Nullable<uint32_t> v5) {
257 return (HR)m_client->sendKeyEvent(marshal_as<std::string>(keyEventName), v1.GetValueOrDefault(0), v2.GetValueOrDefault(0), v3.GetValueOrDefault(0), v4.GetValueOrDefault(0), v5.GetValueOrDefault(0));
258 }
259
260 /// See \refwccc{registerCustomKeyEvent()};
261 HR registerCustomKeyEvent(String ^customEventName, [Out] UInt32 %puiCustomEventId, [Optional] Nullable<bool> useLegacyTransmit) {
262 pin_ptr<UInt32> pui = &puiCustomEventId;
263 return (HR)m_client->registerCustomKeyEvent(marshal_as<std::string>(customEventName), pui, useLegacyTransmit.GetValueOrDefault(false));
264 }
265 /// See \refwccc{registerCustomKeyEvent()}. This method overload doesn't provide the generated event ID as a return value.
266 HR registerCustomKeyEvent(String ^customEventName, [Optional] Nullable<bool> useLegacyTransmit) {
267 return (HR)m_client->registerCustomKeyEvent(marshal_as<std::string>(customEventName), nullptr, useLegacyTransmit.GetValueOrDefault(false));
268 }
269
270 /// See \refwccc{removeCustomKeyEvent(uint32_t)}
271 HR removeCustomKeyEvent(UInt32 eventId) { return (HR)m_client->removeCustomKeyEvent(eventId); }
272 /// See \refwccc{removeCustomKeyEvent(const std::string&)}
273 HR removeCustomKeyEvent(String ^customEventName) { return (HR)m_client->removeCustomKeyEvent(marshal_as<std::string>(customEventName)); }
274
275 /// \}
276 /// \name Metadata retrieval
277 /// \{
278
279 /// See \refwccc{list()}
280 HR list(LookupItemType itemsType) { return (HR)m_client->list((WSE::LookupItemType)itemsType); }
281 /// See \refwccc{lookup()}
282 HR lookup(LookupItemType itemType, String ^itemName, [Out] Int32 %piResult)
283 {
284 pin_ptr<Int32> pi = &piResult;
285 return (HR)m_client->lookup((WSE::LookupItemType)itemType, marshal_as<std::string>(itemName), pi);
286 }
287
288 /// \}
289 /// \name Low level API
290 /// \{
291
292 /// See \refwccc{sendCommand()}
293 HR sendCommand(Command ^command) { return (HR)m_client->sendCommand(command); }
294 /// See \refwccc{sendCommandWithResponse()}
295 HR sendCommandWithResponse(Command ^command, [Out] Command^ %response, [Optional] Nullable<uint32_t> timeout)
296 {
298 const HRESULT hr = m_client->sendCommandWithResponse(command, &resp, (timeout.HasValue ? timeout.Value : 0));
299 response = gcnew Command(resp);
300 return (HR)hr;
301 }
302
303 /// \}
304 /// \name Logging settings
305 /// \{
306
307 /// See \refwccc{logLevel()}
308 LogLevel logLevel(LogFacility facility, LogSource source) {
309 return (LogLevel)m_client->logLevel((WSE::LogFacility)facility, (WASimCommander::Client::LogSource)source);
310 }
311 /// See \refwccc{setLogLevel()}
312 void setLogLevel(LogLevel level, LogFacility facility, LogSource source) {
313 m_client->setLogLevel((WSE::LogLevel)level, (WSE::LogFacility)facility, (WASimCommander::Client::LogSource)source);
314 }
315
316 /// \}
317
318
319 private:
320 WASimCommander::Client::WASimClient *m_client = nullptr;
321 ref class Private;
322 Private ^d = nullptr;
323 };
324
325 #undef WSE
326
327}
C+/CLI wrapper implementation of WASimCommander::Client::WASimClient. See documentation for the C++ c...
HR executeCalculatorCode(String^ code, CalcResultType resultType, [Out] double % pfResult, [Out] String^ % psResult)
Execute calculator code with both numeric and string results.
uint32_t serverVersion()
Returns version number of the WASimModule server, if known. The version is populated after a successf...
HR removeDataRequest(const uint32_t requestId)
See WASimClient::removeDataRequest().
HR getLocalVariable(String ^ variableName, String ^ unitName, [Out] double % pfResult)
See WASimClient::getLocalVariable().
HR getVariable(VariableRequest ^ var, [Out] double % pfResult)
Get the value of a variable with a numeric result type. This is the most typical use case since most ...
HR sendCommand(Command ^ command)
See WASimClient::sendCommand().
delegate void ResponseDelegate(Command ^)
Event delegate for all Command structures received from server (OnResponseReceived).
delegate void ListResultsDelegate(ListResult ^)
Event delegate for delivering list results, eg. of local variables sent from Server (OnListResults).
HR setOrCreateLocalVariable(String ^ variableName, String ^ unitName, const double value)
See WASimClient::setOrCreateLocalVariable().
void Dispose()
This class implements a Disposable type object and should be disposed-of appropriately by calling cli...
bool isConnected()
Returns true if connected to WASimModule server.
bool isInitialized()
Returns true if connected to the Simulator (SimConnect).
array< UInt32 > ^ dataRequestIdsList()
See WASimClient::dataRequestIdsList().
ClientStatus status()
Get current connection status of this client.
HR connectSimulator([Optional] Nullable< uint32_t > timeout)
Connect to the Simulator engine on a local connection.
HR setVariable(VariableRequest ^ var, const double value)
See WASimClient::setVariable(const VariableRequest &, double).
HR executeCalculatorCode(String^ code, CalcResultType resultType, [Out] double % pfResult)
Execute calculator code with a numeric result type.
HR saveDataRequestAsync(DataRequest ^ request)
See WASimClient::saveDataRequest() as used with async = true
HR setVariable(VariableRequest ^ var, String ^ stringValue)
See WASimClient::setVariable(const VariableRequest &, const std::string &).
int networkConfigurationId()
See WASimClient::networkConfigurationId().
HR removeCustomKeyEvent(UInt32 eventId)
See WASimClient::removeCustomKeyEvent(uint32_t).
delegate void LogDelegate(LogRecord ^, LogSource)
Event delegate for log entries (from both Client and Server) (OnLogRecordReceived).
DataRequestRecord ^ dataRequest(uint32_t requestId)
See WASimClient::dataRequest().
HR getOrCreateLocalVariable(String ^ variableName, double defaultValue, [Out] double % pfResult)
HR setDataRequestsPaused(bool paused)
See WASimClient::setDataRequestsPaused().
HR sendCommandWithResponse(Command ^ command, [Out] Command^ % response, [Optional] Nullable< uint32_t > timeout)
See WASimClient::sendCommandWithResponse().
HR executeCalculatorCode(String^ code, CalcResultType resultType, [Out] String^ % psResult)
Execute calculator code with a string result type.
HR connectServer([Optional] Nullable< uint32_t > timeout)
See WASimClient::connectServer().
HR getLocalVariable(String ^ variableName, [Out] double % pfResult)
See WASimClient::getLocalVariable().
array< DataRequestRecord ^> ^ dataRequests()
See WASimClient::dataRequests().
void setLogLevel(LogLevel level, LogFacility facility, LogSource source)
See WASimClient::setLogLevel().
HR connectSimulator(int networkConfigId, [Optional] Nullable< uint32_t > timeout)
Connect to the Simulator engine using a specific network configuration ID from a SimConnect....
HR setLocalVariable(String ^ variableName, const double value)
See WASimClient::setLocalVariable().
void setDefaultTimeout(uint32_t ms)
See WASimClient::setDefaultTimeout().
void disconnectServer()
See WASimClient::disconnectServer().
ListResultsDelegate^ OnListResults
Delivers list results after a successful WASimClient.list() command.
HR list(LookupItemType itemsType)
See WASimClient::list().
RegisteredEvent ^ registeredEvent(uint32_t eventId)
See WASimClient::registeredEvent().
uint32_t pingServer([Optional] Nullable< uint32_t > timeout)
See WASimClient::pingServer().
WASimClient(UInt32 clientId)
Construct a new client with the given ID. The ID must be unique among any other possible clients and ...
HR registerCustomKeyEvent(String ^ customEventName, [Optional] Nullable< bool > useLegacyTransmit)
See WASimClient::registerCustomKeyEvent(). This method overload doesn't provide the generated event I...
CommandResultDelegate^ OnCommandResult
This event is triggered whenever any response to a Command is returned from the Server....
ResponseDelegate^ OnResponseReceived
This event is triggered whenever any Command is received from the server. This is typically Ack or Na...
void disconnectSimulator()
See WASimClient::disconnectSimulator().
HR registerCustomKeyEvent(String ^ customEventName, [Out] UInt32 % puiCustomEventId, [Optional] Nullable< bool > useLegacyTransmit)
See WASimClient::registerCustomKeyEvent();.
HR saveDataRequest(DataRequest ^ request)
See WASimClient::saveDataRequest() as used with async = false
HR setLocalVariable(String ^ variableName, String ^ unitName, const double value)
Get the value of a variable with a numeric result type. This is the most typical use case since most ...
LogDelegate^ OnLogRecordReceived
Log records delivered from Client and/or Server.
HR lookup(LookupItemType itemType, String ^ itemName, [Out] Int32 % piResult)
See WASimClient::lookup().
HR setSimVarVariable(String ^ variableName, uint8_t index, String ^ stringValue)
See WASimClient::setSimVarVariable(const std::string &, uint8_t, const std::string &).
HR setSimVarVariable(String ^ variableName, String ^ unitName, const double value)
See WASimClient::setSimVarVariable(const std::string &, const std::string &, double).
uint32_t defaultTimeout()
See WASimClient::defaultTimeout().
HR removeCustomKeyEvent(String ^ customEventName)
See WASimClient::removeCustomKeyEvent(const std::string&).
LogLevel logLevel(LogFacility facility, LogSource source)
See WASimClient::logLevel().
HR executeCalculatorCode(String^ code)
Execute calculator code without result
HR sendKeyEvent(uint32_t keyEventId, [Optional] Nullable< uint32_t > v1, [Optional] Nullable< uint32_t > v2, [Optional] Nullable< uint32_t > v3, [Optional] Nullable< uint32_t > v4, [Optional] Nullable< uint32_t > v5)
See WASimClient::sendKeyEvent(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t) const.
HR setSimVarVariable(String ^ variableName, uint8_t index, String ^ unitName, const double value)
See WASimClient::setSimVarVariable(const std::string &, uint8_t, const std::string &,...
HR setSimVarVariable(String ^ variableName, String ^ stringValue)
See WASimClient::setSimVarVariable(const std::string &, const std::string &).
HR removeEvent(uint32_t eventId)
See WASimClient::removeEvent().
ClientEventDelegate^ OnClientEvent
WASimClient events like connection and disconnection.
HR registerEvent(RegisteredEvent ^ eventData)
See WASimClient::registerEvent().
delegate void DataDelegate(DataRequestRecord ^)
Event delegate for subscription result data (OnDataReceived).
uint32_t clientVersion()
Returns version number of the WASimClient.
HR updateDataRequest(uint32_t requestId)
See WASimClient::updateDataRequest().
HR setOrCreateLocalVariable(String ^ variableName, const double value)
See WASimClient::setOrCreateLocalVariable().
HR transmitEvent(uint32_t eventId)
See WASimClient::transmitEvent().
DataDelegate^ OnDataReceived
Delivers data value subscription updates as they arrive from the Server.
delegate void CommandResultDelegate(Command ^)
Event delegate for command responses returned from server (OnCommandResult).
array< RegisteredEvent ^> ^ registeredEvents()
See WASimClient::registeredEvents().
void setNetworkConfigurationId(int configId)
See WASimClient::setNetworkConfigurationId().
delegate void ClientEventDelegate(ClientEvent ^)
Event delegate for Client events (OnClientEvent)
HR sendKeyEvent(String ^ keyEventName, [Optional] Nullable< uint32_t > v1, [Optional] Nullable< uint32_t > v2, [Optional] Nullable< uint32_t > v3, [Optional] Nullable< uint32_t > v4, [Optional] Nullable< uint32_t > v5)
See WASimClient::sendKeyEvent(const std::string&, uint32_t, uint32_t, uint32_t, uint32_t,...
WASimCommander Client implementation. Handles all aspects of communication with the WASimCommander Se...
Definition: WASimClient.h:85
bool isInitialized() const
Check if simulator network link is established.
HRESULT registerEvent(const RegisteredEvent &eventData)
Register a reusable event which executes a pre-set RPN calculator code string. The code is pre-compil...
HRESULT sendCommandWithResponse(const Command &command, Command *response, uint32_t timeout=0)
Sends a command, in the form of a WASimCommander::Command structure, to the server for processing and...
RegisteredEvent registeredEvent(uint32_t eventId)
Returns a copy of a RegisteredEvent which has been previously added with registerEvent()....
bool isConnected() const
Check WASimCommander server connection status.
uint32_t defaultTimeout() const
Get the current default server response timeout value, which is used in all network requests....
HRESULT executeCalculatorCode(const std::string &code, WASimCommander::Enums::CalcResultType resultType=WASimCommander::Enums::CalcResultType::None, double *pfResult=nullptr, std::string *psResult=nullptr) const
Run a string of MSFS Gauge API calculator code in RPN format, possibly with some kind of result expec...
uint32_t clientVersion() const
Return the current WASimClient version number. Version numbers are in "BCD" format: MAJOR << 24 | MIN...
ClientStatus status() const
Get current connection status of this client.
HRESULT updateDataRequest(uint32_t requestId)
Trigger a data update on a previously-added DataRequest. Designed to refresh data on subscriptions wi...
void setLogLevel(WASimCommander::Enums::LogLevel level, WASimCommander::Enums::LogFacility facility=WASimCommander::Enums::LogFacility::Remote, LogSource source=LogSource::Client)
Set the current minimum logging severity level for the specified facility and source to level.
HRESULT setSimVarVariable(const std::string &variableName, const std::string &unitName, double value)
Sets a numeric value on an 'A' (aka "SimVar" / "Simulator Variable") type variable....
Definition: WASimClient.h:262
HRESULT lookup(WASimCommander::Enums::LookupItemType itemType, const std::string &itemName, int32_t *piResult)
Request server-side lookup of an named item to find the corresponding numeric ID.
HRESULT connectSimulator(uint32_t timeout=0)
Initialize the simulator network link and set up minimum necessary for WASimCommander server ping or ...
HRESULT removeDataRequest(const uint32_t requestId)
Remove a previously-added DataRequest. This clears the subscription and any tracking/meta data from b...
HRESULT sendCommand(const Command &command) const
Sends a command, in the form of a WASimCommander::Command structure, to the server for processing....
HRESULT connectServer(uint32_t timeout=0)
Connect to WASimCommander server. This will implicitly call connectSimulator() first if it hasn't alr...
HRESULT registerCustomKeyEvent(const std::string &customEventName, uint32_t *puiCustomEventId=nullptr, bool useLegacyTransmit=false)
Register a "Custom Simulator [Key] Event" by providing an event name. The method optionally returns t...
HRESULT removeEvent(uint32_t eventId)
Remove an event previously registered with registerEvent() method. This is effectively the same as ca...
void setNetworkConfigurationId(int configId)
SimConnect is used for the network layer. This setting specifies the SimConnect.cfg index to use,...
HRESULT transmitEvent(uint32_t eventId)
Trigger an event previously registered with registerEvent(). This is a more direct alternative to tri...
DataRequestRecord dataRequest(uint32_t requestId) const
Returns a copy of a DataRequestRecord which has been previously added. If the request with the given ...
HRESULT setOrCreateLocalVariable(const std::string &variableName, const double value, const std::string &unitName=std::string())
Set a Local Variable value by variable name, creating it first if it does not already exist....
HRESULT removeCustomKeyEvent(const std::string &customEventName)
Remove a Custom Event previously registered with registerCustomEvent() method using the event's name....
HRESULT setVariable(const VariableRequest &variable, const double value)
Set a Variable value by name, with optional named unit type. Although any settable variable type can ...
void disconnectSimulator()
Shut down all network connections (and disconnect WASimCommander server if connected)....
HRESULT setDataRequestsPaused(bool paused) const
Enables or disables all data request subscription updates at the same time. Use this to temporarily s...
uint32_t pingServer(uint32_t timeout=0)
Check if WASimCommander Server exists (Simulator running, the WASIM module is installed and working)....
uint32_t serverVersion() const
Return the version number of the last-connected, or successfully pinged, WASimModule (sever),...
HRESULT sendKeyEvent(uint32_t keyEventId, uint32_t v1=0, uint32_t v2=0, uint32_t v3=0, uint32_t v4=0, uint32_t v5=0) const
Can be used to trigger standard Simulator "Key Events" as well as "custom" Gauge API/SimConnect event...
HRESULT list(WASimCommander::Enums::LookupItemType itemsType=WASimCommander::Enums::LookupItemType::LocalVariable)
Send a request for a list update to the server. The results are delivered using the callback set in s...
WASimCommander::Enums::LogLevel logLevel(WASimCommander::Enums::LogFacility facility, LogSource source=LogSource::Client) const
Get the current minimum logging severity level for the specified facility and source.
int networkConfigurationId() const
SimConnect is used for the network layer. This setting specifies the SimConnect.cfg index to use....
void disconnectServer()
Disconnect from the WASimCommander server. This does not close the Simulator network connection (use ...
HRESULT setLocalVariable(const std::string &variableName, const double value, const std::string &unitName=std::string())
A convenience version of setVariable() for Local variable types. Equivalent to setVariable(VariableRe...
HRESULT saveDataRequest(const DataRequest &request, bool async=false)
Add a new WASimCommander::DataRequest for a variable or calculated result, or update an existing data...
void setDefaultTimeout(uint32_t ms)
Get current connection status of this client.
WASimCommander::CLI::Client namespace. Implementation of the C++ WASimClient as a C++/CLI ....
WASimCommander::CLI::Enums namespace. C++/CLI specific definitions only. See documentation for WASimC...
Definition: Enums.h:42
HR
Method return status values; HRESULT "alias"
Definition: Enums.h:50
WASimCommander::CLI::Structs namespace. CLI/.NET versions of WASimCommander API and Client data struc...
Definition: Structs.h:43
LogSource
Log entry source, Client or Server.
Definition: enums_impl.h:74
Client Event data, delivered via callback.
Definition: Structs.h:442
Command data structure. The member contents depend on the command type as described in each command t...
Definition: Structs.h:142
Structure for value update subscription requests.
Definition: Structs.h:212
DataRequestRecord inherits and extends WASimCommander::CLI::Structs::DataRequest with data pertinent ...
Definition: Structs.h:346
Structure for delivering list results, eg. of local variables sent from Server.
Definition: Structs.h:464
Structure to hold data for registered (reusable) calculator events. Used to submit events with WASimC...
Definition: Structs.h:496
Structure for using with WASimClient::getVariable() and WASimClient::setVariable() to specify informa...
Definition: Structs.h:528
Command data structure. The member contents depend on the command type as described in each command t...