Package com.grt192.sensor

Source Code of com.grt192.sensor.GRTSwitch

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.grt192.sensor;

import com.grt192.core.Sensor;
import edu.wpi.first.wpilibj.DigitalInput;

/**
* A simple switch utilizing a GPIO port
* Binary switch
* @author Bonan
*/
public class GRTSwitch extends Sensor {
    public static final double CLOSED = Sensor.TRUE;
    public static final double OPEN = Sensor.FALSE;
    private DigitalInput input;

    public GRTSwitch(int i, int i0) {
        this(i, i0, "");
    }

    public GRTSwitch(int channel, int pollTime, String id) {
        this.sleepTime = pollTime;
        input = new DigitalInput(channel);
        setState("State", OPEN);
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public DigitalInput getInput() {
        return input;
    }

    public void setInput(DigitalInput input) {
        this.input = input;
    }

    public void poll() {
        setState("State", input.get() ? CLOSED : OPEN);
    }

    public String toString() {
        return "switch";
    }
}
TOP

Related Classes of com.grt192.sensor.GRTSwitch

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.