Package com.grt192.actuator

Source Code of com.grt192.actuator.GRTSolenoid

package com.grt192.actuator;

import com.grt192.core.Actuator;
import com.grt192.core.Command;
import edu.wpi.first.wpilibj.Solenoid;

/**
* Abstraction for any single solenoid valve for pneumatics
*/
public class GRTSolenoid extends Actuator {

    private static final int DEFAULT_SLOT = 7;

    private Solenoid solenoid;
    public static final double ON = 1.0;
    public static final double OFF = 0.0;

    /**
     * Creates a new solenoid on a defined channel.
     * This uses DEFAULT_SLOT
     * @param channel
     */
    public GRTSolenoid(int channel) {
        this(DEFAULT_SLOT, channel);
    }

    /**
     * Creates a new solenoid on a desired channel in a specific slot.
     * @param slot The slot where the 9472 "relay" module is plugged into.
     * @param channel
     */
    public GRTSolenoid(int slot, int channel) {
        solenoid = new Solenoid(slot, channel);
    }

    /**
     * Executes next Command.  Command should have a value of 1.0 for forward and
     * -1.0 for reverse.
     * @param c
     */
    public void executeCommand(Command c) {
        if (c.getValue() == ON) {
            solenoid.set(true);
        } else if (c.getValue() == OFF) {
            solenoid.set(false);
        }
    }

    /**
     * Solenoid is in the off position
     */
    protected void halt() {
        solenoid.set(false);
    }

    /**
     * Returns the String "Solenoid"
     * @return
     */
    public String toString() {
        return "Solenoid";
    }
}
TOP

Related Classes of com.grt192.actuator.GRTSolenoid

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.