commandevaluators

package
v0.0.0-...-75739c8 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommandMap = make(map[string]CommandEvaluator)

CommandMap is a singleton that maps known commands to their evaluation structure. init will return a pointer to this.

View Source
var EVALUATORS = map[string]CommandEvaluator{
	"PowerOnDefault":                 &PowerOnDefault{},
	"StandbyDefault":                 &StandbyDefault{},
	"ChangeVideoInputDefault":        &ChangeVideoInputDefault{},
	"ChangeAudioInputDefault":        &ChangeAudioInputDefault{},
	"ChangeVideoInputVideoSwitcher":  &ChangeVideoInputVideoSwitcher{},
	"BlankDisplayDefault":            &BlankDisplayDefault{},
	"UnBlankDisplayDefault":          &UnBlankDisplayDefault{},
	"MuteDefault":                    &MuteDefault{},
	"UnMuteDefault":                  &UnMuteDefault{},
	"SetVolumeDefault":               &SetVolumeDefault{},
	"MuteDSP":                        &MuteDSP{},
	"UnmuteDSP":                      &UnMuteDSP{},
	"SetVolumeDSP":                   &SetVolumeDSP{},
	"ChangeVideoInputTieredSwitcher": &ChangeVideoInputTieredSwitchers{},
}

EVALUATORS is the soft singleton command map

Functions

func CheckCommands

func CheckCommands(commands map[string]base.Command, commandName string) (bool, base.Command)

CheckCommands searches a list of Commands to see if it contains any command by the name given. returns T/F, as well as the command if true.

func FilterDevicesByRole

func FilterDevicesByRole(deviceList []base.Device, roleID string) []base.Device

FilterDevicesByRole searches a list of devices for the devices that have the given roles, and returns a new list of those devices

func FindDevice

func FindDevice(deviceList []base.Device, searchID string) base.Device

FindDevice searches a list of devices for the device specified by the given ID and returns it

func GetDSPMediaInputAction

func GetDSPMediaInputAction(dbRoom base.Room, room rest.PublicRoom, event ei.Event, input string, deviceSpecific bool, destination base.DestinationDevice) (base.ActionStructure, error)

GetDSPMediaInputAction determines the devices affected and actions needed for this command.

func GetDSPMediaMuteAction

func GetDSPMediaMuteAction(dbRoom base.Room, dsp base.Device, room rest.PublicRoom, eventInfo events.Event, deviceSpecific bool) ([]base.ActionStructure, error)

GetDSPMediaMuteAction generates a list of actions based on information about the room and the DSP.

func GetDSPMediaUnMuteAction

func GetDSPMediaUnMuteAction(dbRoom base.Room, dsp base.Device, room rest.PublicRoom, eventInfo events.Event, deviceSpecific bool) ([]base.ActionStructure, error)

GetDSPMediaUnMuteAction generates a list of actions based on the room, DSP, and event information.

func GetDSPMediaVolumeAction

func GetDSPMediaVolumeAction(dbRoom base.Room, dsp base.Device, room rest.PublicRoom, eventInfo ei.Event, volume int) ([]base.ActionStructure, error)

GetDSPMediaVolumeAction generates a list of actions based on the room, DSP, and event information.

func GetDisplayMuteAction

func GetDisplayMuteAction(device base.Device, room rest.PublicRoom, eventInfo events.Event, deviceSpecific bool) (base.ActionStructure, error)

GetDisplayMuteAction generates an action based on the information about the room and display.

func GetDisplayUnMuteAction

func GetDisplayUnMuteAction(device base.Device, room rest.PublicRoom, eventInfo events.Event, deviceSpecific bool) (base.ActionStructure, error)

GetDisplayUnMuteAction generates an action based on the display, room, and event information.

func GetDisplayVolumeAction

func GetDisplayVolumeAction(device base.Device, room rest.PublicRoom, eventInfo ei.Event, volume int) (base.ActionStructure, error)

GetDisplayVolumeAction generates an action based on the room, display and event information.

func GetGeneralMuteRequestActionsDSP

func GetGeneralMuteRequestActionsDSP(dbRoom base.Room, room rest.PublicRoom, eventInfo events.Event, destination base.DestinationDevice) ([]base.ActionStructure, error)

GetGeneralMuteRequestActionsDSP assumes only one DSP, but allows for the possiblity of multiple devices not routed through the DSP room-wide mute requests DO NOT include mics

func GetGeneralUnMuteRequestActionsDSP

func GetGeneralUnMuteRequestActionsDSP(dbRoom base.Room, room rest.PublicRoom, eventInfo events.Event) ([]base.ActionStructure, error)

