statedefinition

package
v0.0.0-...-8472d0d Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 2 Imported by: 20

Documentation

Index

Constants

View Source
const (
	Production = "production"
	Stage      = "stage"
	Test       = "test"
	Dev        = "development"
)

Designations

View Source
const (
	DMPS       = "dmps"
	Pi         = "pi"
	Scheduling = "scheduling"
	Timeclock  = "timeclock"
)

SystemTypes

Variables

This section is empty.

Functions

func CompareDevices

func CompareDevices(base, new StaticDevice) (diff StaticDevice, merged StaticDevice, changes bool, err *nerr.E)

CompareDevices takes a base devices, and calculates the difference between the two, returning it in the staticDevice return value. Bool denotes if there were any differences

Types

type Alert

type Alert struct {
	AlertSent time.Time `json:"alert-sent,omitempty"`
	Alerting  bool      `json:"alerting,omitempty"`
	Message   string    `json:"message,omitempty"`
}

type State

type State struct {
	ID    string      // id of the document to update in elk
	Key   string      // key to update in a entry in the static index
	Time  time.Time   // time the state took effect, must be later than the one saved to be stored.
	Tags  []string    //tags
	Value interface{} // value of key to set in static index
}

type StaticDevice

type StaticDevice struct {
	//common fields
	DeviceID                string           `json:"deviceID,omitempty"`
	Alerting                *bool            `json:"alerting,omitempty"`
	Alerts                  map[string]Alert `json:"alerts,omitempty"`
	NotificationsSuppressed *bool            `json:"notifications-suppressed,omitempty"`
	Building                string           `json:"building,omitempty"`
	Room                    string           `json:"room,omitempty"`
	Hostname                string           `json:"hostname,omitempty"`
	LastStateReceived       time.Time        `json:"last-state-received,omitempty"`
	LastHeartbeat           time.Time        `json:"last-heartbeat,omitempty"`
	LastUserInput           time.Time        `json:"last-user-input,omitempty"`

	DeviceType  string `json:"device-type,omitempty"`
	DeviceClass string `json:"device-class,omitempty"`
	DeviceName  string `json:"device-name,omitempty"`

	Tags []string `json:"tags,omitempty"`

	//semi-common fields LastHeartbeat time.Time `json:"last-heartbeat,omitempty"` LastUserInput time.Time `json:"last-user-input,omitempty"`
	Power           string `json:"power,omitempty"`
	Active          string `json:"active,omitempty"`
	Secure          string `json:"secure,omitempty"`
	HardwareVersion string `json:"hardware-version,omitempty"`
	SoftwareVersion string `json:"software-version,omitempty"`
	FirmwareVersion string `json:"firmware-version"`
	SerialNumber    string `json:"serial-number"`
	IPAddress       string `json:"ip-address"`
	MACAddress      string `json:"mac-address"`
	ModelName       string `json:"model-name"`

	DNSAddress     string `json:"dns-address,omitempty"`
	DefaultGateway string `json:"default-gateway"`

	//Control Processor Specific Fields
	Websocket      string `json:"websocket,omitempty"`
	WebsocketCount *int   `json:"websocket-count,omitempty"`

	//Display Specific Fields
	Blanked      *bool  `json:"blanked,omitempty"`
	Input        string `json:"input,omitempty"`
	LampHours    *int   `json:"lamp-hours,omitempty"`
	Temperature  *int   `json:"temperature,omitempty"`
	ActiveSignal *bool  `json:"active-signal,omitempty"`

	//Audio Device Specific Fields
	Muted  *bool `json:"muted,omitempty"`
	Volume *int  `json:"volume,omitempty"`

	//Fields specific to Microphones
	BatteryChargeBars         *int   `json:"battery-charge-bars,omitempty"`
	BatteryChargeMinutes      *int   `json:"battery-charge-minutes,omitempty"`
	BatteryChargePercentage   *int   `json:"battery-charge-percentage,omitempty"`
	BatteryChargeHoursMinutes string `json:"battery-charge-hours-minutes,omitempty"`
	BatteryCycles             *int   `json:"battery-cycles,omitempty"`
	BatteryType               string `json:"battery-type,omitempty"`
	MicrophoneChannel         string `json:"microphone-channel,omitempty"`
	Interference              string `json:"interference,omitempty"`

	CurrentUserCount *int `json:"current-user-count,omitempty"`
	PresenterCount   *int `json:"presenter-count,omitempty"`

	//meta fields for use in kibana
	Control               string `json:"control,omitempty"`                //the id - used in a URL
	EnableNotifications   string `json:"enable-notifications,omitempty"`   //the id - used in a URL
	SuppressNotifications string `json:"suppress-notifications,omitempty"` //the id - used in a URL
	ViewDashboard         string `json:"ViewDashboard,omitempty"`          //the id - used in a URL

	//Linux Device Information
	CPUUsagePercentage    *float64 `json:"cpu-usage-percent,omitempty"`
	VMemUsage             *float64 `json:"v-mem-used-percent,omitempty"`
	SMemUsage             *float64 `json:"s-mem-used-percent,omitempty"`
	CPUTemp               *float64 `json:"cpu-thermal0-temp,omitempty"`
	DiskWrites            *int     `json:"writes-to-mmcblk0,omitempty"`
	DiskUsagePercentage   *float64 `json:"disk-used-percent,omitempty"`
	AverageProcessesSleep *float64 `json:"avg-procs-u-sleep,omitempty"`

	BroadcomChipTemp *float64 `json:"bcm2835_thermal0-temp,omitempty"`

	//DMPS information
	StatusMessage   string `json:"status-message,omitempty"`
	TransmitRFPower string `json:"transmit-rf-power,omitempty"`

	UpdateTimes map[string]time.Time `json:"field-state-received"`
}

StaticDevice . ************************* IMPORTANT - if you add fields to this struct be sure to change the CompareDevices function *************************

type StaticRoom

type StaticRoom struct {
	//information fields
	BuildingID string `json:"buildingID,omitempty"`
	RoomID     string `json:"roomID,omitempty"`

	//State fields
	MaintenenceMode        *bool     `json:"maintenence-mode,omitempty"`       //if the system is in maintenence mode.
	MaintenenceModeEndTime time.Time `json:"maintenence-mode-until,omitempty"` //if the system is in maintenence mode, when to put it back in monitoring.
	Monitoring             *bool     `json:"monitoring,omitempty"`             //if the system is in monitoring currently.

	Designation string   `json:"designation,omitempty"`
	SystemType  []string `json:"system-type,omitempty"` //pi, dmps, scheduling, timeclock. If a room has more than one there may be multiple entries into this field.

	Tags []string `json:"tags,omitempty"`

	UpdateTimes map[string]time.Time `json:"update-times"`

	AlertsToSupress []string `json:"alerts-to-supress"`
}

StaticRoom represents the same information that is in the static index

func CompareRooms

func CompareRooms(base, new StaticRoom) (diff, merged StaticRoom, changes bool, err *nerr.E)

CompareRooms takes two rooms and compares them, changes from new to base will only be included if they have a timestamp in UpdateTimes later than that in base for the same field

func (*StaticRoom) HasSystemType

func (r *StaticRoom) HasSystemType(s string) bool

Jump to

Keyboard shortcuts

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