Skip to content

Commit

Permalink
Add sensor type to pull thread
Browse files Browse the repository at this point in the history
  • Loading branch information
nlathia committed Jul 1, 2015
1 parent a9fd574 commit 69e968b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
43 changes: 17 additions & 26 deletions src/com/emotionsense/demo/data/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public class MainActivity extends Activity

private AbstractDataLogger logger;
private ESSensorManager sensorManager;
private SubscribeThread[] subscribeThread;
private SubscribeThread[] subscribeThreads;
private SenseOnceThread[] pullThreads;

private final int[] pullSensors = { };
private final int[] pushSensors = {};
private final int[] pullSensors = {};

@Override
protected void onCreate(Bundle savedInstanceState)
Expand All @@ -37,8 +39,19 @@ protected void onCreate(Bundle savedInstanceState)
sensorManager = ESSensorManager.getSensorManager(this);

// Use this thread to collect a single sample of pull sensor data
SenseOnceThread sensingThread = new SenseOnceThread(this, sensorManager, logger);
sensingThread.start();
pullThreads = new SenseOnceThread[pullSensors.length];
for (int i = 0; i < pullSensors.length; i++)
{
pullThreads[i] = new SenseOnceThread(this, sensorManager, logger, pullSensors[i]);
pullThreads[i].start();
}

subscribeThreads = new SubscribeThread[pushSensors.length];
for (int i = 0; i < pushSensors.length; i++)
{
subscribeThreads[i] = new SubscribeThread(this, sensorManager, logger, pushSensors[i]);
subscribeThreads[i].start();
}
}
catch (Exception e)
{
Expand All @@ -48,28 +61,6 @@ protected void onCreate(Bundle savedInstanceState)
}
}

@Override
protected void onDestroy()
{
super.onDestroy();
for (SubscribeThread thread : subscribeThread)
{
thread.stopSensing();
}
}

@Override
protected void onResume()
{
super.onResume();
subscribeThread = new SubscribeThread[pullSensors.length];
for (int i = 0; i < pullSensors.length; i++)
{
subscribeThread[i] = new SubscribeThread(this, sensorManager, logger, pullSensors[i]);
subscribeThread[i].start();
}
}

public void onSearchClicked(final View view)
{
try
Expand Down
5 changes: 3 additions & 2 deletions src/com/emotionsense/demo/data/SenseOnceThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@

public class SenseOnceThread extends Thread
{
private final int sensorType = SensorUtils.SENSOR_TYPE_STEP_COUNTER;
private final int sensorType;
private final Activity resultScreen;
private final ESSensorManager sensorManager;
private final AbstractDataLogger logger;

public SenseOnceThread(final Activity resultScreen, final ESSensorManager sensorManager, AbstractDataLogger logger)
public SenseOnceThread(final Activity resultScreen, final ESSensorManager sensorManager, AbstractDataLogger logger, int sensorType)
{
this.resultScreen = resultScreen;
this.sensorManager = sensorManager;
this.logger = logger;
this.sensorType = sensorType;
}

private void toast(final String message)
Expand Down

0 comments on commit 69e968b

Please sign in to comment.