descriptor

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 6 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// SourceFile of the database.
	//
	// Example:
	//  github.com/einride/can-databases/dbc/j1939.dbc
	SourceFile string
	// Version of the database.
	Version string
	// Messages in the database.
	Messages []*Message
	// Nodes in the database.
	Nodes []*Node
}

Database represents a CAN database.

func (*Database) Message

func (d *Database) Message(id uint32) (*Message, bool)

func (*Database) Name

func (d *Database) Name() string

Description returns the name of the Database.

func (*Database) Node

func (d *Database) Node(nodeName string) (*Node, bool)

func (*Database) Signal

func (d *Database) Signal(messageID uint32, signalName string) (*Signal, bool)

type Message

type Message struct {
	// Description of the message.
	Name string
	// ID of the message.
	ID uint32
	// IsExtended is true if the message is an extended CAN message.
	IsExtended bool
	// Length in bytes.
	Length uint8
	// SendType is the message's send type.
	SendType SendType
	// Description of the message.
	Description string
	// Signals in the message payload.
	Signals []*Signal
	// SenderNode is the name of the node sending the message.
	SenderNode string
	// CycleTime is the cycle time of a cyclic message.
	CycleTime time.Duration
	// DelayTime is the allowed delay between cyclic message sends.
	DelayTime time.Duration
}

Message describes a CAN message.

func (*Message) MultiplexerSignal

func (m *Message) MultiplexerSignal() (*Signal, bool)

MultiplexerSignal returns the message's multiplexer signal.

type Node

type Node struct {
	// Description of the CAN node.
	Name string
	// Description of the CAN node.
	Description string
}

Node describes a CAN node.

type SendType

type SendType uint8

SendType represents the send type of a message.

const (
	// SendTypeNone means the send type is unknown or not specified.
	SendTypeNone SendType = iota
	// SendTypeCyclic means the message is sent cyclically.
	SendTypeCyclic
	// SendTypeEvent means the message is only sent upon event or request.
	SendTypeEvent
)

func (SendType) String

func (i SendType) String() string

func (*SendType) UnmarshalString

func (s *SendType) UnmarshalString(str string) error

UnmarshalString sets the value of *s from the provided string.

type Signal

type Signal struct {
	// Description of the signal.
	Name string
	// Start bit.
	Start uint8
	// Length in bits.
	Length uint8
	// IsBigEndian is true if the signal is big-endian.
	IsBigEndian bool
	// IsSigned is true if the signal uses raw signed values.
	IsSigned bool
	// IsMultiplexer is true if the signal is the multiplexor of a multiplexed message.
	IsMultiplexer bool
	// IsMultiplexed is true if the signal is multiplexed.
	IsMultiplexed bool
	// MultiplexerValue is the value of the multiplexer when this signal is present.
	MultiplexerValue uint
	// Offset for real-world transform.
	Offset float64
	// Scale for real-world transform.
	Scale float64
	// Min real-world value.
	Min float64
	// Max real-world value.
	Max float64
	// Unit of the signal.
	Unit string
	// Description of the signal.
	Description string
	// ValueDescriptions of the signal.
	ValueDescriptions []*ValueDescription
	// ReceiverNodes is the list of names of the nodes receiving the signal.
	ReceiverNodes []string
	// DefaultValue of the signal.
	DefaultValue int
}

Signal describes a CAN signal.

func (*Signal) FromPhysical

func (s *Signal) FromPhysical(physical float64) float64

FromPhysical converts a physical signal value to its raw value.

func (*Signal) MarshalBool

func (s *Signal) MarshalBool(d *can.Data, value bool)

MarshalBool sets the bool value of the signal in the provided CAN frame.

func (*Signal) MarshalSigned

func (s *Signal) MarshalSigned(d *can.Data, value int64)

MarshalSigned sets the signed value of the signal in the provided CAN frame.

func (*Signal) MarshalUnsigned

func (s *Signal) MarshalUnsigned(d *can.Data, value uint64)

MarshalUnsigned sets the unsigned value of the signal in the provided CAN frame.

func (*Signal) MaxSigned

func (s *Signal) MaxSigned() int64

MaxSigned returns the maximum signed value representable by the signal.

func (*Signal) MaxUnsigned

func (s *Signal) MaxUnsigned() uint64

MaxUnsigned returns the maximum unsigned value representable by the signal.

func (*Signal) MinSigned

func (s *Signal) MinSigned() int64

MinSigned returns the minimum signed value representable by the signal.

func (*Signal) SaturatedCastSigned

func (s *Signal) SaturatedCastSigned(value int64) int64

SaturatedCastSigned performs a saturated cast of an int64 to the value domain of the signal.

func (*Signal) SaturatedCastUnsigned

func (s *Signal) SaturatedCastUnsigned(value uint64) uint64

SaturatedCastUnsigned performs a saturated cast of a uint64 to the value domain of the signal.

func (*Signal) ToPhysical

func (s *Signal) ToPhysical(value float64) float64

ToPhysical converts a raw signal value to its physical value.

func (*Signal) UnmarshalBool

func (s *Signal) UnmarshalBool(d can.Data) bool

UnmarshalBool returns the bool value of the signal in the provided CAN frame.

func (*Signal) UnmarshalPhysical

func (s *Signal) UnmarshalPhysical(d can.Data) float64

UnmarshalPhysical returns the physical value of the signal in the provided CAN frame.

func (*Signal) UnmarshalSigned

func (s *Signal) UnmarshalSigned(d can.Data) int64

UnmarshalSigned returns the signed value of the signal in the provided CAN frame.

func (*Signal) UnmarshalUnsigned

func (s *Signal) UnmarshalUnsigned(d can.Data) uint64

UnmarshalUnsigned returns the unsigned value of the signal in the provided CAN frame.

func (*Signal) UnmarshalValueDescription

func (s *Signal) UnmarshalValueDescription(d can.Data) (string, bool)

UnmarshalValueDescription returns the value description of the signal in the provided CAN data.

func (*Signal) ValueDescription

func (s *Signal) ValueDescription(value int64) (string, bool)

ValueDescription returns the value description for the provided value.

type ValueDescription

type ValueDescription struct {
	Value       int64
	Description string
}

Jump to

Keyboard shortcuts

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