Package com.grt192.mechanism.partybot

Source Code of com.grt192.mechanism.partybot.ArmBeta

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package com.grt192.mechanism.partybot;

import com.grt192.actuator.GRTGPIORelay;
import com.grt192.core.Command;
import com.grt192.core.Mechanism;

/**
*
* @author Student
*/
public class ArmBeta extends Mechanism {
    private int armState = 0;
    public final int ARM_FORWARD = 1;
    public final int ARM_BACK = 0;
   
    public ArmBeta(GRTGPIORelay arm) {
        arm.start();
        addActuator("Arm", arm);
    }

    public ArmBeta(int relayFwdPort, int relayBwdPort) {
        addActuator("Arm", new GRTGPIORelay(relayFwdPort, relayBwdPort));
        getActuator("Arm").start();
    }

    public void moveArm() {
        if(armState == ARM_BACK) {
            getActuator("Arm").enqueueCommand(
                    new Command(GRTGPIORelay.RELAY_FORWARD));
            armState = ARM_FORWARD;
        }
        if(armState == ARM_FORWARD) {
            getActuator("Arm").enqueueCommand(
                    new Command(GRTGPIORelay.RELAY_FORWARD));
            armState = ARM_BACK;
        }
    }

    public int getArmState() {
        return armState;
    }
}
TOP

Related Classes of com.grt192.mechanism.partybot.ArmBeta

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.