driver

package
v0.0.0-...-0810b70 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Overview

Package driver provides control of both simulated and actual lifts. The package also provide functionality for handling internal orders, as well as taking external orders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BtnLEDClear

func BtnLEDClear(b Btn)

BtnLEDClear turns off the LED in the provided button.

func BtnLEDSet

func BtnLEDSet(b Btn)

BtnLEDSet turns on the LED in the provided button.

func GoToFloor

func GoToFloor(floor int, dir string)

GoToFloor sends the lift carriage to the desired floor and stop there, unless it is stopped before arriving at its destination. A second call to the function will void the previous order if the carriage haven't reached its destination.

func Init

func Init(c Config, done chan error)

Init initializes the driver, and return an error on the done-channel if unable to initialize the driver

func Stop

func Stop()

Stop immediately stop the elevator wherever it is and turns all LEDs off.

func StopForPickup

func StopForPickup(f int, d string)

StopForPickup can be called if the lift should stop in the next floor, to pick someone up.

Types

type Btn

type Btn struct {
	Floor int
	Type  BtnType
}

Btn defines a custom type representing a hardware-button. Floor may be nil.

type BtnType

type BtnType int

BtnType defines the 3 types of buttons that are in use. In order to use the correct integer, the types are available as constants.

const (
	// HallUp is located outside of the lift.
	HallUp BtnType = iota
	// HallDown is located outside of the lift.
	HallDown
	// Cab is located inside of the lift.
	Cab
)

Button type constants

func (*BtnType) String

func (bt *BtnType) String() string

String exports the integer BtnType to a string (either "HallUP","HallDown" or"Cab")

type Config

type Config struct {
	SimMode      bool
	SimPort      string
	Floors       int
	OnNewStatus  func(floor int, dir string, dstFloor int, dstDir string)
	OnDstReached func(b Btn, pickup bool)
	OnBtnPress   func(b Btn)
	Logger       *log.Logger
}

Config defines the configuration for the driver.

Jump to

Keyboard shortcuts

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