v1.3.0.0
WASimCommander::Enums Namespace Reference

WASimCommander::Enums namespace. Contains all enum definitions for the base API. More...

Enumerations

enum class  CommandId : uint8_t {
  None = 0 ,
  Ack ,
  Nak ,
  Ping ,
  Connect ,
  Disconnect ,
  List ,
  Lookup ,
  Get ,
  GetCreate ,
  Set ,
  SetCreate ,
  Exec ,
  Register ,
  Transmit ,
  Subscribe ,
  Update ,
  SendKey ,
  Log
}
 Commands for client-server interaction. Both sides can send commands via dedicated channels by writing a Command data structure. The fields uData, sData and fData referenced below refer to Command::uData, Command::sData and Command::fData respectively. More...
 
enum class  RequestType : uint8_t {
  None = 0 ,
  Named ,
  Calculated
}
 Types of things to request or set. More...
 
enum class  CalcResultType : uint8_t {
  None = 0 ,
  Double ,
  Integer ,
  String ,
  Formatted
}
 The type of result that calculator code is expected to produce. More...
 
enum class  UpdatePeriod : uint8_t {
  Never = 0 ,
  Once ,
  Tick ,
  Millisecond
}
 How often to check for updated request values. More...
 
enum class  LookupItemType : uint8_t {
  None ,
  LocalVariable ,
  SimulatorVariable ,
  TokenVariable ,
  UnitType ,
  KeyEventId ,
  DataRequest ,
  RegisteredEvent
}
 Types of things to look up or list. More...
 
enum class  LogLevel : uint8_t {
  None = 0 ,
  Critical ,
  Error ,
  Warning ,
  Info ,
  Debug ,
  Trace
}
 Logging levels. More...
 
enum class  LogFacility : uint8_t {
  None = 0x00 ,
  Console = 0x01 ,
  File = 0x02 ,
  Remote = 0x04 ,
  All = Console | File | Remote
}
 Logging destination type. More...
 

Variables

Enumeration name strings
static const std::vector< const char * > CommandIdNames
 Enums::CommandId enum names. More...
 
static const std::vector< const char * > RequestTypeNames = { "None", "Named", "Calculated" }
 Enums::RequestType enum names. More...
 
static const std::vector< const char * > CalcResultTypeNames = { "None", "Double", "Integer", "String", "Formatted" }
 Enums::CalcResultType enum names. More...
 
static const std::vector< const char * > UpdatePeriodNames = { "Never", "Once", "Tick", "Millisecond" }
 Enums::UpdatePeriod enum names. More...
 
static const std::vector< const char * > LookupItemTypeNames
 Enums::LookupItemType enum names. More...
 
static const std::vector< const char * > LogLevelNames = { "None", "Critical", "Error", "Warning", "Info", "Debug", "Trace" }
 Enums::LogLevel enum names. More...
 
static const std::vector< const char * > LogFacilityNames
 Enums::LogFacility enum names. More...
 

Detailed Description

WASimCommander::Enums namespace. Contains all enum definitions for the base API.

Enumeration Type Documentation

◆ CommandId

enum class WASimCommander::Enums::CommandId : uint8_t
strong

Commands for client-server interaction. Both sides can send commands via dedicated channels by writing a Command data structure. The fields uData, sData and fData referenced below refer to Command::uData, Command::sData and Command::fData respectively.

See also
Command struct.
Enumerator
None 

An invalid command.

Ack 

Last command acknowledge. CommandId of the original command (which succeeded) is sent in uData. The token value from the original command is also sent back in the token member.

Nak 

Last command failure. CommandId of the original command (which failed) is sent in uData. sData may contain a reason for failure. The token value from the original command is also sent back in the token member.

Ping 

Query for a response from remote server/client. The remote should respond with an Ack command.

Connect 

Reconnect a previously-established client (same as "WASimCommander.Connect" custom event). This CommandId is also sent back in an Ack/Nak response after a client connects (or tries to). In this case the token of the Ack/Nak is the client ID.

