Thread: Java Pneumatics
View Single Post
  #3   Spotlight this post!  
Unread 02-16-2011, 11:29 AM
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: Java Pneumatics

My double and single solenoid class
Code:
package com.shadowh511.mayor.outputs;

import edu.wpi.first.wpilibj.Solenoid;

/**
 *
 * @author sam
 */
public class MySolenoid {
    private Solenoid foo;
    private Solenoid bar;

    private boolean doublek = false;

    /*
     * For a one-solenoid system
     */
    public MySolenoid(int port) {
        foo = new Solenoid(8, port);
        doublek = false;
        System.out.println("MySolenoid enabled on port " + port);
    }

    /*
     * For a double solenoid system
     */
    public MySolenoid(int port1, int port2) {
        doublek = true;
        foo = new Solenoid(8, port1);
        bar = new Solenoid(8, port2);
        System.out.println("Double MySolenoid enabled on ports " + port1 + " and " + port2);
    }

    /*
     * For a double solenoid system, custom slot
     */
    public MySolenoid(int slot, int port1, int port2) {
        doublek = true;
        foo = new Solenoid(slot, port1);
        bar = new Solenoid(slot, port2);
        System.out.println("Double MySolenoid enabled on slot " + slot + " and ports " + port1 + " and " + port2);
    }

    /*
     * Extends the solenoid
     */
    public void extend() {
        foo.set(true);

        if(doublek) {
            bar.set(false);
        }
    }

    /*
     * Retracts the solenoid
     */
    public void retract() {
        foo.set(false);

        if(doublek) {
            bar.set(true);
        }
    }

    /*
     * Gets the state of the first solenoid
     */
    public boolean get() {
        return this.foo.get();
    }

    /*
     * Gets the state of the other solenoid
     */
    public boolean getOther() {
        boolean eggs = bar.get();
        return eggs;
    }
}
__________________
Code:
class team2412(GP):
    def __init__(self):
        GP.__init__(self)
        self.coopertition = True
        self.info = {"name": "Robototes", "school": "Sammamish High School, Bellevue, WA"}
        assert self.kind_people == True
Reply With Quote