From 3c0a7cf062a24094732be347c5dd3c448ccc3815 Mon Sep 17 00:00:00 2001 From: Bharat Kathi Date: Thu, 13 Feb 2025 02:16:38 -0800 Subject: [PATCH] update signal id to timestamp --- message.go | 2 +- signal.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/message.go b/message.go index 5a9433d..124a9e9 100644 --- a/message.go +++ b/message.go @@ -149,7 +149,7 @@ func (f Field) ExportSignals() []Signal { // DefaultSignalExportFunc is the default export function for a field. It exports the field as a single signal with no scaling. func DefaultSignalExportFunc(f Field) []Signal { - return []Signal{Signal{ + return []Signal{{ Name: f.Name, Value: float64(f.Value), RawValue: f.Value, diff --git a/signal.go b/signal.go index d0ff7f9..349d783 100644 --- a/signal.go +++ b/signal.go @@ -22,12 +22,13 @@ const ( // Signal is a type to represent an individual signal coming from the vehicle. // This can be something like a sensor reading, a boolean flag, or a status code. +// Timestamp, VehicleID, and Name are together used to uniquely identify a signal row entry. type Signal struct { - // ID is a unique identifier for the signal. - ID string `json:"id" gorm:"primaryKey"` + // Timestamp is the Unix microseconds of the signal. + Timestamp int `json:"timestamp"` // VehicleID is the unique identifier for the vehicle that the signal is associated with. VehicleID string `json:"vehicle_id"` - // Name represents the type of signal. + // Name represents the name of the signal. Name string `json:"name"` // Value is the value of the signal post-scaling. Value float64 `json:"value"`