org.bluemelon.bluesense
Class SwitchInputDevice

java.lang.Object
  extended by org.bluemelon.bluesense.Device
      extended by org.bluemelon.bluesense.SwitchInputDevice

public class SwitchInputDevice
extends Device

Interface to the switchInputDevice BM7001.

The BM7001 allows you to measure the state of 12 different switches. Besides 12 normal switch the device has been programmed with special software to support automatic measurement of up to six rotary encoders. This means that you don't have to write complicated code anymore. The device simply outputs a number which determines the state of the rotary encoder. Each input can have a configured counter which counts the number of switch state changes. Because these features have been implemented in the device itself you can be sure that your software won't miss any information.


Field Summary
static int INPUT_COUNT
           
static int PROXY_ID
           
static java.lang.String PROXY_TITLE
           
static int[] SUPPORTS
           
static int SWITCHINPUT_PA_1
          Port pin value for pin A1
static int SWITCHINPUT_PA_2
          Port pin value for pin A2
static int SWITCHINPUT_PA_3
          Port pin value for pin A3
static int SWITCHINPUT_PA_4
          Port pin value for pin A4
static int SWITCHINPUT_PA_5
          Port pin value for pin A5
static int SWITCHINPUT_PA_6
          Port pin value for pin A6
static int SWITCHINPUT_PB_1
          Port pin value for pin B1
static int SWITCHINPUT_PB_2
          Port pin value for pin B2
static int SWITCHINPUT_PB_3
          Port pin value for pin B3
static int SWITCHINPUT_PB_4
          Port pin value for pin B4
static int SWITCHINPUT_PB_5
          Port pin value for pin B5
static int SWITCHINPUT_PB_6
          Port pin value for pin B6
static int SWITCHINPUT_RA_1_2
          Port pin value combination for a rotary encoder connection on ports A1 en A2
static int SWITCHINPUT_RA_3_4
          Port pin value combination for a rotary encoder connection on ports A3 en A4
static int SWITCHINPUT_RA_5_6
          Port pin value combination for a rotary encoder connection on ports A5 en A6
static int SWITCHINPUT_RB_1_2
          Port pin value combination for a rotary encoder connection on ports B1 en B2
static int SWITCHINPUT_RB_3_4
          Port pin value combination for a rotary encoder connection on ports B3 en B4
static int SWITCHINPUT_RB_5_6
          Port pin value combination for a rotary encoder connection on ports B5 en B6
 
Constructor Summary
SwitchInputDevice(Master master, int deviceId)
          Creates a 'software' switchInput device with a given id.
 
Method Summary
 boolean configPending()
          Checks if a configuration is being currently being set or being retrieved
 int getChangedCountersMask()
           
 int getChangedInputsMask()
           
 int getChangedRotariesMask()
           
 long getLastSampledCounter(int port)
          returns the last received counter value
 boolean getLastSampledInput(int port)
          returns the last taken bit sample on a specific port
 int getLastSampledInputs()
          returns the last taken multiplexed bit sample.
 int getLastSampledRotary(int rport)
          returns the last received rotary value
 boolean getRequestGetConfigDone()
          Checks if the configuration request is finished
 boolean getRequestGetInputsDone()
          Checks if an 'input values' request is finished
 boolean getRequestSetConfigDone()
          Checks if the configuration set request is finished
 long getSampleCount()
          returns the total number of samples taken since the start of the application
 long getTimeOutUs()
          Returns the current set time out delay.
 void requestGetConfiguration()
          Request to obtain the configuration settings from a adcInput Device.
 void requestGetInputs()
          Send a request to obtain the values of the switch inputs
 void requestNeedsBooleans(int side, boolean needs)
          Sends a request: request that the device should not/should send boolean states
 void requestNeedsCounter(int port, boolean needs)
          Sends a request: request that the device should not/should send counter states
 void requestNeedsRotary(int rport, boolean needs)
          Sends a request: request that the device should not/should send rotary encoder states
 void requestSetConfiguration(int booleansMask, int rotaryMask, int counterMask)
          Request the switchInput device to set the input types
 void setTimeOutUs(long timeOutUs)
          Sets the time out value which is used to check if a request was acknowledged in the set time.
 boolean usesBooleans(int side)
          Find out if we receive the boolean states of hardware side A or B.
 boolean usesCounter(int port)
          Find out if we receive counter states.
 boolean usesRotary(int rport)
          Find out if we receive rotary states.
 
