models

package
v1.0.31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TalkgroupSeederRows = 1
View Source
const UserSeederRows = 2

Variables

This section is empty.

Functions

func ActiveCallExists

func ActiveCallExists(db *gorm.DB, streamID uint, src uint, dst uint, slot bool, groupCall bool) bool

func CountCalls

func CountCalls(db *gorm.DB) int

func CountRepeaterCalls

func CountRepeaterCalls(db *gorm.DB, repeaterID uint) int

func CountRepeaters

func CountRepeaters(db *gorm.DB) (int, error)

func CountTalkgroupCalls

func CountTalkgroupCalls(db *gorm.DB, talkgroupID uint) int

func CountTalkgroups

func CountTalkgroups(db *gorm.DB) (int, error)

func CountTalkgroupsByOwnerID

func CountTalkgroupsByOwnerID(db *gorm.DB, ownerID uint) (int, error)

func CountUserAdmins

func CountUserAdmins(db *gorm.DB) (int, error)

func CountUserCalls

func CountUserCalls(db *gorm.DB, userID uint) int

func CountUserRepeaters

func CountUserRepeaters(db *gorm.DB, id uint) (int, error)

func CountUserSuspended

func CountUserSuspended(db *gorm.DB) (int, error)

func CountUserUnapproved

func CountUserUnapproved(db *gorm.DB) (int, error)

func CountUsers

func CountUsers(db *gorm.DB) (int, error)

func DeleteRepeater

func DeleteRepeater(db *gorm.DB, id uint) error

func DeleteTalkgroup

func DeleteTalkgroup(db *gorm.DB, id uint) error

func DeleteUser

func DeleteUser(db *gorm.DB, id uint) error

func RepeaterExists

func RepeaterExists(db *gorm.DB, repeater Repeater) (bool, error)

func RepeaterIDExists

func RepeaterIDExists(db *gorm.DB, id uint) (bool, error)

func TalkgroupIDExists

func TalkgroupIDExists(db *gorm.DB, id uint) (bool, error)

func UserExists

func UserExists(db *gorm.DB, user User) (bool, error)

func UserIDExists

func UserIDExists(db *gorm.DB, id uint) (bool, error)

Types

type AppSettings

