Giter VIP home page Giter VIP logo

simconnect-go's Introduction

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.

package main

import (
	"fmt"

	simconnect "github.com/JRascagneres/Simconnect-Go"
)

func main() {
	instance, err := simconnect.NewSimConnect("Simconnect-Go")
	if err != nil {
		panic(err)
	}

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

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

	if err := instance.Close(); err != nil {
		panic(err)
	}
}

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.

simconnect-go's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

simconnect-go's Issues

Allow GetReport to take a pointer to a user/client provided struct

This is one of two repo's that I've found on here that take care of the complicated part of ingesting data from the SimConnect.dll, so to start off with, thank you for writing this lib. I've been using it the past couple of nights as tool for trying to understand how a Go Application can talk to a C API via DDLs.

My idea or feature request, and I can submit a PR for the initial parts to see what you think, it to allow the package consumer to provide a struct. Since reflection is already being used to get the name and unit fields, we can tap into that to do some validation if you feel it is warranted. Im going to go ahead and fork the repo and see what i can do myself.

Example doesn't work, here's one that does

The example from the README file doesn't compile, as NewSimConnect() requires a string argument now. Also the last assignment to err is unchecked, which is a bad idea. And finally the example code can only work from within this package, but is typically run from the main package.

This code addresses all these points:

package main

import (
	"fmt"

	simconnect "github.com/JRascagneres/Simconnect-Go"
)

func main() {
	instance, err := simconnect.NewSimConnect("Simconnect-Go")
	if err != nil {
		panic(err)
	}

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

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

	if err := instance.Close(); err != nil {
		panic(err)
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.