26#include <msclr/marshal.h>
27#include <msclr/marshal_cppstd.h>
30#include "WASimCommander_CLI.h"
34using namespace System;
35using namespace System::Collections::Generic;
36using namespace System::Runtime::InteropServices;
37using namespace msclr::interop;
45 #define WSE WASimCommander::Enums
77 #define DELEGATE_DECL(D) { void add(D^); void remove(D^); }
97 explicit WASimClient(UInt32 clientId, String ^configFile);
138 uint32_t
pingServer([Optional] Nullable<uint32_t> timeout) {
return m_client->
pingServer(timeout.HasValue ? timeout.Value : 0); }
194 return (
HR)m_client->
setLocalVariable(marshal_as<std::string>(variableName), value, marshal_as<std::string>(unitName));
200 return (
HR)m_client->
setOrCreateLocalVariable(marshal_as<std::string>(variableName), value, marshal_as<std::string>(unitName));
205 return (
HR)m_client->
setSimVarVariable(marshal_as<std::string>(variableName), marshal_as<std::string>(unitName), value);
209 return (
HR)m_client->
setSimVarVariable(marshal_as<std::string>(variableName), index, marshal_as<std::string>(unitName), value);
213 return (
HR)m_client->
setSimVarVariable(marshal_as<std::string>(variableName), marshal_as<std::string>(stringValue));
217 return (
HR)m_client->
setSimVarVariable(marshal_as<std::string>(variableName), index, marshal_as<std::string>(stringValue));
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));
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));
262 pin_ptr<UInt32> pui = &puiCustomEventId;
263 return (
HR)m_client->
registerCustomKeyEvent(marshal_as<std::string>(customEventName), pui, useLegacyTransmit.GetValueOrDefault(
false));
267 return (
HR)m_client->
registerCustomKeyEvent(marshal_as<std::string>(customEventName),
nullptr, useLegacyTransmit.GetValueOrDefault(
false));
280 HR list(LookupItemType itemsType) {
return (
HR)m_client->
list((WSE::LookupItemType)itemsType); }
282 HR lookup(LookupItemType itemType, String ^itemName, [Out] Int32 %piResult)
284 pin_ptr<Int32> pi = &piResult;
285 return (
HR)m_client->
lookup((WSE::LookupItemType)itemType, marshal_as<std::string>(itemName), pi);
299 response = gcnew
Command(resp);
308 LogLevel
logLevel(LogFacility facility, LogSource source) {
312 void setLogLevel(LogLevel level, LogFacility facility, LogSource source) {
322 Private ^d =
nullptr;
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...
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....
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...
HR
Method return status values; HRESULT "alias"
WASimCommander::CLI::Structs namespace. CLI/.NET versions of WASimCommander API and Client data struc...
LogSource
Log entry source, Client or Server.
Client Event data, delivered via callback.
Command data structure. The member contents depend on the command type as described in each command t...
Structure for value update subscription requests.
DataRequestRecord inherits and extends WASimCommander::CLI::Structs::DataRequest with data pertinent ...
Structure for delivering list results, eg. of local variables sent from Server.
Structure to hold data for registered (reusable) calculator events. Used to submit events with WASimC...
Structure for using with WASimClient::getVariable() and WASimClient::setVariable() to specify informa...
Command data structure. The member contents depend on the command type as described in each command t...