Documentation ¶
Overview ¶
Package acmelib contains structures and methods for creating complex CAN (Controlled Area Network) networks.
Index ¶
- Variables
- func CalculateBusLoad(bus *Bus, defCycleTime int) (float64, error)
- func ExportBus(w io.Writer, bus *Bus)
- func ExportNetwork(network *Network, basePath string) error
- func ExportToMarkdown(network *Network, w io.Writer) error
- type AddEntityError
- type AppendSignalError
- type ArgumentError
- type AttributableEntity
- type Attribute
- type AttributeAssignment
- func (aa *AttributeAssignment) Attribute() Attribute
- func (aa *AttributeAssignment) Entity() AttributableEntity
- func (aa *AttributeAssignment) EntityID() EntityID
- func (aa *AttributeAssignment) ToBusEntity() (*Bus, error)
- func (aa *AttributeAssignment) ToMessageEntity() (*Message, error)
- func (aa *AttributeAssignment) ToNodeEntity() (*Node, error)
- func (aa *AttributeAssignment) ToSignalEntity() (Signal, error)
- func (aa *AttributeAssignment) Value() any
- type AttributeType
- type AttributeValueError
- type Bus
- func (b *Bus) AddNodeInterface(nodeInterface *NodeInterface) error
- func (b *Bus) AssignAttribute(attribute Attribute, value any) error
- func (wa Bus) AttributeAssignments() []*AttributeAssignment
- func (b *Bus) Baudrate() int
- func (b *Bus) CANIDBuilder() *CANIDBuilder
- func (e Bus) CreateTime() time.Time
- func (e Bus) Desc() string
- func (e Bus) EntityID() EntityID
- func (e Bus) EntityKind() EntityKind
- func (b *Bus) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)
- func (b *Bus) GetNodeInterfaceByNodeName(nodeName string) (*NodeInterface, error)
- func (e Bus) Name() string
- func (b *Bus) Nodes() []*NodeInterface
- func (b *Bus) ParentNetwork() *Network
- func (wa Bus) RemoveAllAttributeAssignments()
- func (b *Bus) RemoveAllNodeInterfaces()
- func (b *Bus) RemoveAttributeAssignment(attributeEntityID EntityID) error
- func (b *Bus) RemoveNodeInterface(nodeInterfaceEntityID EntityID) error
- func (b *Bus) SetBaudrate(baudrate int)
- func (b *Bus) SetCANIDBuilder(canIDBuilder *CANIDBuilder)
- func (e Bus) SetDesc(desc string)
- func (b *Bus) SetType(typ BusType)
- func (b *Bus) String() string
- func (b *Bus) Type() BusType
- func (b *Bus) UpdateName(newName string) error
- type BusType
- type CANID
- type CANIDBuilder
- func (b *CANIDBuilder) Calculate(messagePriority MessagePriority, messageID MessageID, nodeID NodeID) CANID
- func (e CANIDBuilder) CreateTime() time.Time
- func (e CANIDBuilder) Desc() string
- func (e CANIDBuilder) EntityID() EntityID
- func (e CANIDBuilder) EntityKind() EntityKind
- func (e CANIDBuilder) Name() string
- func (b *CANIDBuilder) Operations() []*CANIDBuilderOp
- func (t CANIDBuilder) ReferenceCount() int
- func (t CANIDBuilder) References() []R
- func (e CANIDBuilder) SetDesc(desc string)
- func (b *CANIDBuilder) String() string
- func (b *CANIDBuilder) UseBitMask(from, len int)
- func (b *CANIDBuilder) UseCAN2A() *CANIDBuilder
- func (b *CANIDBuilder) UseMessageID(from, len int) *CANIDBuilder
- func (b *CANIDBuilder) UseMessagePriority(from int) *CANIDBuilder
- func (b *CANIDBuilder) UseNodeID(from, len int) *CANIDBuilder
- type CANIDBuilderOp
- type CANIDBuilderOpKind
- type ConversionError
- type EntityError
- type EntityID
- type EntityKind
- type EnumAttribute
- func (ea *EnumAttribute) DefValue() string
- func (ea *EnumAttribute) GetValueAtIndex(valueIndex int) (string, error)
- 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 (a EnumAttribute) Type() AttributeType
- func (ea *EnumAttribute) Values() []string
- type EnumSignal
- func (es *EnumSignal) AssignAttribute(attribute Attribute, value any) error
- func (es *EnumSignal) Enum() *SignalEnum
- func (s EnumSignal) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)
- 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) RemoveAttributeAssignment(attributeEntityID EntityID) error
- func (s EnumSignal) SendType() SignalSendType
- func (es *EnumSignal) SetEnum(enum *SignalEnum) error
- func (s EnumSignal) SetSendType(sendType SignalSendType)
- func (s EnumSignal) SetStartValue(startValue int)
- func (s EnumSignal) StartValue() int
- 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 (fa *FloatAttribute) Max() float64
- func (fa *FloatAttribute) Min() float64
- 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)
- func (a FloatAttribute) Type() AttributeType
- type GetEntityError
- type GroupIDError
- type InsertSignalError
- type IntegerAttribute
- func (ia *IntegerAttribute) DefValue() int
- func (ia *IntegerAttribute) IsHexFormat() bool
- func (ia *IntegerAttribute) Max() int
- func (ia *IntegerAttribute) Min() int
- 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)
- func (a IntegerAttribute) Type() AttributeType
- type Message
- func (m *Message) AddReceiver(receiver *NodeInterface)
- func (m *Message) AppendSignal(signal Signal) error
- func (m *Message) AssignAttribute(attribute Attribute, value any) error
- func (wa Message) AttributeAssignments() []*AttributeAssignment
- func (m *Message) ByteOrder() MessageByteOrder
- func (m *Message) CompactSignals()
- func (e Message) CreateTime() time.Time
- func (m *Message) CycleTime() int
- func (m *Message) DelayTime() int
- func (e Message) Desc() string
- func (e Message) EntityID() EntityID
- func (e Message) EntityKind() EntityKind
- func (m *Message) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)
- func (m *Message) GetCANID() CANID
- func (m *Message) GetSignal(signalEntityID EntityID) (Signal, error)
- func (m *Message) HasStaticCANID() bool
- func (m *Message) ID() MessageID
- func (m *Message) InsertSignal(signal Signal, startBit int) error
- func (e Message) Name() string
- func (m *Message) Priority() MessagePriority
- func (m *Message) Receivers() []*NodeInterface
- func (wa Message) RemoveAllAttributeAssignments()
- func (m *Message) RemoveAllSignals()
- func (m *Message) RemoveAttributeAssignment(attributeEntityID EntityID) error
- func (m *Message) RemoveReceiver(receiverEntityID EntityID)
- func (m *Message) RemoveSignal(signalEntityID EntityID) error
- func (m *Message) SendType() MessageSendType
- func (m *Message) SenderNodeInterface() *NodeInterface
- func (m *Message) SetByteOrder(byteOrder MessageByteOrder)
- func (m *Message) SetCycleTime(cycleTime int)
- func (m *Message) SetDelayTime(delayTime int)
- func (e Message) SetDesc(desc string)
- func (m *Message) SetPriority(priority MessagePriority)
- func (m *Message) SetSendType(sendType MessageSendType)
- func (m *Message) SetStartDelayTime(startDelayTime int)
- func (m *Message) SetStaticCANID(canID CANID)
- 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) UpdateID(newID MessageID) error
- func (m *Message) UpdateName(newName string) error
- type MessageByteOrder
- type MessageID
- type MessageIDError
- type MessagePriority
- type MessageSendType
- type MultiplexerSignal
- func (ms *MultiplexerSignal) AssignAttribute(attribute Attribute, value any) error
- func (ms *MultiplexerSignal) ClearAllSignalGroups()
- func (ms *MultiplexerSignal) ClearSignalGroup(groupID int) error
- func (s MultiplexerSignal) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, 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 (s MultiplexerSignal) RemoveAttributeAssignment(attributeEntityID EntityID) error
- func (ms *MultiplexerSignal) RemoveSignal(signalEntityID EntityID) error
- func (s MultiplexerSignal) SendType() SignalSendType
- func (s MultiplexerSignal) SetSendType(sendType SignalSendType)
- func (s MultiplexerSignal) SetStartValue(startValue int)
- func (ms *MultiplexerSignal) ShiftSignalLeft(signalEntityID EntityID, amount int) int
- func (ms *MultiplexerSignal) ShiftSignalRight(signalEntityID EntityID, amount int) int
- func (s MultiplexerSignal) StartValue() 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) EntityKind() EntityKind
- 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 (n *Node) AssignAttribute(attribute Attribute, value any) error
- func (wa Node) AttributeAssignments() []*AttributeAssignment
- func (e Node) CreateTime() time.Time
- func (e Node) Desc() string
- func (e Node) EntityID() EntityID
- func (e Node) EntityKind() EntityKind
- func (n *Node) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)
- func (n *Node) ID() NodeID
- func (n *Node) Interfaces() []*NodeInterface
- func (e Node) Name() string
- func (wa Node) RemoveAllAttributeAssignments()
- func (n *Node) RemoveAttributeAssignment(attributeEntityID EntityID) error
- func (e Node) SetDesc(desc string)
- func (n *Node) String() string
- func (n *Node) UpdateName(newName string) error
- type NodeID
- type NodeIDError
- type NodeInterface
- func (ni *NodeInterface) AddMessage(message *Message) error
- func (e NodeInterface) CreateTime() time.Time
- func (e NodeInterface) Desc() string
- func (e NodeInterface) EntityID() EntityID
- func (e NodeInterface) EntityKind() EntityKind
- func (ni *NodeInterface) Messages() []*Message
- func (e NodeInterface) Name() string
- func (ni *NodeInterface) Node() *Node
- func (ni *NodeInterface) Number() int
- func (ni *NodeInterface) ParentBus() *Bus
- func (ni *NodeInterface) RemoveAllMessages()
- func (ni *NodeInterface) RemoveMessage(messageEntityID EntityID) error
- func (e NodeInterface) SetDesc(desc string)
- func (ni *NodeInterface) String() string
- type RemoveEntityError
- type Signal
- 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 (e SignalEnum) EntityKind() EntityKind
- func (se *SignalEnum) GetSize() int
- func (se *SignalEnum) MaxIndex() int
- func (se *SignalEnum) MinSize() int
- func (e SignalEnum) Name() string
- func (t SignalEnum) ReferenceCount() int
- func (t SignalEnum) References() []R
- 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 (e SignalEnumValue) EntityKind() EntityKind
- 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 NewCustomSignalType(name string, size int, signed bool, min, max, scale, offset float64) (*SignalType, error)
- func NewDecimalSignalType(name string, size int) (*SignalType, error)
- func NewFlagSignalType(name string) *SignalType
- func NewIntegerSignalType(name string, size int, signed bool) (*SignalType, error)
- func (e SignalType) CreateTime() time.Time
- func (e SignalType) Desc() string
- func (e SignalType) EntityID() EntityID
- func (e SignalType) EntityKind() EntityKind
- func (st *SignalType) Kind() SignalTypeKind
- func (st *SignalType) Max() float64
- func (st *SignalType) Min() float64
- func (e SignalType) Name() string
- func (st *SignalType) Offset() float64
- func (t SignalType) ReferenceCount() int
- func (t SignalType) References() []R
- func (st *SignalType) Scale() float64
- func (e SignalType) SetDesc(desc string)
- func (st *SignalType) SetMax(max float64)
- func (st *SignalType) SetMin(min float64)
- func (st *SignalType) SetOffset(offset float64)
- func (st *SignalType) SetScale(scale float64)
- 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 (e SignalUnit) EntityKind() EntityKind
- func (su *SignalUnit) Kind() SignalUnitKind
- func (e SignalUnit) Name() string
- func (t SignalUnit) ReferenceCount() int
- func (t SignalUnit) References() []R
- func (e SignalUnit) SetDesc(desc string)
- func (su *SignalUnit) String() string
- func (su *SignalUnit) Symbol() string
- type SignalUnitKind
- type StandardSignal
- func (ss *StandardSignal) AssignAttribute(attribute Attribute, value any) error
- func (s StandardSignal) GetAttributeAssignment(attributeEntityID EntityID) (*AttributeAssignment, error)
- func (ss *StandardSignal) GetSize() int
- func (s StandardSignal) GetStartBit() int
- func (s StandardSignal) Kind() SignalKind
- func (s StandardSignal) ParentMessage() *Message
- func (s StandardSignal) ParentMultiplexerSignal() *MultiplexerSignal
- func (s StandardSignal) RemoveAttributeAssignment(attributeEntityID EntityID) error
- func (s StandardSignal) SendType() SignalSendType
- func (s StandardSignal) SetSendType(sendType SignalSendType)
- func (s StandardSignal) SetStartValue(startValue int)
- func (ss *StandardSignal) SetType(typ *SignalType) error
- func (ss *StandardSignal) SetUnit(unit *SignalUnit)
- func (s StandardSignal) StartValue() int
- 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 (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)
- func (a StringAttribute) Type() AttributeType
- 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 ¶
func CalculateBusLoad ¶ added in v0.7.0
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 ¶
ExportBus exports the given Bus to DBC. It writes the content of the result DBC file into the io.Writer.
func ExportNetwork ¶
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.
Types ¶
type AddEntityError ¶
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 ¶
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 ¶
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
func (aa *AttributeAssignment) Entity() AttributableEntity
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 ¶
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 ¶
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
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) 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
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) Nodes ¶
func (b *Bus) Nodes() []*NodeInterface
Nodes returns a slice of all nodes in the Bus sorted by node id.
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) 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
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
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 ¶
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.
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
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
func (bo *CANIDBuilderOp) Kind() CANIDBuilderOpKind
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 ¶
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 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 (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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
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
CreateTime returns the time when the entity was created.
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
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) HasStaticCANID ¶ added in v0.6.0
HasStaticCANID returns whether the Message has a static CAN-ID.
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) 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
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 ¶
RemoveReceiver removes a receiver from the Message.
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 ¶
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 ¶
SetCycleTime sets the message cycle time in ms.
func (*Message) SetDelayTime ¶
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 ¶
SetStartDelayTime sets the start delay time of the Message.
func (*Message) SetStaticCANID ¶ added in v0.6.0
SetStaticCANID sets the static CAN-ID 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 ¶
StartDelayTime returns the message start delay time.
func (*Message) UpdateID ¶ added in v0.6.0
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.
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 ¶
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:
- 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 ¶
func (s MultiplexerSignal) ParentMessage() *Message
func (MultiplexerSignal) ParentMultiplexerSignal ¶
func (s MultiplexerSignal) ParentMultiplexerSignal() *MultiplexerSignal
func (MultiplexerSignal) RemoveAttributeAssignment ¶ added in v0.7.0
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 ¶
type NameError ¶
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) EntityKind ¶ added in v0.7.0
func (e Network) EntityKind() EntityKind
EntityKind returns the kind 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 ¶
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 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 ¶
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
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
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) Interfaces ¶ added in v0.6.0
func (n *Node) Interfaces() []*NodeInterface
Interfaces returns a slice with all the interfaces of the Node.
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
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.
type NodeIDError ¶
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
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 ¶
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 ¶
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) 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 ¶
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 ¶
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 ¶
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) 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) 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 ¶
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) 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 (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 ¶
type StartBitError ¶
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 ¶
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
Source Files ¶
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
|
|