xplane v0.6.0 XPlane.Data

Get and set X-Plane data.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Request latest values of the listed data reference ids. Values will not be available until you have called XPlane.Data.request_updates/2. If you request a data reference that we have not received a value for, an

Request updates of the specified data references at the corresponding frequency. Values can then be retrieved using XPlane.Data.latest_updates/2. A small delay occurs during the call to give the GenServer a chance to collect at least one value for each requested data reference.

Set one or more writable data reference values.

Start GenServer to exchange data references with a specific X-Plane instance.

Start GenServer linked to current process to exchange data references with a specific X-Plane instance.

Stop the GenServer listening for data reference updates, and tell X-Plane to stop sending any we are currently subscribed to.

Link to this section Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

latest_updates(instance, data_ref_id_list)
latest_updates(XPlane.Instance.t(), [atom()]) :: %{atom: float() | nil}

Request latest values of the listed data reference ids. Values will not be available until you have called XPlane.Data.request_updates/2. If you request a data reference that we have not received a value for, an:

{:error, {no_values, [list of requested data reference ids missing values]}}`

message is returned. This seemed to be more a more useful way to handle missing values, because most clients will need all the requested values to do their work.

Parameters

  • instance: X-Plane instance from list returned by XPlane.Instance.list/0
  • data_ref_ids: List of data reference ids to return values for

Example

iex> master |> XPlane.Data.latest_updates([:flightmodel_position_elevation])
%{flightmodel_position_elevation: ...}`
Link to this function

request_updates(instance, data_ref_id_freq)
request_updates(XPlane.Instance.t(), [{atom(), integer()}]) ::
  :ok | {:error, list()}

Request updates of the specified data references at the corresponding frequency. Values can then be retrieved using XPlane.Data.latest_updates/2. A small delay occurs during the call to give the GenServer a chance to collect at least one value for each requested data reference.

Parameters

  • instance: X-Plane instance from list returned by XPlane.Instance.list/0
  • data_ref_id_freq: Keyword list of data reference ids and integer updates per second

Example

iex> XPlane.Data.request_updates(master, [flightmodel_position_indicated_airspeed: 10])
:ok
Link to this function

set(instance, data_ref_id_values)
set(XPlane.Instance.t(), [{atom(), number()}]) :: :ok | {:error, list()}

Set one or more writable data reference values.

Parameters

  • instance: X-Plane instance from list returned by XPlane.Instance.list/0
  • data_ref_id_values: Keyword list of data reference ids and floating point new values to set

Example

iex> XPlane.Data.set(master, [flightmodel_position_local_y: 1000.0])
:ok
Link to this function

start(instance, opts \\ [])
start(XPlane.Instance.t(), list()) :: {:ok, pid()} | {:error, any()} | :ignore

Start GenServer to exchange data references with a specific X-Plane instance.

Parameters

Link to this function

start_link(instance, opts \\ [])
start_link(XPlane.Instance.t(), list()) ::
  {:ok, pid()} | {:error, any()} | :ignore

Start GenServer linked to current process to exchange data references with a specific X-Plane instance.

Parameters

Link to this function

stop(instance)
stop(XPlane.Instance.t()) :: :ok | {:error, any()}

Stop the GenServer listening for data reference updates, and tell X-Plane to stop sending any we are currently subscribed to.