Minor adjustments/cleanups for SpeakerController application
authorrtrimana <rtrimana@uci.edu>
Fri, 2 Mar 2018 21:57:05 +0000 (13:57 -0800)
committerrtrimana <rtrimana@uci.edu>
Fri, 2 Mar 2018 21:57:05 +0000 (13:57 -0800)
benchmarks/Java/SpeakerController/SpeakerController.java
benchmarks/other/PhoneInterface/SpeakerLocator/app/src/main/res/values/strings.xml

index 00b6dba..9a5cc83 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();
                }
 
 
index d05272a..edc98d6 100644 (file)
@@ -1,7 +1,7 @@
 <resources>
     <string name="app_name">SpeakerLocator</string>
     <string name="action_settings">Settings</string>
-    <string name="gateway_ip">192.168.2.191</string>
+    <string name="gateway_ip">192.168.1.191</string>
     <string name="mac_1">b0:b9:8a:73:69:f4</string>
     <string name="mac_2">b0:b9:8a:73:69:f3</string>
     <string name="mac_3">00:24:98:9a:92:ef</string>