Documentation
¶
Overview ¶
Package lift provide an united interface for connection to either physical lifts or simulated lifts for use in the course TTK4145 at The Norwegian University of Science and Technology. This package is based on work done by Martin Korsgaard, Morten Fyhn and github.com/klasbo.
This package have not been tested with physical hardware, but the simulator part are tested on Ubuntu 17.04. To be able to compile you must have the Comedi drivers which can be downloaded by:
wget http://www.comedi.org/download/comedilib-0.10.2.tar.gz tar -xvzf comedilib-0.10.2.tar.gz cd comedilib-0.10.2 && ./configure && make && sudo make install
Furthermore is the simulator by github.com/klasbo statically embedded in the project using the http://github.com/gobuffalo/packr tool. This mean that to generate standalone binaries first do
go get -u github.com/gobuffalo/packr/... # Installation, only needed once packr # Generate static files that contain binaries and config.
Example ¶
Basic usage.
package main import ( "github.com/hdhauk/lift" ) func main() { // The order to which options or how many options you supply doesn't matter. // Here we configure the simulator to have 6 floors, and to listen on port 9999. // If neither is supplied the defaults will be used (4 floors and a random port). sim, err := lift.NewSim(lift.NumFloors(6), lift.ComPort(9999)) if err != nil { panic(err) } if err := sim.Init(); err != nil { panic(err) } // The simulator can then be controlled by using the methods defined by Lifter. // Example: sim.SetMotorDirection(1) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lifter ¶
type Lifter interface { Init() error SetMotorDirection(direction int) OrderButtonLight(button int, floor int, on bool) FloorIndicator(floor int) DoorLight(on bool) StopLight(on bool) OrderButton(button int, floor int) (pressed bool) FloorSensor() (inFloor bool, floor int) StopButton() (pressed bool) Obstruction() (active bool) }
Lifter is the interface for what the lifts can do. It offers few guarantees and will generally simply do nothing if used wrong. The following conventions are used:
Direction: -1 = down, 0 = stop, 1 = up Buttons: 0 = hall up, 1 = hall down, 2 = inside lift
type SimOption ¶
type SimOption func(*liftSim) error
SimOption are option functions for simulated lifts.
func BtnDepressedTime ¶
BtnDepressedTime sets the duration a button will be considered pressed after the actual key event happens.
func ComPort ¶
ComPort sets what port the simulator should listen on. This must be unique per instance of simulators. Must be in the range 1024 - 65535.
func TravelTimeBetweenFloors ¶
TravelTimeBetweenFloors sets the travel time between each floor.
func TravelTimePassingFloors ¶
TravelTimePassingFloors sets the time spent within the sensors range when passing a floor.