Disconnect 

Stop data updates for this client. Use the Connect command to resume updates. The server may also spontaneously send a Disconnect command in case it is shutting down or otherwise terminating connections.

List 

Request a listing of items like local variables. uData should be one of WASimCommander::LookupItemType enum values (Sim and Token vars currently cannot be listed). List is returned as a series of List type response commands with sData as var name and uData is var ID, followed by an Ack at the end. A Nak response is returned if the item type cannot be listed for any reason.

Lookup 

Get information about an item, such as the ID of a variable or unit name. uData should be one of WASimCommander::LookupItemType enum values and sData is the name of the thing to look up. Ack is returned on success with the ID of the variable/unit in the fData member (as an INT32) and the original requested string name echoed back in sData. In case of lookup failure, a Nak response is returned with possible reason in sData.

Get 

Get a named variable value with optional unit type. uData is a char of the variable type, eg. 'L' for local, 'A' for SimVar, or 'T' for Token. Only 'L', 'A' and 'E' types support unit specifiers.
sData is the variable name or numeric ID, optionally followed by comma (,) and unit name or numeric ID (no spaces). For indexed SimVars, include the index after the variable name, separated by a colon (:).
For example, a SimVar: uData = 'A'; sData = "PROP BETA:2,degrees";
Other variables types can also be requested ('B', 'E', 'M', etc) but such requests are simply converted to a calculator string and processed as an Exec type command (using an Exec command directly may be more efficient).
Result is returned with the Ack response in fData as a double-precision value. In case of failure a Nak is returned with possible error message in sData.

GetCreate 

Same as Get but creates a local 'L' variable if it doesn't already exist (with register_named_variable() Gauge API). Use Lookup command to check if a variable exists.
Since v1.2: If a variable is created, the value provided in fData will be used as the initial value of the variable, and will be returned as the result (essentially providing a default value in this case). Previous versions would not set a value (or unit type) on the variable after creating it and would return the default of 0.0.
Creating variables only works with L (local) types. Since v1.2, for all other types this command will be handled the same as Get. Previous versions would return a Nak.

Set 

