com.motorola.oem.hapi
Class A2dChannel

java.lang.Object
  extended by com.motorola.oem.hapi.A2dChannel

public final class A2dChannel
extends java.lang.Object

 The A2dChannel class contains methods for configuration, and receiving notifications from the A2d channels.

General description:

There are three types of A2d notifications modes defined:

1) Automatic notification off - Always available and doesn't need special configuration.
2) Automatic notification by period - Notification will be executed cyclically with pre-defined period.
See class A2dAutoPeriodConfig
3) Automatic notification by threshold - Report will be executed when:
a. Applied voltage decreases from the level above the high threshold of low border to the level below
the low threshold of the low border;
b. Applied voltage increases from the level below the low threshold of the high border to the level above
then high threshold of the high border;
See class A2dAutoThresholdConfig

Notification types can be enabled independently by the startNotification(com.motorola.oem.hapi.A2dAutoPeriodConfig) methods and may be re-defined at any time.
If the A2d configuration was not defined, the default definition will be taken instead - notification off.

Limitations:
1) Period must be defined in integral multiples of 4, for example 4,8,12,...,100,..(Minimum period value is 4 sec).
2) Threshold notification resolution is 4 seconds.(I.e. checking of threshold condition is done every 4 seconds).
3) A2d reading resolution is 255 units.(0 represents 0 volt and 255 represent 2.3 volt).


Field Summary
static int AUTO_NOTIFICATION_OFF
          Constant specifying AUTO_NOTIFICATION_OFF mode.
static int AUTO_NOTIFICATION_PERIOD
          Constant specifying AUTO_NOTIFICATION_PERIOD mode.
static int AUTO_NOTIFICATION_THRESHOLD
          constant specifying AUTO_NOTIFICATION_THRESHOLD mode.
 
Method Summary
 int getChannelNotificationMode()
          Gets notification mode for this channel.
 int getConverterNum()
          Gets a converter number mapped to this channel.
 A2dEventListener getListener()
          Gets listener of this channel.
 A2dAutoPeriodConfig getPeriodModeData()
          Gets A2dAutoPeriodConfig instance related to this channel.
 A2dAutoThresholdConfig getThresholdModeData()
          Gets A2dAutoThresholdConfig instance related to this channel.
 int getValue()
          Gets value from a channel.
 void setListener(A2dEventListener listener)
          Sets listener for this channel.
 void startNotification(A2dAutoPeriodConfig period_config_data)
          Sets channel to auto notification by period.
 void startNotification(A2dAutoThresholdConfig threshold_config_data)
          Sets channel to auto notification by threshold.
 void stopNotification()
          Sets a channel to auto notification off.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTO_NOTIFICATION_OFF

public static final int AUTO_NOTIFICATION_OFF
Constant specifying AUTO_NOTIFICATION_OFF mode.

See Also:
Constant Field Values

AUTO_NOTIFICATION_PERIOD

public static final int AUTO_NOTIFICATION_PERIOD
Constant specifying AUTO_NOTIFICATION_PERIOD mode.

See Also:
Constant Field Values

AUTO_NOTIFICATION_THRESHOLD

public static final int AUTO_NOTIFICATION_THRESHOLD
constant specifying AUTO_NOTIFICATION_THRESHOLD mode.

See Also:
Constant Field Values
Method Detail

startNotification

public void startNotification(A2dAutoPeriodConfig period_config_data)
                       throws A2dException
Sets channel to auto notification by period.
 A2d value will be returned as a parameter to A2dEventListener.onNotification(int, int, int) method of
 A2dEventlistener instance related to this channel,
 therefore, setting a listener for this channel is a preliminary condition. 
 Call startNotification on channel which already configures to work in auto notification mode will 
 reconfigure the channel.

Parameters:
period_config_data - A2dAutoPeriodConfig instance holds period of time between cyclically report.
Throws:
A2dException - If A2d java API is not enable. Error code - A2dException.UNIT_DISABLED_ERROR
If call startNotification without setting listener. Error code - A2dException.SET_CHANNEL_ERROR
If platform failed to set channel to auto notification by period. Error code - A2dException.SET_CHANNEL_ERROR

startNotification

public void startNotification(A2dAutoThresholdConfig threshold_config_data)
                       throws A2dException
Sets channel to auto notification by threshold.
 A2d value will be returned as parameter to A2dEventListener.onNotification(int, int, int) method
 of A2dEventlistener instance related to this channel.
 Therefore set listener of this channel is a preliminary condition. 
 Call startNotification on channel which already configures to work in auto notification mode will 
 reconfigure the channel.

Parameters:
threshold_config_data - A2dAutoThersholdConfig instance that hold threshold definition.
Thresholds must accomplish the following conditions:
THRESHOLD_LOW_LIMIT_LOW <= THRESHOLD_HIGH_LIMIT_LOW
THRESHOLD_HIGH_LIMIT_LOW < THRESHOLD_LOW_LIMIT_HIGH
THRESHOLD_LOW_LIMIT_HIGH <= THRESHOLD_HIGH_LIMIT_HIGH
Throws:
A2dException - If A2d java API is not enable. Error code - A2dException.UNIT_DISABLED_ERROR
If call startNotification without setting listener. Error code - A2dException.SET_CHANNEL_ERROR
If platform failed to set channel to auto notification by threshold. Error code - A2dException.SET_CHANNEL_ERROR

stopNotification

public void stopNotification()
                      throws A2dException
Sets a channel to auto notification off.

Throws:
A2dException - If platform failed to set channel to auto notification off. Error code - A2dException.SET_CHANNEL_ERROR

getValue

public int getValue()
             throws A2dException,
                    java.lang.InterruptedException
Gets value from a channel.
 getValue is a synchronized method. At any time only one thread can execute it.
 This method will be blocked until receiving a notification.

Returns:
A2d query value.
Throws:
A2dException - If A2d java API is not enabled. Error code - A2dException.UNIT_DISABLED_ERROR
getValue is called with invalid parameters. Error code - A2dException.QUERY_CHANNEL_ERROR
java.lang.InterruptedException - Failed to get value.

getConverterNum

public int getConverterNum()
Gets a converter number mapped to this channel.
 Possible values are: 1 => ADC1, 2=> ADC2, 3 => ADC3.

Returns:
converterNum related to this A2dChannel instance.

getChannelNotificationMode

public int getChannelNotificationMode()
Gets notification mode for this channel.
 
 Possible values are: 0 => AUTO_NOTIFICATION_OFF, 1 => AUTO_NOTIFICATION_PERIOD, 2 => AUTO_NOTIFICATION_THRESHOLD.

Returns:
channelNotificationMode related to this A2dChannel instance.

getThresholdModeData

public A2dAutoThresholdConfig getThresholdModeData()
Gets A2dAutoThresholdConfig instance related to this channel.

Returns:
thresholdModeData instance related to this A2dChannel instance. When the notification mode is different from AUTO_NOTIFICATION_THRESHOLD null is returned.

getPeriodModeData

public A2dAutoPeriodConfig getPeriodModeData()
Gets A2dAutoPeriodConfig instance related to this channel.

Returns:
periodModeData instance related to this A2dChannel instance. When notification mode different from AUTO_NOTIFICATION_PERIOD null is returned.

setListener

public void setListener(A2dEventListener listener)
                 throws A2dException
Sets listener for this channel.

Parameters:
listener - External listener object to receive events.
Throws:
A2dException - If attempt to set null listener. Error code - OEMException.GENERAL_ERROR

getListener

public A2dEventListener getListener()
Gets listener of this channel.

Returns:
A2dEventListener instance related to this channel.