acmelib

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

README

acmelib

Go Reference Go Report Card

[!IMPORTANT] Thi repo was moved to squadracorse organization.

A Golang package for modelling complex CAN networks.

The package documentation can be found here.

Getting started

Prerequisites

Golang 1.22

Installation

Run the following Go command to install the acmelib package:

go get -u github.com/squadracorsepolito/acmelib

TODOs

  • Adding examples
  • Adding JSON/Yaml and Protobuf parsing of the model
  • Improving test coverage

Documentation

Overview

Package acmelib contains structures and methods for creating complex CAN (Controlled Area Network) networks.

Index

Constants

This section is empty.

Variables

View Source
var ErrIntersect = errors.New("is intersecting")

ErrIntersect is returned when two entities are intersecting.

View Source
var ErrInvalidType = errors.New("invalid type")

ErrInvalidType is returned when an invalid type is used.

View Source
var ErrIsDuplicated = errors.New("is duplicated")

ErrIsDuplicated is returned when an entity is duplicated.

View Source
var ErrIsNegative = errors.New("is negative")

ErrIsNegative is returned when a value is negative.

View Source
var ErrIsNil = errors.New("is nil")

ErrIsNil is returned when a value or entity is nil.

View Source
var ErrIsZero = errors.New("is zero")

ErrIsZero is returned when a value is zero.

View Source
var ErrNoSpaceLeft = errors.New("not enough space left")

ErrNoSpaceLeft is returned when there is not enough space left.

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when an entity is not found.

View Source
var ErrOutOfBounds = errors.New("out of bounds")

ErrOutOfBounds is returned when a value is out of bounds.

Functions

func CalculateBusLoad added in v0.7.0

func CalculateBusLoad(bus *Bus, defCycleTime int) (float64, error)

CalculateBusLoad returns the estimed load of the given Bus in the worst case scenario. The default cycle time is used when a message within the bus does not have one set. If the bus does not have the baudrate set, it returns 0.

It returns an ArgumentError if the given default cycle time is invalid.

func ExportBus

func ExportBus(w io.Writer, bus *Bus)

ExportBus exports the given Bus to DBC. It writes the content of the result DBC file into the io.Writer.

func ExportNetwork

func ExportNetwork(network *Network, basePath string) error

ExportNetwork exports the given Network to DBC. It will create a directory with the given base path and network name. Into the directory, it will create a DBC file for each Bus of the network.

func ExportToMarkdown added in v0.6.0

func ExportToMarkdown(network *Network, w io.Writer) error

ExportToMarkdown exports the given Network to a markdown document. It writes the markdown document to the given io.Writer.

Types

type AddEntityError

type AddEntityError struct {
	EntityID EntityID
	Name     string
	Err      error
}

AddEntityError is returned when an entity cannot be added. The EntityID field is the ID of the entity and the Name field is the name, and the Err field is the cause.

func (*AddEntityError) Error

func (e *AddEntityError) Error() string

func (*AddEntityError) Unwrap

func (e *AddEntityError) Unwrap() error

type AppendSignalError

type AppendSignalError struct {
	EntityID EntityID
	Name     string
	Err      error
}

AppendSignalError is returned when a signal cannot be appended. The EntityID field is the ID of the signal, the Name field is the name, and the Err field is the cause.

func (*AppendSignalError) Error

func (e *AppendSignalError) Error() string

func (*AppendSignalError) Unwrap

func (e *AppendSignalError) Unwrap() error

type ArgumentError

type ArgumentError struct {
	Name string
	Err  error
}

ArgumentError is returned when an argument is invalid. The Name field is the name of the argument and the Err field is the cause.

func (*ArgumentError) Error

func (e *ArgumentError) Error() string

func (*ArgumentError) Unwrap

func (e *ArgumentError) Unwrap() error

type AttributableEntity added in v0.7.0

type AttributableEntity interface {

	// EntityID returns the unique identifier of the entity.
	EntityID() EntityID
	// EntityKind returns the kind of the entity.
	EntityKind() EntityKind
	// Name returns the name of the entity.
	Name() string

	// AssignAttribute assigns the given attribute/value pair to the entity.
	AssignAttribute(attribute Attribute, value any) error
	// RemoveAttributeAssignment removes the attribute assignment
	// with the given attribute entity id from the entity.
	RemoveAttributeAssignment(attributeEntityID EntityID) error
	// RemoveAllAttributeAssignments removes all the attribute assignments from the entity.
	RemoveAllAttributeAssignments()
	// AttributeAssignments returns a slice of all attribute assignments of the entity.
	AttributeAssignments() []*AttributeAssignment
	// GetAttributeAssignment returns the attribute assignment
	// with the given attribute entity id from the entity.
	GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)
	// contains filtered or unexported methods
}

AttributableEntity represents an entity that can hold attributes.

type Attribute

type Attribute interface {
	// EntityID returns the entity id of the attribute.
	EntityID() EntityID
	// Name returns the name of the attribute.
	Name() string
	// Desc returns the description of the attribute.
	Desc() string
	// CreateTime returns the time of creation of the attribute.
	CreateTime() time.Time

	// Type returns the kind of the attribute.
	Type() AttributeType

	// References returns a slice of references of the attribute.
	References() []*AttributeAssignment

	String() string

	// ToString converts the attribute to a string attribute.
	ToString() (*StringAttribute, error)
	// ToInteger converts the attribute to a integer attribute.
	ToInteger() (*IntegerAttribute, error)
	// ToFloat converts the attribute to a float attribute.
	ToFloat() (*FloatAttribute, error)
	// ToEnum converts the attribute to a enum attribute.
	ToEnum() (*EnumAttribute, error)
	// contains filtered or unexported methods
}

Attribute interface specifies all common methods of StringAttribute, IntegerAttribute, FloatAttribute, and EnumAttribute.

type AttributeAssignment added in v0.7.0

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

AttributeAssignment represents a link between an Attribute and an AttributableEntity with an assigned value.

func (*AttributeAssignment) Attribute added in v0.7.0

func (aa *AttributeAssignment) Attribute() Attribute

Attribute returns the Attribute of the AttributeAssignment.

func (*AttributeAssignment) Entity added in v0.7.0

Entity returns the AttributableEntity of the AttributeAssignment.

func (*AttributeAssignment) EntityID added in v0.7.0

func (aa *AttributeAssignment) EntityID() EntityID

EntityID returns the entity id of the AttributableEntity of the AttributeAssignment.

func (*AttributeAssignment) ToBusEntity added in v0.7.0

func (aa *AttributeAssignment) ToBusEntity() (*Bus, error)

ToBusEntity returns the AttributableEntity as a Bus.

It returns a ConversionError if the kind of the entity is not equal to EntityKindBus.

func (*AttributeAssignment) ToMessageEntity added in v0.7.0

func (aa *AttributeAssignment) ToMessageEntity() (*Message, error)

ToMessageEntity returns the AttributableEntity as a Message.

It returns a ConversionError if the kind of the entity is not equal to EntityKindMessage.

func (*AttributeAssignment) ToNodeEntity added in v0.7.0

func (aa *AttributeAssignment) ToNodeEntity() (*Node, error)

ToNodeEntity returns the AttributableEntity as a Node.

It returns a ConversionError if the kind of the entity is not equal to EntityKindNode.

func (*AttributeAssignment) ToSignalEntity added in v0.7.0

func (aa *AttributeAssignment) ToSignalEntity() (Signal, error)

ToSignalEntity returns the AttributableEntity as a Signal.

It returns a ConversionError if the kind of the entity is not equal to EntityKindSignal.

func (*AttributeAssignment) Value added in v0.7.0

func (aa *AttributeAssignment) Value() any

Value returns the value of the AttributeAssignment.

type AttributeType added in v0.7.0

type AttributeType int

AttributeType defines the type of an Attribute.

const (
	// AttributeTypeString defines a string attribute.
	AttributeTypeString AttributeType = iota
	// AttributeTypeInteger defines an integer attribute.
	AttributeTypeInteger
	// AttributeTypeFloat defines a float attribute.
	AttributeTypeFloat
	// AttributeTypeEnum defines an enum attribute.
	AttributeTypeEnum
)

func (AttributeType) String added in v0.7.0

func (at AttributeType) String() string

type AttributeValueError added in v0.7.0

type AttributeValueError struct {
	Err error
}

AttributeValueError is returned when an attribute value is invalid. The Err field contains the cause.

func (*AttributeValueError) Error added in v0.7.0

func (e *AttributeValueError) Error() string

func (*AttributeValueError) Unwrap added in v0.7.0

func (e *AttributeValueError) Unwrap() error

type Bus

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

Bus is the virtual representation of physical CAN bus cable. It holds a list of nodes that are connected to it.

func ImportDBCFile

func ImportDBCFile(filename string, r io.Reader) (*Bus, error)

ImportDBCFile imports a DBC file passed as io.Reader and converts it to a Bus. The given filename will be used as the name of the bus.

func NewBus

func NewBus(name string) *Bus

NewBus creates a new Bus with the given name and description. By default, the bus is set to be of type CAN 2.0A.

func (*Bus) AddNodeInterface added in v0.6.0

func (b *Bus) AddNodeInterface(nodeInterface *NodeInterface) error

