Minor adjustments/cleanups for SpeakerController application
[iot2.git] / benchmarks / Java / SpeakerController / SpeakerController.java
index 00b6dbaf5d0d8dccfd6275dca269e21d42023f80..9a5cc83eab57d858fdcf97d75a085dd0e77ece85 100644 (file)
@@ -150,27 +150,19 @@ public class SpeakerController extends UnicastRemoteObject implements GPSGateway
                                // Get the speaker objects one by one assuming that we could have
                                // more than one speaker per room
                                for (SpeakerSmart speakers : roomSpeakerRel.get(room)) {
-                                       // System.out.println("DEBUG: Turn on speaker!");
-
-                                       //try {
-
-                                               // start the speaker playback if the speaker is not playing yet
-                                               if (!speakers.getPlaybackState()) {
-
-                                                       System.out.println("Turning a speaker On in room: " + room.getRoomID());
-                                                       speakers.startPlayback();
-                                                       speakers.setPosition(currentPosition);
-
-                                               } else {
-                                                       // get average of the positions
-                                                       currPosTotal += speakers.getPosition();
-                                                       currPosCount++;
-                                               }
-
-
-                                       //} catch (RemoteException e) {
-                                       //      e.printStackTrace();
-                                       //}
+                                       System.out.println("DEBUG: Turn on speaker!");
+                                       // start the speaker playback if the speaker is not playing yet
+                                       if (!speakers.getPlaybackState()) {
+
+                                               System.out.println("Turning a speaker On in room: " + room.getRoomID());
+                                               speakers.startPlayback();
+                                               speakers.setPosition(currentPosition);
+
+                                       } else {
+                                               // get average of the positions
+                                               currPosTotal += speakers.getPosition();
+                                               currPosCount++;
+                                       }
                                }
 
                                if (currPosCount != 0) {
@@ -183,11 +175,7 @@ public class SpeakerController extends UnicastRemoteObject implements GPSGateway
                                                // we were kind of far so update all the positions
 
                                                for (SpeakerSmart speakers : roomSpeakerRel.get(room)) {
-                                                       //try {
-                                                               speakers.setPosition(currentPosOfSpeakers);
-                                                       //} catch (RemoteException e) {
-                                                       //      e.printStackTrace();
-                                                       //}
+                                                       speakers.setPosition(currentPosOfSpeakers);
                                                }
                                        }
 
@@ -253,15 +241,15 @@ public class SpeakerController extends UnicastRemoteObject implements GPSGateway
                // If we have new data, we update the speaker streaming
                if (newDataAvailable.get()) {
 
-                       // System.out.println("DEBUG: New data is available!!!");
-                       // System.out.println("DEBUG: Ring status: " + ringStatus);
+                       System.out.println("DEBUG: New data is available!!!");
+                       System.out.println("DEBUG: Ring status: " + ringStatus);
                        // Check for ring status first
                        if (ringStatus) {
 
                                // Turn off all speakers if ring status is true (phone is ringing)
                                for (RoomSmart room : audioRooms.values()) {
 
-                                       // System.out.println("DEBUG: Update status off for speakers! Phone is ringing!!!");
+                                       System.out.println("DEBUG: Update status off for speakers! Phone is ringing!!!");
                                        // Turn off speaker
                                        roomSpeakersOnOffStatus.put(room, false);
                                }
@@ -272,27 +260,22 @@ public class SpeakerController extends UnicastRemoteObject implements GPSGateway
                                // Check for every room
                                for (RoomSmart room : audioRooms.values()) {
 
-                                       //try {
-                                               // Turn on the right speaker based on room ID sent from phone app
-                                               // Stream audio to a speaker based on room ID
-                                               if (room.getRoomID() == roomIdentifier) {
+                                       // Turn on the right speaker based on room ID sent from phone app
+                                       // Stream audio to a speaker based on room ID
+                                       if (room.getRoomID() == roomIdentifier) {
 
-                                                       // System.out.println("DEBUG: This room ID: " + room.getRoomID());
-                                                       // System.out.println("DEBUG: Turn on the speaker(s) in this room!!!");
-                                                       // Set speaker status to on
-                                                       roomSpeakersOnOffStatus.put(room, true);
+                                               System.out.println("DEBUG: This room ID: " + room.getRoomID());
+                                               System.out.println("DEBUG: Turn on the speaker(s) in this room!!!");
+                                               // Set speaker status to on
+                                               roomSpeakersOnOffStatus.put(room, true);
 
-                                               } else {
-                                                       // for the rooms whose IDs aren't equal to roomIdentifier
+                                       } else {
+                                               // for the rooms whose IDs aren't equal to roomIdentifier
 
-                                                       // System.out.println("DEBUG: Turn on speaker!");
-                                                       // Set speaker status to off
-                                                       roomSpeakersOnOffStatus.put(room, false);
-                                               }
-
-                                       //} catch (RemoteException ex) {
-                                       //      ex.printStackTrace();
-                                       //}
+                                               System.out.println("DEBUG: Turn on speaker!");
+                                               // Set speaker status to off
+                                               roomSpeakersOnOffStatus.put(room, false);
+                                       }
                                }
                        }
                        // Finish processing data - put this back to false
@@ -407,14 +390,9 @@ public class SpeakerController extends UnicastRemoteObject implements GPSGateway
                // Setup the cameras, start them all and assign each one a motion detector
                for (GPSGatewaySmart gw : gpsSet.values()) {
 
-                       //try {
-                               // initialize, register callback, and start the gateway
-                               gw.init();
-                               gw.registerCallback(this);
-                               gw.start();
-                       //} catch (RemoteException ex) {
-                       //      ex.printStackTrace();
-                       //}
+                       gw.init();
+                       gw.registerCallback(this);
+                       gw.start();
                }