simconnect

package module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 12 Imported by: 0

README

Simconnect-Go GoDoc GitHub tag license

This Simconnect library is used to communicate with primary Microsoft Flight Simulator 2020 using Golang. However, given its use of the SimConnect API it should be able to communicate with other flight simulators whcih also support the SimConnect API.

This attempts to be a little more of a high-level library attempting to abstract much of the SimConnect complexity from the user.

Status

The current version is considered an early release and will therefore keep changing. Breaking changes will be avoided but may happen if required.

Currently Implemented

  • Request Data on User Aircraft (SimConnect_RequestDataOnSimObjectType)
  • Request Data on Object (SimConnect_RequestDataOnSimObject)
  • Load Flight Plan into Users Aircraft (SimConnect_FlightPlanLoad)
  • Create parked ATC AI aircraft (SimConnect_AICreateParkedATCAircraft)
  • Create Non ATC AI aircraft SimConnect_AICreateNonATCAircraft()
  • Set Data on Object including user (SimConnect_SetDataOnSimObject)
  • Create enroute ATC Aircraft (SimConnect_AICreateEnrouteATCAircraft)
  • Set Flight Plan for AI ATC Aircraft (SimConnect_AISetAircraftFlightPlan)
  • Remove Objects (SimConnect_AIRemoveObject)

Install

go get -u github.com/JRascagneres/Simconnect-Go
and import with
import (simconnect "github.com/JRascagneres/Simconnect-Go")

Very Simple Usage

Very simple example which starts the connection, grabs the current user data and closes the connection.

instance, err := NewSimConnect()
if err != nil {
    panic(err)
}

report, err := instance.GetReport()
if err != nil {
    panic(err)
}

fmt.Printf("User Altitude: %f\n", report.Altitude)

err = instance.Close()

Documentation

All Documentation can be found through the godoc

Contributing

Issues, feature requests or improvements welcome!

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APReport added in v0.0.11

type APReport struct {
	simconnect_data.RecvSimobjectDataByType
	Title         [256]byte `name:"Title"`
	APSelectedAlt float64   `name:"AUTOPILOT ALTITUDE LOCK VAR:3" unit:"feet"`
	APAltSlot     int32     `name:"AUTOPILOT ALTITUDE SLOT INDEX" unit:"number"`
}

type Report

type Report struct {
	simconnect_data.RecvSimobjectDataByType
	Title                             [256]byte `name:"Title"`
	ATCAirline                        [128]byte `name:"ATC Airline"`
	ATCFlightNumber                   [128]byte `name:"ATC Flight Number"`
	ATCID                             [128]byte `name:"ATC ID"`
	Kohlsman                          float64   `name:"Kohlsman setting hg" unit:"inHg"`
	Altitude                          float64   `name:"Plane Altitude" unit:"feet"`
	AltitudeAboveGround               float64   `name:"Plane Alt Above Ground" unit:"feet"`
	Latitude                          float64   `name:"Plane Latitude" unit:"degrees"`
	Longitude                         float64   `name:"Plane Longitude" unit:"degrees"`
	Airspeed                          float64   `name:"Airspeed Indicated" unit:"knot"`
	AirspeedBarberPole                float64   `name:"Airspeed Barber Pole" unit:"knot"`
	GroundSpeed                       float64   `name:"Ground Velocity" unit:"knots"`
	OnGround                          int32     `name:"Sim On Ground" unit:"bool"`
	Heading                           float32   `name:"Plane Heading Degrees True"`
	HeadingMag                        float32   `name:"Plane Heading Degrees Magnetic"`
	Pitch                             float32   `name:"Plane Pitch Degrees"`
	Bank                              float32   `name:"Plane Bank Degrees"`
	GForce                            float32   `name:"G Force"`
	VerticalSpeedRelativeToWorld      float32   `name:"Velocity World Y" unit:"Feet per second"`
	VerticalSpeedAircraft             float32   `name:"Vertical Speed" unit:"Feet per second"`
	VerticalSpeedPlaneTouchdownNormal float64   `name:"Plane Touchdown Normal Velocity" unit:"Feet per second"`
	Crosswind                         float32   `name:"Aircraft Wind X" unit:"Knots"`
	Headwind                          float32   `name:"Aircraft Wind Z" unit:"Knots"`
	FuelTotal                         float32   `name:"Fuel Total Quantity Weight" unit:"kg"`
	WindSpeed                         float32   `name:"Ambient Wind Velocity" unit:"knot"`
	WindDirection                     float32   `name:"Ambient Wind Direction" unit:"radians"`
	FuelCapacity                      float32   `name:"FUEL TOTAL CAPACITY" unit:"gallons"`
	FuelWeightPerGallon               float32   `name:"FUEL WEIGHT PER GALLON" unit:"kg"`
	FuelFlow                          float32   `name:"ESTIMATED FUEL FLOW" unit:"kilograms per second"`
	AmbientTemperature                float32   `name:"Ambient Temperature" unit:"Celsius"`
	AmbientPressure                   float32   `name:"Ambient Pressure" unit:"inHg"`
	Parked                            int32     `name:"Plane In Parking State"`
	Engine1Combustion                 int32     `name:"General Eng Combustion:1" unit:"bool"`
	Engine2Combustion                 int32     `name:"General Eng Combustion:2" unit:"bool"`
	Engine3Combustion                 int32     `name:"General Eng Combustion:3" unit:"bool"`
	Engine4Combustion                 int32     `name:"General Eng Combustion:4" unit:"bool"`
	EngineCount                       int32     `name:"Number Of Engines"`

	ADFStandbyFrequency1 float64 `name:"ADF STANDBY FREQUENCY:1" unit:"MHz"`
	ADFActiveFrequency1  float64 `name:"ADF ACTIVE FREQUENCY:1" unit:"MHz"`
	ADFStandbyFrequency2 float64 `name:"ADF STANDBY FREQUENCY:2" unit:"MHz"`
	ADFActiveFrequency2  float64 `name:"ADF ACTIVE FREQUENCY:2" unit:"MHz"`
	COMStandbyFrequency1 float64 `name:"COM STANDBY FREQUENCY:1" unit:"MHz"`
	COMActiveFrequency1  float64 `name:"COM ACTIVE FREQUENCY:1" unit:"MHz"`
	COMStandbyFrequency2 float64 `name:"COM STANDBY FREQUENCY:2" unit:"MHz"`
	COMActiveFrequency2  float64 `name:"COM ACTIVE FREQUENCY:2" unit:"MHz"`
	NAVStandbyFrequency1 float64 `name:"NAV STANDBY FREQUENCY:1" unit:"MHz"`
	NAVActiveFrequency1  float64 `name:"NAV ACTIVE FREQUENCY:1" unit:"MHz"`
	NAVStandbyFrequency2 float64 `name:"NAV STANDBY FREQUENCY:2" unit:"MHz"`
	NAVActiveFrequency2  float64 `name:"NAV ACTIVE FREQUENCY:2" unit:"MHz"`
}