AddNodeInterface adds a NodeInterface to the Bus.

It returns an ArgumentError if the given node interface is nil or a NameError/NodeIDError if the node name/id is already used.

func (*Bus) AssignAttribute added in v0.7.0

func (b *Bus) AssignAttribute(attribute Attribute, value any) error

AssignAttribute assigns the given attribute/value pair to the Bus.

It returns an ArgumentError if the attribute is nil, or an AttributeValueError if the value does not conform to the attribute.

func (Bus) AttributeAssignments added in v0.7.0

func (wa Bus) AttributeAssignments() []*AttributeAssignment

AttributeAssignments returns a slice of all attribute assignments of the entity.

func (*Bus) Baudrate

func (b *Bus) Baudrate() int

Baudrate returns the baudrate of the Bus.

func (*Bus) CANIDBuilder added in v0.6.0

func (b *Bus) CANIDBuilder() *CANIDBuilder

CANIDBuilder returns the CANIDBuilder of the Bus. If it is not set, it returns the default CAN-ID builder.

func (Bus) CreateTime added in v0.7.0

func (e Bus) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (Bus) Desc added in v0.7.0

func (e Bus) Desc() string

Desc returns the description of the entity.

func (Bus) EntityID added in v0.7.0

func (e Bus) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (Bus) EntityKind added in v0.7.0

func (e Bus) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (*Bus) GetAttributeAssignment added in v0.7.0

func (b *Bus) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)

GetAttributeAssignment returns the AttributeAssignment with the given attribute entity id from the Bus.

It returns an ErrNotFound if the provided attribute entity id is not found.

func (*Bus) GetNodeInterfaceByNodeName added in v0.6.0

func (b *Bus) GetNodeInterfaceByNodeName(nodeName string) (*NodeInterface, error)

GetNodeInterfaceByNodeName returns the NodeInterface with the given node name.

It returns an ErrNotFound wrapped by a NameError if the node name does not match any node interface.

func (Bus) Name added in v0.7.0

func (e Bus) Name() string

Name returns the name of the entity.

func (*Bus) Nodes

func (b *Bus) Nodes() []*NodeInterface

Nodes returns a slice of all nodes in the Bus sorted by node id.

func (*Bus) ParentNetwork

func (b *Bus) ParentNetwork() *Network

ParentNetwork returns the Network that the Bus is part of. If the Bus is not part of a Network, it returns nil.

func (Bus) RemoveAllAttributeAssignments added in v0.7.0

func (wa Bus) RemoveAllAttributeAssignments()

RemoveAllAttributeAssignments removes all the attribute assignments from the entity.

func (*Bus) RemoveAllNodeInterfaces added in v0.6.0

func (b *Bus) RemoveAllNodeInterfaces()

RemoveAllNodeInterfaces removes all node interfaces from the Bus.

func (*Bus) RemoveAttributeAssignment added in v0.7.0

func (b *Bus) RemoveAttributeAssignment(attributeEntityID EntityID) error

RemoveAttributeAssignment removes the AttributeAssignment with the given attribute entity id from the Bus.

It returns an ErrNotFound if the provided attribute entity id is not found.

func (*Bus) RemoveNodeInterface added in v0.6.0

func (b *Bus) RemoveNodeInterface(nodeInterfaceEntityID EntityID) error

RemoveNodeInterface removes a NodeInterface from the Bus.

It returns an ErrNotFound if the given entity id does not match any node interface.

func (*Bus) SetBaudrate

func (b *Bus) SetBaudrate(baudrate int)

SetBaudrate sets the baudrate of the Bus.

func (*Bus) SetCANIDBuilder added in v0.6.0

func (b *Bus) SetCANIDBuilder(canIDBuilder *CANIDBuilder)

SetCANIDBuilder sets the CANIDBuilder of the Bus.

func (Bus) SetDesc added in v0.7.0

func (e Bus) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*Bus) SetType added in v0.6.1

func (b *Bus) SetType(typ BusType)

SetType sets the type of the Bus.

func (*Bus) String

func (b *Bus) String() string

func (*Bus) Type added in v0.6.1

func (b *Bus) Type() BusType

Type returns the type of the Bus.

func (*Bus) UpdateName

func (b *Bus) UpdateName(newName string) error

UpdateName updates the name of the Bus. It may return an error if the new name is already in use within a network.

type BusType added in v0.6.1

type BusType int

BusType is the type of a Bus.

const (
	// BusTypeCAN2A represents a CAN 2.0A bus.
	BusTypeCAN2A BusType = iota
)

func (BusType) String added in v0.6.1

func (bt BusType) String() string

type CANID added in v0.6.0

type CANID uint32

CANID is the CAN-ID of a Message within a Bus. Every message should have a different CAN-ID.

type CANIDBuilder added in v0.6.0

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

CANIDBuilder is a builder used to describe how to generate the CAN-ID of the messages within a Bus.

func NewCANIDBuilder added in v0.6.0

func NewCANIDBuilder(name string) *CANIDBuilder

NewCANIDBuilder creates a new CANIDBuilder with the given name.

func (*CANIDBuilder) Calculate added in v0.6.0

func (b *CANIDBuilder) Calculate(messagePriority MessagePriority, messageID MessageID, nodeID NodeID) CANID

Calculate returns the CAN-ID calculated by applying the operations.

func (CANIDBuilder) CreateTime added in v0.6.0

func (e CANIDBuilder) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (CANIDBuilder) Desc added in v0.6.0

func (e CANIDBuilder) Desc() string

Desc returns the description of the entity.

func (CANIDBuilder) EntityID added in v0.6.0

func (e CANIDBuilder) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (CANIDBuilder) EntityKind added in v0.7.0

func (e CANIDBuilder) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (CANIDBuilder) Name added in v0.6.0

func (e CANIDBuilder) Name() string

Name returns the name of the entity.

func (*CANIDBuilder) Operations added in v0.6.0

func (b *CANIDBuilder) Operations() []*CANIDBuilderOp

Operations returns the operations performed by the CANIDBuilder.

func (CANIDBuilder) ReferenceCount added in v0.6.0

func (t CANIDBuilder) ReferenceCount() int

func (CANIDBuilder) References added in v0.6.0

func (t CANIDBuilder) References() []R

func (CANIDBuilder) SetDesc added in v0.6.0

func (e CANIDBuilder) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*CANIDBuilder) String added in v0.6.0

func (b *CANIDBuilder) String() string

func (*CANIDBuilder) UseBitMask added in v0.7.0

func (b *CANIDBuilder) UseBitMask(from, len int)

UseBitMask adds a bit mask operation from the given index and length.

func (*CANIDBuilder) UseCAN2A added in v0.7.0

func (b *CANIDBuilder) UseCAN2A() *CANIDBuilder

UseCAN2A adds a bit mask from 0 with a length of 11, which makes the calculated CAN-ID conformed to the CAN 2.0A.

func (*CANIDBuilder) UseMessageID added in v0.6.0

func (b *CANIDBuilder) UseMessageID(from, len int) *CANIDBuilder

UseMessageID adds an operation that involves the message id from the given index and length.

func (*CANIDBuilder) UseMessagePriority added in v0.6.0

func (b *CANIDBuilder) UseMessagePriority(from int) *CANIDBuilder

UseMessagePriority adds an operation that involves the message priority from the given index. The length of the operation is fixed (2 bits).

func (*CANIDBuilder) UseNodeID added in v0.6.0

func (b *CANIDBuilder) UseNodeID(from, len int) *CANIDBuilder

UseNodeID adds an operation that involves the node id from the given index and length.

type CANIDBuilderOp added in v0.6.0

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

CANIDBuilderOp is an operation performed by the CANIDBuilder.

func (*CANIDBuilderOp) From added in v0.6.0

func (bo *CANIDBuilderOp) From() int

From returns the index of the first bit on which the operation is performed.

func (*CANIDBuilderOp) Kind added in v0.6.0

Kind returns the kind of the operation.

func (*CANIDBuilderOp) Len added in v0.6.0

func (bo *CANIDBuilderOp) Len() int

Len returns the number of bits on which the operation is performed.

type CANIDBuilderOpKind added in v0.6.0

type CANIDBuilderOpKind int

CANIDBuilderOpKind is the kind of an operation perfomed by the CANIDBuilder.

const (
	// CANIDBuilderOpKindMessagePriority represents an operation
	// that involves the message priority.
	CANIDBuilderOpKindMessagePriority CANIDBuilderOpKind = iota
	// CANIDBuilderOpKindMessageID represents an operation
	// that involves the message id.
	CANIDBuilderOpKindMessageID
	// CANIDBuilderOpKindNodeID represents an operation
	// that involves the node id.
	CANIDBuilderOpKindNodeID
	// CANIDBuilderOpKindBitMask represents a bit masking operation.
	CANIDBuilderOpKindBitMask
)

func (CANIDBuilderOpKind) String added in v0.6.0

func (bok CANIDBuilderOpKind) String() string

type ConversionError

type ConversionError struct {
	From string
	To   string
}

ConversionError is returned when a signal cannot be converted.

func (*ConversionError) Error

func (e *ConversionError) Error() string

type EntityError

type EntityError struct {
	Kind     EntityKind
	EntityID EntityID
	Name     string
	Err      error
}

