Skip to content

Commit

Permalink
fix indentation for global signal enums
Browse files Browse the repository at this point in the history
  • Loading branch information
FerroO2000 committed Mar 16, 2024
1 parent 3f2fefe commit a313423
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
)

const version = "v0.5.0"
const version = "v0.5.1"

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Expand Down
12 changes: 6 additions & 6 deletions examples/simple_enum_ref.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ BA_DEF_ BO_ "VFrameFormat" ENUM "StandardCAN","ExtendedCAN","reserved","J1939PG"
BA_DEF_ BO_ "MsgPeriodMS" INT 0 65535;
BA_DEF_ BO_ "GenMsgCycleTime" INT 0 1000;
BA_DEF_ BO_ "GenMsgSendType" ENUM "NoMsgSendType","Cyclic","IfActive","cyclicIfActive","NotUsed";
BA_DEF_ SG_ "SPN" INT 0 524287;
BA_DEF_ SG_ "TestFloatAtt" FLOAT 0 25.75;
BA_DEF_ SG_ "GenSigSendType" ENUM "NoSigSendType","Cyclic","OnWrite","OnWriteWithRepetition","OnChange","OnChangeWithRepetition","IfActive","IfActiveWithRepetition","NotUsed";
BA_DEF_DEF_ "FloatAtt" 1.5;
BA_DEF_ SG_ "SPN" INT 0 524287;
BA_DEF_DEF_ "Baudrate" 1000000;
BA_DEF_DEF_ "FloatAtt" 1.5;
BA_DEF_DEF_ "TestString" "";
BA_DEF_DEF_ "VFrameFormat" "J1939PG";
BA_DEF_DEF_ "MsgPeriodMS" 0;
BA_DEF_DEF_ "GenMsgCycleTime" 0;
BA_DEF_DEF_ "GenMsgSendType" "NoMsgSendType";
BA_DEF_DEF_ "VFrameFormat" "J1939PG";
BA_DEF_DEF_ "MsgPeriodMS" 0;
BA_DEF_DEF_ "SPN" 0;
BA_DEF_DEF_ "TestFloatAtt" 1.5;
BA_DEF_DEF_ "GenSigSendType" "NoSigSendType";
BA_ "TestString" BU_ Node2 "test";
BA_ "GenMsgSendType" BO_ 2364540158 2;
BA_ "VFrameFormat" BO_ 2364540158 0;
BA_ "MsgPeriodMS" BO_ 2364540158 100;
BA_ "GenMsgCycleTime" BO_ 2364540158 10;
BA_ "GenMsgSendType" BO_ 2364540158 2;
BA_ "SPN" SG_ 2364540158 Engine_Speed 190;
BA_ "TestFloatAtt" SG_ 2364540158 Engine_Speed 10.5;
BA_ "GenSigSendType" SG_ 2364540158 Engine_Status 1;

VAL_ 2364540158 Engine_Status 1 "Idle" 2 "Running" 0 "Off";
VAL_ 2364540158 Engine_Status 0 "Off" 1 "Idle" 2 "Running";
16 changes: 9 additions & 7 deletions pkg/can_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (c *CanModel) Init() {
}
}
}

for _, msg := range c.Messages {
for attName := range msg.Attributes {
if msgAtt, ok := c.MessageAttributes[attName]; ok {
Expand All @@ -129,13 +130,14 @@ func (c *CanModel) Init() {
sigAtt.assignSignal(msg.ID, sig)
}

// check if signal has an enum_ref, if so, attach the global signal_enum
if len(sig.Enum) == 0 && len(sig.EnumRef) > 0 {
if enum, ok := c.SignalEnums[sig.EnumRef]; ok {
sig.Enum = enum
} else {
fmt.Printf("WARNING: signal '%s' -> enum_ref '%s' is not defined in global signal enums -> SKIPPED\n", sig.signalName, sig.EnumRef)
}
}

// check if signal has an enum_ref, if so, attach the global signal_enum
if len(sig.Enum) == 0 && len(sig.EnumRef) > 0 {
if enum, ok := c.SignalEnums[sig.EnumRef]; ok {
sig.Enum = enum
} else {
fmt.Printf("WARNING: signal '%s' -> enum_ref '%s' is not defined in global signal enums -> SKIPPED\n", sig.signalName, sig.EnumRef)
}
}
}
Expand Down

0 comments on commit a313423

Please sign in to comment.