Documentation ¶
Overview ¶
Package acmelib contains structures and methods for creating complex CAN (Controlled Area Network) networks.
Index ¶
- Variables
- func ExportBus(w io.Writer, bus *Bus)
- func ExportNetwork(network *Network, basePath string) error
- type AddEntityError
- type AppendSignalError
- type ArgumentError
- type Attribute
- type AttributeKind
- type AttributeRef
- type AttributeRefKind
- type AttributeValue
- type Bus
- func (ae Bus) AddAttributeValue(attribute Attribute, value any) error
- func (b *Bus) AddNode(node *Node) error
- func (ae Bus) AttributeValues() []*AttributeValue
- func (b *Bus) Baudrate() uint
- func (ae Bus) GetAttributeValue(attributeEntityID EntityID) (*AttributeValue, error)
- func (b *Bus) GetNodeByName(nodeName string) (*Node, error)
- func (b *Bus) Nodes() []*Node
- func (b *Bus) ParentNetwork() *Network
- func (ae Bus) RemoveAllAttributeValues()
- func (b *Bus) RemoveAllNodes()
- func (ae Bus) RemoveAttributeValue(attributeEntityID EntityID) error
- func (b *Bus) RemoveNode(nodeEntityID EntityID) error
- func (b *Bus) SetBaudrate(baudrate uint)
- func (b *Bus) String() string
- func (b *Bus) UpdateName(newName string) error
- type ConversionError
- type EntityError
- type EntityID
- type EntityKind
- type EnumAttribute
- func (ea *EnumAttribute) DefValue() string
- func (ea *EnumAttribute) GetValueAtIndex(valueIndex int) (string, error)
- func (a EnumAttribute) Kind() AttributeKind
- func (a EnumAttribute) References() []*AttributeRef
- func (ea *EnumAttribute) String() string
- func (ea *EnumAttribute) ToEnum() (*EnumAttribute, error)
- func (ea *EnumAttribute) ToFloat() (*FloatAttribute, error)
- func (ea *EnumAttribute) ToInteger() (*IntegerAttribute, error)
- func (ea *EnumAttribute) ToString() (*StringAttribute, error)
- func (ea *EnumAttribute) Values() []string
- type EnumSignal
- func (s EnumSignal) ByteOrder() SignalByteOrder
- func (es *EnumSignal) Enum() *SignalEnum
- func (es *EnumSignal) GetSize() int
- func (s EnumSignal) GetStartBit() int
- func (s EnumSignal) Kind() SignalKind
- func (s EnumSignal) ParentMessage() *Message
- func (s EnumSignal) ParentMultiplexerSignal() *MultiplexerSignal
- func (s EnumSignal) SendType() SignalSendType
- func (s EnumSignal) SetByteOrder(byteOrder SignalByteOrder)
- func (es *EnumSignal) SetEnum(enum *SignalEnum) error
- func (s EnumSignal) SetSendType(sendType SignalSendType)
- func (es *EnumSignal) String() string
- func (es *EnumSignal) ToEnum() (*EnumSignal, error)
- func (es *EnumSignal) ToMultiplexer() (*MultiplexerSignal, error)
- func (es *EnumSignal) ToStandard() (*StandardSignal, error)
- func (s EnumSignal) UpdateName(newName string) error
- type ErrGreaterThen
- type ErrIsRequired
- type ErrLowerThen
- type FloatAttribute
- func (fa *FloatAttribute) DefValue() float64
- func (a FloatAttribute) Kind() AttributeKind
- func (fa *FloatAttribute) Max() float64
- func (fa *FloatAttribute) Min() float64
- func (a FloatAttribute) References() []*AttributeRef
- func (fa *FloatAttribute) String() string
- func (fa *FloatAttribute) ToEnum() (*EnumAttribute, error)
- func (fa *FloatAttribute) ToFloat() (*FloatAttribute, error)
- func (fa *FloatAttribute) ToInteger() (*IntegerAttribute, error)
- func (fa *FloatAttribute) ToString() (*StringAttribute, error)
- type GetEntityError
- type GroupIDError
- type InsertSignalError
- type IntegerAttribute
- func (ia *IntegerAttribute) DefValue() int
- func (ia *IntegerAttribute) IsHexFormat() bool
- func (a IntegerAttribute) Kind() AttributeKind
- func (ia *IntegerAttribute) Max() int
- func (ia *IntegerAttribute) Min() int
- func (a IntegerAttribute) References() []*AttributeRef
- func (ia *IntegerAttribute) SetFormatHex()
- func (ia *IntegerAttribute) String() string
- func (ia *IntegerAttribute) ToEnum() (*EnumAttribute, error)
- func (ia *IntegerAttribute) ToFloat() (*FloatAttribute, error)
- func (ia *IntegerAttribute) ToInteger() (*IntegerAttribute, error)
- func (ia *IntegerAttribute) ToString() (*StringAttribute, error)
- type Message
- func (ae Message) AddAttributeValue(attribute Attribute, value any) error
- func (m *Message) AddReceiver(receiver *Node)
- func (m *Message) AppendSignal(signal Signal) error
- func (ae Message) AttributeValues() []*AttributeValue
- func (m *Message) CANID() MessageCANID
- func (m *Message) CompactSignals()
- func (m *Message) CycleTime() int
- func (m *Message) DelayTime() int
- func (ae Message) GetAttributeValue(attributeEntityID EntityID) (*AttributeValue, error)
- func (m *Message) GetSignal(signalEntityID EntityID) (Signal, error)
- func (m *Message) InsertSignal(signal Signal, startBit int) error
- func (m *Message) Priority() MessagePriority
- func (m *Message) Receivers() []*Node
- func (ae Message) RemoveAllAttributeValues()
- func (m *Message) RemoveAllSignals()
- func (ae Message) RemoveAttributeValue(attributeEntityID EntityID) error
- func (m *Message) RemoveReceiver(receiverEntityID EntityID)
- func (m *Message) RemoveSignal(signalEntityID EntityID) error
- func (m *Message) SendType() MessageSendType
- func (m *Message) SenderNode() *Node
- func (m *Message) SetCANID(messageCANID MessageCANID)
- func (m *Message) SetCANIDGeneratorFn(canIDGeneratorFn MessageCANIDGeneratorFn)
- func (m *Message) SetCycleTime(cycleTime int)
- func (m *Message) SetDelayTime(delayTime int)
- func (m *Message) SetPriority(priority MessagePriority)
- func (m *Message) SetSendType(sendType MessageSendType)
- func (m *Message) SetStartDelayTime(startDelayTime int)
- func (m *Message) ShiftSignalLeft(signalEntityID EntityID, amount int) int
- func (m *Message) ShiftSignalRight(signalEntityID EntityID, amount int) int
- func (m *Message) SignalNames() []string
- func (m *Message) Signals() []Signal
- func (m *Message) SizeByte() int
- func (m *Message) StartDelayTime() int
- func (m *Message) String() string
- func (m *Message) UpdateName(newName string) error
- type MessageCANID
- type MessageCANIDGeneratorFn
- type MessageIDError
- type MessagePriority
- type MessageSendType
- type MultiplexerSignal
- func (s MultiplexerSignal) ByteOrder() SignalByteOrder
- func (ms *MultiplexerSignal) ClearAllSignalGroups()
- func (ms *MultiplexerSignal) ClearSignalGroup(groupID int) error
- func (ms *MultiplexerSignal) GetGroupCountSize() int
- func (ms *MultiplexerSignal) GetSignalGroup(groupID int) []Signal
- func (ms *MultiplexerSignal) GetSignalGroups() [][]Signal
- func (ms *MultiplexerSignal) GetSize() int
- func (s MultiplexerSignal) GetStartBit() int
- func (ms *MultiplexerSignal) GroupCount() int
- func (ms *MultiplexerSignal) GroupSize() int
- func (ms *MultiplexerSignal) InsertSignal(signal Signal, startBit int, groupIDs ...int) error
- func (s MultiplexerSignal) Kind() SignalKind
- func (s MultiplexerSignal) ParentMessage() *Message
- func (s MultiplexerSignal) ParentMultiplexerSignal() *MultiplexerSignal
- func (ms *MultiplexerSignal) RemoveSignal(signalEntityID EntityID) error
- func (s MultiplexerSignal) SendType() SignalSendType
- func (s MultiplexerSignal) SetByteOrder(byteOrder SignalByteOrder)
- func (s MultiplexerSignal) SetSendType(sendType SignalSendType)
- func (ms *MultiplexerSignal) ShiftSignalLeft(signalEntityID EntityID, amount int) int
- func (ms *MultiplexerSignal) ShiftSignalRight(signalEntityID EntityID, amount int) int
- func (ms *MultiplexerSignal) String() string
- func (ms *MultiplexerSignal) ToEnum() (*EnumSignal, error)
- func (ms *MultiplexerSignal) ToMultiplexer() (*MultiplexerSignal, error)
- func (ms *MultiplexerSignal) ToStandard() (*StandardSignal, error)
- func (s MultiplexerSignal) UpdateName(newName string) error
- type NameError
- type Network
- func (n *Network) AddBus(bus *Bus) error
- func (n *Network) Buses() []*Bus
- func (e Network) CreateTime() time.Time
- func (e Network) Desc() string
- func (e Network) EntityID() EntityID
- func (e Network) Name() string
- func (n *Network) RemoveAllBuses()
- func (n *Network) RemoveBus(busEntityID EntityID) error
- func (e Network) SetDesc(desc string)
- func (n *Network) String() string
- func (n *Network) UpdateName(newName string)
- type Node
- func (ae Node) AddAttributeValue(attribute Attribute, value any) error
- func (n *Node) AddMessage(message *Message) error
- func (ae Node) AttributeValues() []*AttributeValue
- func (ae Node) GetAttributeValue(attributeEntityID EntityID) (*AttributeValue, error)
- func (n *Node) ID() NodeID
- func (n *Node) Messages() []*Message
- func (n *Node) ParentBuses() []*Bus
- func (ae Node) RemoveAllAttributeValues()
- func (n *Node) RemoveAllMessages()
- func (ae Node) RemoveAttributeValue(attributeEntityID EntityID) error
- func (n *Node) RemoveMessage(messageEntityID EntityID) error
- func (n *Node) String() string
- func (n *Node) UpdateName(newName string) error
- type NodeID
- type NodeIDError
- type RemoveEntityError
- type Signal
- type SignalByteOrder
- type SignalEnum
- func (se *SignalEnum) AddValue(value *SignalEnumValue) error
- func (e SignalEnum) CreateTime() time.Time
- func (e SignalEnum) Desc() string
- func (e SignalEnum) EntityID() EntityID
- func (se *SignalEnum) GetSize() int
- func (se *SignalEnum) MaxIndex() int
- func (se *SignalEnum) MinSize() int
- func (e SignalEnum) Name() string
- func (se *SignalEnum) RemoveAllValues()
- func (se *SignalEnum) RemoveValue(valueEntityID EntityID) error
- func (e SignalEnum) SetDesc(desc string)
- func (se *SignalEnum) SetMinSize(minSize int)
- func (se *SignalEnum) String() string
- func (se *SignalEnum) UpdateName(newName string)
- func (se *SignalEnum) Values() []*SignalEnumValue
- type SignalEnumValue
- func (e SignalEnumValue) CreateTime() time.Time
- func (e SignalEnumValue) Desc() string
- func (e SignalEnumValue) EntityID() EntityID
- func (sev *SignalEnumValue) Index() int
- func (e SignalEnumValue) Name() string
- func (sev *SignalEnumValue) ParentEnum() *SignalEnum
- func (e SignalEnumValue) SetDesc(desc string)
- func (sev *SignalEnumValue) String() string
- func (sev *SignalEnumValue) UpdateIndex(newIndex int) error
- func (sev *SignalEnumValue) UpdateName(newName string) error
- type SignalKind
- type SignalSendType
- type SignalSizeError
- type SignalType
- func (e SignalType) CreateTime() time.Time
- func (e SignalType) Desc() string
- func (e SignalType) EntityID() EntityID
- func (st *SignalType) Kind() SignalTypeKind
- func (st *SignalType) Max() float64
- func (st *SignalType) Min() float64
- func (e SignalType) Name() string
- func (e SignalType) SetDesc(desc string)
- func (st *SignalType) Signed() bool
- func (st *SignalType) Size() int
- func (st *SignalType) String() string
- type SignalTypeKind
- type SignalUnit
- func (e SignalUnit) CreateTime() time.Time
- func (e SignalUnit) Desc() string
- func (e SignalUnit) EntityID() EntityID
- func (su *SignalUnit) Kind() SignalUnitKind
- func (e SignalUnit) Name() string
- func (e SignalUnit) SetDesc(desc string)
- func (su *SignalUnit) String() string
- func (su *SignalUnit) Symbol() string
- type SignalUnitKind
- type StandardSignal
- func (s StandardSignal) ByteOrder() SignalByteOrder
- func (ss *StandardSignal) GetSize() int
- func (s StandardSignal) GetStartBit() int
- func (s StandardSignal) Kind() SignalKind
- func (ss *StandardSignal) Max() float64
- func (ss *StandardSignal) Min() float64
- func (ss *StandardSignal) Offset() float64
- func (s StandardSignal) ParentMessage() *Message
- func (s StandardSignal) ParentMultiplexerSignal() *MultiplexerSignal
- func (ss *StandardSignal) Scale() float64
- func (s StandardSignal) SendType() SignalSendType
- func (s StandardSignal) SetByteOrder(byteOrder SignalByteOrder)
- func (ss *StandardSignal) SetPhysicalValues(min, max, offset, scale float64) error
- func (s StandardSignal) SetSendType(sendType SignalSendType)
- func (ss *StandardSignal) SetType(typ *SignalType) error
- func (ss *StandardSignal) SetUnit(unit *SignalUnit)
- func (ss *StandardSignal) String() string
- func (ss *StandardSignal) ToEnum() (*EnumSignal, error)
- func (ss *StandardSignal) ToMultiplexer() (*MultiplexerSignal, error)
- func (ss *StandardSignal) ToStandard() (*StandardSignal, error)
- func (ss *StandardSignal) Type() *SignalType
- func (ss *StandardSignal) Unit() *SignalUnit
- func (s StandardSignal) UpdateName(newName string) error
- type StartBitError
- type StringAttribute
- func (sa *StringAttribute) DefValue() string
- func (a StringAttribute) Kind() AttributeKind
- func (a StringAttribute) References() []*AttributeRef
- func (sa *StringAttribute) String() string
- func (sa *StringAttribute) ToEnum() (*EnumAttribute, error)
- func (sa *StringAttribute) ToFloat() (*FloatAttribute, error)
- func (sa *StringAttribute) ToInteger() (*IntegerAttribute, error)
- func (sa *StringAttribute) ToString() (*StringAttribute, error)
- type UpdateIndexError
- type UpdateNameError
- type ValueIndexError
Constants ¶
This section is empty.
Variables ¶
var ErrIntersect = errors.New("is intersecting")
ErrIntersect is returned when two entities are intersecting.
var ErrInvalidType = errors.New("invalid type")
ErrInvalidType is returned when an invalid type is used.
var ErrIsDuplicated = errors.New("is duplicated")
ErrIsDuplicated is returned when an entity is duplicated.
var ErrIsNegative = errors.New("is negative")
ErrIsNegative is returned when a value is negative.
var ErrIsNil = errors.New("is nil")
ErrIsNil is returned when a value or entity is nil.
var ErrIsZero = errors.New("is zero")
ErrIsZero is returned when a value is zero.
var ErrNoSpaceLeft = errors.New("not enough space left")
ErrNoSpaceLeft is returned when there is not enough space left.
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when an entity is not found.
var ErrOutOfBounds = errors.New("out of bounds")
ErrOutOfBounds is returned when a value is out of bounds.
Functions ¶
Types ¶
type AddEntityError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *AddEntityError) Error() string
func (*AddEntityError) Unwrap ¶ added in v0.5.0
func (e *AddEntityError) Unwrap() error
type AppendSignalError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *AppendSignalError) Error() string
func (*AppendSignalError) Unwrap ¶ added in v0.5.0
func (e *AppendSignalError) Unwrap() error
type ArgumentError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *ArgumentError) Error() string
func (*ArgumentError) Unwrap ¶ added in v0.5.0
func (e *ArgumentError) Unwrap() error
type Attribute ¶
type Attribute interface { // EntityID returns the entity id of an attribute. EntityID() EntityID // Name returns the name of an attribute. Name() string // Desc returns the description of an attribute. Desc() string // CreateTime returns the time of creation of an attribute. CreateTime() time.Time // Kind returns the kind of an attribute. Kind() AttributeKind // References returns a slice of references of an attribute. References() []*AttributeRef 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 AttributeKind ¶
type AttributeKind string
AttributeKind defines the kind of an Attribute.
const ( // AttributeKindString defines a string attribute. AttributeKindString AttributeKind = "attribute-string" // AttributeKindInteger defines an integer attribute. AttributeKindInteger AttributeKind = "attribute-integer" // AttributeKindFloat defines a float attribute. AttributeKindFloat AttributeKind = "attribute-float" // AttributeKindEnum defines an enum attribute. AttributeKindEnum AttributeKind = "attribute-enum" )
type AttributeRef ¶
type AttributeRef struct {
// contains filtered or unexported fields
}
AttributeRef connects an Attribute to an entity and the value the latter has associated to the former. It is useful to connect an attribute to the entities that are using it.
func (*AttributeRef) EntityID ¶
func (af *AttributeRef) EntityID() EntityID
EntityID returns the entity id of the AttributeRef
func (*AttributeRef) Kind ¶
func (af *AttributeRef) Kind() AttributeRefKind
Kind returns the kind of the AttributeRef
func (*AttributeRef) Value ¶
func (af *AttributeRef) Value() any
Value returns the value of the AttributeRef
type AttributeRefKind ¶
type AttributeRefKind string
AttributeRefKind defines the kind of an AttributeRef.
const ( // AttributeRefKindBus defines a bus reference. AttributeRefKindBus AttributeRefKind = "attribute_ref-bus" // AttributeRefKindNode defines a node reference. AttributeRefKindNode AttributeRefKind = "attribute_ref-node" // AttributeRefKindMessage defines a message reference. AttributeRefKindMessage AttributeRefKind = "attribute_ref-message" // AttributeRefKindSignal defines a signal reference. AttributeRefKindSignal AttributeRefKind = "attribute_ref-signal" )
type AttributeValue ¶
type AttributeValue struct {
// contains filtered or unexported fields
}
AttributeValue connects a general Attribute to the value associated by an entity.
func (*AttributeValue) Attribute ¶
func (av *AttributeValue) Attribute() Attribute
Attribute returns the Attribute of the AttributeValue.
func (*AttributeValue) Value ¶
func (av *AttributeValue) Value() any
Value returns the value of the AttributeValue.
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 ¶ added in v0.5.0
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 (Bus) AddAttributeValue ¶
AddAttributeValue adds an Attribute to the entity and it assign the given value to it. It may return an error if the given value is not valid for the given Attribute.
func (*Bus) AddNode ¶
AddNode adds the given Node to the Bus. It may return an error if the node name or the node id is already used by the bus.
func (Bus) AttributeValues ¶
func (ae Bus) AttributeValues() []*AttributeValue
AttributeValues returns slice of all the attributes of the entity.
func (Bus) GetAttributeValue ¶
func (ae Bus) GetAttributeValue(attributeEntityID EntityID) (*AttributeValue, error)
GetAttributeValue returns the Attribute with the given entity id from the entity. It may return an error if the attribute with the given entity id does not exist in the entity.
func (*Bus) GetNodeByName ¶ added in v0.4.0
GetNodeByName returns the Node with the given name from the Bus. It may return an error if the node with the given name is not part of the bus.
func (*Bus) ParentNetwork ¶
ParentNetwork returns the Network that the Bus is part of. If the Bus is not part of a Network, it returns nil.
func (Bus) RemoveAllAttributeValues ¶
func (ae Bus) RemoveAllAttributeValues()
RemoveAllAttributeValues removes all [Attributes] from the entity.
func (*Bus) RemoveAllNodes ¶
func (b *Bus) RemoveAllNodes()
RemoveAllNodes removes all nodes from the Bus.
func (Bus) RemoveAttributeValue ¶
RemoveAttributeValue removes an Attribute with the given entity id from the entity. It also removes the reference to the entity from the attribute. It may return an error if the attribute with the given entity id does not exist in the entity.
func (*Bus) RemoveNode ¶
RemoveNode removes a Node that matches the given entity id from the Bus. It may return an error if the node with the given entity id is not part of the bus.
func (*Bus) SetBaudrate ¶
SetBaudrate sets the baudrate of the Bus.
type ConversionError ¶ added in v0.5.1
ConversionError is returned when a signal cannot be converted.
func (*ConversionError) Error ¶ added in v0.5.1
func (e *ConversionError) Error() string
type EntityError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *EntityError) Error() string
func (*EntityError) Unwrap ¶ added in v0.5.0
func (e *EntityError) Unwrap() error
type EntityID ¶
type EntityID string
EntityID is the unique identifier of an entity. Entities are:
- networks
- buses
- nodes
- messages
- signals
- signal types
- signal enums
- signal enum values
- signal units
- attributes
type EntityKind ¶ added in v0.5.0
type EntityKind string
EntityKind is the kind of an entity.
const ( // EntityKindNetwork represents a [Network] entity. EntityKindNetwork EntityKind = "network" // EntityKindBus represents a [Bus] entity. EntityKindBus EntityKind = "bus" // EntityKindNode represents a [Node] entity. EntityKindNode EntityKind = "node" // EntityKindMessage represents a [Message] entity. EntityKindMessage EntityKind = "message" // EntityKindSignal represents a [Signal] entity. EntityKindSignal EntityKind = "signal" // EntityKindSignalType represents a [SignalType] entity. EntityKindSignalType EntityKind = "signal_type" // EntityKindSignalEnum represents a [SignalEnum] entity. EntityKindSignalEnum EntityKind = "signal_enum" // EntityKindSignalEnumValue represents a [SignalEnumValue] entity. EntityKindSignalEnumValue EntityKind = "signal_enum_value" // EntityKindSignalUnit represents a [SignalUnit] entity. EntityKindSignalUnit EntityKind = "signal_unit" // EntityKindAttribute represents a [Attribute] entity. EntityKindAttribute EntityKind = "attribute" )
func (EntityKind) String ¶ added in v0.5.0
func (k 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) Kind ¶
func (a EnumAttribute) Kind() AttributeKind
func (EnumAttribute) References ¶
func (a EnumAttribute) References() []*AttributeRef
func (*EnumAttribute) String ¶ added in v0.3.0
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) 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) ByteOrder ¶ added in v0.5.0
func (s EnumSignal) ByteOrder() SignalByteOrder
func (*EnumSignal) Enum ¶
func (es *EnumSignal) Enum() *SignalEnum
Enum returns the SignalEnum of the EnumSignal.
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 ¶ added in v0.5.0
func (s EnumSignal) ParentMessage() *Message
func (EnumSignal) ParentMultiplexerSignal ¶ added in v0.5.0
func (s EnumSignal) ParentMultiplexerSignal() *MultiplexerSignal
func (EnumSignal) SendType ¶ added in v0.5.0
func (s EnumSignal) SendType() SignalSendType
func (EnumSignal) SetByteOrder ¶ added in v0.5.0
func (s EnumSignal) SetByteOrder(byteOrder SignalByteOrder)
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 ¶ added in v0.5.0
func (s EnumSignal) SetSendType(sendType SignalSendType)
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 ¶
type ErrGreaterThen ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *ErrGreaterThen) Error() string
type ErrIsRequired ¶ added in v0.5.0
type ErrIsRequired struct {
Thing string
}
ErrIsRequired is returned when something is required. The Thing field is what is required.
func (*ErrIsRequired) Error ¶ added in v0.5.0
func (e *ErrIsRequired) Error() string
type ErrLowerThen ¶ added in v0.5.0
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 ¶ added in v0.5.0
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) Kind ¶
func (a FloatAttribute) Kind() AttributeKind
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) References ¶
func (a FloatAttribute) References() []*AttributeRef
func (*FloatAttribute) String ¶ added in v0.3.0
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.
type GetEntityError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *GetEntityError) Error() string
func (*GetEntityError) Unwrap ¶ added in v0.5.0
func (e *GetEntityError) Unwrap() error
type GroupIDError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *GroupIDError) Error() string
func (*GroupIDError) Unwrap ¶ added in v0.5.0
func (e *GroupIDError) Unwrap() error
type InsertSignalError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *InsertSignalError) Error() string
func (*InsertSignalError) Unwrap ¶ added in v0.5.0
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) Kind ¶
func (a IntegerAttribute) Kind() AttributeKind
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) References ¶
func (a IntegerAttribute) References() []*AttributeRef
func (*IntegerAttribute) SetFormatHex ¶
func (ia *IntegerAttribute) SetFormatHex()
SetFormatHex sets the format of the IntegerAttribute to hex.
func (*IntegerAttribute) String ¶ added in v0.3.0
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.
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 ¶
NewMessage creates a new Message with the given name and size in bytes. By default a MessagePriority of MessagePriorityVeryHigh is used.
func (Message) AddAttributeValue ¶
AddAttributeValue adds an Attribute to the entity and it assign the given value to it. It may return an error if the given value is not valid for the given Attribute.
func (*Message) AddReceiver ¶
func (*Message) AppendSignal ¶
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) AttributeValues ¶
func (ae Message) AttributeValues() []*AttributeValue
AttributeValues returns slice of all the attributes of the entity.
func (*Message) CANID ¶ added in v0.5.0
func (m *Message) CANID() MessageCANID
CANID returns the message CAN id.
func (*Message) CompactSignals ¶
func (m *Message) CompactSignals()
CompactSignals compacts the Message payload.
func (Message) GetAttributeValue ¶
func (ae Message) GetAttributeValue(attributeEntityID EntityID) (*AttributeValue, error)
GetAttributeValue returns the Attribute with the given entity id from the entity. It may return an error if the attribute with the given entity id does not exist in the entity.
func (*Message) InsertSignal ¶
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) Priority ¶
func (m *Message) Priority() MessagePriority
Priority returns the message priority.
func (Message) RemoveAllAttributeValues ¶
func (ae Message) RemoveAllAttributeValues()
RemoveAllAttributeValues removes all [Attributes] from the entity.
func (*Message) RemoveAllSignals ¶
func (m *Message) RemoveAllSignals()
RemoveAllSignals removes all signals from the Message.
func (Message) RemoveAttributeValue ¶
RemoveAttributeValue removes an Attribute with the given entity id from the entity. It also removes the reference to the entity from the attribute. It may return an error if the attribute with the given entity id does not exist in the entity.
func (*Message) RemoveReceiver ¶
func (*Message) RemoveSignal ¶
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 ¶ added in v0.4.0
func (m *Message) SendType() MessageSendType
SendType returns the message send type.
func (*Message) SenderNode ¶ added in v0.3.0
SenderNode returns the Node that sends the Message. It returns nil if the message is not added to a node.
func (*Message) SetCANID ¶ added in v0.5.0
func (m *Message) SetCANID(messageCANID MessageCANID)
SetCANID sets the message CAN id. When the id is set in this way, the id generator function is not used anymore.
func (*Message) SetCANIDGeneratorFn ¶ added in v0.5.0
func (m *Message) SetCANIDGeneratorFn(canIDGeneratorFn MessageCANIDGeneratorFn)
SetCANIDGeneratorFn sets the message CAN id generator function.
func (*Message) SetCycleTime ¶
SetCycleTime sets the message cycle time.
func (*Message) SetDelayTime ¶ added in v0.4.0
SetDelayTime sets the delay time of the Message.
func (*Message) SetPriority ¶
func (m *Message) SetPriority(priority MessagePriority)
SetPriority sets the message priority.
func (*Message) SetSendType ¶ added in v0.4.0
func (m *Message) SetSendType(sendType MessageSendType)
SetSendType sets the send type of the Message.
func (*Message) SetStartDelayTime ¶ added in v0.4.0
SetStartDelayTime sets the start delay time of the Message.
func (*Message) ShiftSignalLeft ¶
ShiftSignalLeft shifts the signal with the given entity id left by the given amount. It returns the amount of bits shifted.
func (*Message) ShiftSignalRight ¶
ShiftSignalRight shifts the signal with the given entity id right by the given amount. It returns the amount of bits shifted.
func (*Message) SignalNames ¶
SignalNames returns a slice of all signal names in the Message.
func (*Message) StartDelayTime ¶ added in v0.4.0
StartDelayTime returns the message start delay time.
type MessageCANID ¶ added in v0.5.0
type MessageCANID uint32
MessageCANID is the bus unique identifier of a Message. By default 11 bits ids are used.
func (MessageCANID) String ¶ added in v0.5.0
func (id MessageCANID) String() string
type MessageCANIDGeneratorFn ¶ added in v0.5.0
type MessageCANIDGeneratorFn func(priority MessagePriority, messageID int, nodeID NodeID) (messageCANID MessageCANID)
MessageCANIDGeneratorFn is callback used for generating automatically the MessageCANID of a Message. It is triggered when a Message is added to a Node or when the former is removed. It takes as prameters the priority of the message, the number of messages sended by the node, and the node id, then it returns the computed message id. By default the messages calculate their 11 bit ids by putting the node id in the 4 lsb, the message id (the nth message sent by the node) from bit 4 to 9, and the priority in the 2 msb.
type MessageIDError ¶ added in v0.5.0
type MessageIDError struct { MessageID MessageCANID 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 ¶ added in v0.5.0
func (e *MessageIDError) Error() string
func (*MessageIDError) Unwrap ¶ added in v0.5.0
func (e *MessageIDError) Unwrap() error
type MessagePriority ¶
type MessagePriority uint
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 ¶ added in v0.4.0
type MessageSendType string
MessageSendType rappresents the transition type of a Message.
const ( // MessageSendTypeUnset defines an unset transmission type. MessageSendTypeUnset MessageSendType = "NoMsgSendType" // MessageSendTypeCyclic defines a cyclic transmission type. MessageSendTypeCyclic MessageSendType = "Cyclic" // MessageSendTypeCyclicIfActive defines a cyclic if active transmission type. MessageSendTypeCyclicIfActive MessageSendType = "CyclicIfActive" // MessageSendTypeCyclicAndTriggered defines a cyclic and triggered transmission type. MessageSendTypeCyclicAndTriggered MessageSendType = "CyclicAndTriggered" // MessageSendTypeCyclicIfActiveAndTriggered defines a cyclic if active and triggered transmission type. MessageSendTypeCyclicIfActiveAndTriggered MessageSendType = "CyclicIfActiveAndTriggered" )
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) ByteOrder ¶ added in v0.5.0
func (s MultiplexerSignal) ByteOrder() SignalByteOrder
func (*MultiplexerSignal) ClearAllSignalGroups ¶ added in v0.5.0
func (ms *MultiplexerSignal) ClearAllSignalGroups()
ClearAllSignalGroups removes all signals from all groups.
func (*MultiplexerSignal) ClearSignalGroup ¶ added in v0.5.0
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) GetGroupCountSize ¶ added in v0.5.0
func (ms *MultiplexerSignal) GetGroupCountSize() int
GetGroupCountSize returns the number of bits needed to select the right group.
func (*MultiplexerSignal) GetSignalGroup ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (ms *MultiplexerSignal) GroupCount() int
GroupCount returns the number of groups.
func (*MultiplexerSignal) GroupSize ¶ added in v0.5.0
func (ms *MultiplexerSignal) GroupSize() int
GroupSize returns the size of a group.
func (*MultiplexerSignal) InsertSignal ¶ added in v0.5.0
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:
- NameError in case of an invalid signal name
- StartBitError in case of an invalid start bit
- GroupIDError in case of an invalid group ID
func (MultiplexerSignal) Kind ¶
func (s MultiplexerSignal) Kind() SignalKind
func (MultiplexerSignal) ParentMessage ¶ added in v0.5.0
func (s MultiplexerSignal) ParentMessage() *Message
func (MultiplexerSignal) ParentMultiplexerSignal ¶ added in v0.5.0
func (s MultiplexerSignal) ParentMultiplexerSignal() *MultiplexerSignal
func (*MultiplexerSignal) RemoveSignal ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (s MultiplexerSignal) SendType() SignalSendType
func (MultiplexerSignal) SetByteOrder ¶ added in v0.5.0
func (s MultiplexerSignal) SetByteOrder(byteOrder SignalByteOrder)
func (MultiplexerSignal) SetSendType ¶ added in v0.5.0
func (s MultiplexerSignal) SetSendType(sendType SignalSendType)
func (*MultiplexerSignal) ShiftSignalLeft ¶ added in v0.5.0
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 ¶ added in v0.5.0
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) 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 ¶
type NameError ¶ added in v0.5.0
NameError is returned when a name is invalid. The Name field is the name and the Err field is the cause.
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 ¶
NewNetwork returns a new Network with the given name.
func (*Network) AddBus ¶
AddBus adds a Bus to the Network. It may return an error if the bus name is already taken.
func (Network) CreateTime ¶
CreateTime returns the time when the entity was created.
func (Network) EntityID ¶
func (e Network) EntityID() EntityID
EntityID returns the unique identifier of the entity.
func (*Network) RemoveAllBuses ¶
func (n *Network) RemoveAllBuses()
RemoveAllBuses removes all [Bus]es from the Network.
func (*Network) RemoveBus ¶
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 ¶ added in v0.3.0
func (e Network) SetDesc(desc string)
SetDesc sets the description of the entity.
func (*Network) UpdateName ¶
UpdateName updates the name of the Network.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is the representation of an ECU. It holds a list of messages which are sent to other nodes thought the bus. A node can be assigned to more then 1 bus.
func NewNode ¶
NewNode creates a new Node with the given name and id. The id must be unique among all nodes within a bus.
func (Node) AddAttributeValue ¶
AddAttributeValue adds an Attribute to the entity and it assign the given value to it. It may return an error if the given value is not valid for the given Attribute.
func (*Node) AddMessage ¶
AddMessage adds a Message to the Node. This means that the given message will be sent by the node. It may return an error if the message name or the message id is already used by the node.
func (Node) AttributeValues ¶
func (ae Node) AttributeValues() []*AttributeValue
AttributeValues returns slice of all the attributes of the entity.
func (Node) GetAttributeValue ¶
func (ae Node) GetAttributeValue(attributeEntityID EntityID) (*AttributeValue, error)
GetAttributeValue returns the Attribute with the given entity id from the entity. It may return an error if the attribute with the given entity id does not exist in the entity.
func (*Node) Messages ¶
Messages returns a slice of messages that the Node sends sorted by message id.
func (*Node) ParentBuses ¶
ParentBuses returns a slice of [Bus]es that the Node is part of.
func (Node) RemoveAllAttributeValues ¶
func (ae Node) RemoveAllAttributeValues()
RemoveAllAttributeValues removes all [Attributes] from the entity.
func (*Node) RemoveAllMessages ¶
func (n *Node) RemoveAllMessages()
RemoveAllMessages removes all messages from the Node.
func (Node) RemoveAttributeValue ¶
RemoveAttributeValue removes an Attribute with the given entity id from the entity. It also removes the reference to the entity from the attribute. It may return an error if the attribute with the given entity id does not exist in the entity.
func (*Node) RemoveMessage ¶
RemoveMessage removes a Message that matches the given entity id from the Node. It may return an error if the message with the given entity id is not sent by the node.
type NodeID ¶
type NodeID uint32
NodeID is a unique identifier for a node. It must be manually assigned by the user.
type NodeIDError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *NodeIDError) Error() string
func (*NodeIDError) Unwrap ¶ added in v0.5.0
func (e *NodeIDError) Unwrap() error
type RemoveEntityError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *RemoveEntityError) Error() string
func (*RemoveEntityError) Unwrap ¶ added in v0.5.0
func (e *RemoveEntityError) Unwrap() error
type Signal ¶
type Signal interface { // EntityID returns the entity id of the signal. EntityID() EntityID // 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 // AddAttributeValue adds to the signal an attribute and its value. AddAttributeValue(attribute Attribute, value any) error // RemoveAttributeValue removes from the signal an attribute and its value. RemoveAttributeValue(attributeEntityID EntityID) error // RemoveAllAttributeValues removes all attribute and their values from the signal. RemoveAllAttributeValues() // AttributeValues returns all attribute and their values from the signal. AttributeValues() []*AttributeValue // GetAttributeValue returns the value of an attribute and its value from the signal. GetAttributeValue(attributeEntityID EntityID) (*AttributeValue, 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 // SetByteOrder sets the byte order of the signal. // By default it is set to little endian. SetByteOrder(byteOrder SignalByteOrder) // ByteOrder returns the byte order of the signal. ByteOrder() SignalByteOrder // 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 SignalByteOrder ¶ added in v0.5.0
type SignalByteOrder string
SignalByteOrder represents the byte order of a Signal.
const ( // SignalByteOrderLittleEndian defines a little endian byte order. SignalByteOrderLittleEndian SignalByteOrder = "signal_byte_order-little_endian" // SignalByteOrderBigEndian defines a big endian byte order. SignalByteOrderBigEndian SignalByteOrder = "signal_byte_order-big_endian" )
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 ¶
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) 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 ¶ added in v0.3.0
func (se *SignalEnum) MinSize() int
MinSize return the minimum size of the SignalEnum in bits.
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 ¶ added in v0.3.0
func (e SignalEnum) SetDesc(desc string)
SetDesc sets the description of the entity.
func (*SignalEnum) SetMinSize ¶ added in v0.3.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶
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) 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 ¶ added in v0.3.0
func (e SignalEnumValue) SetDesc(desc string)
SetDesc sets the description of the entity.
func (*SignalEnumValue) String ¶ added in v0.2.0
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 string
SignalKind rappresents the kind of a Signal. It can be standard, enum, or multiplexer
const ( // SignalKindStandard defines a standard signal. SignalKindStandard SignalKind = "signal-standard" // SignalKindEnum defines a enum signal. SignalKindEnum SignalKind = "signal-enum" // SignalKindMultiplexer defines a multiplexer signal. SignalKindMultiplexer SignalKind = "signal-multiplexer" )
type SignalSendType ¶ added in v0.5.0
type SignalSendType string
SignalSendType rappresents the send type of a Signal.
const ( // SignalSendTypeUnset defines an unset transmission type. SignalSendTypeUnset SignalSendType = "NoSigSendType" // SignalSendTypeCyclic defines a cyclic transmission type. SignalSendTypeCyclic SignalSendType = "Cyclic" // SignalSendTypeOnWrite defines an on write transmission type. SignalSendTypeOnWrite SignalSendType = "OnWrite" // SignalSendTypeOnWriteWithRepetition defines an on write with repetition transmission type. SignalSendTypeOnWriteWithRepetition SignalSendType = "OnWriteWithRepetition" // SignalSendTypeOnChange defines an on change transmission type. SignalSendTypeOnChange SignalSendType = "OnChange" // SignalSendTypeOnChangeWithRepetition defines an on change with repetition transmission type. SignalSendTypeOnChangeWithRepetition SignalSendType = "OnChangeWithRepetition" // SignalSendTypeIfActive defines an if active transmission type. SignalSendTypeIfActive SignalSendType = "IfActive" // SignalSendTypeIfActiveWithRepetition defines an if active with repetition transmission type. SignalSendTypeIfActiveWithRepetition SignalSendType = "IfActiveWithRepetition" )
type SignalSizeError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *SignalSizeError) Error() string
func (*SignalSizeError) Unwrap ¶ added in v0.5.0
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 ¶
NewCustomSignalType creates a new SignalType of kind SignalTypeKindCustom with the given name, size, signed, order, and min/max values. 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. The order is set to little endian.
func NewFloatSignalType ¶
func NewFloatSignalType(name string, size int) (*SignalType, error)
NewFloatSignalType creates a new SignalType of kind SignalTypeKindFloat with the given name and size. The order is set to little endian. It may return an error if the size is negative.
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. The order is set to little endian. It may return an error if the size is negative.
func (SignalType) CreateTime ¶
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) 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) SetDesc ¶ added in v0.3.0
func (e SignalType) SetDesc(desc string)
SetDesc sets the description of the entity.
func (*SignalType) Signed ¶
func (st *SignalType) Signed() bool
Signed returns whether the SignalType is signed.
func (*SignalType) String ¶ added in v0.2.0
func (st *SignalType) String() string
type SignalTypeKind ¶
type SignalTypeKind string
SignalTypeKind represents the kind of a SignalType.
const ( // SignalTypeKindCustom defines a signal of type custom. SignalTypeKindCustom SignalTypeKind = "signal_type-custom" // SignalTypeKindFlag defines a signal of type flag (1 bit). SignalTypeKindFlag SignalTypeKind = "signal_type-flag" // SignalTypeKindInteger defines a signal of type integer. SignalTypeKindInteger SignalTypeKind = "signal_type-integer" // SignalTypeKindFloat defines a signal of type float. SignalTypeKindFloat SignalTypeKind = "signal_type-float" )
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 ¶
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) Kind ¶
func (su *SignalUnit) Kind() SignalUnitKind
Kind returns the kind of the SignalUnit.
func (SignalUnit) SetDesc ¶ added in v0.3.0
func (e SignalUnit) SetDesc(desc string)
SetDesc sets the description of the entity.
func (*SignalUnit) String ¶ added in v0.2.0
func (su *SignalUnit) String() string
func (*SignalUnit) Symbol ¶
func (su *SignalUnit) Symbol() string
Symbol returns the symbol of the SignalUnit.
type SignalUnitKind ¶
type SignalUnitKind string
SignalUnitKind defines the kind of a SignalUnit.
const ( // SignalUnitKindCustom defines a custom unit. SignalUnitKindCustom SignalUnitKind = "signal_unit-custom" // SignalUnitKindTemperature defines a temperature unit. SignalUnitKindTemperature SignalUnitKind = "signal_unit-temperature" // SignalUnitKindElectrical defines an electrical unit. SignalUnitKindElectrical SignalUnitKind = "signal_unit-electrical" // SignalUnitKindPower defines a power unit. SignalUnitKindPower SignalUnitKind = "signal_unit-power" )
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) ByteOrder ¶ added in v0.5.0
func (s StandardSignal) ByteOrder() SignalByteOrder
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) Max ¶
func (ss *StandardSignal) Max() float64
Max returns the maximum value of the StandardSignal. It may differ from the maximum value of the signal type associated with the StandardSignal.
func (*StandardSignal) Min ¶
func (ss *StandardSignal) Min() float64
Min returns the minimum value of the StandardSignal. It may differ from the minimum value of the signal type associated with the StandardSignal.
func (*StandardSignal) Offset ¶
func (ss *StandardSignal) Offset() float64
Offset returns the offset of the StandardSignal.
func (StandardSignal) ParentMessage ¶ added in v0.5.0
func (s StandardSignal) ParentMessage() *Message
func (StandardSignal) ParentMultiplexerSignal ¶ added in v0.5.0
func (s StandardSignal) ParentMultiplexerSignal() *MultiplexerSignal
func (*StandardSignal) Scale ¶
func (ss *StandardSignal) Scale() float64
Scale returns the scale of the StandardSignal.
func (StandardSignal) SendType ¶ added in v0.5.0
func (s StandardSignal) SendType() SignalSendType
func (StandardSignal) SetByteOrder ¶ added in v0.5.0
func (s StandardSignal) SetByteOrder(byteOrder SignalByteOrder)
func (*StandardSignal) SetPhysicalValues ¶ added in v0.3.0
func (ss *StandardSignal) SetPhysicalValues(min, max, offset, scale float64) error
SetPhysicalValues sets the physical min, max, offset, and scale of the StandardSignal. It returns an error if the scale is equal to 0.
func (StandardSignal) SetSendType ¶ added in v0.5.0
func (s StandardSignal) SetSendType(sendType SignalSendType)
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) 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 ¶
type StartBitError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *StartBitError) Error() string
func (*StartBitError) Unwrap ¶ added in v0.5.0
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) Kind ¶
func (a StringAttribute) Kind() AttributeKind
func (StringAttribute) References ¶
func (a StringAttribute) References() []*AttributeRef
func (*StringAttribute) String ¶ added in v0.3.0
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.
type UpdateIndexError ¶ added in v0.5.0
type UpdateIndexError struct {
Err error
}
UpdateIndexError is returned when an index cannot be updated. The Err field is the cause.
func (*UpdateIndexError) Error ¶ added in v0.5.0
func (e *UpdateIndexError) Error() string
func (*UpdateIndexError) Unwrap ¶ added in v0.5.0
func (e *UpdateIndexError) Unwrap() error
type UpdateNameError ¶ added in v0.5.0
type UpdateNameError struct {
Err error
}
UpdateNameError is returned when a name cannot be updated.
func (*UpdateNameError) Error ¶ added in v0.5.0
func (e *UpdateNameError) Error() string
func (*UpdateNameError) Unwrap ¶ added in v0.5.0
func (e *UpdateNameError) Unwrap() error
type ValueIndexError ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e *ValueIndexError) Error() string
func (*ValueIndexError) Unwrap ¶ added in v0.5.0
func (e *ValueIndexError) Unwrap() error