@@ -15,76 +15,32 @@ public SensorNode(ISensor sensor, PersistentSettings settings)
1515 {
1616 Sensor = sensor ;
1717 _settings = settings ;
18-
19- switch ( sensor . SensorType )
18+ Format = sensor . SensorType switch
2019 {
21- case SensorType . Voltage :
22- Format = "{0:F3} V" ;
23- break ;
24- case SensorType . Current :
25- Format = "{0:F3} A" ;
26- break ;
27- case SensorType . Clock :
28- Format = "{0:F1} MHz" ;
29- break ;
30- case SensorType . Load :
31- Format = "{0:F1} %" ;
32- break ;
33- case SensorType . Temperature :
34- Format = "{0:F1} °C" ;
35- break ;
36- case SensorType . Fan :
37- Format = "{0:F0} RPM" ;
38- break ;
39- case SensorType . Flow :
40- Format = "{0:F1} L/h" ;
41- break ;
42- case SensorType . Control :
43- Format = "{0:F1} %" ;
44- break ;
45- case SensorType . Level :
46- Format = "{0:F1} %" ;
47- break ;
48- case SensorType . Power :
49- Format = "{0:F1} W" ;
50- break ;
51- case SensorType . Data :
52- Format = "{0:F1} GB" ;
53- break ;
54- case SensorType . SmallData :
55- Format = "{0:F1} MB" ;
56- break ;
57- case SensorType . Factor :
58- Format = "{0:F3}" ;
59- break ;
60- case SensorType . IntFactor :
61- Format = "{0:F0}" ;
62- break ;
63- case SensorType . Frequency :
64- Format = "{0:F1} Hz" ;
65- break ;
66- case SensorType . Throughput :
67- Format = "{0:F1} B/s" ;
68- break ;
69- case SensorType . TimeSpan :
70- Format = "{0:g}" ;
71- break ;
72- case SensorType . Timing :
73- Format = "{0:F3} ns" ;
74- break ;
75- case SensorType . Energy :
76- Format = "{0:F0} mWh" ;
77- break ;
78- case SensorType . Noise :
79- Format = "{0:F0} dBA" ;
80- break ;
81- case SensorType . Conductivity :
82- Format = "{0:F1} µS/cm" ;
83- break ;
84- case SensorType . Humidity :
85- Format = "{0:F0} %" ;
86- break ;
87- }
20+ SensorType . Voltage => "{0:0.###} V" ,
21+ SensorType . Current => "{0:0.###} A" ,
22+ SensorType . Clock => "{0:0.#} MHz" ,
23+ SensorType . Load => "{0:0.#} %" ,
24+ SensorType . Temperature => "{0:0.#} °C" ,
25+ SensorType . Fan => "{0:F0} RPM" ,
26+ SensorType . Flow => "{0:0.#} L/h" ,
27+ SensorType . Control => "{0:0.#} %" ,
28+ SensorType . Level => "{0:0.#} %" ,
29+ SensorType . Power => "{0:0.#} W" ,
30+ SensorType . Data => "{0:0.#} GB" ,
31+ SensorType . SmallData => "{0:0.#} MB" ,
32+ SensorType . Factor => "{0:0.###}" ,
33+ SensorType . IntFactor => "{0:F0}" ,
34+ SensorType . Frequency => "{0:0.#} Hz" ,
35+ SensorType . Throughput => "{0:0.#} B/s" ,
36+ SensorType . TimeSpan => "{0:g}" ,
37+ SensorType . Timing => "{0:0.###} ns" ,
38+ SensorType . Energy => "{0:F0} mWh" ,
39+ SensorType . Noise => "{0:F0} dBA" ,
40+ SensorType . Conductivity => "{0:0.#} µS/cm" ,
41+ SensorType . Humidity => "{0:F0} %" ,
42+ _ => Format
43+ } ;
8844
8945 bool hidden = settings . GetValue ( new Identifier ( sensor . Identifier , "hidden" ) . ToString ( ) , sensor . IsDefaultHidden ) ;
9046 base . IsVisible = ! hidden ;
@@ -168,7 +124,7 @@ public string ValueToString(float? value)
168124 {
169125 case SensorType . Temperature when UnitManager . IsFahrenheitUsed :
170126 {
171- return $ "{ value * 1.8 + 32 : F1 } °F";
127+ return $ "{ value * 1.8 + 32 : 0.# } °F";
172128 }
173129 case SensorType . Throughput :
174130 {
@@ -194,11 +150,11 @@ public string ValueToString(float? value)
194150 if ( value < 1024 )
195151 result = $ "{ value : F0} bps";
196152 else if ( value < 1048576 )
197- result = $ "{ value / 1024 : F1 } Kbps";
153+ result = $ "{ value / 1024 : 0.# } Kbps";
198154 else if ( value < 1073741824 )
199- result = $ "{ value / 1048576 : F1 } Mbps";
155+ result = $ "{ value / 1048576 : 0.# } Mbps";
200156 else
201- result = $ "{ value / 1073741824 : F1 } Gbps";
157+ result = $ "{ value / 1073741824 : 0.# } Gbps";
202158 }
203159
204160 break ;
@@ -210,7 +166,7 @@ public string ValueToString(float? value)
210166 {
211167 const int _1MB = 1048576 ;
212168
213- result = value < _1MB ? $ "{ value / 1024 : F1 } KB/s" : $ "{ value / _1MB : F1 } MB/s";
169+ result = value < _1MB ? $ "{ value / 1024 : 0.# } KB/s" : $ "{ value / _1MB : 0.# } MB/s";
214170
215171 break ;
216172 }
0 commit comments