-
Notifications
You must be signed in to change notification settings - Fork 0
/
kcd.go
51 lines (45 loc) · 1.67 KB
/
kcd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package canparse
import (
"encoding/xml"
)
// KcdDatabase mirrors the generic Database type with added XML decoding tags for the
// KCD format.
type KcdDatabase struct {
XMLName xml.Name `xml:"NetworkDefinition"`
KcdBusses []KcdBus `xml:"Bus"`
}
// KcdBus mirrors the generic Bus type with added XML decoding tags for the KCD
// format.
type KcdBus struct {
XMLName xml.Name `xml:"Bus"`
Name string `xml:"name,attr"`
KcdMessages []KcdMessage `xml:"Message"`
}
// KcdMessage mostly mirrors the generic Message type with added XML decoding tags
// for the KCD format. The Format field is part of the KCD standard but is not yet
// included in the generic Message type.
type KcdMessage struct {
XMLName xml.Name `xml:"Message"`
Id string `xml:"id,attr"`
Name string `xml:"name,attr"`
Length int `xml:"length,attr"`
Format string `xml:"format,attr"`
KcdSignals []KcdSignal `xml:"Signal"`
}
// KcdSignal mostly mirrors the generic Signal type with added XML decoding tags
// for the KCD format. It contains a sub struct Value in adherence with the KCD
// standard.
type KcdSignal struct {
XMLName xml.Name `xml:"Signal"`
Name string `xml:"name,attr"`
Offset int `xml:"offset,attr"` // KCD signal offset maps to signal start
Length int `xml:"length,attr"`
KcdValue KcdValue `xml:"Value"`
}
// KcdValue adhering to the KCD standard.
type KcdValue struct {
XMLName xml.Name `xml:"Value"`
Unit string `xml:"unit,attr"`
Slope float64 `xml:"slope,attr"` // KCD value slope maps to signal scale
Intercept float64 `xml:"intercept,attr"` // KCD value intercept maps to signal offset
}