/* * 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 X (azimuth) value to the number following. For example X-900 * sets X to -900. X can range from -1800 (far left) to 1800 (far right). Values * outside this range will saturate to these limits. The center (home) position * is zero. This value is persistent until changed with another X command, * except when the I (increment position) command is executed. Setting X (or Y) * doesn't cause any motion to occur. It just tells the Ninja where you will be * wanting to go when you eventually tell it to move. * * @author Manish Pandya (July 1 2008) */ public class SetX extends CommandIntParam { /** * 1800 (far right) */ public static final int XMAX = 1800; /** * -1800 (far left) */ public static final int XMIN = -1800; /** * Constructs an SetX command with desired azimuth * * @param xVal * desired azimuth in integer * @throws ValueOutOfRangeException * when desired azimuth is out of range */ public SetX(int xVal) throws ValueOutOfRangeException { if (xVal < XMIN || xVal > XMAX) { throw new ValueOutOfRangeException( "X (azimuth) must fall within the range of " + XMIN + " (far left) to " + XMAX + " (far right) as per PhiPi firmware; You requested " + xVal); } command = "x"; this.paramVal = xVal; } /* * (non-Javadoc) * * @see org.hooliguns.ninja.telnet.Command#getHumanName() */ public String getHumanName() { return "SetX command"; } @Override public byte[] execute(CommandExecutionUnit ceu) { ceu.setDestinationX(paramVal); return super.execute(ceu); } }