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 ¶
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.