EntityError is returned when a method of an entity fails. The Kind field is the entity kind, the EntityID field is the ID, the Name field is the name, and the Err field is the cause.

func (*EntityError) Error

func (e *EntityError) Error() string

func (*EntityError) Unwrap

func (e *EntityError) Unwrap() error

type EntityID

type EntityID string

EntityID is the unique identifier of an entity.

func (EntityID) String

func (id EntityID) String() string

type EntityKind

type EntityKind int

EntityKind is the kind of an entity.

const (
	// EntityKindNetwork represents a [Network] entity.
	EntityKindNetwork EntityKind = iota
	// EntityKindBus represents a [Bus] entity.
	EntityKindBus
	// EntityKindNode represents a [Node] entity.
	EntityKindNode
	// EntityKindNodeInterface represents a [NodeInterface] entity.
	EntityKindNodeInterface
	// EntityKindMessage represents a [Message] entity.
	EntityKindMessage
	// EntityKindSignal represents a [Signal] entity.
	EntityKindSignal
	// EntityKindSignalType represents a [SignalType] entity.
	EntityKindSignalType
	// EntityKindSignalUnit represents a [SignalUnit] entity.
	EntityKindSignalUnit
	// EntityKindSignalEnum represents a [SignalEnum] entity.
	EntityKindSignalEnum
	// EntityKindSignalEnumValue represents a [SignalEnumValue] entity.
	EntityKindSignalEnumValue
	// EntityKindAttribute represents a [Attribute] entity.
	EntityKindAttribute
	// EntityKindCANIDBuilder represents a [CANIDBuilder] entity.
	EntityKindCANIDBuilder
)

func (EntityKind) String

func (ek EntityKind) String() string

type EnumAttribute

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

EnumAttribute is an Attribute that holds an enum as value.

func NewEnumAttribute

func NewEnumAttribute(name string, values ...string) (*EnumAttribute, error)

NewEnumAttribute creates a new EnumAttribute with the given name and values. The first value is always selected as the default one. It may return an error if no values are passed.

func (*EnumAttribute) DefValue

func (ea *EnumAttribute) DefValue() string

DefValue returns the default value of the EnumAttribute.

func (*EnumAttribute) GetValueAtIndex

func (ea *EnumAttribute) GetValueAtIndex(valueIndex int) (string, error)

GetValueAtIndex returns the value at the given index. The index refers to the order of the values in the factory method. It may return an error if the index is out of range.

func (*EnumAttribute) String

func (ea *EnumAttribute) String() string

func (*EnumAttribute) ToEnum

func (ea *EnumAttribute) ToEnum() (*EnumAttribute, error)

ToEnum returns the EnumAttribute itself.

func (*EnumAttribute) ToFloat

func (ea *EnumAttribute) ToFloat() (*FloatAttribute, error)

ToFloat always returns an error.

func (*EnumAttribute) ToInteger

func (ea *EnumAttribute) ToInteger() (*IntegerAttribute, error)

ToInteger always returns an error.

func (*EnumAttribute) ToString

func (ea *EnumAttribute) ToString() (*StringAttribute, error)

ToString always returns an error.

func (EnumAttribute) Type added in v0.7.0

func (a EnumAttribute) Type() AttributeType

func (*EnumAttribute) Values

func (ea *EnumAttribute) Values() []string

Values returns the values of the EnumAttribute in the order specified in the factory method.

type EnumSignal

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

EnumSignal is a signal that holds a SignalEnum.

func NewEnumSignal

func NewEnumSignal(name string, enum *SignalEnum) (*EnumSignal, error)

NewEnumSignal creates a new EnumSignal with the given name and SignalEnum. It may return an error if the given SignalEnum is nil.

func (*EnumSignal) AssignAttribute added in v0.7.0

func (es *EnumSignal) AssignAttribute(attribute Attribute, value any) error

AssignAttribute assigns the given attribute/value pair to the EnumSignal.

It returns an ArgumentError if the attribute is nil, or an AttributeValueError if the value does not conform to the attribute.

func (*EnumSignal) Enum

func (es *EnumSignal) Enum() *SignalEnum

Enum returns the SignalEnum of the EnumSignal.

func (EnumSignal) GetAttributeAssignment added in v0.7.0

func (s EnumSignal) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)

func (*EnumSignal) GetSize

func (es *EnumSignal) GetSize() int

GetSize returns the size of the EnumSignal.

func (EnumSignal) GetStartBit

func (s EnumSignal) GetStartBit() int

func (EnumSignal) Kind

func (s EnumSignal) Kind() SignalKind

func (EnumSignal) ParentMessage

func (s EnumSignal) ParentMessage() *Message

func (EnumSignal) ParentMultiplexerSignal

func (s EnumSignal) ParentMultiplexerSignal() *MultiplexerSignal

func (EnumSignal) RemoveAttributeAssignment added in v0.7.0

func (s EnumSignal) RemoveAttributeAssignment(attributeEntityID EntityID) error

func (EnumSignal) SendType

func (s EnumSignal) SendType() SignalSendType

func (*EnumSignal) SetEnum

func (es *EnumSignal) SetEnum(enum *SignalEnum) error

SetEnum sets the SignalEnum of the EnumSignal to the given one. It may return an error if the given SignalEnum is nil, or if the new enum size cannot fit in the message payload.

func (EnumSignal) SetSendType

func (s EnumSignal) SetSendType(sendType SignalSendType)

func (EnumSignal) SetStartValue added in v0.6.0

func (s EnumSignal) SetStartValue(startValue int)

func (EnumSignal) StartValue added in v0.6.0

func (s EnumSignal) StartValue() int

func (*EnumSignal) String

func (es *EnumSignal) String() string

func (*EnumSignal) ToEnum

func (es *EnumSignal) ToEnum() (*EnumSignal, error)

ToEnum returns the EnumSignal itself.

func (*EnumSignal) ToMultiplexer

func (es *EnumSignal) ToMultiplexer() (*MultiplexerSignal, error)

ToMultiplexer always returns an error, because an EnumSignal cannot be converted to a MultiplexerSignal.

func (*EnumSignal) ToStandard

func (es *EnumSignal) ToStandard() (*StandardSignal, error)

ToStandard always returns an error, because an EnumSignal cannot be converted to a StandardSignal.

func (EnumSignal) UpdateName

func (s EnumSignal) UpdateName(newName string) error

type ErrGreaterThen

type ErrGreaterThen struct {
	Target string
}

ErrGreaterThen is returned when a value is greater than a target. The Target field is the target.

func (*ErrGreaterThen) Error

func (e *ErrGreaterThen) Error() string

type ErrIsRequired

type ErrIsRequired struct {
	Thing string
}

ErrIsRequired is returned when something is required. The Thing field is what is required.

func (*ErrIsRequired) Error

func (e *ErrIsRequired) Error() string

type ErrLowerThen

type ErrLowerThen struct {
	Target string
}

ErrLowerThen is returned when a value is lower than a target. The Target field is the target.

func (*ErrLowerThen) Error

func (e *ErrLowerThen) Error() string

type FloatAttribute

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

FloatAttribute is an Attribute that holds a float value.

func NewFloatAttribute

func NewFloatAttribute(name string, defValue, min, max float64) (*FloatAttribute, error)

NewFloatAttribute creates a new FloatAttribute with the given name, default value, min, and max. It may return an error if the default value is out of the min/max range, or if the min value is greater then the max value.

func (*FloatAttribute) DefValue

func (fa *FloatAttribute) DefValue() float64

DefValue returns the default value of the FloatAttribute.

func (*FloatAttribute) Max

func (fa *FloatAttribute) Max() float64

Max returns the max value of the FloatAttribute.

func (*FloatAttribute) Min

func (fa *FloatAttribute) Min() float64

Min returns the min value of the FloatAttribute.

func (*FloatAttribute) String

func (fa *FloatAttribute) String() string

func (*FloatAttribute) ToEnum

func (fa *FloatAttribute) ToEnum() (*EnumAttribute, error)

ToEnum always returns an error.

func (*FloatAttribute) ToFloat

func (fa *FloatAttribute) ToFloat() (*FloatAttribute, error)

ToFloat returns the FloatAttribute itself.

func (*FloatAttribute) ToInteger

func (fa *FloatAttribute) ToInteger() (*IntegerAttribute, error)

ToInteger always returns an error.

func (*FloatAttribute) ToString

func (fa *FloatAttribute) ToString() (*StringAttribute, error)

ToString always returns an error.

func (FloatAttribute) Type added in v0.7.0

func (a FloatAttribute) Type() AttributeType

type GetEntityError

type GetEntityError struct {
	EntityID EntityID
	Err      error
}

GetEntityError is returned when an entity cannot be retrieved. The EntityID field is the ID of the entity and the Err field is the cause.

func (*GetEntityError) Error

func (e *GetEntityError) Error() string

func (*GetEntityError) Unwrap

func (e *GetEntityError) Unwrap() error

type GroupIDError

type GroupIDError struct {
	GroupID int
	Err     error
}

GroupIDError is returned when a group ID is invalid. The GroupID field is the group ID and the Err field is the cause.

func (*GroupIDError) Error

func (e *GroupIDError) Error() string

func (*GroupIDError) Unwrap

