monitor

package module
v0.0.0-...-fbf0113 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: BSD-2-Clause Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCadMonitorLoggedOut represents a status where the application needs to reauthenticate
	ErrCadMonitorLoggedOut = errors.New("logged out")
)

Functions

func CadDateTime

func CadDateTime(orig string) time.Time

func CadDateTimeShort

func CadDateTimeShort(orig string) time.Time

func RegisterCadMonitor

func RegisterCadMonitor(name string, m func() CadMonitor)

RegisterCadMonitor adds a new CadMonitor instance to the registry

Types

type AegisMonitor

type AegisMonitor struct {
	// Suffix is the required suffix for units. Leaving blank disables
	// qualification by this value.
	Suffix string

	// LoginURL (example: "http://cadview.qvec.org/NewWorld.CAD.ViewOnly/"
	// or "http://cadview.qvec.org/")
	BaseURL string

	// FDID represents the FDID string which will be right padded to select
	// only local FDID events.
	FDID string

	// Numeric protocol; 0 defaults to latest
	Protocol int64
	// contains filtered or unexported fields
}

AegisMonitor represents a CadMonitor for the AEGIS CAD system

func (*AegisMonitor) ConfigureFromValues

func (c *AegisMonitor) ConfigureFromValues(values map[string]string) error

func (*AegisMonitor) GetActiveAndUnassignedCalls

func (c *AegisMonitor) GetActiveAndUnassignedCalls() (map[string]CallStatus, error)

func (*AegisMonitor) GetActiveCalls

func (c *AegisMonitor) GetActiveCalls() ([]string, error)

func (*AegisMonitor) GetClearedCalls

func (c *AegisMonitor) GetClearedCalls(dt string) (map[string]string, error)

GetClearedCalls fetches all cleared calls for specified date in format MM/DD/YYYY.

func (*AegisMonitor) GetStatus

func (c *AegisMonitor) GetStatus(content []byte, id string) (CallStatus, error)

func (*AegisMonitor) GetStatusFromURL

func (c *AegisMonitor) GetStatusFromURL(url string) (CallStatus, error)

func (*AegisMonitor) KeepAlive

func (c *AegisMonitor) KeepAlive() error

func (*AegisMonitor) LoggedIn

func (c *AegisMonitor) LoggedIn() bool

func (*AegisMonitor) Login

func (c *AegisMonitor) Login(user, pass string) error

func (*AegisMonitor) Monitor

func (c *AegisMonitor) Monitor(callback func(CallStatus) error, pollInterval int) error

Monitor runs a monitoring function with a callback function

func (*AegisMonitor) SetDebug

func (c *AegisMonitor) SetDebug(d bool)

SetDebug enables or disables debug

func (*AegisMonitor) SetTerminateMonitor

func (c *AegisMonitor) SetTerminateMonitor(t bool)

func (AegisMonitor) TerminateMonitor

func (c AegisMonitor) TerminateMonitor() bool

type CadMonitor

type CadMonitor interface {
	// ConfigureFromValues populates fields specific to an implementation of
	// CadMonitor from a map[string]string.
	ConfigureFromValues(map[string]string) error
	// Login authenticates to a CAD system using the provided username and password
	Login(string, string) error
	// GetActiveCalls returns a list of active call URLs or identifiers
	GetActiveCalls() ([]string, error)
	// GetActiveAndUnassignedCalls returns a list of CallStatus objects for unassigned and
	// current calls
	GetActiveAndUnassignedCalls() (map[string]CallStatus, error)
	// GetStatus given an identifier retrieves a CallStatus entry that describes a call
	GetStatus([]byte, string) (CallStatus, error)
	// GetStatusFromURL given an identifier retrieves a CallStatus entry that describes a call
	GetStatusFromURL(string) (CallStatus, error)
	// GetClearedCalls retrieves a map of ids for cleared calls for a specific date
	GetClearedCalls(string) (map[string]string, error)
	// SetDebug determines whether debug is enabled or not
	SetDebug(bool)
	// KeepAlive represents some manner of maintaining a persistent connection
	KeepAlive() error
	TerminateMonitor() bool
	SetTerminateMonitor(bool)
	// Monitor actively runs a monitoring function with a callback
	Monitor(func(CallStatus) error, int) error
}

CadMonitor defines the interface for all monitors used to watch CAD systems.

func InstantiateCadMonitor

func InstantiateCadMonitor(name string) (m CadMonitor, err error)

InstantiateCadMonitor instantiates a CadMonitor by name

type CallStatus

type CallStatus struct {
	gorm.Model    `json:"-"`
	ID            string                `json:"id" gorm:"-"`
	CallID        string                `json:"call_id" gorm:"size:64,uniqueIndex:call_idx"`
	CallTime      time.Time             `json:"call_time" gorm:"uniqueIndex:call_idx"`
	DispatchTime  time.Time             `json:"dispatch_time" gorm:"index"`
	ArrivalTime   sql.NullTime          `json:"arrival_time"`
	CallType      string                `json:"call_type"`
	CallerPhone   string                `json:"caller_phone" gorm:"size:32"`
	NatureOfCall  string                `json:"nature_of_call" gorm:"index"`
	Location      string                `json:"location" gorm:"index"`
	District      string                `json:"district"`
	CrossStreets  string                `json:"cross_streets"`
	Priority      int                   `json:"priority" gorm:"index"`
	Incidents     []Incident            `json:"incidents" db:"-" gorm:"foreignKey:CallStatusID"`
	Narratives    []Narrative           `json:"narratives" db:"-" gorm:"foreignKey:CallStatusID"`
	Units         []UnitStatus          `json:"units" db:"-" gorm:"foreignKey:CallStatusID"`
	UnitStatusMap map[string]UnitStatus `json:"unit_status_map" db:"-" gorm:"-" sql:"-"`
	LastUpdated   time.Time             `json:"last_updated"`
	RawHTML       string                `json:"raw_html"`
}

type Incident

type Incident struct {
	gorm.Model     `json:"-"`
	CallStatusID   string `json:"cs_id" gorm:"index;size:64"`
	FDID           string `json:"fdid" gorm:"size:10;uniqueIndex:incident_fdid"`
	IncidentNumber string `json:"incident_number" gorm:"size:32;uniqueIndex:incident_fdid"`
}

type Narrative

type Narrative struct {
	gorm.Model   `json:"-"`
	CallStatusID string    `json:"cs_id" gorm:"uniqueIndex:narrative_idx;size:64"`
	RecordedTime time.Time `json:"recorded_time" gorm:"uniqueIndex:narrative_idx"`
	Message      string    `json:"message"`
	User         string    `json:"user"`
}

type UnitStatus

type UnitStatus struct {
	gorm.Model   `json:"-"`
	CallStatusID string `json:"cs_id" gorm:"uniqueIndex:unit_idx;size:64"`
	Unit         string `json:"unit" gorm:"size:32;uniqueIndex:unit_idx"`
	Status       string `json:"status"`
	DispatchTime string `json:"dispatch_time" gorm:"index"`
	EnRouteTime  string `json:"enroute_time" gorm:"index"`
	ArrivedTime  string `json:"arrived_time" gorm:"index"`
	ClearedTime  string `json:"cleared_time"`
}

Jump to

Keyboard shortcuts

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