@@ -109,6 +109,7 @@ func main() {
109109 for _ , datum := range vehicleData .Data {
110110 fieldName := datum .Key .String () // Get the field name from the enum
111111 value := datum .Value
112+
112113 switch v := value .Value .(type ) {
113114 case * protos.Value_DoubleValue :
114115 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (v .DoubleValue )
@@ -126,6 +127,14 @@ func main() {
126127 numericValue = 0.0
127128 }
128129 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (numericValue )
130+ case * protos.Value_StringValue :
131+ // Handle string value by setting a metric label
132+ vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (0 ) // Placeholder value
133+ // Alternatively, you might consider using a different metric type or logging
134+ log .Printf ("Received string value for field %s: %s" , fieldName , v .StringValue )
135+ case * protos.Value_Invalid :
136+ // Handle invalid value
137+ log .Printf ("Received invalid value for field %s" , fieldName )
129138 case * protos.Value_LocationValue :
130139 // Handle LocationValue separately
131140 vehicleDataGauge .WithLabelValues ("Latitude" , vehicleData .Vin ).Set (v .LocationValue .Latitude )
@@ -134,12 +143,12 @@ func main() {
134143 // Handle Doors by setting individual door states
135144 doors := v .DoorValue
136145 doorFields := map [string ]bool {
137- "DriverFront " : doors .DriverFront ,
138- "PassengerFront " : doors .PassengerFront ,
139- "DriverRear " : doors .DriverRear ,
140- "PassengerRear " : doors .PassengerRear ,
141- "TrunkFront" : doors .TrunkFront ,
142- "TrunkRear" : doors .TrunkRear ,
146+ "DriverFrontDoor " : doors .DriverFront ,
147+ "PassengerFrontDoor " : doors .PassengerFront ,
148+ "DriverRearDoor " : doors .DriverRear ,
149+ "PassengerRearDoor " : doors .PassengerRear ,
150+ "TrunkFront" : doors .TrunkFront ,
151+ "TrunkRear" : doors .TrunkRear ,
143152 }
144153 for doorName , state := range doorFields {
145154 var numericValue float64
@@ -155,6 +164,7 @@ func main() {
155164 timeValue := v .TimeValue
156165 totalSeconds := float64 (timeValue .Hour * 3600 + timeValue .Minute * 60 + timeValue .Second )
157166 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (totalSeconds )
167+ // Handle all enum types
158168 case * protos.Value_ChargingValue :
159169 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .ChargingValue .Number ()))
160170 case * protos.Value_ShiftStateValue :
@@ -189,18 +199,19 @@ func main() {
189199 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .SeatFoldPositionValue .Number ()))
190200 case * protos.Value_TractorAirStatusValue :
191201 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .TractorAirStatusValue .Number ()))
202+ case * protos.Value_TrailerAirStatusValue :
203+ vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .TrailerAirStatusValue .Number ()))
192204 case * protos.Value_FollowDistanceValue :
193205 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .FollowDistanceValue .Number ()))
194206 case * protos.Value_ForwardCollisionSensitivityValue :
195207 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .ForwardCollisionSensitivityValue .Number ()))
196208 case * protos.Value_GuestModeMobileAccessValue :
197209 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .GuestModeMobileAccessValue .Number ()))
198- case * protos.Value_TrailerAirStatusValue :
199- vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .TrailerAirStatusValue .Number ()))
200210 case * protos.Value_DetailedChargeStateValue :
201211 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (float64 (v .DetailedChargeStateValue .Number ()))
202212 default :
203- // Skip unsupported types
213+ // Log unhandled types
214+ log .Printf ("Unhandled value type for field %s" , fieldName )
204215 continue
205216 }
206217 }
0 commit comments