func (e *GroupIDError) Unwrap() error

type InsertSignalError

type InsertSignalError struct {
	EntityID EntityID
	Name     string
	StartBit int
	Err      error
}

InsertSignalError is returned when a signal cannot be inserted. The EntityID field is the ID of the signal, the Name field is the name, the StartBit field is the start bit, and the Err field is the cause.

func (*InsertSignalError) Error

func (e *InsertSignalError) Error() string

func (*InsertSignalError) Unwrap

func (e *InsertSignalError) Unwrap() error

type IntegerAttribute

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

IntegerAttribute is an Attribute that holds an integer value.

func NewIntegerAttribute

func NewIntegerAttribute(name string, defValue, min, max int) (*IntegerAttribute, error)

NewIntegerAttribute creates a new IntegerAttribute with the given name, default value, min, and max. It may return an error if the default value is out of the min/max range, or if the min value is greater then the max value.

func (*IntegerAttribute) DefValue

func (ia *IntegerAttribute) DefValue() int

DefValue returns the default value of the IntegerAttribute.

func (*IntegerAttribute) IsHexFormat

func (ia *IntegerAttribute) IsHexFormat() bool

IsHexFormat reports whether the IntegerAttribute is in hex format.

func (*IntegerAttribute) Max

func (ia *IntegerAttribute) Max() int

Max returns the max value of the IntegerAttribute.

func (*IntegerAttribute) Min

func (ia *IntegerAttribute) Min() int

Min returns the min value of the IntegerAttribute.

func (*IntegerAttribute) SetFormatHex

func (ia *IntegerAttribute) SetFormatHex()

SetFormatHex sets the format of the IntegerAttribute to hex.

func (*IntegerAttribute) String

func (ia *IntegerAttribute) String() string

func (*IntegerAttribute) ToEnum

func (ia *IntegerAttribute) ToEnum() (*EnumAttribute, error)

ToEnum always returns an error.

func (*IntegerAttribute) ToFloat

func (ia *IntegerAttribute) ToFloat() (*FloatAttribute, error)

ToFloat always returns an error.

func (*IntegerAttribute) ToInteger

func (ia *IntegerAttribute) ToInteger() (*IntegerAttribute, error)

ToInteger returns the IntegerAttribute itself.

func (*IntegerAttribute) ToString

func (ia *IntegerAttribute) ToString() (*StringAttribute, error)

ToString always returns an error.

func (IntegerAttribute) Type added in v0.7.0

func (a IntegerAttribute) Type() AttributeType

type Message

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

Message is the representation of data sent by a node thought the bus. It holds a list of signals that are contained in the message payload.

func NewMessage

func NewMessage(name string, id MessageID, sizeByte int) *Message

NewMessage creates a new Message with the given name, id and size in bytes. By default a MessagePriority of MessagePriorityVeryHigh is used.

func (*Message) AddReceiver

func (m *Message) AddReceiver(receiver *NodeInterface)

AddReceiver adds a receiver to the Message.

func (*Message) AppendSignal

func (m *Message) AppendSignal(signal Signal) error

AppendSignal appends a Signal to the last position of the Message payload. It may return an error if the signal name is already used within the message, or if the signal cannot fit in the available space left at the end of the message payload.

func (*Message) AssignAttribute added in v0.7.0

func (m *Message) AssignAttribute(attribute Attribute, value any) error

AssignAttribute assigns the given attribute/value pair to the Message.

It returns an ArgumentError if the attribute is nil, or an AttributeValueError if the value does not conform to the attribute.

func (Message) AttributeAssignments added in v0.7.0

func (wa Message) AttributeAssignments() []*AttributeAssignment

AttributeAssignments returns a slice of all attribute assignments of the entity.

func (*Message) ByteOrder added in v0.6.0

func (m *Message) ByteOrder() MessageByteOrder

ByteOrder returns the byte order of the Message.

func (*Message) CompactSignals

func (m *Message) CompactSignals()

CompactSignals compacts the Message payload.

func (Message) CreateTime added in v0.7.0

func (e Message) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (*Message) CycleTime

func (m *Message) CycleTime() int

CycleTime returns the message cycle time.

func (*Message) DelayTime

func (m *Message) DelayTime() int

DelayTime returns the message delay time.

func (Message) Desc added in v0.7.0

func (e Message) Desc() string

Desc returns the description of the entity.

func (Message) EntityID added in v0.7.0

func (e Message) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (Message) EntityKind added in v0.7.0

func (e Message) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (*Message) GetAttributeAssignment added in v0.7.0

func (m *Message) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)

GetAttributeAssignment returns the AttributeAssignment with the given attribute entity id from the Message.

It returns an ErrNotFound if the provided attribute entity id is not found.

func (*Message) GetCANID added in v0.6.0

func (m *Message) GetCANID() CANID

GetCANID returns the CANID associated to the Message. If the message has a static CAN-ID, it will be returned. If the message does not have a sender NodeInterface, it will return the message id. Otherwise, it will calculate the CAN-ID based on the CANIDBuilder provided by the Bus which owns the node interface.

func (*Message) GetSignal

func (m *Message) GetSignal(signalEntityID EntityID) (Signal, error)

GetSignal returns the Signal that matches the given entity id.

func (*Message) HasStaticCANID added in v0.6.0

func (m *Message) HasStaticCANID() bool

HasStaticCANID returns whether the Message has a static CAN-ID.

func (*Message) ID added in v0.6.0

func (m *Message) ID() MessageID

ID returns the id of the Message.

func (*Message) InsertSignal

func (m *Message) InsertSignal(signal Signal, startBit int) error

InsertSignal inserts a Signal at the given position of the Message payload. The start bit defines the index of the message payload where the signal will start. It may return an error if the signal name is already used within the message, or if the signal cannot fit in the available space left at the start bit.

func (Message) Name added in v0.7.0

func (e Message) Name() string

Name returns the name of the entity.

func (*Message) Priority

func (m *Message) Priority() MessagePriority

Priority returns the message priority.

func (*Message) Receivers

func (m *Message) Receivers() []*NodeInterface

Receivers returns a slice of all receivers of the Message.

func (Message) RemoveAllAttributeAssignments added in v0.7.0

func (wa Message) RemoveAllAttributeAssignments()

RemoveAllAttributeAssignments removes all the attribute assignments from the entity.

func (*Message) RemoveAllSignals

func (m *Message) RemoveAllSignals()

RemoveAllSignals removes all signals from the Message.

func (*Message) RemoveAttributeAssignment added in v0.7.0

func (m *Message) RemoveAttributeAssignment(attributeEntityID EntityID) error

RemoveAttributeAssignment removes the AttributeAssignment with the given attribute entity id from the Message.

It returns an ErrNotFound if the provided attribute entity id is not found.

func (*Message) RemoveReceiver

func (m *Message) RemoveReceiver(receiverEntityID EntityID)

RemoveReceiver removes a receiver from the Message.

func (*Message) RemoveSignal

func (m *Message) RemoveSignal(signalEntityID EntityID) error

RemoveSignal removes a Signal that matches the given entity id from the Message. It may return an error if the signal with the given entity id is not part of the message payload.

func (*Message) SendType

func (m *Message) SendType() MessageSendType

SendType returns the message send type.

func (*Message) SenderNodeInterface added in v0.6.0

func (m *Message) SenderNodeInterface() *NodeInterface

SenderNodeInterface returns the NodeInterface that is responsible for sending the Message. If the Message is not sent by a NodeInterface, it will return nil.

func (*Message) SetByteOrder added in v0.6.0

func (m *Message) SetByteOrder(byteOrder MessageByteOrder)

SetByteOrder sets the byte order of the Message.

func (*Message) SetCycleTime

func (m *Message) SetCycleTime(cycleTime int)

SetCycleTime sets the message cycle time in ms.

func (*Message) SetDelayTime

func (m *Message) SetDelayTime(delayTime int)

SetDelayTime sets the delay time of the Message.

func (Message) SetDesc added in v0.7.0

func (e Message) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*Message) SetPriority

func (m *Message) SetPriority(priority MessagePriority)

SetPriority sets the message priority.

func (*Message) SetSendType

func (m *Message) SetSendType(sendType MessageSendType)

SetSendType sets the send type of the Message.

func (*Message) SetStartDelayTime

func (m *Message) SetStartDelayTime(startDelayTime int)

SetStartDelayTime sets the start delay time of the Message.

func (*Message) SetStaticCANID added in v0.6.0

func (m *Message) SetStaticCANID(canID CANID)

SetStaticCANID sets the static CAN-ID of the Message.

func (*Message) ShiftSignalLeft

func (m *Message) ShiftSignalLeft(signalEntityID EntityID, amount int) int

ShiftSignalLeft shifts the signal with the given entity id left by the given amount. It returns the amount of bits shifted.

func (*Message) ShiftSignalRight

func (m *Message) ShiftSignalRight(signalEntityID EntityID, amount int) int

ShiftSignalRight shifts the signal with the given entity id right by the given amount. It returns the amount of bits shifted.

func (*Message) SignalNames

func (m *Message) SignalNames() []string

SignalNames returns a slice of all signal names in the Message.

func (*Message) Signals

func (m *Message) Signals() []Signal

Signals returns a slice of all signals in the Message.

