/* * Copyright (C) 2008 Manish Pandya, [manish at meetamanish dot com] * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * */ package org.hooliguns.ninja.telnet.phiPiMod; import org.hooliguns.ninja.telnet.CommandExecutionUnit; import org.hooliguns.ninja.telnet.ValueOutOfRangeException; /** * Set the desired Y (altitude) value to the number following. For example Y70 * sets Y to 70. Y can range from -1200 (far down) to 550 (far up). Values * outside this range will saturate to these limits. The center (home) position * is zero (looking straight ahead). This value is persistent until changed with * another Y command, except when the I (increment position) command is * executed. * * @author Manish Pandya (July 1 2008) */ public class SetY extends CommandIntParam { /** * 550 (far up) */ public static final int YMAX = 550; /** * -1200 (far down) */ public static final int YMIN = -1200; /** * Constructs a SetY command with desired altitude * * @param yVal * desired altitude in integer * @throws ValueOutOfRangeException * when desired altitude is out of range */ public SetY(int yVal) throws ValueOutOfRangeException { if (yVal < YMIN || yVal > YMAX) { throw new ValueOutOfRangeException( "Y (altitude) must fall within the range of " + YMIN + " (far down) to " + YMAX + " (far up) as per PhiPi firmware; You requested " + yVal); } command = "y"; this.paramVal = yVal; } /* * (non-Javadoc) * * @see org.hooliguns.ninja.telnet.Command#getHumanName() */ public String getHumanName() { return "SetY command"; } @Override public byte[] execute(CommandExecutionUnit ceu) { ceu.setDestinationY(paramVal); return super.execute(ceu); } }