Skip to content

Commit

Permalink
sync pc
Browse files Browse the repository at this point in the history
  • Loading branch information
FerroO2000 committed May 13, 2024
1 parent 7e77498 commit 7fb77b0
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 47 deletions.
6 changes: 5 additions & 1 deletion canid_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ func (bo *CANIDBuilderOp) Len() int {
}

type CANIDBuilder struct {
*entity

operations []*CANIDBuilderOp
}

func NewCANIDBuilder() *CANIDBuilder {
func NewCANIDBuilder(name string) *CANIDBuilder {
return &CANIDBuilder{
entity: newEntity(name),

operations: []*CANIDBuilderOp{},
}
}
Expand Down
2 changes: 1 addition & 1 deletion canid_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func Test_CANIDBuilder(t *testing.T) {
assert := assert.New(t)

b := NewCANIDBuilder()
b := NewCANIDBuilder("canid_builder")
b.UseMessagePriority(30).UseMessageID(4, 10).UseNodeID(0, 4)

msgPriority := MessagePriorityLow
Expand Down
52 changes: 32 additions & 20 deletions examples/markdown/MCB.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,20 @@ BO_ 49 SB_FRONT_sdcStatus: 1 SB_FRONT
SG_ SDC_POST_COCKPIT_isClosed : 3|1@1+ (1,0) [0|1] "" DSPACE

BO_ 1024 SB_FRONT_ntcResistance: 8 SB_FRONT
SG_ RAD_NTC_IN_resistance : 0|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ RAD_NTC_OUT_resistance : 10|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ JACKET_NTC_FRONT_resistance : 20|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ JACKET_NTC_REAR_resistance : 30|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ COLDPLATE_NTC_resistance : 40|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ NTC_SPARE_resistance : 50|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ JACKET_FL_NTC_resistance : 0|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ JACKET_FR_NTC_resistance : 10|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ COLDPLATE_L_NTC_resistance : 20|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ COLDPLATE_R_NTC_resistance : 30|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ SPARE_NTC_0_resistance : 40|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ SPARE_NTC_1_resistance : 50|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE

BO_ 1025 SB_REAR_ntcResistance: 8 SB_REAR
SG_ JACKET_RL_NTC_resistance : 0|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ JACKET_RR_NTC_resistance : 10|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ RAD_RL_IN_NTC_resistance : 20|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ RAD_RL_OUT_NTC_resistance : 30|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ RAD_RR_IN_NTC_resistance : 40|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ RAD_RR_OUT_NTC_resistance : 50|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE

BO_ 48 SB_REAR_sdcStatus: 1 SB_REAR
SG_ SDC_POST_BSPD_isClosed : 0|1@1+ (1,0) [0|1] "" DSPACE
Expand All @@ -169,6 +177,9 @@ BO_ 50 SB_REAR_dischargeStatus: 1 SB_REAR






BO_ 5 Sens_Front_1: 8 SB_FRONT
SG_ Throttle_0_Voltage_mV : 0|16@1+ (1,0) [0|65535] "" DSPACE
SG_ Throttle_1_Voltage_mV : 16|16@1+ (1,0) [0|65535] "" DSPACE
Expand Down Expand Up @@ -246,13 +257,7 @@ BO_ 512 dSpace_PeripheralsCTRL: 3 DSPACE



BO_ 1025 Sens_Rear_NTC: 8 SB_REAR
SG_ NTC_1_Resistance : 0|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ NTC_2_Resistance : 10|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ NTC_3_Resistance : 20|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ NTC_4_Resistance : 30|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ NTC_5_Resistance : 40|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE
SG_ NTC_6_Resistance : 50|10@1+ (31.25,1000) [0|31968.75] "Ohm" DSPACE


BO_ 1026 Sens_Rear_2: 4 SB_REAR
SG_ CoolingPressure_DX_Voltage_mV : 0|16@1+ (1,0) [0|65535] "" DSPACE
Expand Down Expand Up @@ -353,12 +358,19 @@ CM_ SG_ 49 SDC_POST_INERTIA_isClosed "States whether the SDC post inertia switch
CM_ SG_ 49 SDC_POST_BOTS_isClosed "States whether the SDC post BOTS is closed.";
CM_ SG_ 49 SDC_POST_COCKPIT_isClosed "States whether the SDC post cockpit push button is closed.";

CM_ SG_ 1024 RAD_NTC_IN_resistance "The resistance of the radiator IN NTC expressed in Ohm.";
CM_ SG_ 1024 RAD_NTC_OUT_resistance "The resistance of the radiator OUT NTC expressed in Ohm.";
CM_ SG_ 1024 JACKET_NTC_FRONT_resistance "The resistance of the jacket front NTC expressed in Ohm.";
CM_ SG_ 1024 JACKET_NTC_REAR_resistance "The resistance of the jacket rear NTC expressed in Ohm.";
CM_ SG_ 1024 COLDPLATE_NTC_resistance "The resistance of the coldplate NTC expressed in Ohm.";
CM_ SG_ 1024 NTC_SPARE_resistance "The resistance of the spare NTC expressed in Ohm.";
CM_ SG_ 1024 JACKET_FL_NTC_resistance "The resistance of the front left jacket NTC expressed in Ohm.";
CM_ SG_ 1024 JACKET_FR_NTC_resistance "The resistance of the front right jacket NTC expressed in Ohm.";
CM_ SG_ 1024 COLDPLATE_L_NTC_resistance "The resistance of the left coldplate NTC expressed in Ohm.";
CM_ SG_ 1024 COLDPLATE_R_NTC_resistance "The resistance of the right coldplate NTC expressed in Ohm.";
CM_ SG_ 1024 SPARE_NTC_0_resistance "The resistance of the spare NTC #0 expressed in Ohm.";
CM_ SG_ 1024 SPARE_NTC_1_resistance "The resistance of the spare NTC #1 expressed in Ohm.";

CM_ SG_ 1024 JACKET_RL_NTC_resistance "The resistance of the rear left jacket NTC expressed in Ohm.";
CM_ SG_ 1024 JACKET_RR_NTC_resistance "The resistance of the rear right jacket NTC expressed in Ohm.";
CM_ SG_ 1024 RAD_RL_IN_NTC_resistance "The resistance of the rear left IN radiator NTC expressed in Ohm.";
CM_ SG_ 1024 RAD_RL_OUT_NTC_resistance "The resistance of the rear left OUT radiator NTC expressed in Ohm.";
CM_ SG_ 1024 RAD_RR_IN_NTC_resistance "The resistance of the rear right IN radiator NTC expressed in Ohm.";
CM_ SG_ 1024 RAD_RR_OUT_NTC_resistance "The resistance of the rear right OUT radiator NTC expressed in Ohm.";

CM_ SG_ 48 SDC_POST_BSPD_isClosed "States whether the SDC post BSPD is closed.";
CM_ SG_ 48 SDC_PRE_PUSH_BTNS_isClosed "States whether the SDC per push buttons (hoop right/left) is closed.";
Expand All @@ -375,7 +387,6 @@ CM_ SG_ 50 DISCHARGE_isOpen "States whether the discharge is open.";


CM_ BO_ 1026 "(period: 10 ms)";
CM_ BO_ 1025 "(period: 10 ms)";
CM_ BO_ 5 "(period: 10 ms)";
CM_ BO_ 16 "(period: 10 ms)";
CM_ BO_ 18 "(period: 100 ms)";
Expand Down Expand Up @@ -409,4 +420,5 @@ BA_ "GenMsgCycleTime" BO_ 261 2000;
BA_ "GenMsgCycleTime" BO_ 38 500;
BA_ "GenMsgCycleTime" BO_ 49 10;
BA_ "GenMsgCycleTime" BO_ 1024 10;
BA_ "GenMsgCycleTime" BO_ 1025 10;
BA_ "GenMsgCycleTime" BO_ 48 10;
38 changes: 18 additions & 20 deletions examples/markdown/SC24.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,14 @@ Cycle Time: **10** ms

Receivers: [DSPACE](#DSPACE)

| Name | Start Bit | Size | Min | Max | Offset | Scale | Unit | Description |
|-----------------------------|-----------|------|-----|----------|--------|-------|------|----------------------------------------------------------|
| RAD_NTC_IN_resistance | 0 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the radiator IN NTC expressed in Ohm. |
| RAD_NTC_OUT_resistance | 10 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the radiator OUT NTC expressed in Ohm. |
| JACKET_NTC_FRONT_resistance | 20 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the jacket front NTC expressed in Ohm. |
| JACKET_NTC_REAR_resistance | 30 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the jacket rear NTC expressed in Ohm. |
| COLDPLATE_NTC_resistance | 40 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the coldplate NTC expressed in Ohm. |
| NTC_SPARE_resistance | 50 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the spare NTC expressed in Ohm. |
| Name | Start Bit | Size | Min | Max | Offset | Scale | Unit | Description |
|----------------------------|-----------|------|-----|----------|--------|-------|------|----------------------------------------------------------------|
| JACKET_FL_NTC_resistance | 0 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the front left jacket NTC expressed in Ohm. |
| JACKET_FR_NTC_resistance | 10 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the front right jacket NTC expressed in Ohm. |
| COLDPLATE_L_NTC_resistance | 20 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the left coldplate NTC expressed in Ohm. |
| COLDPLATE_R_NTC_resistance | 30 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the right coldplate NTC expressed in Ohm. |
| SPARE_NTC_0_resistance | 40 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the spare NTC #0 expressed in Ohm. |
| SPARE_NTC_1_resistance | 50 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | The resistance of the spare NTC #1 expressed in Ohm. |

---
### SB_REAR
Expand Down Expand Up @@ -450,25 +450,23 @@ Receivers: [DSPACE](#DSPACE)
| Straingauge_PushRL_Voltage_mV | 32 | 16 | 0 | 65535 | 0 | 1 | - | - |
| Straingauge_TieRL_Voltage_mV | 48 | 16 | 0 | 65535 | 0 | 1 | - | - |

#### Sens_Rear_NTC
(period: 10 ms)

#### SB_REAR_ntcResistance
CAN-ID: **1025**

Size: **8** bytes

Cycle Time: -
Cycle Time: **10** ms

Receivers: [DSPACE](#DSPACE)

| Name | Start Bit | Size | Min | Max | Offset | Scale | Unit | Description |
|------------------|-----------|------|-----|----------|--------|-------|------|-------------|
| NTC_1_Resistance | 0 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| NTC_2_Resistance | 10 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| NTC_3_Resistance | 20 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| NTC_4_Resistance | 30 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| NTC_5_Resistance | 40 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| NTC_6_Resistance | 50 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| Name | Start Bit | Size | Min | Max | Offset | Scale | Unit | Description |
|---------------------------|-----------|------|-----|----------|--------|-------|------|-------------|
| JACKET_RL_NTC_resistance | 0 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| JACKET_RR_NTC_resistance | 10 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| RAD_RL_IN_NTC_resistance | 20 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| RAD_RL_OUT_NTC_resistance | 30 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| RAD_RR_IN_NTC_resistance | 40 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |
| RAD_RR_OUT_NTC_resistance | 50 | 10 | 0 | 31968.75 | 1000 | 31.25 | Ohm | - |

#### Sens_Rear_2
(period: 10 ms)
Expand Down
25 changes: 20 additions & 5 deletions signal_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,34 @@ import (
)

// SignalUnitKind defines the kind of a [SignalUnit].
type SignalUnitKind string
type SignalUnitKind int

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

func (suk SignalUnitKind) String() string {
switch suk {
case SignalUnitKindCustom:
return "custom"
case SignalUnitKindTemperature:
return "temperature"
case SignalUnitKindElectrical:
return "electrical"
case SignalUnitKindPower:
return "power"
default:
return "unknown"
}
}

// SignalUnit is an entity that defines the physical unit of a [Signal].
type SignalUnit struct {
*entity
Expand Down
26 changes: 26 additions & 0 deletions template.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package acmelib

type templateRef interface {
EntityID() EntityID
}

type template[Ent any, Ref templateRef] struct {
entity Ent
refs *set[EntityID, Ref]
}

func newTemplate[Ent any, Ref templateRef](e Ent) *template[Ent, Ref] {
return &template[Ent, Ref]{
entity: e,

refs: newSet[EntityID, Ref](),
}
}

func (t *template[Ent, Ref]) addRef(ref Ref) {
t.refs.add(ref.EntityID(), ref)
}

func (t *template[Ent, Ref]) removeRef(refID EntityID) {
t.refs.remove(refID)
}

0 comments on commit 7fb77b0

Please sign in to comment.