func (*Message) SizeByte

func (m *Message) SizeByte() int

SizeByte returns the size of the Message in bytes.

func (*Message) StartDelayTime

func (m *Message) StartDelayTime() int

StartDelayTime returns the message start delay time.

func (*Message) String

func (m *Message) String() string

func (*Message) UpdateID added in v0.6.0

func (m *Message) UpdateID(newID MessageID) error

UpdateID updates the id of the Message. It will also reset the static CAN-ID of the message.

It may return an error if the new message id is already used within a NodeInterface.

func (*Message) UpdateName

func (m *Message) UpdateName(newName string) error

UpdateName updates the name of the Message. It may return an error if the new name is already used within a node.

type MessageByteOrder added in v0.6.0

type MessageByteOrder int

MessageByteOrder rappresents the byte order of the payload of a Message. By default a MessageByteOrder of MessageByteOrderLittleEndian is used.

const (
	// MessageByteOrderLittleEndian defines a little endian byte order.
	MessageByteOrderLittleEndian MessageByteOrder = iota
	// MessageByteOrderBigEndian defines a big endian byte order.
	MessageByteOrderBigEndian
)

func (MessageByteOrder) String added in v0.7.0

func (mbo MessageByteOrder) String() string

type MessageID added in v0.6.0

type MessageID uint32

MessageID rappresents the ID of a Message. It must be unique within all the messages sended by a NodeInterface.

type MessageIDError

type MessageIDError struct {
	MessageID MessageID
	Err       error
}

MessageIDError is returned when a [MessageCANID] is invalid. The MessageID field is the message ID and the Err field is the cause.

func (*MessageIDError) Error

func (e *MessageIDError) Error() string

func (*MessageIDError) Unwrap

func (e *MessageIDError) Unwrap() error

type MessagePriority

type MessagePriority uint32

MessagePriority rappresents the priority of a Message. The priorities are very high, high, medium, and low. The higher priority has the value 0 and the lower has 3.

const (
	// MessagePriorityVeryHigh defines a very high priority.
	MessagePriorityVeryHigh MessagePriority = iota
	// MessagePriorityHigh defines an high priority.
	MessagePriorityHigh
	// MessagePriorityMedium defines a medium priority.
	MessagePriorityMedium
	// MessagePriorityLow defines a low priority.
	MessagePriorityLow
)

type MessageSendType

type MessageSendType int

MessageSendType rappresents the transition type of a Message.

const (
	// MessageSendTypeUnset defines an unset transmission type.
	MessageSendTypeUnset MessageSendType = iota
	// MessageSendTypeCyclic defines a cyclic transmission type.
	MessageSendTypeCyclic
	// MessageSendTypeCyclicIfActive defines a cyclic if active transmission type.
	MessageSendTypeCyclicIfActive
	// MessageSendTypeCyclicAndTriggered defines a cyclic and triggered transmission type.
	MessageSendTypeCyclicAndTriggered
	// MessageSendTypeCyclicIfActiveAndTriggered defines a cyclic if active and triggered transmission type.
	MessageSendTypeCyclicIfActiveAndTriggered
)

func (MessageSendType) String added in v0.6.0

func (mst MessageSendType) String() string

type MultiplexerSignal

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

MultiplexerSignal is a signal that holds groups of other signals that are selected/multiplexed by the value of the group id. It can multiplex all the kinds of signals (StandardSignal, EnumSignal, MultiplexerSignal), so it is possible to create multiple levels of multiplexing.

func NewMultiplexerSignal

func NewMultiplexerSignal(name string, groupCount, groupSize int) (*MultiplexerSignal, error)

NewMultiplexerSignal creates a new MultiplexerSignal with the given name, group count and group size. The group count defines the number of groups that the signal will hold and the group size defines the dimension in bits of each group.

It will return an ArgumentError if group count or group size is invalid.

func (*MultiplexerSignal) AssignAttribute added in v0.7.0

func (ms *MultiplexerSignal) AssignAttribute(attribute Attribute, value any) error

AssignAttribute assigns the given attribute/value pair to the MultiplexerSignal.

It returns an ArgumentError if the attribute is nil, or an AttributeValueError if the value does not conform to the attribute.

func (*MultiplexerSignal) ClearAllSignalGroups

func (ms *MultiplexerSignal) ClearAllSignalGroups()

ClearAllSignalGroups removes all signals from all groups.

func (*MultiplexerSignal) ClearSignalGroup

func (ms *MultiplexerSignal) ClearSignalGroup(groupID int) error

ClearSignalGroup removes all signals from a group with the given group ID.

It will return a GroupIDError if the given group ID is invalid.

func (MultiplexerSignal) GetAttributeAssignment added in v0.7.0

func (s MultiplexerSignal) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)

func (*MultiplexerSignal) GetGroupCountSize

func (ms *MultiplexerSignal) GetGroupCountSize() int

GetGroupCountSize returns the number of bits needed to select the right group.

func (*MultiplexerSignal) GetSignalGroup

func (ms *MultiplexerSignal) GetSignalGroup(groupID int) []Signal

GetSignalGroup returns a slice of signals present in the group selected by the given group ID. The signals are sorted by their start bit.

func (*MultiplexerSignal) GetSignalGroups

func (ms *MultiplexerSignal) GetSignalGroups() [][]Signal

GetSignalGroups returns a slice of groups sorted by their group ID. Each group contains a slice of signals sorted by their start bit.

func (*MultiplexerSignal) GetSize

func (ms *MultiplexerSignal) GetSize() int

GetSize returns the total size of the MultiplexerSignal. The returned value is the sum of the size of the groups and the number of bits needed to select the right group. e.g. with group count = 8 and group size = 16, the total size will be 3 + 16 = 19 bits, since 8 groups can be selected by 3 bits.

func (MultiplexerSignal) GetStartBit

func (s MultiplexerSignal) GetStartBit() int

func (*MultiplexerSignal) GroupCount

func (ms *MultiplexerSignal) GroupCount() int

GroupCount returns the number of groups.

func (*MultiplexerSignal) GroupSize

func (ms *MultiplexerSignal) GroupSize() int

GroupSize returns the size of a group.

func (*MultiplexerSignal) InsertSignal

func (ms *MultiplexerSignal) InsertSignal(signal Signal, startBit int, groupIDs ...int) error

InsertSignal inserts a Signal at the given start bit. If no group IDs are given, the signal will be considered as fixed and it will be inserted into all groups. If group IDs are given, the signal will be inserted into the given groups.

It will return an InsertSignalError if the signal cannot be inserted at the given start bit into the given group. This error can wrap:

func (MultiplexerSignal) Kind

func (s MultiplexerSignal) Kind() SignalKind

func (MultiplexerSignal) ParentMessage

func (s MultiplexerSignal) ParentMessage() *Message

func (MultiplexerSignal) ParentMultiplexerSignal

func (s MultiplexerSignal) ParentMultiplexerSignal() *MultiplexerSignal

func (MultiplexerSignal) RemoveAttributeAssignment added in v0.7.0

func (s MultiplexerSignal) RemoveAttributeAssignment(attributeEntityID EntityID) error

func (*MultiplexerSignal) RemoveSignal

func (ms *MultiplexerSignal) RemoveSignal(signalEntityID EntityID) error

RemoveSignal removes the Signal with the given entity ID.

It will return an RemoveEntityError if the signal cannot be removed.

func (MultiplexerSignal) SendType

func (s MultiplexerSignal) SendType() SignalSendType

func (MultiplexerSignal) SetSendType

func (s MultiplexerSignal) SetSendType(sendType SignalSendType)

func (MultiplexerSignal) SetStartValue added in v0.6.0

func (s MultiplexerSignal) SetStartValue(startValue int)

func (*MultiplexerSignal) ShiftSignalLeft

func (ms *MultiplexerSignal) ShiftSignalLeft(signalEntityID EntityID, amount int) int

ShiftSignalLeft shifts the Signal with the given entity ID left by the given amount and it returns the number of bits shifted. It will not shift signals that are fixed or assigned to more then one group.

func (*MultiplexerSignal) ShiftSignalRight

func (ms *MultiplexerSignal) ShiftSignalRight(signalEntityID EntityID, amount int) int

ShiftSignalRight shifts the Signal with the given entity ID right by the given amount and it returns the number of bits shifted. It will not shift signals that are fixed or assigned to more then one group.

func (MultiplexerSignal) StartValue added in v0.6.0

func (s MultiplexerSignal) StartValue() int

func (*MultiplexerSignal) String

func (ms *MultiplexerSignal) String() string

func (*MultiplexerSignal) ToEnum

func (ms *MultiplexerSignal) ToEnum() (*EnumSignal, error)

ToEnum always returns a ConversionError, since MultiplexerSignal cannot be converted to EnumSignal.

func (*MultiplexerSignal) ToMultiplexer

func (ms *MultiplexerSignal) ToMultiplexer() (*MultiplexerSignal, error)

ToMultiplexer always returns the MultiplexerSignal itself.

func (*MultiplexerSignal) ToStandard

func (ms *MultiplexerSignal) ToStandard() (*StandardSignal, error)

ToStandard always returns a ConversionError, since MultiplexerSignal cannot be converted to StandardSignal.

func (MultiplexerSignal) UpdateName

