Clean up tg ID stuff
This commit is contained in:
parent
c423749f26
commit
d0c398f6f7
2 changed files with 7 additions and 12 deletions
|
@ -127,7 +127,7 @@ func (t *cache) add(rec *Talkgroup) error {
|
|||
t.Lock()
|
||||
defer t.Unlock()
|
||||
|
||||
tg := TG(rec.System.ID, int(rec.Talkgroup.Tgid))
|
||||
tg := TG(rec.System.ID, rec.Talkgroup.Tgid)
|
||||
t.tgs[tg] = rec
|
||||
t.systems[int32(rec.System.ID)] = rec.System.Name
|
||||
|
||||
|
|
|
@ -28,7 +28,11 @@ func (ids *IDs) Packed() []int64 {
|
|||
return r
|
||||
}
|
||||
|
||||
func TG[T int | uint | int64 | uint64 | int32 | uint32](sys, tgid T) ID {
|
||||
type intId interface {
|
||||
int | uint | int64 | uint64 | int32 | uint32
|
||||
}
|
||||
|
||||
func TG[T intId, U intId](sys T, tgid U) ID {
|
||||
return ID{
|
||||
System: uint32(sys),
|
||||
Talkgroup: uint32(tgid),
|
||||
|
@ -42,14 +46,5 @@ func (t ID) Pack() int64 {
|
|||
|
||||
func (t ID) String() string {
|
||||
return fmt.Sprintf("%d:%d", t.System, t.Talkgroup)
|
||||
}
|
||||
|
||||
func PackedTGs(tg []ID) []int64 {
|
||||
s := make([]int64, len(tg))
|
||||
|
||||
for i, v := range tg {
|
||||
s[i] = v.Pack()
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue