org.bluemelon.bluesense
Class RelayOutputDevice

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

public class RelayOutputDevice
extends Device


Field Summary
static int OUTPUTCOUNT
           
static int PROXY_ID
           
static java.lang.String PROXY_TITLE
           
static int RELAYOUTPUT_P_1
          Port pin value for pin 1
static int RELAYOUTPUT_P_2
          Port pin value for pin 2
static int RELAYOUTPUT_P_3
          Port pin value for pin 3
static int[] SUPPORTS
           
 
Constructor Summary
RelayOutputDevice(Master master, int deviceId)
          Creates a bluesense device with id 'deviceid'
 
Method Summary
 boolean getCurrentOutput(int port)
          returns output state of a pin
 int getCurrentOutputs()
          Returns the current output states (in a multiplexed value)
 boolean getPendingOutput(int port)
          Returns the 'tobe set' state of an output
 int getPendingOutputs()
          Returns a bitmask containing which outputs are be set after the request finishes
 boolean getRequestSetOutputsDone()
          Checks if the output set request is finished
 long getTimeOutUs()
          Returns the current set time out delay.
 void requestGetOutputs()
          Sends a request to retrieve the current set output states
 void requestSetOutput(int port, boolean state)
          Sends a request to set a single output to a new state
 void requestSetOutputs(int mask, int states)
          Sends a request to update the output states of the device.
 void setTimeOutUs(int timeOutUs)
          Sets the time out value which is used to check if a request was acknowledged in the set time.
 
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

OUTPUTCOUNT

public static final int OUTPUTCOUNT

RELAYOUTPUT_P_1

public static final int RELAYOUTPUT_P_1
Port pin value for pin 1


RELAYOUTPUT_P_2

public static final int RELAYOUTPUT_P_2
Port pin value for pin 2


RELAYOUTPUT_P_3

public static final int RELAYOUTPUT_P_3
Port pin value for pin 3

Constructor Detail

RelayOutputDevice

public RelayOutputDevice(Master master,
                         int deviceId)
Creates a bluesense device with id 'deviceid'

Parameters:
deviceId - the new device has getFound() set to false until the device has been physically detected!
Method Detail

requestGetOutputs

public void requestGetOutputs()
Sends a request to retrieve the current set output states


getCurrentOutput

public boolean getCurrentOutput(int port)
returns output state of a pin

Parameters:
port - port pin value. @see bsRelayOutput_pA_1

getCurrentOutputs

public int getCurrentOutputs()
Returns the current output states (in a multiplexed value)


requestSetOutput

public void requestSetOutput(int port,
                             boolean state)
Sends a request to set a single output to a new state

Parameters:
port - port pin value. @see bsRelayOutput_p_1
state - the new state of the output. 1 activates, 0 disables.

getRequestSetOutputsDone

public boolean getRequestSetOutputsDone()
Checks if the output set request is finished

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

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(int 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.

requestSetOutputs

public void requestSetOutputs(int mask,
                              int states)
Sends a request to update the output states of the device.

Parameters:
mask - a bit mask indicating which outputs to update
states - an uint16_t bit mask containing the new output states. Only those outputs will be updated for which a bit is set in the relevantBits parameter

getPendingOutputs

public int getPendingOutputs()
Returns a bitmask containing which outputs are be set after the request finishes

Returns:
an uint16_t containing for each output a bit. If the bit is 1, then the output will be set when the request is completed

getPendingOutput

public boolean getPendingOutput(int port)
Returns the 'tobe set' state of an output

Parameters:
port - port pin value. @see bsRelayOutput_pA_1
Returns:
true if the output will be activated, or false when it will be deactivated.