func (s MultiplexerSignal) UpdateName(newName string) error

type NameError

type NameError struct {
	Name string
	Err  error
}

NameError is returned when a name is invalid. The Name field is the name and the Err field is the cause.

func (*NameError) Error

func (e *NameError) Error() string

func (*NameError) Unwrap

func (e *NameError) Unwrap() error

type Network

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

Network is the highest level entity in the package. Its main purpose is to hold all buses belonging to the same network. For example, a car can be seen as a network with multiple buses that are serving different areas or ECUs in the vehicle.

func NewNetwork

func NewNetwork(name string) *Network

NewNetwork returns a new Network with the given name.

func (*Network) AddBus

func (n *Network) AddBus(bus *Bus) error

AddBus adds a Bus to the Network. It may return an error if the bus name is already taken.

func (*Network) Buses

func (n *Network) Buses() []*Bus

Buses returns a slice of all [Bus]es in the Network sorted by name.

func (Network) CreateTime

func (e Network) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (Network) Desc

func (e Network) Desc() string

Desc returns the description of the entity.

func (Network) EntityID

func (e Network) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (Network) EntityKind added in v0.7.0

func (e Network) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (Network) Name

func (e Network) Name() string

Name returns the name of the entity.

func (*Network) RemoveAllBuses

func (n *Network) RemoveAllBuses()

RemoveAllBuses removes all [Bus]es from the Network.

func (*Network) RemoveBus

func (n *Network) RemoveBus(busEntityID EntityID) error

RemoveBus removes a Bus that matches the given entity id from the Network. It may return an error if the bus with the given entity id is not part of the network.

func (Network) SetDesc

func (e Network) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*Network) String

func (n *Network) String() string

func (*Network) UpdateName

func (n *Network) UpdateName(newName string)

UpdateName updates the name of the Network.

type Node

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

Node is the representation of an ECU or an electronic component capable to send messages over a Bus through one or more NodeInterface. It holds a list of interfaces that can send messages on the bus.

func NewNode

func NewNode(name string, id NodeID, interfaceCount int) *Node

NewNode creates a new Node with the given name, id and count of interfaces. The id must be unique among all nodes within a bus.

func (*Node) AssignAttribute added in v0.7.0

func (n *Node) AssignAttribute(attribute Attribute, value any) error

AssignAttribute assigns the given attribute/value pair to the Node.

It returns an ArgumentError if the attribute is nil, or an AttributeValueError if the value does not conform to the attribute.

func (Node) AttributeAssignments added in v0.7.0

func (wa Node) AttributeAssignments() []*AttributeAssignment

AttributeAssignments returns a slice of all attribute assignments of the entity.

func (Node) CreateTime added in v0.7.0

func (e Node) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (Node) Desc added in v0.7.0

func (e Node) Desc() string

Desc returns the description of the entity.

func (Node) EntityID added in v0.7.0

func (e Node) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (Node) EntityKind added in v0.7.0

func (e Node) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (*Node) GetAttributeAssignment added in v0.7.0

func (n *Node) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)

GetAttributeAssignment returns the AttributeAssignment with the given attribute entity id from the Node.

It returns an ErrNotFound if the provided attribute entity id is not found.

func (*Node) ID

func (n *Node) ID() NodeID

ID returns the id of the Node.

func (*Node) Interfaces added in v0.6.0

func (n *Node) Interfaces() []*NodeInterface

Interfaces returns a slice with all the interfaces of the Node.

func (Node) Name added in v0.7.0

func (e Node) Name() string

Name returns the name of the entity.

func (Node) RemoveAllAttributeAssignments added in v0.7.0

func (wa Node) RemoveAllAttributeAssignments()

RemoveAllAttributeAssignments removes all the attribute assignments from the entity.

func (*Node) RemoveAttributeAssignment added in v0.7.0

func (n *Node) RemoveAttributeAssignment(attributeEntityID EntityID) error

RemoveAttributeAssignment removes the AttributeAssignment with the given attribute entity id from the Node.

It returns an ErrNotFound if the provided attribute entity id is not found.

func (Node) SetDesc added in v0.7.0

func (e Node) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*Node) String

func (n *Node) String() string

func (*Node) UpdateName

func (n *Node) UpdateName(newName string) error

UpdateName updates the name of the Node. By updating the name, also the name of the interfaces are updated.

It may return a NameError that wraps the cause of the error.

type NodeID

type NodeID uint32

NodeID is a unique identifier for a Node.

func (NodeID) String

func (nid NodeID) String() string

type NodeIDError

type NodeIDError struct {
	NodeID NodeID
	Err    error
}

NodeIDError is returned when a NodeID is invalid. The NodeID field is the node ID and the Err field is the cause.

func (*NodeIDError) Error

func (e *NodeIDError) Error() string

func (*NodeIDError) Unwrap

func (e *NodeIDError) Unwrap() error

type NodeInterface added in v0.6.0

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

NodeInterface represents an interface between a Bus and a Node.

func (*NodeInterface) AddMessage added in v0.6.0

func (ni *NodeInterface) AddMessage(message *Message) error

AddMessage adds a Message that the NodeInterface can send.

It returns an ArgumentError if the given message is nil or a NameError/MessageIDError if the message name/id is already used.

func (NodeInterface) CreateTime added in v0.6.0

func (e NodeInterface) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (NodeInterface) Desc added in v0.6.0

func (e NodeInterface) Desc() string

Desc returns the description of the entity.

func (NodeInterface) EntityID added in v0.6.0

func (e NodeInterface) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (NodeInterface) EntityKind added in v0.7.0

func (e NodeInterface) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (*NodeInterface) Messages added in v0.6.0

func (ni *NodeInterface) Messages() []*Message

Messages returns a slice of messages sended by the NodeInterface.

func (NodeInterface) Name added in v0.6.0

func (e NodeInterface) Name() string

Name returns the name of the entity.

func (*NodeInterface) Node added in v0.6.0

func (ni *NodeInterface) Node() *Node

Node returns the Node that owns the NodeInterface.

func (*NodeInterface) Number added in v0.6.0

func (ni *NodeInterface) Number() int

Number returns the number of the NodeInterface. The number is unique among all the interfaces within a Node and it cannot be manually assigned.

func (*NodeInterface) ParentBus added in v0.6.0

func (ni *NodeInterface) ParentBus() *Bus

ParentBus returns the Bus attached to the NodeInterface.

func (*NodeInterface) RemoveAllMessages added in v0.6.0

func (ni *NodeInterface) RemoveAllMessages()

RemoveAllMessages removes all the messages sent by the NodeInterface.

func (*NodeInterface) RemoveMessage added in v0.6.0

func (ni *NodeInterface) RemoveMessage(messageEntityID EntityID) error

RemoveMessage removes a Message sent by the NodeInterface.

It returns an ErrNotFound if the given entity id does not match any message.

func (NodeInterface) SetDesc added in v0.6.0

func (e NodeInterface) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*NodeInterface) String added in v0.6.0

func (ni *NodeInterface) String() string

type RemoveEntityError

type RemoveEntityError struct {
	EntityID EntityID
	Err      error
}

RemoveEntityError is returned when an entity cannot be removed. The EntityID field is the ID of the entity and the Err field is the cause.

func (*RemoveEntityError) Error

func (e *RemoveEntityError) Error() string

func (*RemoveEntityError) Unwrap

func (e *RemoveEntityError) Unwrap() error

type Signal

type Signal interface {

	// EntityID returns the entity id of the signal.
	EntityID() EntityID
	// EntityKind returns the entity kind of the signal.
	EntityKind() EntityKind
	// Name returns the name of the signal.
	Name() string
	// SetDesc stes the description of the signal.
	SetDesc(desc string)
	// Desc returns the description of the signal.
	Desc() string
	// CreateTime returns the creation time of the signal.
	CreateTime() time.Time

	// AssignAttribute assigns the given attribute/value pair to the signal.
	AssignAttribute(attribute Attribute, value any) error
	// RemoveAttributeAssignment removes the attribute assignment
	// with the given attribute entity id from the Signal.
	RemoveAttributeAssignment(attributeEntityID EntityID) error
	// RemoveAllAttributeAssignments removes all the attribute assignments from the signal.
	RemoveAllAttributeAssignments()
	// AttributeAssignments returns a slice of all attribute assignments of the signal.
	AttributeAssignments() []*AttributeAssignment
	// GetAttributeAssignment returns the attribute assignment
	// with the given attribute entity id from the signal.
	GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)

	String() string

	// Kind returns the kind of the signal.
	Kind() SignalKind

	// ParentMessage returns the parent message of the signal or nil if not set.
	ParentMessage() *Message
	// ParentMultiplexerSignal returns the parent multiplexer signal of the signal
	// or nil if not set.
	ParentMultiplexerSignal() *MultiplexerSignal

	// SetStartValue sets the initial raw value of the signal.
	SetStartValue(startValue int)
	// StartValue returns the initial raw value of the signal.
	StartValue() int
	// SetSendType sets the send type of the signal.
	SetSendType(sendType SignalSendType)
	// SendType returns the send type of the signal.
	SendType() SignalSendType

	// GetStartBit returns the start bit of the signal.
	GetStartBit() int

	// GetSize returns the size of the signal.
	GetSize() int

	// ToStandard returns the signal as a standard signal.
	ToStandard() (*StandardSignal, error)
	// ToEnum returns the signal as a enum signal.
	ToEnum() (*EnumSignal, error)
	// ToMultiplexer returns the signal as a multiplexer signal.
	ToMultiplexer() (*MultiplexerSignal, error)
	// contains filtered or unexported methods
}

