openxc

package module
v0.0.0-...-7fd481d Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

go-openxc

godoc Build Status Go Report Card

go-openxc is a simple Go library for working with the OpenXC Platform.

This implementation is far less mature than the official libraries and bindings provided by the OpenXC project, but is a first step in enabling the use of OpenXC in Go applications.

The interfaces have further been designed with extensibility in mind, allowing for additional data sources to be added, as well as to allow OpenXC messaging and vehicle information embedding in more complex applications while remaining compliant with the OpenXC messaging specification.

Installation

Install:

go get -u github.com/adaptant-labs/go-openxc

Import:

import "github.com/adaptant-labs/go-openxc"

Testing and Contributing

Note that this is only an initial implementation of a subset of the OpenXC API to facilitate working with OpenXC datasets. It is by no means a feature complete implementation of the API, and is expected to grow gradually and incrementally as it begins to be used in other projects.

For issues with the current implementation, feature requests, or general wishlist items, feel free to open an issue, or, better yet, submit a pull request.

Online Documentation

Online API documentation is provided through godoc, this can be accessed directly on the package entry in the godoc package repository.

The go-openxc gopher logo is a modification of the gopher vector image by Takuya Ueda (https://twitter.com/tenntenn), superimposed with the OpenXC logo from the OpenXC Platform Media Kit (http://openxcplatform.com/overview/media.html). The resulting work is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Creative Commons licensing

Acknowledgements

This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 731678.

License

go-openxc is licensed under the terms of the Apache 2.0 license, the full version of which can be found in the LICENSE file included in the distribution.

Documentation

Overview

Package openxc provides a simple API for working with data from the OpenXC platform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDataSource

func RegisterDataSource(name string, drv DataSourceDriver)

RegisterDataSource makes a data source driver available under the specified name. Only a single registration per unique name is supported, multiple registrations under the same driver name will result in a panic.

func VehicleMessageToState

func VehicleMessageToState(state *VehicleState, msg VehicleMessage)

VehicleMessageToState updates the VehicleState information with the contents of a single VehicleMessage.

Types

type DataSource

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

DataSource provides a generic interface for the management of OpenXC data sources.

func OpenDataSource

func OpenDataSource(driverName, dataSourceName string) (*DataSource, error)

OpenDataSource opens the named DataSource

func (*DataSource) CloseDataSource

func (ds *DataSource) CloseDataSource() error

CloseDataSource closes the data source. Each caller that has opened the data source is responsible for closing it directly.

func (*DataSource) ReadDataSource

func (ds *DataSource) ReadDataSource() (VehicleMessage, error)

ReadDataSource reads a single VehicleMessage from the data source stream. This may be called multiple times to advance across the stream, and will return with an EOF when the stream runs out.

func (*DataSource) ResetDataSource

func (ds *DataSource) ResetDataSource() error

ResetDataSource provides a reset/rewind mechanism for the data source. This can be useful when dealing with static data that must be replayed multiple times, either in a loop, or on a per-connection basis.

type DataSourceDriver

type DataSourceDriver interface {
	Open(name string) error
	Close() error
	Read() (VehicleMessage, error)
	Reset() error
}

DataSourceDriver provides the backing driver interface for each DataSource.

type VehicleMessage

type VehicleMessage struct {
	Name  string
	Value interface{}
	Event bool
}

VehicleMessage is the top-level wrapper for the OpenXC messaging format. Two types of messages, according to their JSON encoding, are dealt with by the specification:

Simple vehicle messages:

{"name": "headlamp_status", "value": false}

Extended vehicle messages:

{"name": "headlamp_status", "value": false, "event": false}

type VehicleState

type VehicleState struct {
	HeadlampStatus        bool
	HighBeamStatus        bool
	WindshieldWiperStatus bool
	BrakePedalStatus      bool
	ParkingBrakeStatus    bool

	DoorStatus       string
	IgnitionStatus   string
	TurnSignalStatus string

	GearLeverPosition        string
	TransmissionGearPosition string

	FuelLevel                float64
	Latitude                 float64
	Longitude                float64
	AcceleratorPedalPosition float64
	EngineSpeed              float64
	VehicleSpeed             float64
	FuelConsumedSinceRestart float64
	Odometer                 float64
	SteeringWheelAngle       float64
	TorqueAtTransmission     float64
}

VehicleState contains basic state information about a given vehicle.

Jump to

Keyboard shortcuts

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