Skip to content

Commit

Permalink
Formatted java code.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiddiZ committed Oct 22, 2017
1 parent 13aef31 commit 9799031
Show file tree
Hide file tree
Showing 34 changed files with 168 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public final class ParameterIdList
/*
* This parameter list belongs to the communication protocol number 0.
*/
public final static byte BATTERY_VOLTAGE = 1,
public final static byte BATTERY_VOLTAGE = 1,
GYRO_ANGLE = 2,
TACHO_LEFT = 3,
TACHO_RIGHT = 4,
Expand Down
7 changes: 4 additions & 3 deletions NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/NXT.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class NXT

/**
* Is the main method on the NXT. Calls the mainMenu method to create the visible menu and initiate the Communication and Balancing Thread.
*
* @param unused
* @throws InterruptedException
*/
Expand All @@ -36,11 +37,11 @@ public static void main(String[] args) throws InterruptedException {
}

/**
* Initiates the Connection, by calling the connect method of the COMMUNICATOR.
*
* The method runs in a endless loop until the Escape Button is hold down during a connection timeout,
* Initiates the Connection, by calling the connect method of the COMMUNICATOR.
* The method runs in a endless loop until the Escape Button is hold down during a connection timeout,
* if the connection is whether established nor beeing established the NXT tries to connect with the PC.
* If startBalancing is set to true, then the Method initiates SensorData and starts the Balancing thread after 3 seconds.
*
* @throws InterruptedException
*/
public static void mainMenu() throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public AbstractConnector() {

/**
* Check if an connection is established.
*
* @return true iff an connection is established.
*/
public final boolean connectionEstablished() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
*/
final class BluetoothConnector extends AbstractConnector
{
@Override
/**
* Performs the connection. after 20 seconds it breaks the attempt and sets connection to null.
* This method is blocking.
*/
@Override
public void run() {
connection = Bluetooth.waitForConnection(20000, NXTConnection.PACKET);
isConnecting = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public final class CommunicatorNXT extends AbstractCommunicator
final private byte protocolVersion = 2;
public static boolean sendEvoMeasurement = false;


/**
* Constructor of the NXT Communicator. It registers all handlers at the beginning to allow for processing of incoming commands,
* after an connection is established.
Expand Down Expand Up @@ -123,11 +122,10 @@ public void disconnect() {
}
}


/**
* Private class to send an Status Packet and the value of the UltraSonic sensor each tick. It provides the declared auto status package from the communication protokol.
*
* @author Gregor
*
*/
private final class NXTCommandListener extends CommandListener
{
Expand Down Expand Up @@ -175,7 +173,8 @@ protected void logException(IOException ex) {
}

/**
* Sends the internal Protocol Version that this NXT is using.
* Sends the internal Protocol Version that this NXT is using.
*
* @throws IOException
*/
public void sendProtocolVersion() throws IOException {
Expand All @@ -186,6 +185,7 @@ public void sendProtocolVersion() throws IOException {

/**
* This function returns an integer value corresponding the paramID that was asked by the PC.
*
* @param param paramID of the requested value.
* @param value integer value of the requested variable.
* @throws IOException
Expand All @@ -209,6 +209,7 @@ public void sendGetReturnUltraSensor(byte value) throws IOException {

/**
* This function returns a float values corresponding the paramID that were asked by the PC.
*
* @param param paramID of the requested value.
* @param value float value of the requested variable.
* @throws IOException
Expand All @@ -222,6 +223,7 @@ public void sendGetReturn(byte param, float value) throws IOException {

/**
* This function returns two float values corresponding the paramID that were asked by the PC.
*
* @param param paramID of the requested value.
* @param value1 float value of the requested variable.
* @param value2 float value of the requested variable.
Expand All @@ -237,6 +239,7 @@ public void sendGetReturn(byte param, float value1, float value2) throws IOExcep

/**
* This function returns four float values corresponding the paramID that were asked by the PC.
*
* @param param paramID of the requested value.
* @param value1 float value of the requested variable.
* @param value2 float value of the requested variable.
Expand All @@ -256,6 +259,7 @@ public void sendGetReturn(byte param, float value1, float value2, float value3,

/**
* This function returns a double value corresponding the paramID that were asked by the PC.
*
* @param param paramID of the requested value.
* @param value double value of the requested variable.
* @throws IOException
Expand All @@ -269,6 +273,7 @@ public void sendGetReturn(byte param, double value) throws IOException {

/**
* This function returns four double values corresponding the paramID that were asked by the PC.
*
* @param param paramID of the requested value.
* @param value1 double value of the requested variable.
* @param value2 double value of the requested variable.
Expand All @@ -288,6 +293,7 @@ public void sendGetReturn(byte param, double value1, double value2, double value

/**
* This function returns a long value corresponding the paramID that were asked by the PC.
*
* @param param paramID of the requested value.
* @param value long value of the requested variable.
* @throws IOException
Expand All @@ -301,6 +307,7 @@ public void sendGetReturn(byte param, long value) throws IOException {

/**
* This function returns a boolean value corresponding the paramID that were asked by the PC.
*
* @param param paramID of the requested value.
* @param value boolean value of the requested variable.
* @throws IOException
Expand All @@ -314,6 +321,7 @@ public void sendGetReturn(byte param, boolean value) throws IOException {

/**
* Sends a Messega Info the the PC with an custom message. The length of the message can have between 0 and 255 chars.
*
* @param length length of infoMessage
* @param infoMessage an array of chars containing the message
* @throws IOException
Expand All @@ -327,6 +335,7 @@ public void sendLogInfo(byte length, byte[] infoMessage) throws IOException {

/**
* Setter for the autoStatusThread. Activates or deactivetes the sending of auto status packages
*
* @param isOn of true, then activates the autoStatusThread, otherwise deactivates it.
*/
public void setAutoStatusThread(boolean isOn) {
Expand All @@ -338,6 +347,7 @@ public void setAutoStatusThread(boolean isOn) {

/**
* Sends a defined error code message to the PC. An IOException is catched in case the error was caused by an connection error.
*
* @param errorCode error code defined in errorCodes
*/
public static void sendErrorCode(byte errorCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
*/
final class USBConnector extends AbstractConnector
{
@Override
/**
* Performs the connection. after 5 seconds it breaks the attempt and sets connection to null.
* This method is blocking.
*/
@Override
public void run() {
connection = USB.waitForConnection(5000, NXTConnection.PACKET);
isConnecting = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
*/
public class BalancingHandler implements CommandHandler
{
@Override
/**
* This method reads a boolean of the DataInputStream and
* either starts or stops the balancing of the NXT depending on the value.
* The value is displayed on the NXT.
*
* @param is: The DataInputStream the handler uses to receive data.
*/
@Override
public void handle(DataInputStream is) throws IOException {
final boolean enabled = is.readBoolean();
if (enabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
*/
public class DisconnectHandler implements CommandHandler
{
@Override
/**
* This method calls a static method of the {@link CommunicatorNXT} to disconnect safely.
* @param is: The DataInputStream the handler could use to receive data. This handler does not use the input-stream.
*
* @param is: The DataInputStream the handler could use to receive data. This handler does not use the input-stream.
*/
@Override
public void handle(DataInputStream is) throws IOException {
CommunicatorNXT.staticDisconnect();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
public final class GetHandler implements CommandHandler
{
@Override
/**
* This method reads a parameter and switches it.
* Depending on the parameter, the number and type of the values to be send varies.
Expand All @@ -29,6 +28,7 @@ public final class GetHandler implements CommandHandler
*
* @param is: The DataInputStream the handler uses to receive data
*/
@Override
public void handle(DataInputStream is) throws IOException {
final byte param = is.readByte();
switch (param) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
*/
public class MoveHandler implements CommandHandler
{
@Override
/**
* This method reads a float of the input-stream
* and calls a method of the {@link MotorController} to let the NXT move the distance.
* Displays the received command and the distance on the NXT.
*
* @param is: The DataInputStream the handler uses to receive data.
*/
@Override
public void handle(DataInputStream is) throws IOException {
final float distance = is.readFloat();
MotorController.move(distance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
*/
public final class SetHandler implements CommandHandler
{
@Override
/**
* This method reads a parameter and switches it.
* Depending on the parameter, the number and type of the values varies.
* In most cases, this method simply sets the internal values of the NXT to the new values.
*
* <p>
* Notable parameters that differ in this:
* AUTO_STATUS_PACKET additionally displays the parameter and the value on the NXT.
* PID_MOTOR_DISTANCE, PID_MOTOR_SPEED and PARAM_WHEEL_DIAMETER need some calculation.
* EVO_COLLECT_TESTDATA eventually calls a method of {@link SensorData} to reset the test data.
*
* <p>
* The default case displays an error message on the NXT that the parameter is unknown.
*
* @param is: The DataInputStream the handler uses to receive data.
*/
@Override
public void handle(DataInputStream is) throws IOException {
final byte param = is.readByte();
switch (param) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
*/
public class TurnHandler implements CommandHandler
{
@Override
/**
* This method reads a float and
* calls a method of the {@link MotorController} to let the NXT turn by the angle.
* Displays the received command and angle on the NXT.
*
* @param is: The DataInputStream the handler uses to receive data.
*/
@Override
public void handle(DataInputStream is) throws IOException {
final float angle = is.readFloat();
MotorController.turn(angle);
System.out.println("Turning by " + angle + "°");
System.out.println("Turning by " + angle + "");
}
}
1 change: 0 additions & 1 deletion PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/PC.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* The main function of the PC Project, that lunches the GUI is started here.
*
* @author Christian
*
*/

public class PC
Expand Down
Loading

0 comments on commit 9799031

Please sign in to comment.