Methods inherited from class org.bluemelon.bluesense.Device
addDeviceEventListener, detect, getFirmwareVersion, getId, getType, getTypeName, isAccessible, removeDeviceEventListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_TITLE

public static final java.lang.String PROXY_TITLE

PROXY_ID

public static final int PROXY_ID

SUPPORTS

public static final int[] SUPPORTS

INPUT_COUNT

public static final int INPUT_COUNT

SWITCHINPUT_RA_1_2

public static final int SWITCHINPUT_RA_1_2
Port pin value combination for a rotary encoder connection on ports A1 en A2


SWITCHINPUT_RA_3_4

public static final int SWITCHINPUT_RA_3_4
Port pin value combination for a rotary encoder connection on ports A3 en A4


SWITCHINPUT_RA_5_6

public static final int SWITCHINPUT_RA_5_6
Port pin value combination for a rotary encoder connection on ports A5 en A6


SWITCHINPUT_RB_1_2

public static final int SWITCHINPUT_RB_1_2
Port pin value combination for a rotary encoder connection on ports B1 en B2


SWITCHINPUT_RB_3_4

public static final int SWITCHINPUT_RB_3_4
Port pin value combination for a rotary encoder connection on ports B3 en B4


SWITCHINPUT_RB_5_6

public static final int SWITCHINPUT_RB_5_6
Port pin value combination for a rotary encoder connection on ports B5 en B6


SWITCHINPUT_PA_1

public static final int SWITCHINPUT_PA_1
Port pin value for pin A1


SWITCHINPUT_PA_2

public static final int SWITCHINPUT_PA_2
Port pin value for pin A2


SWITCHINPUT_PA_3

public static final int SWITCHINPUT_PA_3
Port pin value for pin A3


SWITCHINPUT_PA_4

public static final int SWITCHINPUT_PA_4
Port pin value for pin A4


SWITCHINPUT_PA_5

public static final int SWITCHINPUT_PA_5
Port pin value for pin A5


SWITCHINPUT_PA_6

public static final int SWITCHINPUT_PA_6
Port pin value for pin A6


SWITCHINPUT_PB_1

public static final int SWITCHINPUT_PB_1
Port pin value for pin B1


SWITCHINPUT_PB_2

public static final int SWITCHINPUT_PB_2
Port pin value for pin B2


SWITCHINPUT_PB_3

public static final int SWITCHINPUT_PB_3
Port pin value for pin B3


SWITCHINPUT_PB_4

public static final int SWITCHINPUT_PB_4
Port pin value for pin B4


SWITCHINPUT_PB_5

public static final int SWITCHINPUT_PB_5
Port pin value for pin B5


SWITCHINPUT_PB_6

public static final int SWITCHINPUT_PB_6
Port pin value for pin B6

Constructor Detail

SwitchInputDevice

public SwitchInputDevice(Master master,
                         int deviceId)
Creates a 'software' switchInput device with a given id. The device will inacessible until a physical device with the same id is detected.

Parameters:
master -
deviceId -
Method Detail

getLastSampledInput

public boolean getLastSampledInput(int port)
returns the last taken bit sample on a specific port

Parameters:
port - port pin value. @see bsSwitchInput_pA_1
Returns:
true if port activated, false if inactive

getLastSampledInputs

public int getLastSampledInputs()
returns the last taken multiplexed bit sample. A multiplexed sample is built as: port[0]+port[1]*2+port[2]*4+port[3]*8+...+port[11]*2048

Returns:
the multiplex sample containing the port states.

getLastSampledCounter

public long getLastSampledCounter(int port)
returns the last received counter value