Report contains data for a given sim object

type SetSimObjectDataExpose

type SetSimObjectDataExpose struct {
	Airspeed  float64
	Altitude  float64
	Bank      float32
	Heading   float32
	Latitude  float64
	Longitude float64
	OnGround  bool
	Pitch     float32
}

type SimconnectInstance

type SimconnectInstance struct {
	// contains filtered or unexported fields
}

func NewSimConnect

func NewSimConnect(simconnectName string) (*SimconnectInstance, error)

NewSimConnect returns a new instance of SimConnect which will be used to call the methods.

func (*SimconnectInstance) Close

func (instance *SimconnectInstance) Close() error

Close will end the connection to the SimConnect API

func (*SimconnectInstance) CreateEnrouteATCAircraft

func (instance *SimconnectInstance) CreateEnrouteATCAircraft(containerTitle, tailNumber string, flightNumber uint32, flightPlanPath string, flightPlanPosition float32, touchAndGo bool, requestID uint32) (*uint32, error)

CreateEnrouteATCAircraft allows you to create an ATC already part way through its flight plan. See SimConnect API reference.

func (*SimconnectInstance) GetAPReport added in v0.0.11

func (instance *SimconnectInstance) GetAPReport() (*APReport, error)

GetAPReport returns APReport struct containing current user data

func (*SimconnectInstance) GetReport

func (instance *SimconnectInstance) GetReport() (*Report, error)

GetReport returns Report struct containing current user data

func (*SimconnectInstance) GetReportOnObjectID

func (instance *SimconnectInstance) GetReportOnObjectID(objectID uint32) (*Report, error)

GetReportOnObjectID returns a Report struct containing the data for the Object ID passed in

func (*SimconnectInstance) LoadFlightPlan

func (instance *SimconnectInstance) LoadFlightPlan(flightPlanPath string) error

LoadFlightPlan will load the supplied flight plan path into the users aircraft. FlightPlanPath must be a pln but the .pln extension must not be supplied with the flight plan.

func (*SimconnectInstance) LoadNonATCAircraft

func (instance *SimconnectInstance) LoadNonATCAircraft(containerTitle, tailNumber string, initPos simconnect_data.SimconnectDataInitPosition, requestID int) (*uint32, error)

LoadNonATCAircraft will load a non ATC (vfr) aircraft with the specified parameters. See SimConnect API reference.

func (*SimconnectInstance) LoadParkedATCAircraft

func (instance *SimconnectInstance) LoadParkedATCAircraft(containerTitle, tailNumber, airportICAO string, requestID int) (*uint32, error)

LoadParkedATCAircraft will load a parked ATC aircraft with the specified parameters. See SimConnect API reference.

func (*SimconnectInstance) MapClientEventToSimEvent added in v0.0.9

func (instance *SimconnectInstance) MapClientEventToSimEvent(eventID uint32, eventName string) error

func (*SimconnectInstance) RemoveAIObject

func (instance *SimconnectInstance) RemoveAIObject(objectID, requestID uint32) error

RemoveAIObject will remove an AI object from the sim. See SimConnect API reference.

func (*SimconnectInstance) SendText added in v0.0.11

func (instance *SimconnectInstance) SendText(eventID uint32, duration float64, textString string) error

SendText will display a text notification in the simulator. Note: This will only be shown if 'Software Tips' are set to 'on' in the Assistance Options in the case of MSFS

func (*SimconnectInstance) SetAircraftFlightPlan

func (instance *SimconnectInstance) SetAircraftFlightPlan(objectID, requestID uint32, flightPlanPath string) error

SetAircraftFlightPlan allows you to set a flight plan for an existing aircraft. See SimConnect API reference.

func (*SimconnectInstance) SetDataOnSimObject

func (instance *SimconnectInstance) SetDataOnSimObject(objectID uint32, data []SetSimObjectDataExpose) error

SetDataOnSimObject allows you to set data for a given sim object, 0 can be used to apply the data to the users aircraft. See SimConnect API reference.

func (*SimconnectInstance) SubscribeToSystemEvent added in v0.0.9

func (instance *SimconnectInstance) SubscribeToSystemEvent(eventID uint32, eventName string) error

func (*SimconnectInstance) TransmitClientID added in v0.0.9

func (instance *SimconnectInstance) TransmitClientID(eventID uint32, data uint32) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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