Skip to content

Commit

Permalink
sync pc
Browse files Browse the repository at this point in the history
  • Loading branch information
FerroO2000 committed Apr 28, 2024
1 parent 1eb15de commit 59c6f2b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 46 deletions.
2 changes: 1 addition & 1 deletion adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func newDBCAdapter() *dbcAdapter {
}

func (a *dbcAdapter) adaptFile(dbcFile *dbc.File) (*Bus, error) {
bus := NewBus(dbcFile.Location.Filename)
bus := NewBus(dbcFile.Location().Filename)

for _, comment := range dbcFile.Comments {
a.mapComment(comment)
Expand Down
36 changes: 18 additions & 18 deletions dbc/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (wl *withLocation) Location() *Location {
// which shall be part of the CAN network. The functional behavior
// of the ECU is not addressed by the DBC file.
type File struct {
Location *Location
withLocation

Version string
NewSymbols *NewSymbols
Expand Down Expand Up @@ -72,7 +72,7 @@ type File struct {
// ['BA_DEF_REL_'] ['BA_REL_'] ['BA_DEF_DEF_REL_'] ['BU_SG_REL_']
// ['BU_EV_REL_'] ['BU_BO_REL_'] [SG_MUL_VAL_'] ];
type NewSymbols struct {
Location *Location
withLocation

Symbols []string
}
Expand All @@ -91,7 +91,7 @@ type NewSymbols struct {
//
// BTR2 = unsigned_integer ;
type BitTiming struct {
Location *Location
withLocation

Baudrate uint32
BitTimingReg1 uint32
Expand Down Expand Up @@ -125,7 +125,7 @@ type Nodes struct {
//
// value_table_name = DBC_identifier ;
type ValueTable struct {
Location *Location
withLocation

Name string
Values []*ValueDescription
Expand Down Expand Up @@ -168,7 +168,7 @@ const (
//
// value_descriptions_for_env_var = 'VAL_' env_var_name { value_description } ';' ;
type ValueEncoding struct {
Location *Location
withLocation

Kind ValueEncodingKind
MessageID uint32
Expand Down Expand Up @@ -350,7 +350,7 @@ const (
// signal_extended_value_type = '0' | '1' | '2' | '3' ;
// (* 0=signed or unsigned integer, 1=32-bit IEEE-float, 2=64-bit IEEE-double *)
type SignalExtValueType struct {
Location *Location
withLocation

MessageID uint32
SignalName string
Expand All @@ -367,7 +367,7 @@ type SignalExtValueType struct {
//
// Message_transmitter = 'BO_TX_BU_' message_id ':' {transmitter} ';' ;
type MessageTransmitter struct {
Location *Location
withLocation

MessageID uint32
Transmitters []string
Expand Down Expand Up @@ -434,7 +434,7 @@ const (
//
// access_node = node_name | 'VECTOR__XXX' ;
type EnvVar struct {
Location *Location
withLocation

Name string
Type EnvVarType
Expand All @@ -459,7 +459,7 @@ type EnvVar struct {
//
// data_size = unsigned_integer ;
type EnvVarData struct {
Location *Location
withLocation

EnvVarName string
DataSize uint32
Expand All @@ -480,7 +480,7 @@ type EnvVarData struct {
//
// value_table = value_table_name ;
type SignalType struct {
Location *Location
withLocation

TypeName string
Size uint32
Expand All @@ -501,7 +501,7 @@ type SignalType struct {
//
// signal_type_ref = 'SGTYPE_' message_id signal_name ':' signal_type_name ';' ;
type SignalTypeRef struct {
Location *Location
withLocation

TypeName string
MessageID uint32
Expand All @@ -517,7 +517,7 @@ type SignalTypeRef struct {
//
// signal_group_name = DBC_identifier ; repetitions = unsigned_integer ;
type SignalGroup struct {
Location *Location
withLocation

MessageID uint32
GroupName string
Expand Down Expand Up @@ -555,7 +555,7 @@ const (
// 'EV_' env_var_name char_string)
// ';' ;
type Comment struct {
Location *Location
withLocation

Kind CommentKind
Text string
Expand Down Expand Up @@ -618,7 +618,7 @@ const (
// 'STRING' |
// 'ENUM' [char_string {',' char_string}]
type Attribute struct {
Location *Location
withLocation

Kind AttributeKind
Type AttributeType
Expand Down Expand Up @@ -654,7 +654,7 @@ const (
//
// attribute_value = unsigned_integer | signed_integer | double | char_string ;
type AttributeDefault struct {
Location *Location
withLocation

Type AttributeDefaultType
AttributeName string
Expand Down Expand Up @@ -689,7 +689,7 @@ const (
// 'EV_' env_var_name attribute_value)
// ';' ;
type AttributeValue struct {
Location *Location
withLocation

AttributeKind AttributeKind
Type AttributeValueType
Expand Down Expand Up @@ -721,7 +721,7 @@ type AttributeValue struct {
//
// message_id = unsigned_integer ; multiplexed_signal_name = DBC_identifier ; multiplexor_switch_name = DBC_identifier ;
type ExtendedMux struct {
Location *Location
withLocation

MessageID uint32
MultiplexorName string
Expand All @@ -735,7 +735,7 @@ type ExtendedMux struct {
//
// multiplexor_value_range = unsigned_integer '-' unsigned_integer ;
type ExtendedMuxRange struct {
Location *Location
withLocation

From uint32
To uint32
Expand Down
36 changes: 18 additions & 18 deletions dbc/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (p *Parser) Parse() (*File, error) {
ast := new(File)

t := p.scan()
ast.Location = p.getLocation()
ast.withLocation.loc = p.getLocation()

for !t.isEOF() {
switch t.kind {
Expand Down Expand Up @@ -290,7 +290,7 @@ func (p *Parser) parseNewSymbols() (*NewSymbols, error) {
p.foundNewSym = true

ns := new(NewSymbols)
ns.Location = p.getLocation()
ns.withLocation.loc = p.getLocation()

if err := p.expectPunct(punctColon); err != nil {
return nil, err
Expand Down Expand Up @@ -330,7 +330,7 @@ func (p *Parser) parseBitTiming() (*BitTiming, error) {
}

bt := new(BitTiming)
bt.Location = p.getLocation()
bt.withLocation.loc = p.getLocation()

if err := p.expectPunct(punctColon); err != nil {
return nil, err
Expand Down Expand Up @@ -441,7 +441,7 @@ func (p *Parser) parseValueDescription() (*ValueDescription, error) {

func (p *Parser) parseValueTable() (*ValueTable, error) {
vt := new(ValueTable)
vt.Location = p.getLocation()
vt.withLocation.loc = p.getLocation()

t := p.scan()
if !t.isIdent() {
Expand Down Expand Up @@ -726,7 +726,7 @@ func (p *Parser) parseSignal() (*Signal, error) {

func (p *Parser) parseMessageTransmitter() (*MessageTransmitter, error) {
mt := new(MessageTransmitter)
mt.Location = p.getLocation()
mt.withLocation.loc = p.getLocation()

msgID, err := p.parseMessageID()
if err != nil {
Expand Down Expand Up @@ -765,7 +765,7 @@ func (p *Parser) parseEnvVarName() (string, error) {

func (p *Parser) parseEnvVar() (*EnvVar, error) {
envVar := new(EnvVar)
envVar.Location = p.getLocation()
envVar.withLocation.loc = p.getLocation()

t := p.scan()
if !t.isIdent() {
Expand Down Expand Up @@ -892,7 +892,7 @@ func (p *Parser) parseEnvVar() (*EnvVar, error) {

func (p *Parser) parseEnvVarData() (*EnvVarData, error) {
evData := new(EnvVarData)
evData.Location = p.getLocation()
evData.withLocation.loc = p.getLocation()

evName, err := p.parseEnvVarName()
if err != nil {
Expand Down Expand Up @@ -923,10 +923,10 @@ func (p *Parser) parseEnvVarData() (*EnvVarData, error) {

func (p *Parser) parseSignalType() (*SignalType, *SignalTypeRef, error) {
sigType := new(SignalType)
sigType.Location = p.getLocation()
sigType.withLocation.loc = p.getLocation()

sigTypeRef := new(SignalTypeRef)
sigTypeRef.Location = p.getLocation()
sigTypeRef.withLocation.loc = p.getLocation()

t := p.scan()
p.unscan()
Expand Down Expand Up @@ -1120,7 +1120,7 @@ func (p *Parser) parseSignalType() (*SignalType, *SignalTypeRef, error) {

func (p *Parser) parseComment() (*Comment, error) {
com := new(Comment)
com.Location = p.getLocation()
com.withLocation.loc = p.getLocation()

t := p.scan()
switch t.kind {
Expand Down Expand Up @@ -1205,7 +1205,7 @@ func (p *Parser) parseAttributeName() (string, error) {

func (p *Parser) parseAttribute() (*Attribute, error) {
att := new(Attribute)
att.Location = p.getLocation()
att.withLocation.loc = p.getLocation()

t := p.scan()
switch t.kind {
Expand Down Expand Up @@ -1346,7 +1346,7 @@ func (p *Parser) parseAttribute() (*Attribute, error) {

func (p *Parser) parseAttributeDefault() (*AttributeDefault, error) {
attDef := new(AttributeDefault)
attDef.Location = p.getLocation()
attDef.withLocation.loc = p.getLocation()

attName, err := p.parseAttributeName()
if err != nil {
Expand Down Expand Up @@ -1398,7 +1398,7 @@ func (p *Parser) parseAttributeDefault() (*AttributeDefault, error) {

func (p *Parser) parseAttributeValue() (*AttributeValue, error) {
attVal := new(AttributeValue)
attVal.Location = p.getLocation()
attVal.withLocation.loc = p.getLocation()

t := p.scan()
if !t.isString() {
Expand Down Expand Up @@ -1503,7 +1503,7 @@ func (p *Parser) parseAttributeValue() (*AttributeValue, error) {

func (p *Parser) parseValueEncoding() (*ValueEncoding, error) {
valEnc := new(ValueEncoding)
valEnc.Location = p.getLocation()
valEnc.withLocation.loc = p.getLocation()

t := p.scan()
p.unscan()
Expand Down Expand Up @@ -1557,7 +1557,7 @@ func (p *Parser) parseValueEncoding() (*ValueEncoding, error) {

func (p *Parser) parseSignalGroup() (*SignalGroup, error) {
sigGroup := new(SignalGroup)
sigGroup.Location = p.getLocation()
sigGroup.withLocation.loc = p.getLocation()

msgID, err := p.parseMessageID()
if err != nil {
Expand Down Expand Up @@ -1602,7 +1602,7 @@ func (p *Parser) parseSignalGroup() (*SignalGroup, error) {

func (p *Parser) parseSignalExtValueType() (*SignalExtValueType, error) {
valType := new(SignalExtValueType)
valType.Location = p.getLocation()
valType.withLocation.loc = p.getLocation()

msgID, err := p.parseMessageID()
if err != nil {
Expand Down Expand Up @@ -1644,7 +1644,7 @@ func (p *Parser) parseSignalExtValueType() (*SignalExtValueType, error) {

func (p *Parser) parseExtendedMuxRange() (*ExtendedMuxRange, error) {
extMuxR := new(ExtendedMuxRange)
extMuxR.Location = p.getLocation()
extMuxR.withLocation.loc = p.getLocation()

t := p.scan()
if !t.isNumberRange() {
Expand All @@ -1667,7 +1667,7 @@ func (p *Parser) parseExtendedMuxRange() (*ExtendedMuxRange, error) {

func (p *Parser) parseExtendedMux() (*ExtendedMux, error) {
extMux := new(ExtendedMux)
extMux.Location = p.getLocation()
extMux.withLocation.loc = p.getLocation()

msgID, err := p.parseMessageID()
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package acmelib

import (
"io"
"log"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -38,6 +37,7 @@ func Test_ExportBus(t *testing.T) {

stdSig0, err := NewStandardSignal("std_sig_0", size4Type)
assert.NoError(err)
stdSig0.SetUnit(NewSignalUnit("deg_celsius", SignalUnitKindTemperature, "degC"))
stdSig0.SetByteOrder(SignalByteOrderBigEndian)
assert.NoError(msg0.AppendSignal(stdSig0))

Expand Down Expand Up @@ -131,8 +131,6 @@ func Test_ExportBus(t *testing.T) {
fileBuf := &strings.Builder{}
ExportBus(fileBuf, bus0)

log.Print(fileBuf)

testFile, err := os.Open(cmpExportBusFilename)
assert.NoError(err)

Expand Down
Loading

0 comments on commit 59c6f2b

Please sign in to comment.