Documentation ¶
Index ¶
- Constants
- Variables
- func CheckInput(i interface{}) error
- func CheckInputs(typ string, v ...interface{}) error
- func CheckOutput(p Port) error
- func Connect(i interface{}, port Port) error
- func DebugOutput(w io.Writer, p *Profile, names ...string)
- func PortString(p Port) string
- func Register(name string, fn func() Block)
- func RegisterBoolFunc(name string, fn func(Param) (func(bool) bool, error))
- func RegisterCmpFunc(name string, fn func(a, b float64) bool)
- func RegisterHatFunc(name string, f HatFunc)
- func RegisterLogicFunc(name string, fn func(a, b bool) bool)
- func RegisterMathBlock(name string, fn func(a, b float64) float64)
- func RegisterParam(name string, fn func(Param) (Block, error))
- func RegisterScalarFunc(name string, fn func(Param) (func(float64) float64, error))
- func RegisterStickFunc(name string, ff func(p Param) (StickFunc, error))
- func RegisterType(t Type)
- func VarArgCheck(t string, iv interface{}, min int) error
- func VarArgInput(t string, iv interface{}) *varArgInput
- type Block
- type Closer
- type HatFunc
- type IO
- type InputMap
- type MapDecl
- type OutputMap
- type Param
- type Port
- type PortType
- type PortTypeMap
- type Profile
- type Proto
- type StickFunc
- type Ticker
- type Type
- type TypeInputMap
- type TypeMap
Constants ¶
const ( HatCentre = 0 HatNorth = 1 HatEast = 2 HatSouth = 4 HatWest = 8 HatMask = 15 HatMax = 16 )
hat values are bitmasks
const ( Invalid = PortType(parser.Invalid) Bool = PortType(parser.Bool) Float64 = PortType(parser.Scalar) Int = PortType(parser.Hat) Any = PortType(parser.Any) )
const (
DefaultTickFreq = 1e3 // 1 millisecond
)
Variables ¶
var DefaultTypeMap = make(TypeMap)
Functions ¶
func CheckInput ¶
func CheckInput(i interface{}) error
func CheckInputs ¶
func CheckOutput ¶
func PortString ¶
func RegisterCmpFunc ¶
func RegisterHatFunc ¶
func RegisterLogicFunc ¶
func RegisterMathBlock ¶
func RegisterScalarFunc ¶
func RegisterType ¶
func RegisterType(t Type)
func VarArgCheck ¶
func VarArgInput ¶
func VarArgInput(t string, iv interface{}) *varArgInput
Types ¶
type Block ¶
type Block interface { Input() InputMap Output() OutputMap // Validate reports whether the Block is valid after setup. // It must check if all its non-optional inputs were set correctly. // Optional inputs should be set to a usable value typically // during Block creation. Validate() error }
a block is a set of inputs and outputs producer blocks may have nil inputs, and sink blocks may have nil outputs
type InputMap ¶
type InputMap interface { TypeInputMap Set(sel string, port Port) error }
func SingleInput ¶
type OutputMap ¶
func SingleOutput ¶
type Param ¶
type Param interface { Arg(string) float64 OptArg(string, float64) float64 TickFreq() float64 // ticks per seconds: 1e6/float64(c.UpdateMicros) TickTime() float64 // time in seconds elapsed duting one tick: float64(c.UpdateMicros) / 1e6 }
ProtoParam represents an empty parameter map used during prototype creation in type checks. Arg() values will are eauql to 0.5, and OptArg() always returns the default. An update frequency of 1e3 is assumed. Block types registered using Register() or RegisterParam() should not return an error when this value is provided.
type PortTypeMap ¶
type Proto ¶
Proto is a simple block type that implements input and output port reporting using a prototype block.
func (*Proto) Accept ¶
func (t *Proto) Accept(i PortTypeMap) (PortTypeMap, error)
func (*Proto) Input ¶
func (t *Proto) Input() TypeInputMap
type Ticker ¶
type Ticker interface {
Tick()
}
ticker is an interface for blocks that needs update once upon each update tick.
type Type ¶
type Type interface { Name() string New(Param) (Block, error) Verify(Param) error // verify parameters Input() TypeInputMap Accept(in PortTypeMap) (PortTypeMap, error) // tests wether type accepts in, and what it would return in this case }
type TypeInputMap ¶
TypeInputMap specifies order of inputs and their types for a Block Type. It is an error to call Type() with sel not in Names().