type AppSettings struct {
	ID        uint `gorm:"primaryKey"`
	HasSeeded bool
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type Call

type Call struct {
	ID             uint           `json:"id" gorm:"primarykey"`
	CallData       []byte         `json:"-"`
	StreamID       uint           `json:"-"`
	StartTime      time.Time      `json:"start_time"`
	Duration       time.Duration  `json:"duration"`
	Active         bool           `json:"active"`
	User           User           `json:"user" gorm:"foreignKey:UserID"`
	UserID         uint           `json:"-"`
	Repeater       Repeater       `json:"repeater" gorm:"foreignKey:RepeaterID"`
	RepeaterID     uint           `json:"-"`
	TimeSlot       bool           `json:"time_slot"`
	GroupCall      bool           `json:"group_call"`
	IsToTalkgroup  bool           `json:"is_to_talkgroup"`
	ToTalkgroupID  *uint          `json:"-"`
	ToTalkgroup    Talkgroup      `json:"to_talkgroup" gorm:"foreignKey:ToTalkgroupID"`
	IsToUser       bool           `json:"is_to_user"`
	ToUserID       *uint          `json:"-"`
	ToUser         User           `json:"to_user" gorm:"foreignKey:ToUserID"`
	IsToRepeater   bool           `json:"is_to_repeater"`
	ToRepeaterID   *uint          `json:"-"`
	ToRepeater     Repeater       `json:"to_repeater" gorm:"foreignKey:ToRepeaterID"`
	DestinationID  uint           `json:"destination_id"`
	TotalPackets   uint           `json:"-"`
	LostSequences  uint           `json:"-"`
	Loss           float32        `json:"loss"`
	Jitter         float32        `json:"jitter"`
	LastFrameNum   uint           `json:"-"`
	LastSeq        uint           `json:"-"`
	BER            float32        `json:"ber"`
	RSSI           float32        `json:"rssi"`
	TotalBits      uint           `json:"-"`
	TotalErrors    int            `json:"-"`
	LastPacketTime time.Time      `json:"-"`
	HasHeader      bool           `json:"-"`
	HasTerm        bool           `json:"-"`
	CreatedAt      time.Time      `json:"-"`
	UpdatedAt      time.Time      `json:"-"`
	DeletedAt      gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindActiveCall

func FindActiveCall(db *gorm.DB, streamID uint, src uint, dst uint, slot bool, groupCall bool) (Call, error)

func FindCalls

func FindCalls(db *gorm.DB) []Call

func FindRepeaterCalls

func FindRepeaterCalls(db *gorm.DB, repeaterID uint) []Call

func FindTalkgroupCalls

func FindTalkgroupCalls(db *gorm.DB, talkgroupID uint) []Call

func FindUserCalls

func FindUserCalls(db *gorm.DB, userID uint) []Call

type Packet

type Packet struct {
	Signature   string             `msg:"signature"`
	Seq         uint               `msg:"seq"`
	Src         uint               `msg:"src"`
	Dst         uint               `msg:"dst"`
	Repeater    uint               `msg:"repeater"`
	Slot        bool               `msg:"slot"`
	GroupCall   bool               `msg:"groupCall"`
	FrameType   dmrconst.FrameType `msg:"frameType,extension"`
	DTypeOrVSeq uint               `msg:"dtypeOrVSeq"`
	StreamID    uint               `msg:"streamID"`
	DMRData     [33]byte           `msg:"dmrData"`
	// The next two are technically unsigned, but the data type is 1 byte
	// We also want to be able to represent -1 as a null, so we use int
	BER  int `msg:"ber"`
	RSSI int `msg:"rssi"`
}

Packet is a DMR packet

func UnpackPacket

func UnpackPacket(data []byte) (Packet, bool)

func (*Packet) Encode

func (p *Packet) Encode() []byte

func (Packet) Equal

func (p Packet) Equal(other Packet) bool

func (*Packet) String

func (p *Packet) String() string

type RawDMRPacket

type RawDMRPacket struct {
	Data       []byte `msg:"data"`
	RemoteIP   string `msg:"remote_ip"`
	RemotePort int    `msg:"remote_port"`
}

RawDMRPacket is a raw DMR packet

type Repeater

type Repeater struct {
	RadioID               uint           `json:"id" gorm:"primaryKey" msg:"radio_id"`
	Connection            string         `json:"-" gorm:"-" msg:"connection"`
	Connected             time.Time      `json:"connected_time" msg:"connected"`
	PingsReceived         uint           `json:"-" gorm:"-" msg:"pings_received"`
	LastPing              time.Time      `json:"last_ping_time" msg:"last_ping"`
	IP                    string         `json:"-" gorm:"-" msg:"ip"`
	Port                  int            `json:"-" gorm:"-" msg:"port"`
	Salt                  uint32         `json:"-" gorm:"-" msg:"salt"`
	Callsign              string         `json:"callsign" msg:"callsign"`
	RXFrequency           uint           `json:"rx_frequency" msg:"rx_frequency"`
	TXFrequency           uint           `json:"tx_frequency" msg:"tx_frequency"`
	TXPower               uint           `json:"tx_power" msg:"tx_power"`
	ColorCode             uint           `json:"color_code" msg:"color_code"`
	Latitude              float32        `json:"latitude" msg:"latitude"`
	Longitude             float32        `json:"longitude" msg:"longitude"`
	Height                int            `json:"height" msg:"height"`
	Location              string         `json:"location" msg:"location"`
	Description           string         `json:"description" msg:"description"`
	Slots                 uint           `json:"slots" msg:"slots"`
	URL                   string         `json:"url" msg:"url"`
	SoftwareID            string         `json:"software_id" msg:"software_id"`
	PackageID             string         `json:"package_id" msg:"package_id"`
	Password              string         `json:"-" msg:"-"`
	TS1StaticTalkgroups   []Talkgroup    `json:"ts1_static_talkgroups" gorm:"many2many:repeater_ts1_static_talkgroups;" msg:"-"`
	TS2StaticTalkgroups   []Talkgroup    `json:"ts2_static_talkgroups" gorm:"many2many:repeater_ts2_static_talkgroups;" msg:"-"`
	TS1DynamicTalkgroupID *uint          `json:"-" msg:"-"`
	TS2DynamicTalkgroupID *uint          `json:"-" msg:"-"`
	TS1DynamicTalkgroup   Talkgroup      `json:"ts1_dynamic_talkgroup" gorm:"foreignKey:TS1DynamicTalkgroupID" msg:"-"`
	TS2DynamicTalkgroup   Talkgroup      `json:"ts2_dynamic_talkgroup" gorm:"foreignKey:TS2DynamicTalkgroupID" msg:"-"`
	Owner                 User           `json:"owner" gorm:"foreignKey:OwnerID" msg:"-"`
	OwnerID               uint           `json:"-" msg:"-"`
	Hotspot               bool           `json:"hotspot" msg:"hotspot"`
	CreatedAt             time.Time      `json:"created_at" msg:"-"`
	UpdatedAt             time.Time      `json:"-" msg:"-"`
	DeletedAt             gorm.DeletedAt `json:"-" gorm:"index" msg:"-"`
}

Repeater is the model for a DMR repeater

func FindRepeaterByID

func FindRepeaterByID(db *gorm.DB, id uint) (Repeater, error)

func GetUserRepeaters

func GetUserRepeaters(db *gorm.DB, id uint) ([]Repeater, error)

func ListRepeaters

func ListRepeaters(db *gorm.DB) ([]Repeater, error)

func (*Repeater) InTS1StaticTalkgroups

func (p *Repeater) InTS1StaticTalkgroups(dest uint) bool

func (*Repeater) InTS2StaticTalkgroups

func (p *Repeater) InTS2StaticTalkgroups(dest uint) bool

func (*Repeater) String

func (p *Repeater) String() string

func (*Repeater) WantRX

func (p *Repeater) WantRX(packet Packet) (bool, bool)

func (*Repeater) WantRXCall added in v1.0.15

func (p *Repeater) WantRXCall(call Call) (bool, bool)

type Talkgroup

type Talkgroup struct {
	ID          uint           `json:"id" gorm:"primaryKey"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Admins      []User         `json:"admins" gorm:"many2many:talkgroup_admins;"`
	NCOs        []User         `json:"ncos" gorm:"many2many:talkgroup_ncos;"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"-"`
	DeletedAt   gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindTalkgroupByID

func FindTalkgroupByID(db *gorm.DB, id uint) (Talkgroup, error)

func FindTalkgroupsByOwnerID

func FindTalkgroupsByOwnerID(db *gorm.DB, ownerID uint) ([]Talkgroup, error)

func ListTalkgroups

func ListTalkgroups(db *gorm.DB) ([]Talkgroup, error)

type TalkgroupsSeeder

type TalkgroupsSeeder struct {
	gorm_seeder.SeederAbstract
}

func (*TalkgroupsSeeder) Clear

func (s *TalkgroupsSeeder) Clear(db *gorm.DB) error

func (*TalkgroupsSeeder) Seed

func (s *TalkgroupsSeeder) Seed(db *gorm.DB) error

type User

type User struct {
	ID        uint           `json:"id" gorm:"primaryKey" binding:"required"`
	Callsign  string         `json:"callsign" gorm:"uniqueIndex" binding:"required"`
	Username  string         `json:"username" gorm:"uniqueIndex" binding:"required"`
	Password  string         `json:"-"`
	Admin     bool           `json:"admin"`
	Approved  bool           `json:"approved" binding:"required"`
	Suspended bool           `json:"suspended"`
	Repeaters []Repeater     `json:"repeaters" gorm:"foreignKey:OwnerID"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindUserAdmins

func FindUserAdmins(db *gorm.DB) ([]User, error)

func FindUserByID

func FindUserByID(db *gorm.DB, id uint) (User, error)

func FindUserSuspended

func FindUserSuspended(db *gorm.DB) ([]User, error)

func FindUserUnapproved

func FindUserUnapproved(db *gorm.DB) ([]User, error)

func ListUsers

func ListUsers(db *gorm.DB) ([]User, error)

func (User) TableName

func (u User) TableName() string

type UsersSeeder

type UsersSeeder struct {
	gorm_seeder.SeederAbstract
}

func (*UsersSeeder) Clear

func (s *UsersSeeder) Clear(db *gorm.DB) error

func (*UsersSeeder) Seed

func (s *UsersSeeder) Seed(db *gorm.DB) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL