Package com.grt192.core

Examples of com.grt192.core.Controller


    }

    public void changeMechPos(boolean state, int side) {
        if (state) {
            if (side == LEFT) {
                this.MechShifter1.enqueueCommand(new Command(MechShifter1.ON));
            } else {
                this.MechShifter2.enqueueCommand(new Command(MechShifter2.ON));
            }
        } else {
            if (side == LEFT) {
                this.MechShifter1.enqueueCommand(new Command(MechShifter1.OFF));
            } else {
                this.MechShifter2.enqueueCommand(new Command(MechShifter2.OFF));
            }
        }

    }
View Full Code Here


    }

    public void changeDTPos(boolean state, int side) {
         if (state) {
            if (side == LEFT) {
                this.DTShifter1.enqueueCommand(new Command(DTShifter1.ON));
            } else {
                this.DTShifter2.enqueueCommand(new Command(DTShifter2.ON));
            }
        } else {
            if (side == LEFT) {
                this.DTShifter1.enqueueCommand(new Command(DTShifter1.OFF));
            } else {
                this.DTShifter2.enqueueCommand(new Command(DTShifter2.OFF));
            }
        }
    }
View Full Code Here

        return driveMode;
    }
   
    public void executeCommand(Command c) {

        Command c1 = this.dequeue();
        switch (driveMode) {
            case 0: {
                if(c1 == null)
                    c1 = c;
                driveTrain.tankDrive(c.getValue(), c1.getValue());
                //left.set(c.getValue());
                //right.set(c1.getValue());
                break;
            }
            case 1: {
                driveTrain.arcadeDrive(c.getValue(), c1.getValue(), false);
                break;
            }
            case 2: {
                driveTrain.arcadeDrive(c.getValue(), c1.getValue(), true);
                break;
            }
            case 3: {
                driveTrain.drive(c.getValue(), c1.getValue());
                break;
            }
        }
    }
View Full Code Here

                                this.halt();
                        }
                        for(int i=0; i<actuatorCommandListeners.size(); i++){
                            ((ActuatorCommandListener)
                                actuatorCommandListeners.elementAt(i)).commandDidComplete(
                                           new ActuatorEvent(this,
                                           ActuatorEvent.COMMAND_COMPLETE,
                                           this.current));
                        }
                       
                    }
                }
                //minimum loop sleep
                sleep(SLEEP_INTERVAL);
            }catch(Exception e){
                //On exception kill this actuator, as it is
                //unsafe to continue operation
                for(int i=0; i<actuatorCommandListeners.size(); i++){
                    ((ActuatorCommandListener)
                        actuatorCommandListeners.elementAt(i)).commandDidComplete(
                                           new ActuatorEvent(this,
                                           ActuatorEvent.COMMAND_FAILED,
                                           this.current));
                }
                e.printStackTrace();
                stopActuator();
View Full Code Here

                                this.halt();
                        }
                        for(int i=0; i<actuatorCommandListeners.size(); i++){
                            ((ActuatorCommandListener)
                                actuatorCommandListeners.elementAt(i)).commandDidComplete(
                                           new ActuatorEvent(this,
                                           ActuatorEvent.COMMAND_COMPLETE,
                                           this.current));
                        }
                       
                    }
                }
                //minimum loop sleep
                sleep(SLEEP_INTERVAL);
            }catch(Exception e){
                //On exception kill this actuator, as it is
                //unsafe to continue operation
                for(int i=0; i<actuatorCommandListeners.size(); i++){
                    ((ActuatorCommandListener)
                        actuatorCommandListeners.elementAt(i)).commandDidComplete(
                                           new ActuatorEvent(this,
                                           ActuatorEvent.COMMAND_FAILED,
                                           this.current));
                }
                e.printStackTrace();
                stopActuator();
View Full Code Here

    private void notifyButtonListeners(String button, double previousState) {
        for (int i = 0; i < buttonListeners.size(); i++) {
            if (getState(button) == TRUE && getState(button) != previousState) {
                ((ButtonListener) buttonListeners.elementAt(i)).buttonDown(
                        new SensorEvent(this,
                        SensorEvent.DATA_AVAILABLE,
                        this.state), button);
            } else if (getState(button) != TRUE && getState(button) != previousState) {
                ((ButtonListener) buttonListeners.elementAt(i)).buttonUp(
                        new SensorEvent(this,
                        SensorEvent.DATA_AVAILABLE,
                        this.state),
                        button);
            }
        }
View Full Code Here

  }

  protected void notifyAccelerometerSpike(int axis, double value) {
    for (int i = 0; i < accelerometerListeners.size(); i++) {
      ((ADXL345Listener) accelerometerListeners.elementAt(i))
          .didAccelerationSpike(new ADXL345Event(this, axis, value));
    }
  }
View Full Code Here

  }

  protected void notifyAccelerometerChange(int axis, double value) {
    for (int i = 0; i < accelerometerListeners.size(); i++) {
      ((ADXL345Listener) accelerometerListeners.elementAt(i))
          .didAccelerationChange(new ADXL345Event(this, axis, value));
    }
  }
View Full Code Here

  }

  protected void notifyADXL345Listeners(int axis, double value) {
    for (int i = 0; i < accelerometerListeners.size(); i++) {
      ((ADXL345Listener) accelerometerListeners.elementAt(i))
          .didReceiveAcceleration(new ADXL345Event(this, axis, value));
    }
  }
View Full Code Here

            }
        }
    }

    private void notifyListeners(double newVoltage){
        BatteryVoltageEvent ev = new BatteryVoltageEvent(this, newVoltage);
        for(int i = 0; i<listeners.size(); i++){
            ((BatteryVoltageListener)listeners.elementAt(i)).batteryVoltageChanged(ev);
        }
    }
View Full Code Here

TOP

Related Classes of com.grt192.core.Controller

Copyright © 2018 www.massapicom. 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.