-
Notifications
You must be signed in to change notification settings - Fork 3
/
type_28_temperature_probe.go
121 lines (109 loc) · 2.76 KB
/
type_28_temperature_probe.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package dmi
import (
"fmt"
)
type TemperatureProbeStatus byte
const (
TemperatureProbeStatusOther TemperatureProbeStatus = 0x20 + iota
TemperatureProbeStatusUnknown
TemperatureProbeStatusOK
TemperatureProbeStatusNon_critical
TemperatureProbeStatusCritical
TemperatureProbeStatusNon_recoverable
)
func (t TemperatureProbeStatus) String() string {
status := [...]string{
"Other",
"Unknown",
"OK",
"Non-critical",
"Critical",
"Non-recoverable",
}
return status[t-0x20]
}
type TemperatureProbeLocation byte
const (
TemperatureProbeLocationOther TemperatureProbeStatus = 1 + iota
TemperatureProbeLocationUnknown
TemperatureProbeLocationProcessor
TemperatureProbeLocationDisk
TemperatureProbeLocationPeripheralBay
TemperatureProbeLocationSystemManagementModule
TemperatureProbeLocationMotherboard
TemperatureProbeLocationMemoryModule
TemperatureProbeLocationProcessorModule
TemperatureProbeLocationPowerUnit
TemperatureProbeLocationAdd_inCard
TemperatureProbeLocationFrontPanelBoard
TemperatureProbeLocationBackPanelBoard
TemperatureProbeLocationPowerSystemBoard
TemperatureProbeLocationDriveBackPlane
)
func (t TemperatureProbeLocation) String() string {
locations := [...]string{
"Other",
"Unknown",
"Processor",
"Disk",
"Peripheral Bay",
"System Management Module",
"Motherboard",
"Memory Module",
"Processor Module",
"Power Unit",
"Add-in Card",
"Front Panel Board",
"Back Panel Board",
"Power System Board",
"Drive Back Plane",
}
return locations[t-1]
}
type TemperatureProbeLocationAndStatus struct {
Status TemperatureProbeStatus
Location TemperatureProbeLocation
}
func (t TemperatureProbeLocationAndStatus) String() string {
return fmt.Sprintf("\n\t\t\t\tStatus: %s\n\t\t\t\tLocation: %s",
t.Status, t.Location)
}
func NewTemperatureProbeLocationAndStatus(data byte) TemperatureProbeLocationAndStatus {
return TemperatureProbeLocationAndStatus{
Status: TemperatureProbeStatus(data & 0xE0),
Location: TemperatureProbeLocation(data & 0x1F),
}
}
type TemperatureProbe struct {
infoCommon
Description string
LocationAndStatus TemperatureProbeLocationAndStatus
MaximumValue uint16
MinimumValue uint16
Resolution uint16
Tolerance uint16
Accuracy uint16
OEMdefined uint32
NominalValue uint16
}
func (t TemperatureProbe) String() string {
return fmt.Sprintf("Temperature Probe\n"+
"\tDescription: %s\n"+
"\tLocation And Status: %s\n"+
"\tMaximum Value: %d\n"+
"\tMinimum Value: %d\n"+
"\tResolution: %d\n"+
"\tTolerance: %d\n"+
"\tAccuracy: %d\n"+
"\tOE Mdefined: %d\n"+
"\tNominal Value: %d",
t.Description,
t.LocationAndStatus,
t.MaximumValue,
t.MinimumValue,
t.Resolution,
t.Tolerance,
t.Accuracy,
t.OEMdefined,
t.NominalValue)
}