Skip to content
This repository was archived by the owner on Mar 12, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package mapache

// Ping is a type to represent a ping between the vehicle and the server.
// Note that only the uplink latency is saved on the server. The vehicle does receive pongs,
// so it may choose to record the round trip time if it desires.
type Ping struct {
// VehicleID is the unique identifier for the vehicle that sent the ping.
VehicleID string `json:"vehicle_id" gorm:"primaryKey"`
// Ping is the unix millis when the vehicle sent the ping.
Ping int `json:"ping" gorm:"primaryKey"`
// Pong is the unix millis when the vehicle received the ping.
Pong int `json:"pong"`
// Latency is the latency of the ping in milliseconds.
Latency int `json:"latency"`
}

func (Ping) TableName() string {
return "ping"

Check warning on line 18 in ping.go

View check run for this annotation

Codecov / codecov/patch

ping.go#L17-L18

Added lines #L17 - L18 were not covered by tests
}
137 changes: 2 additions & 135 deletions signal_test.go
Original file line number Diff line number Diff line change
@@ -1,138 +1,5 @@
package mapache

// import (
// "reflect"
// "testing"
// )
import "testing"

// func TestSignal_Decode(t *testing.T) {
// t.Run("Test Big Endian Unsigned", func(t *testing.T) {
// f := Signal{
// Bytes: []byte{0x00, 0x01},
// Sign: Unsigned,
// Endian: BigEndian,
// }
// if f.Decode().RawValue != 1 {
// t.Error("Expected 1, got", f.Decode().RawValue)
// }
// })
// t.Run("Test Big Endian Signed", func(t *testing.T) {
// f := Signal{
// Bytes: []byte{0x00, 0x01},
// Sign: Signed,
// Endian: BigEndian,
// }
// if f.Decode().RawValue != 1 {
// t.Error("Expected 1, got", f.Decode().RawValue)
// }
// })
// t.Run("Test Little Endian Unsigned", func(t *testing.T) {
// f := Signal{
// Bytes: []byte{0x00, 0x01},
// Sign: Unsigned,
// Endian: LittleEndian,
// }
// if f.Decode().RawValue != 256 {
// t.Error("Expected 256, got", f.Decode().RawValue)
// }
// })
// t.Run("Test Little Endian Signed", func(t *testing.T) {
// f := Signal{
// Bytes: []byte{0x00, 0x01},
// Sign: Signed,
// Endian: LittleEndian,
// }
// if f.Decode().RawValue != 256 {
// t.Error("Expected 256, got", f.Decode().RawValue)
// }
// })
// t.Run("Test Other", func(t *testing.T) {
// f := Signal{
// Bytes: []byte{0x00, 0x01},
// Sign: -1,
// Endian: -1,
// }
// if f.Decode().RawValue != 0 {
// t.Error("Expected 0, got", f.Decode().RawValue)
// }
// })
// }

// func TestSignal_Encode(t *testing.T) {
// t.Run("Test Big Endian Unsigned", func(t *testing.T) {
// f := Signal{
// Sign: Unsigned,
// Endian: BigEndian,
// RawValue: 1,
// Size: 2,
// }
// b, err := f.Encode()
// if err != nil {
// t.Error("Expected nil, got", err)
// }
// expected := []byte{0x00, 0x01}
// if !reflect.DeepEqual(b.Bytes, expected) {
// t.Error("Expected", expected, "got", b.Bytes)
// }
// })
// t.Run("Test Big Endian Signed", func(t *testing.T) {
// f := Signal{
// Sign: Signed,
// Endian: BigEndian,
// RawValue: 1,
// Size: 2,
// }
// b, err := f.Encode()
// if err != nil {
// t.Error("Expected nil, got", err)
// }
// expected := []byte{0x00, 0x01}
// if !reflect.DeepEqual(b.Bytes, expected) {
// t.Error("Expected", expected, "got", b.Bytes)
// }
// })
// t.Run("Test Little Endian Unsigned", func(t *testing.T) {
// f := Signal{
// Sign: Unsigned,
// Endian: LittleEndian,
// RawValue: 1,
// Size: 2,
// }
// b, err := f.Encode()
// if err != nil {
// t.Error("Expected nil, got", err)
// }
// expected := []byte{0x01, 0x00}
// if !reflect.DeepEqual(b.Bytes, expected) {
// t.Error("Expected", expected, "got", b.Bytes)
// }
// })
// t.Run("Test Little Endian Signed", func(t *testing.T) {
// f := Signal{
// Sign: Signed,
// Endian: LittleEndian,
// RawValue: 1,
// Size: 2,
// }
// b, err := f.Encode()
// if err != nil {
// t.Error("Expected nil, got", err)
// }
// expected := []byte{0x01, 0x00}
// if !reflect.DeepEqual(b.Bytes, expected) {
// t.Error("Expected", expected, "got", b.Bytes)
// }
// })
// t.Run("Test Other", func(t *testing.T) {
// f := Signal{
// Sign: -1,
// Endian: -1,
// RawValue: 1,
// Size: 2,
// }
// _, err := f.Encode()
// if err == nil {
// t.Error("Expected err, got nil")
// }
// })
// }
func TestSignal_TableName(t *testing.T) {}