项目作者: robinhilliard

项目描述 :
An X-Plane network client for Elixir
高级语言: Elixir
项目地址: git://github.com/robinhilliard/elixplane.git
创建时间: 2018-06-17T09:32:57Z
项目社区:https://github.com/robinhilliard/elixplane

开源协议:MIT License

下载


eliXPLANE logo

An X-Plane network client for Elixir [1]. So far you can

  • Detect instances of X-Plane/ PlaneMaker running on the local network
  • Load the closest available DataRef and Command definitions (included with the library [2]) for a specific X-Plane version.
  • Request a list of DataRefs to be sent to you at specified frequencies
  • Write to a writable DataRef
  • Send a command to X-Plane
  1. iex> XPlane.Instance.start
  2. {:ok, #PID<0.154.0>}
  3. iex> [xp] = XPlane.Instance.list
  4. [
  5. %XPlane.Instance{
  6. addr: "192.168.0.22",
  7. computer_name: "Similitude",
  8. host: :xplane,
  9. ip: {192, 168, 0, 22},
  10. major_version: 1,
  11. minor_version: 1,
  12. port: 49000,
  13. role: :master,
  14. seconds_since_seen: 1,
  15. version_number: 105101
  16. }
  17. ]
  18. iex> drefs = XPlane.DataRef.load_version(105000)
  19. ...
  20. iex> drefs |> XPlane.DataRef.describe(~r/flightmodel_position_l/)
  21. flightmodel_position_local_ax The acceleration in local OGL coordinates (mtr/sec2, writable)
  22. flightmodel_position_latitude The latitude of the aircraft (degrees)
  23. ...
  24. flightmodel_position_longitude The longitude of the aircraft (degrees)
  25. flightmodel_position_local_vx The velocity in local OGL coordinates (mtr/sec, writable)
  26. flightmodel_position_local_ay The acceleration in local OGL coordinates (mtr/sec2, writable)
  27. :ok
  28. iex> crefs = XPlane.CmdRef.load_version(105000)
  29. ...
  30. iex> crefs |> XPlane.CmdRef.describe(~r/lights/)
  31. lights_beacon_lights_off Beacon lights off.
  32. lights_beacon_lights_on Beacon lights on.
  33. lights_beacon_lights_toggle Beacon lights toggle.
  34. lights_landing_lights_off Landing lights off.
  35. lights_landing_lights_on Landing lights on.
  36. lights_landing_lights_toggle Landing lights toggle.
  37. ...
  38. iex> XPlane.Cmd.send(xp, [:lights_landing_lights_toggle])
  39. :ok
  40. iex> XPlane.Data.start(xp)
  41. {:ok, #PID<0.157.0>}
  42. iex> XPlane.Data.request_updates(xp, [
  43. ...> flightmodel_position_elevation: 1,
  44. ...> flightmodel_position_longitude: 1,
  45. ...> flightmodel_position_latitude: 1])
  46. :ok
  47. iex> XPlane.Data.latest_updates(xp, [
  48. ...> :flightmodel_position_elevation,
  49. ...> :flightmodel_position_longitude,
  50. ...> :flightmodel_position_latitude])
  51. %{
  52. flightmodel_position_elevation: 17.584819793701172,
  53. flightmodel_position_latitude: -31.069093704223633,
  54. flightmodel_position_longitude: 152.76556396484375
  55. }
  56. iex> XPlane.Data.set(xp, [flightmodel_position_local_y: 6000.0])
  57. :ok
  58. iex> XPlane.Data.stop(xp)
  59. :ok
  60. iex> XPlane.Instance.stop
  61. :ok
  1. Currently assumes that X-Plane and Elixir are running on platforms with the same
    endian byte order.

  2. I confirmed with X-Plane that it’s ok to redistribute the DataRef and Command files:
    https://forums.x-plane.org/index.php?/forums/topic/151455-redistributing-datarefs-files/