Parameters:
port - port pin value. @see bsSwitchInput_pA_1
Returns:
the value of the counter.

getLastSampledRotary

public int getLastSampledRotary(int rport)
returns the last received rotary value

Parameters:
rport - the port pin value. @see bsSwitchInput_rA_1_2
Returns:
the value of the rotary encoder, this value can be negative

getSampleCount

public long getSampleCount()
returns the total number of samples taken since the start of the application

Returns:
the number of taken samples

getRequestGetInputsDone

public boolean getRequestGetInputsDone()
Checks if an 'input values' request is finished

Returns:
true if done, false if still busy

requestGetInputs

public void requestGetInputs()
Send a request to obtain the values of the switch inputs


requestNeedsBooleans

public void requestNeedsBooleans(int side,
                                 boolean needs)
Sends a request: request that the device should not/should send boolean states

Parameters:
side - if 0, side A selected, if 1 side B selected.
needs - if true, device should send boolean states, false device should not send boolean states

requestNeedsCounter

public void requestNeedsCounter(int port,
                                boolean needs)
Sends a request: request that the device should not/should send counter states

Parameters:
port - port pin value. @see bsSwitchInput_pA_1
needs - if true, device should send counter value, false device should not send counter value

requestNeedsRotary

public void requestNeedsRotary(int rport,
                               boolean needs)
Sends a request: request that the device should not/should send rotary encoder states

Parameters:
rport - the port pin value. @see bsSwitchInput_rA_1_2
needs - if true, device should send rotary states, false device should not send rotary states

usesBooleans

public boolean usesBooleans(int side)
Find out if we receive the boolean states of hardware side A or B.

Parameters:
side - if 0, check if side A booleans are received, if 1 check if side B booleans are received.
Returns:
true if states are received, false if boolean states are currently disabled (and will not be received).

usesCounter

public boolean usesCounter(int port)
Find out if we receive counter states.

Parameters:
port - port pin value. @see bsSwitchInput_pA_1
Returns:
true if states are received, false if states are currently disabled (and will not be received).

usesRotary

public boolean usesRotary(int rport)
Find out if we receive rotary states.

Parameters:
rport - the port pin value. @see bsSwitchInput_rA_1_2
Returns:
true if states are received, false if states are currently disabled (and will not be received).

configPending

public boolean configPending()
Checks if a configuration is being currently being set or being retrieved

Returns:
true if busy, false if done

getRequestGetConfigDone

public boolean getRequestGetConfigDone()
Checks if the configuration request is finished

Returns:
true if configuration was retrieved, false if still busy

getRequestSetConfigDone

public boolean getRequestSetConfigDone()
Checks if the configuration set request is finished

Returns:
true if request finished, false if request still busy

requestGetConfiguration

public void requestGetConfiguration()
Request to obtain the configuration settings from a adcInput Device.


requestSetConfiguration

public void requestSetConfiguration(int booleansMask,
                                    int rotaryMask,
                                    int counterMask)
Request the switchInput device to set the input types

Parameters:
booleansMask - receive switch data from side A (bit 0) and/or side B(bit 1)
rotaryMask - receive rotary data from pin 1,2 (bit 0), pin 3,4 (bit 1), pin 5,6 (bit 2)...
counterMask - receiver counter values from pin 1 (bit 0), pin 2 (bit 1), pin 3 (bit 2)....

getTimeOutUs

public long getTimeOutUs()
Returns the current set time out delay. The time out delay is used to check if a request was acknowledged in the set time. If an answer to a request is not received within the set time, the request is resent.

Returns:
the time out value in microseconds.

setTimeOutUs

public void setTimeOutUs(long timeOutUs)
Sets the time out value which is used to check if a request was acknowledged in the set time. If an answer to a request is not received within the set time, the request is resent.

Parameters:
timeOutUs - the value in microseconds which is the maximum duraion between a request and its answer.

getChangedInputsMask

public int getChangedInputsMask()

getChangedRotariesMask

public int getChangedRotariesMask()

getChangedCountersMask

public int getChangedCountersMask()