Signal interface specifies all common methods of StandardSignal, EnumSignal, and [MultiplexerSignal1].

type SignalEnum

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

SignalEnum is the representation of an enum that can be assigned to a signal.

func NewSignalEnum

func NewSignalEnum(name string) *SignalEnum

NewSignalEnum creates a new SignalEnum with the given name.

func (*SignalEnum) AddValue

func (se *SignalEnum) AddValue(value *SignalEnumValue) error

AddValue adds the given SignalEnumValue to the SignalEnum. It may return an error if the value name is already in use within the signal enum, or if it has an invalid index.

func (SignalEnum) CreateTime

func (e SignalEnum) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (SignalEnum) Desc

func (e SignalEnum) Desc() string

Desc returns the description of the entity.

func (SignalEnum) EntityID

func (e SignalEnum) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (SignalEnum) EntityKind added in v0.7.0

func (e SignalEnum) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (*SignalEnum) GetSize

func (se *SignalEnum) GetSize() int

GetSize returns the size of the SignalEnum in bits.

func (*SignalEnum) MaxIndex

func (se *SignalEnum) MaxIndex() int

MaxIndex returns the highest index of the enum values of the SignalEnum.

func (*SignalEnum) MinSize

func (se *SignalEnum) MinSize() int

MinSize return the minimum size of the SignalEnum in bits.

func (SignalEnum) Name

func (e SignalEnum) Name() string

Name returns the name of the entity.

func (SignalEnum) ReferenceCount added in v0.6.0

func (t SignalEnum) ReferenceCount() int

func (SignalEnum) References added in v0.6.0

func (t SignalEnum) References() []R

func (*SignalEnum) RemoveAllValues

func (se *SignalEnum) RemoveAllValues()

RemoveAllValues removes all enum values from the SignalEnum.

func (*SignalEnum) RemoveValue

func (se *SignalEnum) RemoveValue(valueEntityID EntityID) error

RemoveValue removes the SignalEnumValue with the given entity id from the SignalEnum. It may return an error if the value with the given entity id is not found.

func (SignalEnum) SetDesc

func (e SignalEnum) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*SignalEnum) SetMinSize

func (se *SignalEnum) SetMinSize(minSize int)

SetMinSize sets the minimum size in bit of the SignalEnum. By defaul it is set to 1.

func (*SignalEnum) String

func (se *SignalEnum) String() string

func (*SignalEnum) UpdateName

func (se *SignalEnum) UpdateName(newName string)

UpdateName updates the name of the SignalEnum to the given new one.

func (*SignalEnum) Values

func (se *SignalEnum) Values() []*SignalEnumValue

Values returns a slice of all the enum values of the SignalEnum.

type SignalEnumValue

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

SignalEnumValue holds the key (name) and the value (index) of a signal enum entry.

func NewSignalEnumValue

func NewSignalEnumValue(name string, index int) *SignalEnumValue

NewSignalEnumValue creates a new SignalEnumValue with the given name and index.

func (SignalEnumValue) CreateTime

func (e SignalEnumValue) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (SignalEnumValue) Desc

func (e SignalEnumValue) Desc() string

Desc returns the description of the entity.

func (SignalEnumValue) EntityID

func (e SignalEnumValue) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (SignalEnumValue) EntityKind added in v0.7.0

func (e SignalEnumValue) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (*SignalEnumValue) Index

func (sev *SignalEnumValue) Index() int

Index returns the index of the SignalEnumValue.

func (SignalEnumValue) Name

func (e SignalEnumValue) Name() string

Name returns the name of the entity.

func (*SignalEnumValue) ParentEnum

func (sev *SignalEnumValue) ParentEnum() *SignalEnum

ParentEnum returns the parent SignalEnum of the SignalEnumValue, or nil if not set.

func (SignalEnumValue) SetDesc

func (e SignalEnumValue) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*SignalEnumValue) String

func (sev *SignalEnumValue) String() string

func (*SignalEnumValue) UpdateIndex

func (sev *SignalEnumValue) UpdateIndex(newIndex int) error

UpdateIndex updates the index of the SignalEnumValue to the given new one. It may return an error if the new index is invalid.

func (*SignalEnumValue) UpdateName

func (sev *SignalEnumValue) UpdateName(newName string) error

UpdateName updates the name of the SignalEnumValue to the given new one. It may return an error if the new name is already in use within the parent enum.

type SignalKind

type SignalKind int

SignalKind rappresents the kind of a Signal. It can be standard, enum, or multiplexer

const (
	// SignalKindStandard defines a standard signal.
	SignalKindStandard SignalKind = iota
	// SignalKindEnum defines a enum signal.
	SignalKindEnum
	// SignalKindMultiplexer defines a multiplexer signal.
	SignalKindMultiplexer
)

func (SignalKind) String added in v0.6.0

func (sk SignalKind) String() string

type SignalSendType

type SignalSendType int

SignalSendType rappresents the send type of a Signal.

const (
	// SignalSendTypeUnset defines an unset transmission type.
	SignalSendTypeUnset SignalSendType = iota
	// SignalSendTypeCyclic defines a cyclic transmission type.
	SignalSendTypeCyclic
	// SignalSendTypeOnWrite defines an on write transmission type.
	SignalSendTypeOnWrite
	// SignalSendTypeOnWriteWithRepetition defines an on write with repetition transmission type.
	SignalSendTypeOnWriteWithRepetition
	// SignalSendTypeOnChange defines an on change transmission type.
	SignalSendTypeOnChange
	// SignalSendTypeOnChangeWithRepetition defines an on change with repetition transmission type.
	SignalSendTypeOnChangeWithRepetition
	// SignalSendTypeIfActive defines an if active transmission type.
	SignalSendTypeIfActive
	// SignalSendTypeIfActiveWithRepetition defines an if active with repetition transmission type.
	SignalSendTypeIfActiveWithRepetition
)

func (SignalSendType) String added in v0.6.0

func (sst SignalSendType) String() string

type SignalSizeError

type SignalSizeError struct {
	Size int
	Err  error
}

SignalSizeError is returned when a signal size is invalid. The Size field is the size and the Err field is the cause.

func (*SignalSizeError) Error

func (e *SignalSizeError) Error() string

func (*SignalSizeError) Unwrap

func (e *SignalSizeError) Unwrap() error

type SignalType

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

SignalType is the representation of a signal type.

func NewCustomSignalType

func NewCustomSignalType(name string, size int, signed bool, min, max, scale, offset float64) (*SignalType, error)

NewCustomSignalType creates a new SignalType of kind SignalTypeKindCustom with the given name, size, signed, order, min/max values, scale, and offset. It may return an error if the size is negative.

func NewDecimalSignalType added in v0.7.0

func NewDecimalSignalType(name string, size int) (*SignalType, error)

NewDecimalSignalType creates a new SignalType of kind SignalTypeKindDecimal with the given name and size. It may return an error if the size is negative.

func NewFlagSignalType

func NewFlagSignalType(name string) *SignalType

NewFlagSignalType creates a new SignalType of kind SignalTypeKindFlag with the given name.

func NewIntegerSignalType

func NewIntegerSignalType(name string, size int, signed bool) (*SignalType, error)

NewIntegerSignalType creates a new SignalType of kind SignalTypeKindInteger with the given name, size, and signed. It may return an error if the size is negative.

func (SignalType) CreateTime

func (e SignalType) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (SignalType) Desc

func (e SignalType) Desc() string

Desc returns the description of the entity.

func (SignalType) EntityID

func (e SignalType) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (SignalType) EntityKind added in v0.7.0

func (e SignalType) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (*SignalType) Kind

func (st *SignalType) Kind() SignalTypeKind

Kind returns the kind of the SignalType.

func (*SignalType) Max

func (st *SignalType) Max() float64

Max returns the maximum value of the SignalType.

func (*SignalType) Min

func (st *SignalType) Min() float64

Min returns the minimum value of the SignalType.

func (SignalType) Name

func (e SignalType) Name() string

Name returns the name of the entity.

func (*SignalType) Offset added in v0.7.0

func (st *SignalType) Offset() float64

Offset returns the offset of the SignalType.

func (SignalType) ReferenceCount added in v0.6.0

func (t SignalType) ReferenceCount() int

func (SignalType) References added in v0.6.0

func (t SignalType) References() []R

func (*SignalType) Scale added in v0.7.0

func (st *SignalType) Scale() float64

Scale returns the scale of the SignalType.

func (SignalType) SetDesc

func (e SignalType) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*SignalType) SetMax added in v0.7.0

func (st *SignalType) SetMax(max float64)

SetMax sets the maximum value of the SignalType.

func (*SignalType) SetMin added in v0.7.0

func (st *SignalType) SetMin(min float64)

SetMin sets the minimum value of the SignalType.

func (*SignalType) SetOffset added in v0.7.0

func (st *SignalType) SetOffset(offset float64)

