/* * 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 V (velocity) value to the number following. For example V32 * sets V to 32. V can range from 0 (a dead creep) to 63 (maximum slew rate). * Values outside this range saturate to 63. This value is persistent until * changed. The Ninja uses a non-linear velocity scale. That is to say, a * velocity of 48, say, won't necessarily be twice as fast as 24. * * @author Manish Pandya (July 1 2008) * */ public class Velocity extends CommandIntParam { /** * 63 (maximum slew rate) */ public static final int VMAX = 63; /** * 0 (a dead creep) */ public static final int VMIN = 0; /** * Constructs a Velocity command with desired speed * * @param velocity * desired speed in integer * @throws ValueOutOfRangeException * when desired azimuth is out of range */ public Velocity(int velocity) throws ValueOutOfRangeException { if (velocity < VMIN || velocity > VMAX) { throw new ValueOutOfRangeException( "V (velocity) must fall within the range of " + VMIN + " (a dead creep) to " + VMAX + " (maximum slew rate) as per PhiPi firmware; You requested " + velocity); } command = "v"; this.paramVal = velocity; } /* * (non-Javadoc) * * @see org.hooliguns.ninja.telnet.Command#getHumanName() */ public String getHumanName() { return "Velocity command"; } @Override public byte[] execute(CommandExecutionUnit ceu) { ceu.setVelocity(paramVal); return super.execute(ceu); } }