Set a named local variable with optional unit type. uData is a char of the variable type, with default of 'L' for local vars. sData is the variable name or numeric ID (for local vars only), optionally followed by comma (,) and unit name (or numeric unit ID for local vars) (no spaces). The value to set is passed in fData member.
For example, a SimVar: uData = 'A'; sData = "PROP RPM:2,rpm"; fData = 2200;
Other variables types can also be set this way ('A', 'H", 'K', etc) but such requests are simply converted to a calculator string and processed as an Exec type command (using an Exec command directly may be slightly more efficient).

SetCreate 

Same as Set but creates a local 'L' variable if it doesn't already exist (with register_named_variable() Gauge API). Use the Lookup command to check if a variable exists.
Creating variables only works with L (local) types. Since v1.2, for all other types this command will be handled the same as Get. Previous versions would return a Nak.

Exec 

Run calculator code contained in sData with WASimCommander::CalcResultType in uData. Result, if any, is returned with the Ack response, numeric types in fData and strings in sData. (Due to the way the Gauge API calculator function works, a string result is typically also returned even when only a numeric result is requested.)

In case of failure a Nak is returned with possible error message in sData. Note however that the Gauge API functions often happily return a "success" status even when the actual thing you're trying to do fails. The only feedback in this case appears to be the MSFS Console window available from "Dev Tools," which will (usually) log any actual errors.

Register 

Register a named Exec-type event. uData is a unique event ID, and sData a calculator code string. Optional event name in sData before a $ separator (maximum length of STRSZ_ENAME). Default is to use event ID as string.
If the custom event name contains a period (.) then it is used as-is. Otherwise "WASimCommander.[client_name]." will be prepended to the given name.
Use with SimConnect_MapClientEventToSimEvent(id, "event_name") and SimConnect_TransmitClientEvent(), or the Transmit command (below).
To change the calculator string used for an event, re-send this command with the same event ID and a new string to use. The event name cannot be modified after creation.
To remove a registered event, send this command with the event ID to delete and a blank sData.

Transmit 

Trigger an event previously registered with the Register command. uData should be the event ID from the original registration. This is a (faster) alternative to triggering events via SimConnect mappings.

Subscribe 

Sending this command to the server with a uData value of 0 (zero) will suspend (pause) any and all data subscription request value updates. Updates can be resumed again by sending any non-zero value in uData.
This command ID is also used as an Ack/Nak response to new Data Request records being processed. The client must write a DataRequest struct to the shared data area and the server should respond with this command to indicate success/failure.

Update 

Trigger data update of a previously-added Data Request, with the request ID in uData. This is used primarily to request updates for subscription types where the UpdatePeriod is Never or Once. The data is sent in the usual manner for subscriptions, by writing the new value to the related client data area. Note also that this command will force an update of the data, without comparing the result to any (potentially) cached value from previous lookup.

SendKey 

send_key_event(event_id, value) with event_id in uData and an optional UINT32 type value in fData (default is 0).

"The send_key_event function transmits a WM_COMMAND application event. This function transmits a message with the following syntax: `PostMessage(hwndMain, WM_COMMAND, event_id, (LPARAM) value);`"

In practice this means you can send a KEY Event ID directly to the simulator, bypassing SimConnect event name mappings or calculator code evaluation. The event IDs can be found in the MSFS SDK's MSFS/Legacy/gauges.h header file as KEY_* macros, and are also available via the Lookup command. If this command is sent with uData == 0 and sData contains a string, a LookupItemType::KeyEventId lookup will be performed on the Key Event name first and the resulting ID (if any) used.

Custom event IDs (registered by gauges or other modules) can also be triggered this way. There may be other uses for this command... TBD.

Log 

Set severity level for logging to the Client's LogRecord data area. uData should be one of the WASimCommander::LogLevel enum values. LogLevel::None disables logging, which is also the initial default for a newly connected Client. Additionally, the server-wide log levels can be set for the file and console loggers independently. To specify these levels, set fData to one of the WASimCommander::LogFacility enum values. The default of 0 assumes LogFacility::Remote.

Definition at line 38 of file enums_impl.h.

◆ RequestType

enum class WASimCommander::Enums::RequestType : uint8_t
strong

Types of things to request or set.

See also
DataRequest struct.
Enumerator
None 

Use to remove a previously-added request.

Named 

A named variable.

Calculated 

Calculator code.

Definition at line 96 of file enums_impl.h.

◆ CalcResultType

enum class WASimCommander::Enums::CalcResultType : uint8_t
strong

The type of result that calculator code is expected to produce.

See also
DataRequest struct, Enums::CommandId::Exec command.
Enumerator
None 

No result is expected (eg. triggering an event).

Double 

Expect a double ("FLOAT64") type result.

Integer 

Expect an 32bit signed integer result.

String 

Expect a string type result from execute_calculator_code().

Formatted 

Execute code using format_calculator_string() function and expect a string result type.

Definition at line 108 of file enums_impl.h.

◆ UpdatePeriod

enum class WASimCommander::Enums::UpdatePeriod : uint8_t
strong

How often to check for updated request values.

See also
DataRequest struct.
Enumerator
Never 

Suspend all automatic updates, only check value on Enums::CommandId::Update command.

Once 

Update once when DataRequest is added/updated, and then only on Update command.

Tick 

Update as often as possible (see TICK_PERIOD_MS).

Millisecond 

Update every interval milliseconds (interval value must be greater than 0 with effective minimum being the "Tick" period (TICK_PERIOD_MS)).

Definition at line 122 of file enums_impl.h.

◆ LookupItemType

enum class WASimCommander::Enums::LookupItemType : uint8_t
strong

Types of things to look up or list.

See also
Enums::CommandId::List, Enums::CommandId::Lookup commands
Enumerator
None 

Null type, possible internal use, ignored by server.

LocalVariable 

LVar ('L') names and IDs. Available for List and Lookup commands.

SimulatorVariable 

SimVar ('A') names and IDs. Available for Lookup command only.

TokenVariable 

Token Variable ('T'). Available for Lookup command only.

UnitType 

Measurement Unit. Available for Lookup command only.

KeyEventId 

Key Event ID, value of KEY_* macros from "guauges.h" header. Available for Lookup command only (use event name w/out the "KEY_" prefix).

DataRequest 

Saved value subscription for current Client, indexed by requestId and nameOrCode values. Available for List and Lookup commands.

RegisteredEvent 

Saved calculator event for current Client, indexed by eventId and code values. Available for List and Lookup commands.

Definition at line 135 of file enums_impl.h.

◆ LogLevel

enum class WASimCommander::Enums::LogLevel : uint8_t
strong

Logging levels.

See also
LogRecord struct, CommandId::Log command.
Enumerator
None 

Disables logging.

Critical 

Events which cause termination.

Error 

Hard errors preventing function execution.

Warning 

Possible anomalies which do not necessarily prevent execution.

Info 

Informational messages about key processes like startup and shutdown.

Debug 

Verbose debugging information.

Trace 

Very verbose and frequent debugging data, do not use with "slow" logger outputs.

Definition at line 154 of file enums_impl.h.

◆ LogFacility

enum class WASimCommander::Enums::LogFacility : uint8_t
strong

Logging destination type.

See also
CommandId::Log command.
Enumerator
None 

Invalid or default logging facility. For the Enums::CommandId::Log command this is same as Remote.

Console 

Console logging, eg. stderr/stdout.

File 

Log file destination.

Remote 

Remote destination, eg. network transmission or a callback event.

Definition at line 170 of file enums_impl.h.

Variable Documentation

◆ CommandIdNames

const std::vector<const char *> WASimCommander::Enums::CommandIdNames
static
Initial value:
= {
"None", "Ack", "Nak", "Ping", "Connect", "Disconnect", "List", "Lookup",
"Get", "GetCreate", "Set", "SetCreate", "Exec", "Register", "Transmit",
"Subscribe", "Update", "SendKey", "Log" }

Enums::CommandId enum names.

Definition at line 89 of file enums_impl.h.

◆ RequestTypeNames

const std::vector<const char *> WASimCommander::Enums::RequestTypeNames = { "None", "Named", "Calculated" }
static

Enums::RequestType enum names.

Definition at line 104 of file enums_impl.h.

◆ CalcResultTypeNames

const std::vector<const char *> WASimCommander::Enums::CalcResultTypeNames = { "None", "Double", "Integer", "String", "Formatted" }
static

Enums::CalcResultType enum names.

Definition at line 118 of file enums_impl.h.

◆ UpdatePeriodNames

const std::vector<const char *> WASimCommander::Enums::UpdatePeriodNames = { "Never", "Once", "Tick", "Millisecond" }
static

Enums::UpdatePeriod enum names.

Definition at line 131 of file enums_impl.h.

◆ LookupItemTypeNames

const std::vector<const char *> WASimCommander::Enums::LookupItemTypeNames
static
Initial value:
= {
"None", "LocalVariable", "SimulatorVariable", "TokenVariable", "UnitType", "KeyEventId", "DataRequest", "RegisteredEvent"
}

Enums::LookupItemType enum names.

Definition at line 148 of file enums_impl.h.

◆ LogLevelNames

const std::vector<const char *> WASimCommander::Enums::LogLevelNames = { "None", "Critical", "Error", "Warning", "Info", "Debug", "Trace" }
static

Enums::LogLevel enum names.

Definition at line 166 of file enums_impl.h.

◆ LogFacilityNames

const std::vector<const char *> WASimCommander::Enums::LogFacilityNames
static
Initial value:
= {
"None", "Console", "File", "Console | File", "Remote", "Console | Remote", "File | Remote", "All"
}

Enums::LogFacility enum names.

Definition at line 183 of file enums_impl.h.