GetGeneralUnMuteRequestActionsDSP generates a list of actions based on the given room and event information. assumes only one DSP, but allows for the possiblity of multiple devices not routed through the DSP room-wide mute requests DO NOT include mics

func GetGeneralVolumeRequestActionsDSP

func GetGeneralVolumeRequestActionsDSP(dbRoom base.Room, room rest.PublicRoom, eventInfo ei.Event) ([]base.ActionStructure, error)

GetGeneralVolumeRequestActionsDSP generates a list of actions based on the room and DSP info.

func GetMicMuteAction

func GetMicMuteAction(dbRoom base.Room, mic base.Device, room rest.PublicRoom, eventInfo events.Event) (base.ActionStructure, error)

GetMicMuteAction takes the room information and a microphone and generates an action. assumes the mic is only connected to a single DSP

func GetMicUnMuteAction

func GetMicUnMuteAction(dbRoom base.Room, mic base.Device, room rest.PublicRoom, eventInfo events.Event) (base.ActionStructure, error)

GetMicUnMuteAction generates an action based on the room, microphone and event information. assumes the mic is only connected to a single DSP

func GetMicVolumeAction

func GetMicVolumeAction(dbRoom base.Room, mic base.Device, room rest.PublicRoom, eventInfo ei.Event, volume int) (base.ActionStructure, error)

GetMicVolumeAction generates an action based on the room, microphone and event information. we assume microphones are only connected to a DSP commands regarding microphones are only issued to DSP

func GetSwitcherAndCreateAction

func GetSwitcherAndCreateAction(dbRoom base.Room, room rest.PublicRoom, device base.Device, selectedInput, generatingEvaluator, requestor string) (base.ActionStructure, error)

GetSwitcherAndCreateAction gets the videoswitcher in a room, matches the destination port to the new port and creates an action

Types

type BlankDisplayDefault

type BlankDisplayDefault struct {
}

BlankDisplayDefault is struct that implements the CommandEvaluation struct

func (*BlankDisplayDefault) Evaluate

