1   package interfaces;
2   
3   /**
4   * Interface class for both real and simulated robots.
5   * Defines all the input and output methods a controller
6   * can call.
7   *
8   * @author Graham Ritchie && MODIFIED BY: Simon Zienkiewicz
9   */
10  public interface AbstractRobot
11  {
12          /** constant for single motor to move backwards */    
13          public static final int BACKWARD = 0;
14          
15          /** constant for single motor to move forwards */        
16          public static final int FORWARD = 1;  
17          
18          /** constant for MOTOR A */        
19          public static final int MOTOR_A = 0; 
20          
21          /** constant for MOTOR C */        
22          public static final int MOTOR_C = 1; 
23          
24          /** constant for sensor 1 */       
25          public static final int S1 = 1; 
26          
27          /** constant for sensor 2 */        
28          public static final int S2 = 2; 
29          
30          /** sconstant for sensor 3 */        
31          public static final int S3 = 3; 
32          
33          
34      /******************************************
35         Methods for moving the robot - output
36      ******************************************/
37      
38      /**
39      * Sets the robot moving forwards, this will continue until some other 
40      * method is called to stop it
41      */
42      public abstract void forward();
43           
44           /**
45      * Makes the robot move forwards for the given amount of time 
46      * @param time the time in milliseconds
47          */       
48          public abstract void forward(int time);
49         
50      /**
51      * Sets the robot moving backwards, this will continue until some other 
52      * method is called to stop it 
53      */
54      public abstract void backward();
55      
56      /**
57      * Makes the robot move backwards for the given amount of time
58      *
59      * @param time the time in milliseconds
60          */       
61      public abstract void backward(int time);
62      
63      /**
64      * Sets the robot spinning right on a dime, this will continue until some other 
65      * method is called to stop it.
66      */
67      public abstract void right();
68      
69      /**
70      * Spins the robot right on a dime for the given amount of time
71      *
72      * @param time the time in milliseconds
73      */
74      public abstract void right(int time);
75      
76      /**
77      * Sets the robot spinning left on a dime, this will continue until some other 
78      * method is called to stop it.
79      */
80      public abstract void left();
81      
82      /**
83      * Spins the robot left on a dime for the given amount of time
84      *
85      * @param time the time in milliseconds
86      */
87      public abstract void left(int time);
88      
89          /** Sets a single Motor moving, this will continue until some other
90           * method is called to stop it
91           * Created by: Simon Zienkiewicz
92           * @param direction the direction number (AbstractRobot.BACKWARDS or AbstractRobot.FORWARDS
93           * @param motor the motor number (AbstractRobot.MOTOR_A or AbstractRobot.MOTOR_C);
94           */
95          public abstract void singleMotor(int motor, int direction);
96         
97          /** Sets a single Motor moving for the given amount of time
98           * Created by: Simon Zienkiewicz
99           * @param motor the motor number (AbstractRobot.MOTOR_A or AbstractRobot.MOTOR_C);
100          * @param direction the direction number (AbstractRobot.BACKWARDS or AbstractRobot.FORWARDS
101          * @param time the time in milliseconds
102          */
103         public abstract void singleMotor(int motor, int direction, int time);
104     
105         /**
106     * Stops all motors immediately
107     */
108     public abstract void stopMoving();
109     
110         
111     /*************************************************
112       Methods for reading the robot's sensors - input 
113     **************************************************/
114     
115     /**
116     * Get the current reading of this sensor
117     *
118     * @return the current value
119     */
120     public abstract int getSensor1();
121     
122     /**
123     * Get the current reading of this sensor
124     *
125     * @return the current value
126     */
127     public abstract int getSensor2();
128     
129     /**
130     * Get the current reading of this sensor
131     *
132     * @return the current value
133     */
134     public abstract int getSensor3();
135         
136         /**
137     * Gets an array of boolean values for the touch sensors
138         * Created by: Simon Zienkiewicz
139         *
140         * @return boolean values of the status of the sensors
141     */
142         public abstract boolean[] getTouchSensorStatus();
143         
144         
145         /*************************************************
146       Methods for handling LCD output 
147     **************************************************/
148         
149         
150         /**
151     * Display numbers on the LCD
152     *
153     * Created by: Simon Zienkiewicz
154         * @param num the number to display
155     */
156         public abstract void displayNumberLCD(int num);
157                 
158         /**
159     * Clears the display on the LCD
160     *
161     * Modified by: Simon Zienkiewicz
162         */
163         public abstract void clearLCD();
164         
165         /** Display text on the LCD
166          * Created by: Simon Zienkiewicz
167          * @param word string to display
168          */
169         public abstract void displayTextLCD(String word);
170         
171         
172         /*************************************************
173       Methods for handling ROBOT properties 
174     **************************************************/
175         
176         
177         /** Sets the power of the motors for the robot
178          * Created by: Simon Zienkiewicz
179          * @param power the desired power
180          */
181         public abstract void setMotorPower(int power);
182         
183         /**
184     * Gets the power of the motors for the robot
185         * Created by: Simon Zienkiewicz
186         *
187         * @return the power of the motor 0-7
188     */
189         public abstract int getMotorPower();
190                       
191         /**
192     * Gets the voltage of the RCX battery in MilliVolts
193         * Created by: Simon Zienkiewicz
194         *
195         * @return int voltage in the battery of the RCX
196     */
197         public abstract int getVoltage();
198         
199         /**
200     * Activates the light and touch sensors
201         * Created by: Simon Zienkiewicz
202         *
203     */
204         public abstract void activate();
205         
206         /** Plays a sound
207          * Created by: Simon Zienkiewicz
208          * @param frequency the sound frequency
209          * @param duration the duration of the sound in milliseconds
210          */
211         public abstract void playTune(int frequency, int duration);
212                 
213         /**
214     * Makes the robot beep
215     */
216     public abstract void beep();
217         
218         /*************************************************
219       Methods for handling timer/timing events 
220     **************************************************/
221         
222         /** Creates a timer
223          * Created by: Simon Zienkiewicz
224          * @param time the delay for the timer
225          * @return int the timer number
226          */
227         public abstract int createTimer(int time);
228         
229         /** Starts the requested timer
230          * Created by: Simon Zienkiewicz
231          * @param num the timer number
232          */
233         public abstract void startTimer(int num);
234          
235         /** Stops the requested timer
236          * Created by: Simon Zienkiewicz
237          * @param num the timer number
238          */
239         public void stopTimer(int num);
240         
241         /**
242     * Stops all timers
243         * Created by: Simon Zienkiewicz
244         *
245         */
246         public void stopAllTimers();
247         
248         /** Gets the delay from the requested timer
249          * Created by: Simon Zienkiewicz
250          * @param num the timer number
251          * @return int the timer delay
252          */       
253         public int getDelay(int num);
254         
255         /** Sets the delay for the requested timer
256          * Created by: Simon Zienkiewicz
257          * @param num the timer number
258          * @param time the new delay time
259          */       
260         public void setDelay(int num, int time);
261         
262         /** Pauses the simulation
263          * Created by: Simon Zienkiewicz
264          * @param num the number of milliseconds
265          */
266         public abstract void pause(int num);
267         
268         
269                 
270 } 
271