parse

package
v0.0.0-...-e5efe94 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2016 License: MIT, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Full byte = 255

Full is the highest level of dimmer we can output

View Source
const TimeLongForm = "2006-01-02 15:04:05.000000000-0700"

TimeLongForm is the format for storing time in the JSON

Variables

This section is empty.

Functions

func ValidState

func ValidState(name string) ([]byte, error)

ValidState returns a valid schema from `../api/valid`

Types

type Address

type Address int

Address is a certain DMX output address

const MaxAddress Address = 512

MaxAddress is the maximum adddress

type Cue

type Cue struct {
	Name     string   `json:"name"`
	UUID     string   `json:"uuid"`
	Systems  Systems  `json:"systems"`
	Duration Duration `json:"duration"`
}

func (*Cue) Output

func (c *Cue) Output(st *State) (Output, error)

type Cues

type Cues []Cue

func (*Cues) Find

func (cs *Cues) Find(UUID string) (c, prevC *Cue)

Find returns the current cue and the one before it. If None is before it it returns null

type Duration

type Duration int

Duration is the number of MS in a duration

func DurationMarshall

func DurationMarshall(t time.Duration) Duration

DurationMarshall converst a go Duration into an int

func (Duration) Unmarshal

func (d Duration) Unmarshal() time.Duration

Unmarshal converts a int of ms into a go duration

type Fixture

type Fixture struct {
	State  []byte
	Output *Output
	Name   string
	Time   time.Time
}

Fixture is a fixture imported from ../api/valid. It is used for testing.

func GetFixture

func GetFixture(name string) (f Fixture, err error)

GetFixture return a fixture from ../api/vali

func GetFixtures

func GetFixtures() (fs []*Fixture, err error)

GetFixtures returns all the fixture from ../api/valid

type Level

type Level float32

Level describes what output a certain instrument, or groups of instruments is set to

type Live

type Live struct {
	Level   Level   `json:"level"`
	LiveCue LiveCue `json:"cue"`
	Systems Systems `json:"systems"`
}

Live holds everything that is currently up on stage atm

func (*Live) Output

func (l *Live) Output(st *State, now time.Time) (o Output, e error)

Output returns the Output of this `Live`.It combines the LiveCue output with the output of the systems and levels them all with Level

type LiveCue

type LiveCue struct {
	UUID    string  `json:"uuid,omitempty"`
	Time    Time    `json:"time,omitempty"`
	Percent float32 `json:"percent,omitempty"`
}

LiveCue is the current cue that is up

func (*LiveCue) Output

func (lc *LiveCue) Output(st *State, now time.Time) (Output, error)

Output will figure out what the output of the current cue is.

It will use the `Time` or `Percent` to figure out how much of the transition from the previous has happened

If there is a `Time` it will use this as the time started for the current cue, looking at the duration of the current cue as the transition. time. Then with the `now` time it can figure out how far the transition is along

Otherwise, it will look at the `Percent` to show how long the transition is along

If this is the first cue, it will transition from a blank output to it

type Output

type Output map[int]byte

Output is a mapping for DMX output

func OutputFromJSON

func OutputFromJSON(b []byte) (o *Output, err error)

OutputFromJSON takes a JSON mapping of strings to numbers and returns an output

func ParseAndOutput

func ParseAndOutput(b []byte, t time.Time) (Output, error)

ParseAndOutput will simply combines Output() with Parse().

func (Output) AddOnTop

func (o Output) AddOnTop(higherPriority Output) error

AddOnTop takes another output and adds it at a higher priority to this output merging the two

func (Output) MultiplyBy

func (o Output) MultiplyBy(p Level) error

MultiplyBy will take all the output values and multiply them by some float. It will cap at the maximum byte size of 255, if the resault would be over

func (Output) TransitionTo

func (o Output) TransitionTo(next Output, percent float32) Output

TransitionTo will blend the two outputs together, using `percent` to know how far along they are. It will use a linear blend.

type Patch

type Patch map[string][]Tag

Patch holds the mapping of addresses to their attributes

func (*Patch) Filter

func (p *Patch) Filter(q Query) (as []Address)

Filter returns all the addresses that match a certain query

type Query

type Query []QueryItem

Query is used to select certain certain lights dynamically

type QueryItem

type QueryItem struct {
	Address Address `json:"address,omitempty"`
	Tag     Tag     `json:"tag,omitempty"`
}

QueryItem is one selector for choosing lights

func (*QueryItem) Matches

func (qi *QueryItem) Matches(a Address, ts []Tag) bool

Matches checks if an address and tag is matched under this part of the query

type SchemaError

type SchemaError struct {
	Errors []gojsonschema.ResultError
}

SchemaError is returned when a JSON schema does not match.

func (*SchemaError) Error

func (se *SchemaError) Error() (s string)

type State

type State struct {
	Patch Patch `json:"patch"`
	Cues  Cues  `json:"cues"`
	Live  Live  `json:"live"`
}

State contains everything that makes up the current show and stage

func MakeState

func MakeState() (*State, error)

MakeState returns the inital state from the `InitialBytes`

func Parse

func Parse(b []byte) (*State, error)

Parse takes a state json and returns the state for it

func (*State) Output

func (s *State) Output(n time.Time) (o Output, e error)

Output gives the DMX address to value mapping of the current state

func (*State) ToJSON

func (s *State) ToJSON() ([]byte, error)

ToJSON returns the JSON representation of the state

type System

type System struct {
	Level Level  `json:"level"`
	Query Query  `json:"query"`
	UUID  string `json:"uuid"`
}

func (*System) Output

func (s *System) Output(st *State) (o Output)

type Systems

type Systems []System

func (*Systems) Output

func (ss *Systems) Output(st *State) (o Output, e error)

type Tag

type Tag string

Tag is a label for a certain light

type Time

type Time string

Time is how times are stored in the JSON

func TimeFromJSON

func TimeFromJSON(b []byte) (t Time, err error)

TimeFromJSON takes a JSON of a string

func TimeMarshall

func TimeMarshall(t time.Time) Time

TimeMarshall converst a go time to a string

func (*Time) Unmarshal

func (t *Time) Unmarshal() (time.Time, error)

Unmarshal converts a string of time into a go time

Jump to

Keyboard shortcuts

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