package mde.jini.service;

/**
 * The PalmProtocol interface represents the set of commands and status indicators received from
 * and sent to the PalmPilot. The commands map directly into the set of commands used to control
 * the Lego Mindstorms tanks through method calls to the TankProxy class.
 */
public interface PalmProtocol {

   /** Find an available tank proxy in the Jini network and register with it */ 
   public static final String REGISTER          = "register";

   /** Tell the tank to move forward */
   public static final String FORWARD           = "forward";

   /** Tell the tank to move backward */ 
   public static final String BACKWARD          = "backward";

   /** Tell the tank to turn left */
   public static final String LEFT              = "left";

   /** Tell the tank to turn right */ 
   public static final String RIGHT             = "right";

   /** Tell the tank to fire its laser */
   public static final String FIRE              = "fire";

   /** Tell the tank to stop moving/turning */
   public static final String STOP              = "stop";

   /** Ask the tank for its current status (@see TankCommands) */
   public static final String STATUS            = "status";
   
   /** Tells the tank proxy we're done sending commands */ 
   public static final String QUIT              = "quit";

   /** Base for status messages received by the PalmPilot */
   public static final byte STATUS_BASE         = 0x60;

   /** Obstructed bit for tank status byte */
   public static final byte STATUS_OBSTRUCTED   = STATUS_BASE | (1 << 0);

   /** Hit bit for tank status byte */
   public static final byte STATUS_HIT          = STATUS_BASE | (1 << 1);

   /** Error bit for tank status byte */
   public static final byte STATUS_ERROR        = STATUS_BASE | (1 << 2);

   /** Registered bit for tank status byte */
   public static final byte STATUS_REGISTERED   = STATUS_BASE | (1 << 3);

   /** Mask for extracting obstructed bit from tank status byte */
   public static final byte MASK_OBSTRUCTED     = 1 << 0;

   /** Mask for extracting hit bit from tank status byte */
   public static final byte MASK_HIT            = 1 << 1;

   /** Mask for extracting error bit from tank status byte */
   public static final byte MASK_ERROR          = 1 << 2;

   /** Mask for extracting registered bit from tank status byte */
   public static final byte MASK_REGISTERED     = 1 << 3;

}