2024-11-03 08:09:49 -05:00
|
|
|
package talkgroups
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-11-03 09:45:51 -05:00
|
|
|
|
|
|
|
"dynatron.me/x/stillbox/pkg/database"
|
2024-11-03 08:09:49 -05:00
|
|
|
)
|
|
|
|
|
2024-11-03 09:45:51 -05:00
|
|
|
type Talkgroup struct {
|
|
|
|
database.Talkgroup
|
|
|
|
System database.System `json:"system"`
|
|
|
|
Learned bool `json:"learned"`
|
|
|
|
}
|
|
|
|
|
2024-11-13 09:24:11 -05:00
|
|
|
type Metadata map[string]interface{}
|
|
|
|
|
2024-11-07 23:17:16 -05:00
|
|
|
type Names struct {
|
|
|
|
System string
|
|
|
|
Talkgroup string
|
|
|
|
}
|
|
|
|
|
2024-11-03 08:09:49 -05:00
|
|
|
type ID struct {
|
2024-11-06 14:20:15 -05:00
|
|
|
System uint32 `json:"sys"`
|
|
|
|
Talkgroup uint32 `json:"tg"`
|
2024-11-03 08:09:49 -05:00
|
|
|
}
|
|
|
|
|
2024-11-04 11:15:24 -05:00
|
|
|
type IDs []ID
|
|
|
|
|
2024-11-15 10:37:58 -05:00
|
|
|
func (t IDs) Tuples() database.TGTuples {
|
|
|
|
sys := make([]uint32, len(t))
|
|
|
|
tg := make([]uint32, len(t))
|
|
|
|
|
|
|
|
for i := range t {
|
|
|
|
sys[i] = t[i].System
|
|
|
|
tg[i] = t[i].Talkgroup
|
2024-11-04 11:15:24 -05:00
|
|
|
}
|
|
|
|
|
2024-11-15 10:37:58 -05:00
|
|
|
return database.TGTuples{sys, tg}
|
2024-11-04 11:15:24 -05:00
|
|
|
}
|
|
|
|
|
2024-11-07 12:53:20 -05:00
|
|
|
type intId interface {
|
|
|
|
int | uint | int64 | uint64 | int32 | uint32
|
|
|
|
}
|
|
|
|
|
|
|
|
func TG[T intId, U intId](sys T, tgid U) ID {
|
2024-11-03 08:09:49 -05:00
|
|
|
return ID{
|
|
|
|
System: uint32(sys),
|
|
|
|
Talkgroup: uint32(tgid),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t ID) String() string {
|
|
|
|
return fmt.Sprintf("%d:%d", t.System, t.Talkgroup)
|
|
|
|
|
|
|
|
}
|