com.drismo.logic
Class MonitorController

java.lang.Object
  extended by com.drismo.logic.MonitorController
All Implemented Interfaces:
CalibrationListener

public class MonitorController
extends java.lang.Object
implements CalibrationListener

A singleton controller responsible of maintaining and controlling everything related to a monitor activity.

See Also:
MonitorActivityTemplate, AccelerationHandler, LocationHandler, QualityRater, Calibration

Field Summary
private  AccelerationHandler accelerationHandler
           
private  android.media.AudioManager AM
           
private  android.content.Context c
           
private  Calibration calibrator
           
private static MonitorController CONTROLLER
           
private  int CURRENT_STATE
           
private  LocationHandler locationHandler
           
private  MonitorActivityTemplate monitorActivity
           
private  int notifyVibrate
           
private  android.content.pm.PackageManager PM
           
private  QualityToSpeech qtsEngine
           
private  QualityRater qualityRater
           
private  int ringerVibrate
           
static int STATE_CALIBRATING
           
static int STATE_IDLE
           
static int STATE_MONITORING
           
private  TripLogger tripLogger
           
 
Constructor Summary
private MonitorController(android.location.LocationManager lm, android.hardware.SensorManager sm, android.content.Context c)
          Constructor initiating all the necessary objects to control the actual monitor activity.
 
Method Summary
 void cancelCalibration()
          Cancels the calibration, if calibrating.
 java.lang.String getLogFileName()
          Call this function to get the filename of the file currently beeing logged.
 void initiateCalibration()
          Initiates the calibration.
private  void initiateMonitorActivity()
          Initiates the monitor activity by registering it as a listener in the required handlers.
 boolean isMonitoring()
          Check to see if we are monitoring at the moment.
 void onCalibrationCompleted()
          This method is fired when the calibration is done, which means that we got valid yaw, roll and pitch angles (we successfully can rotate the acceleration).
 void onOffsetCalculationComplete()
          This method is fired when the offset calibration is completed.
private  void purgeActivityListener()
          Purges the monitor activity by removing it in all the required handlers.
static MonitorController requestMonitorController(MonitorActivityTemplate a)
          Returns the monitor controller, and set the given monitor activity as the current.
private  void setMonitorActivity(MonitorActivityTemplate a)
          Set the new monitor activity by purging the old and initiating the new.
 void setUpMessenger()
          Sets up the on call/sms response, based on the preferences.
 void startMonitoring()
          Start monitoring.
 void stopMonitoring()
          Stop monitoring.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

c

private android.content.Context c

CONTROLLER

private static volatile MonitorController CONTROLLER

PM

private android.content.pm.PackageManager PM

AM

private android.media.AudioManager AM

STATE_IDLE

public static final int STATE_IDLE
See Also:
Constant Field Values

STATE_CALIBRATING

public static final int STATE_CALIBRATING
See Also:
Constant Field Values

STATE_MONITORING

public static final int STATE_MONITORING
See Also:
Constant Field Values

CURRENT_STATE

private int CURRENT_STATE

ringerVibrate

private int ringerVibrate

notifyVibrate

private int notifyVibrate

calibrator

private Calibration calibrator

accelerationHandler

private AccelerationHandler accelerationHandler

locationHandler

private LocationHandler locationHandler

qualityRater

private QualityRater qualityRater

monitorActivity

private MonitorActivityTemplate monitorActivity

tripLogger

private TripLogger tripLogger

qtsEngine

private QualityToSpeech qtsEngine
Constructor Detail

MonitorController

private MonitorController(android.location.LocationManager lm,
                          android.hardware.SensorManager sm,
                          android.content.Context c)
Constructor initiating all the necessary objects to control the actual monitor activity.

Parameters:
lm - LocationManager provided by the monitor activity.
sm - SensorManager provided by the monitor activity.
c - Application context provided by the monitor activity.
See Also:
requestMonitorController(com.drismo.gui.monitor.MonitorActivityTemplate)
Method Detail

requestMonitorController

public static MonitorController requestMonitorController(MonitorActivityTemplate a)
Returns the monitor controller, and set the given monitor activity as the current.

Parameters:
a - The monitor activity.
Returns:
The monitor controller.

setMonitorActivity

private void setMonitorActivity(MonitorActivityTemplate a)
Set the new monitor activity by purging the old and initiating the new.

Parameters:
a - The give monitor activity.

initiateMonitorActivity

private void initiateMonitorActivity()
Initiates the monitor activity by registering it as a listener in the required handlers.


purgeActivityListener

private void purgeActivityListener()
Purges the monitor activity by removing it in all the required handlers.


initiateCalibration

public void initiateCalibration()
Initiates the calibration.


cancelCalibration

public void cancelCalibration()
Cancels the calibration, if calibrating.


onOffsetCalculationComplete

public void onOffsetCalculationComplete()
Description copied from interface: CalibrationListener
This method is fired when the offset calibration is completed. This means that we got the "starting-point" to detect the driving direction, in addition to the calibrated roll and pitch angles.

Specified by:
onOffsetCalculationComplete in interface CalibrationListener

onCalibrationCompleted

public void onCalibrationCompleted()
Description copied from interface: CalibrationListener
This method is fired when the calibration is done, which means that we got valid yaw, roll and pitch angles (we successfully can rotate the acceleration). vectors.

Specified by:
onCalibrationCompleted in interface CalibrationListener

startMonitoring

public void startMonitoring()
Start monitoring.


setUpMessenger

public void setUpMessenger()
Sets up the on call/sms response, based on the preferences.


stopMonitoring

public void stopMonitoring()
Stop monitoring.


isMonitoring

public boolean isMonitoring()
Check to see if we are monitoring at the moment.

Returns:
True if current state is monitoring.

getLogFileName

public java.lang.String getLogFileName()
Call this function to get the filename of the file currently beeing logged.

Returns:
file name.