SetOffset sets the offset of the SignalType.

func (*SignalType) SetScale added in v0.7.0

func (st *SignalType) SetScale(scale float64)

SetScale sets the scale of the SignalType.

func (*SignalType) Signed

func (st *SignalType) Signed() bool

Signed returns whether the SignalType is signed.

func (*SignalType) Size

func (st *SignalType) Size() int

Size returns the size of the SignalType.

func (*SignalType) String

func (st *SignalType) String() string

type SignalTypeKind

type SignalTypeKind int

SignalTypeKind represents the kind of a SignalType.

const (
	// SignalTypeKindCustom defines a signal of type custom.
	SignalTypeKindCustom SignalTypeKind = iota
	// SignalTypeKindFlag defines a signal of type flag (1 bit).
	SignalTypeKindFlag
	// SignalTypeKindInteger defines a signal of type integer.
	SignalTypeKindInteger
	// SignalTypeKindDecimal defines a signal of type float.
	SignalTypeKindDecimal
)

func (SignalTypeKind) String added in v0.7.0

func (stk SignalTypeKind) String() string

type SignalUnit

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

SignalUnit is an entity that defines the physical unit of a Signal.

func NewSignalUnit

func NewSignalUnit(name string, kind SignalUnitKind, symbol string) *SignalUnit

NewSignalUnit creates a new SignalUnit with the given name, kind, and symbol.

func (SignalUnit) CreateTime

func (e SignalUnit) CreateTime() time.Time

CreateTime returns the time when the entity was created.

func (SignalUnit) Desc

func (e SignalUnit) Desc() string

Desc returns the description of the entity.

func (SignalUnit) EntityID

func (e SignalUnit) EntityID() EntityID

EntityID returns the unique identifier of the entity.

func (SignalUnit) EntityKind added in v0.7.0

func (e SignalUnit) EntityKind() EntityKind

EntityKind returns the kind of the entity.

func (*SignalUnit) Kind

func (su *SignalUnit) Kind() SignalUnitKind

Kind returns the kind of the SignalUnit.

func (SignalUnit) Name

func (e SignalUnit) Name() string

Name returns the name of the entity.

func (SignalUnit) ReferenceCount added in v0.6.0

func (t SignalUnit) ReferenceCount() int

func (SignalUnit) References added in v0.6.0

func (t SignalUnit) References() []R

func (SignalUnit) SetDesc

func (e SignalUnit) SetDesc(desc string)

SetDesc sets the description of the entity.

func (*SignalUnit) String

func (su *SignalUnit) String() string

func (*SignalUnit) Symbol

func (su *SignalUnit) Symbol() string

Symbol returns the symbol of the SignalUnit.

type SignalUnitKind

type SignalUnitKind int

SignalUnitKind defines the kind of a SignalUnit.

const (
	// SignalUnitKindCustom defines a custom unit.
	SignalUnitKindCustom SignalUnitKind = iota
	// SignalUnitKindTemperature defines a temperature unit.
	SignalUnitKindTemperature
	// SignalUnitKindElectrical defines an electrical unit.
	SignalUnitKindElectrical
	// SignalUnitKindPower defines a power unit.
	SignalUnitKindPower
)

func (SignalUnitKind) String added in v0.6.0

func (suk SignalUnitKind) String() string

type StandardSignal

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

StandardSignal is the representation of a normal signal that has a SignalType, a min, a max, an offset, a scale, and can have a SignalUnit.

func NewStandardSignal

func NewStandardSignal(name string, typ *SignalType) (*StandardSignal, error)

NewStandardSignal creates a new StandardSignal with the given name and SignalType. It may return an error if the given SignalType is nil.

func (*StandardSignal) AssignAttribute added in v0.7.0

func (ss *StandardSignal) AssignAttribute(attribute Attribute, value any) error

AssignAttribute assigns the given attribute/value pair to the StandardSignal.

It returns an ArgumentError if the attribute is nil, or an AttributeValueError if the value does not conform to the attribute.

func (StandardSignal) GetAttributeAssignment added in v0.7.0

func (s StandardSignal) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)

func (*StandardSignal) GetSize

func (ss *StandardSignal) GetSize() int

GetSize returns the size of the StandardSignal.

func (StandardSignal) GetStartBit

func (s StandardSignal) GetStartBit() int

func (StandardSignal) Kind

func (s StandardSignal) Kind() SignalKind

func (StandardSignal) ParentMessage

func (s StandardSignal) ParentMessage() *Message

func (StandardSignal) ParentMultiplexerSignal

func (s StandardSignal) ParentMultiplexerSignal() *MultiplexerSignal

func (StandardSignal) RemoveAttributeAssignment added in v0.7.0

func (s StandardSignal) RemoveAttributeAssignment(attributeEntityID EntityID) error

func (StandardSignal) SendType

func (s StandardSignal) SendType() SignalSendType

func (StandardSignal) SetSendType

func (s StandardSignal) SetSendType(sendType SignalSendType)

func (StandardSignal) SetStartValue added in v0.6.0

func (s StandardSignal) SetStartValue(startValue int)

func (*StandardSignal) SetType

func (ss *StandardSignal) SetType(typ *SignalType) error

SetType sets the SignalType of the StandardSignal. It resets the physical values. It may return an error if the given SignalType is nil, or if the new signal type size cannot fit in the message payload.

func (*StandardSignal) SetUnit

func (ss *StandardSignal) SetUnit(unit *SignalUnit)

SetUnit sets the SignalUnit of the StandardSignal to the given one.

func (StandardSignal) StartValue added in v0.6.0

func (s StandardSignal) StartValue() int

func (*StandardSignal) String

func (ss *StandardSignal) String() string

func (*StandardSignal) ToEnum

func (ss *StandardSignal) ToEnum() (*EnumSignal, error)

ToEnum always returns an error, because a StandardSignal cannot be converted to an EnumSignal.

func (*StandardSignal) ToMultiplexer

func (ss *StandardSignal) ToMultiplexer() (*MultiplexerSignal, error)

ToMultiplexer always returns an error, because a [StandardSigna] cannot be converted to a MultiplexerSignal.

func (*StandardSignal) ToStandard

func (ss *StandardSignal) ToStandard() (*StandardSignal, error)

ToStandard returns the StandardSignal itself.

func (*StandardSignal) Type

func (ss *StandardSignal) Type() *SignalType

Type returns the SignalType of the StandardSignal.

func (*StandardSignal) Unit

func (ss *StandardSignal) Unit() *SignalUnit

Unit returns the SignalUnit of the StandardSignal.

func (StandardSignal) UpdateName

func (s StandardSignal) UpdateName(newName string) error

type StartBitError

type StartBitError struct {
	StartBit int
	Err      error
}

StartBitError is returned when a start bit is invalid. The StartBit field is the start bit and the Err field is the cause.

func (*StartBitError) Error

func (e *StartBitError) Error() string

func (*StartBitError) Unwrap

func (e *StartBitError) Unwrap() error

type StringAttribute

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

StringAttribute is an Attribute that holds a string value.

func NewStringAttribute

func NewStringAttribute(name, defValue string) *StringAttribute

NewStringAttribute creates a new StringAttribute with the given name, and default value.

func (*StringAttribute) DefValue

func (sa *StringAttribute) DefValue() string

DefValue returns the default value of the StringAttribute.

func (*StringAttribute) String

func (sa *StringAttribute) String() string

func (*StringAttribute) ToEnum

func (sa *StringAttribute) ToEnum() (*EnumAttribute, error)

ToEnum always returns an error.

func (*StringAttribute) ToFloat

func (sa *StringAttribute) ToFloat() (*FloatAttribute, error)

ToFloat always returns an error.

func (*StringAttribute) ToInteger

func (sa *StringAttribute) ToInteger() (*IntegerAttribute, error)

ToInteger always returns an error.

func (*StringAttribute) ToString

func (sa *StringAttribute) ToString() (*StringAttribute, error)

ToString returns the StringAttribute itself.

func (StringAttribute) Type added in v0.7.0

func (a StringAttribute) Type() AttributeType

type UpdateIndexError

type UpdateIndexError struct {
	Err error
}

UpdateIndexError is returned when an index cannot be updated. The Err field is the cause.

func (*UpdateIndexError) Error

func (e *UpdateIndexError) Error() string

func (*UpdateIndexError) Unwrap

func (e *UpdateIndexError) Unwrap() error

type UpdateNameError

type UpdateNameError struct {
	Err error
}

UpdateNameError is returned when a name cannot be updated.

func (*UpdateNameError) Error

func (e *UpdateNameError) Error() string

func (*UpdateNameError) Unwrap

func (e *UpdateNameError) Unwrap() error

type ValueIndexError

type ValueIndexError struct {
	Index int
	Err   error
}

ValueIndexError is returned when a value index is invalid. The Index field is the index and the Err field is the cause.

func (*ValueIndexError) Error

func (e *ValueIndexError) Error() string

func (*ValueIndexError) Unwrap

func (e *ValueIndexError) Unwrap() error

Directories

Path Synopsis
Package dbc provides a [parser] and a [writer] for DBC files.
Package dbc provides a [parser] and a [writer] for DBC files.
examples
proto

Jump to

Keyboard shortcuts

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