xplane

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MCAST_PORT = 49707
	RETRIES    = 10
)

Variables

View Source
var ErrInvalidBeacon = errors.New("invalid beacon")
View Source
var Logger = slog.Default()

Logger is the logger for the xplane package Defaults to slog.Default(), but can be overridden by the user

Functions

func RequestPositions

func RequestPositions(ctx context.Context, xp_addr *net.UDPAddr, freq uint, c chan<- Position, feedback chan<- string)

RequestPositions will request positions from X-Plane and send them to the channel ctx is the context to stop requesting positions xp_addr is the address of the X-Plane instance c is the channel to send the positions to wg is the wait group to signal when the function is done

Types

type Position

type Position struct {
	Dat_lon     float64 // float longitude of the aircraft in X-Plane of course, in degrees
	Dat_lat     float64 // float latitude
	Dat_ele     float64 // float elevation above sea level in meters
	Y_agl_mtr   float32 // float elevation above the terrain in meters
	Veh_the_loc float32 // float pitch, degrees
	Veh_psi_loc float32 // float true heading, in degrees
	Veh_phi_loc float32 // float roll, in degrees
	Vx_wrl      float32 // float speed in the x, EAST, direction, in meters per second
	Vy_wrl      float32 // float speed in the y, UP, direction, in meters per second
	Vz_wrl      float32 // float speed in the z, SOUTH, direction, in meters per second
	Prad        float32 // float roll rate in radians per second
	Qrad        float32 // float pitch rate in radians per second
	Rrad        float32 // float yaw rate in radians per second
}

func ReadPosition

func ReadPosition(r io.Reader) (*Position, error)

ReadPosition reads a Position from an io.Reader

func (*Position) SOG

func (p *Position) SOG() float64

SOG returns the speed over ground in m/s

type XPlaneBasicBeacon

type XPlaneBasicBeacon struct {
	BeaconMajorVersion uint8  // 1 at the time of X-Plane 10.40, 11.55
	BeaconMinorVersion uint8  // 1 at the time of X-Plane 10.40, 2 for 11.55
	ApplicationHostID  int32  // 1 for X-Plane, 2 for PlaneMaker
	VersionNumber      int32  // 104014 is X-Plane 10.40b14, 115501 is 11.55r2
	Role               uint32 // 1 for master, 2 for extern visual, 3 for IOS
	Port               uint16 // port number X-Plane is listening on
}

XPlaneBasicBeacon is the basic beacon information

type XPlaneBeacon

type XPlaneBeacon struct {
	XPlaneBasicBeacon
	IP           *net.UDPAddr // the IP address of the computer
	ComputerName string       // the hostname of the computer
	RaknetPort   uint16       // port number the X-Plane Raknet clinet is listening on
}

XPlaneBeacon is the full beacon information

func FindXplane

func FindXplane(wait time.Duration) (*XPlaneBeacon, error)

FindXplane will listen for X-Plane beacons on the multicast group and return the first master X-Plane instance found or an error if no master X-Plane instance is found wait is the time to wait for a beacon

func (*XPlaneBeacon) Addr

func (xpb *XPlaneBeacon) Addr() *net.UDPAddr

Addr returns the UDP address of the beacon Since the beacon IP contains the computer IP but the beacon port, this is a new UDP address with the X-Plane port

func (*XPlaneBeacon) ApplicationType

func (xpb *XPlaneBeacon) ApplicationType() string

ApplicationType returns the application type as a string

func (*XPlaneBeacon) BeaconVersion

func (xpb *XPlaneBeacon) BeaconVersion() string

BeaconVersion returns the beacon version as a string

func (*XPlaneBeacon) Details

func (xpb *XPlaneBeacon) Details() string

Details returns a detailed string representation of the beacon

func (*XPlaneBeacon) IsMaster

func (xpb *XPlaneBeacon) IsMaster() bool

IsMaster returns true if the beacon is from the master X-Plane instance

func (*XPlaneBeacon) RaknetAddr

func (xpb *XPlaneBeacon) RaknetAddr() *net.UDPAddr

RaknetAddr returns the UDP address of the Raknet client Since the beacon IP contains the computer IP but the beacon port, this is a new UDP address with the Raknet port

func (*XPlaneBeacon) RoleType

func (xpb *XPlaneBeacon) RoleType() string

RoleType returns the role type as a string

func (*XPlaneBeacon) String

func (xpb *XPlaneBeacon) String() string

String returns a string representation of the beacon This is the normal, human readable identifier for the beacon

type XPlanes

type XPlanes map[string]*XPlaneBeacon

Xplanes is a handy way to keep track of the XPlaneBeacon instances

func (XPlanes) Add

func (xps XPlanes) Add(xpb *XPlaneBeacon)

Add adds a new XPlaneBeacon to the XPlanes map The beacon IP is the ip of the XPlane with the beacon multicast port (49707), but the port is the port that XPlane is listening on which is what we are interested in (usually 49000)

func (XPlanes) Find

func (xps XPlanes) Find(id string) *net.UDPAddr

Find returns the net.UDPAddr for the given XPlane Human Readable identifier

func (XPlanes) List

func (xps XPlanes) List() []string

List returns a list of the XPlane Human Readable identifiers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL