com.digi.xbee.api.io

## Class IOSample

- java.lang.Object
- - com.digi.xbee.api.io.IOSample

-     public class IOSample
      extends Object

  This class represents an IO Data Sample. The sample is built using the the constructor. The sample contains an analog and digital mask indicating which IO lines are configured with that functionality.

  Depending on the protocol the XBee device is executing, the digital and analog masks are retrieved in separated bytes (2 bytes for the digital mask and 1 for the analog mask) or merged (digital and analog masks are contained in the same 2 bytes).

  802.15.4 Protocol

  Digital and analog channels masks

  ------------------------------------------------------------------

  Indicates which digital and ADC IO lines are configured in the module. Each bit corresponds to one digital or ADC IO line on the module:

  > bit 0 = DIO0

  > 1

  > bit 1 = DIO1

  > 0

  > bit 2 = DIO2

  > 0

  > bit 3 = DIO3

  > 1

  > bit 4 = DIO4

  > 0

  > bit 5 = DIO5

  > 1

  > bit 6 = DIO6

  > 0

  > bit 7 = DIO7

  > 0

  > bit 8 = DIO8

  > 0

  > bit 9 = AD0

  > 0

  > bit 10 = AD1

  > 1

  > bit 11 = AD2

  > 1

  > bit 12 = AD3

  > 0

  > bit 13 = AD4

  > 0

  > bit 14 = AD5

  > 0

  > bit 15 = N/A

  > 0

  > Example: mask of `0x0C29` means DIO0, DIO3, DIO5, AD1 and AD2 enabled.

  > 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1

  Other Protocols

  Digital Channel Mask

  ------------------------------------------------------------------

  Indicates which digital IO lines are configured in the module. Each bit corresponds to one digital IO line on the module:

  > bit 0 = DIO0/AD0

  > bit 1 = DIO1/AD1

  > bit 2 = DIO2/AD2

  > bit 3 = DIO3/AD3

  > bit 4 = DIO4/AD4

  > bit 5 = DIO5/AD5/ASSOC

  > bit 6 = DIO6/RTS

  > bit 7 = DIO7/CTS

  > bit 8 = DIO8/DTR/SLEEP_RQ

  > bit 9 = DIO9/ON_SLEEP

  > bit 10 = DIO10/PWM0/RSSI

  > bit 11 = DIO11/PWM1

  > bit 12 = DIO12/CD

  > bit 13 = DIO13

  > bit 14 = DIO14

  > bit 15 = N/A

  > Example: mask of `0x040B` means DIO0, DIO1, DIO2, DIO3 and DIO10 enabled.

  > 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 1

  Analog Channel Mask

  -----------------------------------------------------------------------

  Indicates which lines are configured as ADC. Each bit in the analog channel mask corresponds to one ADC line on the module.

  > bit 0 = AD0/DIO0

  > bit 1 = AD1/DIO1

  > bit 2 = AD2/DIO2

  > bit 3 = AD3/DIO3

  > bit 4 = AD4/DIO4

  > bit 5 = AD5/DIO5/ASSOC

  > bit 6 = N/A

  > bit 7 = Supply Voltage Value

  > Example: mask of `0x03` means AD0, and AD1 enabled.

  > 0 0 0 0 0 0 1 1

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `IOSample(byte[] ioSamplePayload)` Class constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getAnalogMask()` Returns the analog mask.
    `Integer` | `getAnalogValue(IOLine ioLine)` Returns the analog value of the provided IO line.
    `HashMap<IOLine,Integer>` | `getAnalogValues()` Returns the analog values map.
    `int` | `getDigitalHSBMask()` Returns the HSB of the digital mask.
    `int` | `getDigitalLSBMask()` Returns the LSB of the digital mask.
    `int` | `getDigitalMask()` Returns the combined (HSB + LSB) digital mask.
    `IOValue` | `getDigitalValue(IOLine ioLine)` Returns the digital value of the provided IO line.
    `HashMap<IOLine,IOValue>` | `getDigitalValues()` Returns the digital values map.
    `int` | `getPowerSupplyValue()` Returns the value of the power supply voltage.
    `boolean` | `hasAnalogValue(IOLine ioLine)` Returns whether or not the given IO line has an analog value.
    `boolean` | `hasAnalogValues()` Returns whether or not the `IOSample` has analog values.
    `boolean` | `hasDigitalValue(IOLine ioLine)` Returns whether or not this IO sample contains a digital value for the given IO line.
    `boolean` | `hasDigitalValues()` Checks whether or not the `IOSample` has digital values.
    `boolean` | `hasPowerSupplyValue()` Returns whether or not the IOSample has power supply value.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### IOSample

          public IOSample(byte[] ioSamplePayload)

      Class constructor. Instantiates a new object of type `IOSample` with the given IO sample payload.
      Parameters:
        `ioSamplePayload` - The payload corresponding to an IO sample.
      Throws:
        `IllegalArgumentException` - if `ioSamplePayload.length < 5`.
        `NullPointerException` - if `ioSamplePayload == null`.

  - ### Method Detail

    - #### getAnalogMask

          public int getAnalogMask()

      Returns the analog mask.
      Returns:
        Analog mask.

    - #### getAnalogValue

          public Integer getAnalogValue(IOLine ioLine)

      Returns the analog value of the provided IO line.

      To verify if this sample contains an analog value for the given `IOLine`, use the method `hasAnalogValue(IOLine)`.

           if (ioSample.hasAnalogValue(IOLine.DIO0_AD0)) {
               Integer value = ioSample.getAnalogValue(IOLine.DIO0_AD0);
               ...
           } else {
               ...
           }

      Parameters:
        `ioLine` - The IO line to get its analog value.
      Returns:
        The analog value of the given IO line or `null` if the IO sample does not contain an analog value for the given IO line.
      See Also:
        `getAnalogValues()`, `hasAnalogValue(IOLine)`, `hasAnalogValues()`, `IOLine`

    - #### getAnalogValues

          public HashMap<IOLine,Integer> getAnalogValues()

      Returns the analog values map.

      To verify if this sample contains a valid analog values, use the method `hasAnalogValues()`.

           if (ioSample.hasAnalogValues()) {
               HashMap<IOLine, Integer> values = ioSample.getAnalogValues();
               ...
           } else {
               ...
           }

      Returns:
        `HashMap` with the analog value of each configured IO line.
      See Also:
        `getAnalogValue(IOLine)`, `hasAnalogValue(IOLine)`, `hasAnalogValues()`, `IOLine`

    - #### getDigitalHSBMask

          public int getDigitalHSBMask()

      Returns the HSB of the digital mask.
      Returns:
        HSB of the digital mask.
      See Also:
        `getDigitalLSBMask()`, `getDigitalMask()`

    - #### getDigitalLSBMask

          public int getDigitalLSBMask()

      Returns the LSB of the digital mask.
      Returns:
        LSB of the digital mask.
      See Also:
        `getDigitalHSBMask()`, `getDigitalMask()`

    - #### getDigitalMask

          public int getDigitalMask()

      Returns the combined (HSB + LSB) digital mask.
      Returns:
        The combined digital mask.
      See Also:
        `getDigitalLSBMask()`, `getDigitalHSBMask()`

    - #### getDigitalValue

          public IOValue getDigitalValue(IOLine ioLine)

      Returns the digital value of the provided IO line.

      To verify if this sample contains a digital value for the given `IOLine`, use the method `hasDigitalValue(IOLine)`.

           if (ioSample.hasDigitalValue(IOLine.DIO0_AD0)) {
               IOValue value = ioSample.getDigitalValue(IOLine.DIO0_AD0);
               ...
           } else {
               ...
           }

      Parameters:
        `ioLine` - The IO line to get its digital value.
      Returns:
        The `IOValue` of the given IO line or `null` if the IO sample does not contain a digital value for the given IO line.
      See Also:
        `getDigitalValues()`, `hasDigitalValues()`, `IOLine`, `IOValue`

    - #### getDigitalValues

          public HashMap<IOLine,IOValue> getDigitalValues()

      Returns the digital values map.

      To verify if this sample contains a valid digital values, use the method `hasDigitalValues()`.

           if (ioSample.hasDigitalValues()) {
               HashMap<IOLine, IOValue> values = ioSample.getDigitalValues();
               ...
           } else {
               ...
           }

      Returns:
        `HashMap` with the digital value of each configured IO line.
      See Also:
        `getDigitalValue(IOLine)`, `hasDigitalValues()`, `IOLine`, `IOValue`

    - #### getPowerSupplyValue

          public int getPowerSupplyValue()
                                  throws OperationNotSupportedException

      Returns the value of the power supply voltage.

      To verify if this sample contains the power supply voltage, use the method `hasPowerSupplyValue()`.

           if (ioSample.hasPowerSupplyValue()) {
               int value = ioSample.getPowerSupplyValue();
               ...
           } else {
               ...
           }

      Returns:
        The value of the power supply voltage.
      Throws:
        `OperationNotSupportedException` - if the IOSample does not have power supply value.
      See Also:
        `hasPowerSupplyValue()`

    - #### hasAnalogValue

          public boolean hasAnalogValue(IOLine ioLine)

      Returns whether or not the given IO line has an analog value.
      Parameters:
        `ioLine` - The IO line to check if has an analog value.
      Returns:
        `true` if the given IO line has an analog value, `false` otherwise.
      See Also:
        `getAnalogValue(IOLine)`, `getAnalogValues()`, `hasAnalogValues()`, `IOLine`

    - #### hasAnalogValues

          public boolean hasAnalogValues()

      Returns whether or not the `IOSample` has analog values.
      Returns:
        `true` if there are analog values, `false` otherwise.
      See Also:
        `getAnalogValue(IOLine)`, `getAnalogValues()`, `hasAnalogValue(IOLine)`, `IOLine`

    - #### hasDigitalValue

          public boolean hasDigitalValue(IOLine ioLine)

      Returns whether or not this IO sample contains a digital value for the given IO line.
      Parameters:
        `ioLine` - The IO line to check if has a digital value.
      Returns:
        `true` if the given IO line has a digital value, `false` otherwise.
      See Also:
        `hasDigitalValues()`, `IOLine`

    - #### hasDigitalValues

          public boolean hasDigitalValues()

      Checks whether or not the `IOSample` has digital values.
      Returns:
        `true` if there are digital values, `false` otherwise.

    - #### hasPowerSupplyValue

          public boolean hasPowerSupplyValue()

      Returns whether or not the IOSample has power supply value.
      Returns:
        `true` if the IOSample has power supply value, `false` otherwise.
      See Also:
        `getPowerSupplyValue()`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

© Copyright 2014–2014 Digi International Inc. All rights reserved.