func (p *BlankDisplayDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate verifies the information for a BlankDisplayDefault object and generates a list of actions based on the command.

func (*BlankDisplayDefault) GetIncompatibleCommands

func (p *BlankDisplayDefault) GetIncompatibleCommands() (incompatableActions []string)

GetIncompatibleCommands keeps track of actions that are incompatable (on the same device)

func (*BlankDisplayDefault) Validate

func (p *BlankDisplayDefault) Validate(action base.ActionStructure) (err error)

Validate fulfills the Fulfill requirement on the command interface

type ChangeAudioInputDSP

type ChangeAudioInputDSP struct{}

ChangeAudioInputDSP implements the CommandEvaluation struct.

func (*ChangeAudioInputDSP) Evaluate

func (p *ChangeAudioInputDSP) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate verifies the information for a ChangeAudioInputDSP object and generates action based on the command.

type ChangeAudioInputDefault

type ChangeAudioInputDefault struct {
}

ChangeAudioInputDefault implements the CommandEvaluation struct.

func (*ChangeAudioInputDefault) Evaluate

func (p *ChangeAudioInputDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) (actions []base.ActionStructure, count int, err error)

Evaluate verifies the information for a ChangeAudioInputDefault object and generates a list of actions based on the command.

func (*ChangeAudioInputDefault) GetIncompatibleCommands

func (p *ChangeAudioInputDefault) GetIncompatibleCommands() (incompatableActions []string)

GetIncompatibleCommands keeps track of actions that are incompatable (on the same device)

func (*ChangeAudioInputDefault) Validate

func (p *ChangeAudioInputDefault) Validate(action base.ActionStructure) (err error)

Validate fulfills the Fulfill requirement on the command interface

type ChangeVideoInputDefault

type ChangeVideoInputDefault struct {
}

ChangeVideoInputDefault is struct that implements the CommandEvaluation struct

func (*ChangeVideoInputDefault) Evaluate

func (p *ChangeVideoInputDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) (actions []base.ActionStructure, count int, err error)

Evaluate fulfills the CommmandEvaluation evaluate requirement.

func (*ChangeVideoInputDefault) GetIncompatibleCommands

func (p *ChangeVideoInputDefault) GetIncompatibleCommands() (incompatableActions []string)

GetIncompatibleCommands keeps track of actions that are incompatable (on the same device)

func (*ChangeVideoInputDefault) Validate

func (p *ChangeVideoInputDefault) Validate(action base.ActionStructure) (err error)

Validate fulfills the Fulfill requirement on the command interface

type ChangeVideoInputTieredSwitchers

type ChangeVideoInputTieredSwitchers struct {
}

ChangeVideoInputTieredSwitchers implements the CommandEvaluator struct.

func (*ChangeVideoInputTieredSwitchers) ChangeAll

ChangeAll generates a list of actions based on the information about the room.

func (*ChangeVideoInputTieredSwitchers) Evaluate

func (c *ChangeVideoInputTieredSwitchers) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate fulfills the CommmandEvaluation evaluate requirement

func (*ChangeVideoInputTieredSwitchers) GenerateActionsFromPath

func (c *ChangeVideoInputTieredSwitchers) GenerateActionsFromPath(room rest.PublicRoom, path []inputgraph.Node, callbackEngine *statusevaluators.TieredSwitcherCallback, requestor string) ([]base.ActionStructure, error)

GenerateActionsFromPath generates a list of actions from the path in the graph of the room.

func (*ChangeVideoInputTieredSwitchers) GetIncompatibleCommands

func (c *ChangeVideoInputTieredSwitchers) GetIncompatibleCommands() []string

GetIncompatibleCommands lists all incompatible commands for this evaluator.

func (*ChangeVideoInputTieredSwitchers) RoutePath

func (c *ChangeVideoInputTieredSwitchers) RoutePath(room rest.PublicRoom, input, output string, graph inputgraph.InputGraph, callbackEngine *statusevaluators.TieredSwitcherCallback, requestor string) ([]base.ActionStructure, error)

RoutePath makes a path through the graph to determine the actions necessary.

func (*ChangeVideoInputTieredSwitchers) Validate

Validate f

type ChangeVideoInputVideoSwitcher

type ChangeVideoInputVideoSwitcher struct {
}

ChangeVideoInputVideoSwitcher implements the CommandEvaluation struct.

func (*ChangeVideoInputVideoSwitcher) Evaluate

func (c *ChangeVideoInputVideoSwitcher) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate generates a list of actions based on the information given.

func (*ChangeVideoInputVideoSwitcher) GetIncompatibleCommands

func (c *ChangeVideoInputVideoSwitcher) GetIncompatibleCommands() []string

GetIncompatibleCommands f

func (*ChangeVideoInputVideoSwitcher) Validate

Validate veries that the action that was created has correct information.

type CommandEvaluator

type CommandEvaluator interface {
	/*
		 	Evalute takes a public room struct, scans the struct and builds any needed
			actions based on the contents of the struct. It also returns the number of status
			that will be needed
	*/
	Evaluate(base.Room, rest.PublicRoom, string) ([]base.ActionStructure, int, error)
	/*
		  Validate takes an action structure (for the command) and validates
			that the device and parameter are valid for the command.
	*/
	Validate(base.ActionStructure) error
	/*
			   GetIncompatableActions returns a list of commands that are incompatable
		     with this one (i.e. 'standby' and 'power on', or 'mute' and 'volume up')
	*/
	GetIncompatibleCommands() []string
}

CommandEvaluator is an interface that must be implemented for each command to be evaluated.

type MuteDSP

type MuteDSP struct{}

MuteDSP implements the CommandEvaluation struct.

func (*MuteDSP) Evaluate

func (p *MuteDSP) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate takes the information given and generates a list of actions.

func (*MuteDSP) GetIncompatibleCommands

func (p *MuteDSP) GetIncompatibleCommands() []string

GetIncompatibleCommands returns the list of commands that are incompatible with this device.

func (*MuteDSP) Validate

func (p *MuteDSP) Validate(base.ActionStructure) error

Validate verifies that the action given has correct information.

type MuteDefault

type MuteDefault struct {
}

MuteDefault implements the CommandEvaluation struct.

func (*MuteDefault) Evaluate

func (p *MuteDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate takes a public room struct, scans the struct and builds any needed actions based on the contents of the struct.

func (*MuteDefault) GetIncompatibleCommands

func (p *MuteDefault) GetIncompatibleCommands() (incompatibleActions []string)

GetIncompatibleCommands returns a list of commands that are incompatabl with this one (i.e. 'standby' and 'power on', or 'mute' and 'volume up')

func (*MuteDefault) Validate

func (p *MuteDefault) Validate(action base.ActionStructure) error

Validate takes an ActionStructure and determines if the command and parameter are valid for the device specified

type PowerOnDefault

type PowerOnDefault struct {
}

PowerOnDefault implements the CommandEvaluation struct.

func (*PowerOnDefault) Evaluate

func (p *PowerOnDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) (actions []base.ActionStructure, count int, err error)

Evaluate fulfills the CommmandEvaluation evaluate requirement.

func (*PowerOnDefault) GetIncompatibleCommands

func (p *PowerOnDefault) GetIncompatibleCommands() (incompatableActions []string)

GetIncompatibleCommands keeps track of actions that are incompatable (on the same device)

func (*PowerOnDefault) Validate

func (p *PowerOnDefault) Validate(action base.ActionStructure) (err error)

Validate fulfills the Fulfill requirement on the command interface

type SetVolumeDSP

type SetVolumeDSP struct{}

SetVolumeDSP implements the CommandEvaluation struct.

func (*SetVolumeDSP) Evaluate

func (p *SetVolumeDSP) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate generates a list of actions based on the room information.

func (*SetVolumeDSP) GetIncompatibleCommands

func (p *SetVolumeDSP) GetIncompatibleCommands() (incompatibleActions []string)

GetIncompatibleCommands determines the commands from the room that are incompatible with this evaluator.

func (*SetVolumeDSP) Validate

func (p *SetVolumeDSP) Validate(action base.ActionStructure) (err error)

Validate verifies that the action information is correct.

type SetVolumeDefault

type SetVolumeDefault struct {
}

SetVolumeDefault implements the CommandEvaluation struct.

func (*SetVolumeDefault) Evaluate

func (*SetVolumeDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate checks for a volume for the entire room or the volume of a specific device

func (*SetVolumeDefault) GetIncompatibleCommands

func (p *SetVolumeDefault) GetIncompatibleCommands() []string

GetIncompatibleCommands returns a string array of commands incompatible with setting the volume

func (*SetVolumeDefault) Validate

func (p *SetVolumeDefault) Validate(action base.ActionStructure) error

Validate returns an error if the volume is greater than 100 or less than 0

type StandbyDefault

type StandbyDefault struct {
}

StandbyDefault implements the CommandEvaluator struct.

func (*StandbyDefault) Evaluate

func (s *StandbyDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) (actions []base.ActionStructure, count int, err error)

Evaluate fulfills the CommmandEvaluation evaluate requirement.

func (*StandbyDefault) GetIncompatibleCommands

func (s *StandbyDefault) GetIncompatibleCommands() (incompatableActions []string)

GetIncompatibleCommands keeps track of actions that are incompatable (on the same device)

func (*StandbyDefault) Validate

func (s *StandbyDefault) Validate(action base.ActionStructure) (err error)

Validate fulfills the Fulfill requirement on the command interface

type UnBlankDisplayDefault

type UnBlankDisplayDefault struct {
}

UnBlankDisplayDefault implements the CommandEvaluator struct.

func (*UnBlankDisplayDefault) Evaluate

func (p *UnBlankDisplayDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate creates UnBlank actions for the entire room and for individual devices

func (*UnBlankDisplayDefault) GetIncompatibleCommands

func (p *UnBlankDisplayDefault) GetIncompatibleCommands() (incompatibleActions []string)

GetIncompatibleCommands returns a string array containing commands incompatible with UnBlank Display

func (*UnBlankDisplayDefault) Validate

func (p *UnBlankDisplayDefault) Validate(action base.ActionStructure) error

Validate returns an error if a command is invalid for a device

type UnMuteDSP

type UnMuteDSP struct{}

UnMuteDSP implements the CommandEvaluator struct/

func (*UnMuteDSP) Evaluate

func (p *UnMuteDSP) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate generates a list of actions based on the given room information.

func (*UnMuteDSP) GetIncompatibleCommands

func (p *UnMuteDSP) GetIncompatibleCommands() []string

GetIncompatibleCommands determines the list of incompatible commands for this evaluator.

func (*UnMuteDSP) Validate

func (p *UnMuteDSP) Validate(base.ActionStructure) error

Validate verified that the action information is correct.

type UnMuteDefault

type UnMuteDefault struct {
}

UnMuteDefault implements the CommandEvaluator struct.

func (*UnMuteDefault) Evaluate

func (p *UnMuteDefault) Evaluate(dbRoom base.Room, room rest.PublicRoom, requestor string) ([]base.ActionStructure, int, error)

Evaluate generates a list of actions based on the room information.

func (*UnMuteDefault) GetIncompatibleCommands

func (p *UnMuteDefault) GetIncompatibleCommands() (incompatibleActions []string)

GetIncompatibleCommands determines the list of incompatible commands for this evaluator.

func (*UnMuteDefault) Validate

func (p *UnMuteDefault) Validate(action base.ActionStructure) error

Validate verified that the action information is correct.

Jump to

Keyboard shortcuts

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