public class YDigitalIO extends YFunction
Modifier and Type | Class and Description |
---|---|
static interface |
YDigitalIO.TimedReportCallback
TimedReportCallback for DigitalIO
|
static interface |
YDigitalIO.UpdateCallback
Deprecated UpdateCallback for DigitalIO
|
Modifier and Type | Field and Description |
---|---|
protected String |
_command |
protected int |
_outputVoltage |
protected int |
_portDirection |
protected int |
_portOpenDrain |
protected int |
_portPolarity |
protected int |
_portSize |
protected int |
_portState |
protected YDigitalIO.UpdateCallback |
_valueCallbackDigitalIO |
static String |
COMMAND_INVALID
invalid command value
|
static int |
OUTPUTVOLTAGE_EXT_V |
static int |
OUTPUTVOLTAGE_INVALID |
static int |
OUTPUTVOLTAGE_USB_3V |
static int |
OUTPUTVOLTAGE_USB_5V
invalid outputVoltage value
|
static int |
PORTDIRECTION_INVALID
invalid portDirection value
|
static int |
PORTOPENDRAIN_INVALID
invalid portOpenDrain value
|
static int |
PORTPOLARITY_INVALID
invalid portPolarity value
|
static int |
PORTSIZE_INVALID
invalid portSize value
|
static int |
PORTSTATE_INVALID
invalid portState value
|
_advertisedValue, _cacheExpiration, _className, _dataStreams, _func, _funId, _hwId, _lastErrorMsg, _lastErrorType, _logicalName, _serial, _userData, _valueCallbackFunction, _yapi, ADVERTISEDVALUE_INVALID, FUNCTIONDESCRIPTOR_INVALID, LOGICALNAME_INVALID
Modifier | Constructor and Description |
---|---|
protected |
YDigitalIO(String func) |
protected |
YDigitalIO(YAPIContext ctx,
String func) |
Modifier and Type | Method and Description |
---|---|
int |
_invokeValueCallback(String value) |
protected void |
_parseAttr(org.json.JSONObject json_val) |
int |
delayedPulse(int bitno,
int ms_delay,
int ms_duration)
Schedules a pulse on a single bit for a specified duration.
|
static YDigitalIO |
FindDigitalIO(String func)
Retrieves a digital IO port for a given identifier.
|
static YDigitalIO |
FindDigitalIOInContext(YAPIContext yctx,
String func)
Retrieves a digital IO port for a given identifier in a YAPI context.
|
static YDigitalIO |
FirstDigitalIO()
Starts the enumeration of digital IO ports currently accessible.
|
static YDigitalIO |
FirstDigitalIOInContext(YAPIContext yctx)
Starts the enumeration of digital IO ports currently accessible.
|
int |
get_bitDirection(int bitno)
Returns the direction of a single bit from the I/O port (0 means the bit is an input, 1 an output).
|
int |
get_bitOpenDrain(int bitno)
Returns the type of electrical interface of a single bit from the I/O port.
|
int |
get_bitPolarity(int bitno)
Returns the polarity of a single bit from the I/O port (0 means the I/O works in regular mode, 1
means the I/O works in reverse mode).
|
int |
get_bitState(int bitno)
Returns the state of a single bit of the I/O port.
|
String |
get_command() |
int |
get_outputVoltage()
Returns the voltage source used to drive output bits.
|
int |
get_portDirection()
Returns the IO direction of all bits of the port: 0 makes a bit an input, 1 makes it an output.
|
int |
get_portOpenDrain()
Returns the electrical interface for each bit of the port.
|
int |
get_portPolarity()
Returns the polarity of all the bits of the port.
|
int |
get_portSize()
Returns the number of bits implemented in the I/O port.
|
int |
get_portState()
Returns the digital IO port state: bit 0 represents input 0, and so on.
|
String |
getCommand() |
int |
getOutputVoltage()
Returns the voltage source used to drive output bits.
|
int |
getPortDirection()
Returns the IO direction of all bits of the port: 0 makes a bit an input, 1 makes it an output.
|
int |
getPortOpenDrain()
Returns the electrical interface for each bit of the port.
|
int |
getPortPolarity()
Returns the polarity of all the bits of the port.
|
int |
getPortSize()
Returns the number of bits implemented in the I/O port.
|
int |
getPortState()
Returns the digital IO port state: bit 0 represents input 0, and so on.
|
YDigitalIO |
nextDigitalIO()
Continues the enumeration of digital IO ports started using yFirstDigitalIO().
|
int |
pulse(int bitno,
int ms_duration)
Triggers a pulse on a single bit for a specified duration.
|
int |
registerValueCallback(YDigitalIO.UpdateCallback callback)
Registers the callback function that is invoked on every change of advertised value.
|
int |
set_bitDirection(int bitno,
int bitdirection)
Changes the direction of a single bit from the I/O port.
|
int |
set_bitOpenDrain(int bitno,
int opendrain)
Changes the electrical interface of a single bit from the I/O port.
|
int |
set_bitPolarity(int bitno,
int bitpolarity)
Changes the polarity of a single bit from the I/O port.
|
int |
set_bitState(int bitno,
int bitstate)
Sets a single bit of the I/O port.
|
int |
set_command(String newval) |
int |
set_outputVoltage(int newval)
Changes the voltage source used to drive output bits.
|
int |
set_portDirection(int newval)
Changes the IO direction of all bits of the port: 0 makes a bit an input, 1 makes it an output.
|
int |
set_portOpenDrain(int newval)
Changes the electrical interface for each bit of the port.
|
int |
set_portPolarity(int newval)
Changes the polarity of all the bits of the port: For each bit set to 0, the matching I/O works the regular,
intuitive way; for each bit set to 1, the I/O works in reverse mode.
|
int |
set_portState(int newval)
Changes the digital IO port state: bit 0 represents input 0, and so on.
|
int |
setCommand(String newval) |
int |
setOutputVoltage(int newval)
Changes the voltage source used to drive output bits.
|
int |
setPortDirection(int newval)
Changes the IO direction of all bits of the port: 0 makes a bit an input, 1 makes it an output.
|
int |
setPortOpenDrain(int newval)
Changes the electrical interface for each bit of the port.
|
int |
setPortPolarity(int newval)
Changes the polarity of all the bits of the port: For each bit set to 0, the matching I/O works the regular,
intuitive way; for each bit set to 1, the I/O works in reverse mode.
|
int |
setPortState(int newval)
Changes the digital IO port state: bit 0 represents input 0, and so on.
|
int |
toggle_bitState(int bitno)
Reverts a single bit of the I/O port.
|
_AddToCache, _clearDataStreamCache, _devRequest, _download, _escapeAttr, _FindFromCache, _FindFromCacheInContext, _get_json_path_struct, _get_json_path, _json_get_array, _json_get_key, _json_get_string, _parse, _parserHelper, _setAttr, _throw, _UpdateTimedReportCallbackList, _UpdateValueCallbackList, _upload, _upload, clearCache, describe, errMessage, errorMessage, errorType, errType, FindFunction, FindFunctionInContext, FirstFunction, FirstFunctionInContext, functionDescriptor, get_advertisedValue, get_errorMessage, get_errorType, get_friendlyName, get_functionDescriptor, get_functionId, get_hardwareId, get_logicalName, get_module, get_userData, getAdvertisedValue, getErrorMessage, getErrorType, getFriendlyName, getFunctionDescriptor, getFunctionId, getHardwareId, getLogicalName, getModule, getUserData, isOnline, load, loadAttribute, module, muteValueCallbacks, nextFunction, registerValueCallback, set_advertisedValue, set_logicalName, set_userData, setAdvertisedValue, setLogicalName, setUserData, toString, unmuteValueCallbacks, userData
public static final int PORTSTATE_INVALID
public static final int PORTDIRECTION_INVALID
public static final int PORTOPENDRAIN_INVALID
public static final int PORTPOLARITY_INVALID
public static final int PORTSIZE_INVALID
public static final int OUTPUTVOLTAGE_USB_5V
public static final int OUTPUTVOLTAGE_USB_3V
public static final int OUTPUTVOLTAGE_EXT_V
public static final int OUTPUTVOLTAGE_INVALID
public static final String COMMAND_INVALID
protected int _portState
protected int _portDirection
protected int _portOpenDrain
protected int _portPolarity
protected int _portSize
protected int _outputVoltage
protected String _command
protected YDigitalIO.UpdateCallback _valueCallbackDigitalIO
protected YDigitalIO(YAPIContext ctx, String func)
func
- : functionidprotected YDigitalIO(String func)
func
- : functionidprotected void _parseAttr(org.json.JSONObject json_val) throws org.json.JSONException
_parseAttr
in class YFunction
org.json.JSONException
public int get_portState() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPortState() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_portState(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the digital IO port state: bit 0 represents input 0, and so onYAPI_Exception
- on errorpublic int setPortState(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the digital IO port state: bit 0 represents input 0, and so onYAPI_Exception
- on errorpublic int get_portDirection() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPortDirection() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_portDirection(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the IO direction of all bits of the port: 0 makes a bit
an input, 1 makes it an outputYAPI_Exception
- on errorpublic int setPortDirection(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the IO direction of all bits of the port: 0 makes a bit
an input, 1 makes it an outputYAPI_Exception
- on errorpublic int get_portOpenDrain() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPortOpenDrain() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_portOpenDrain(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the electrical interface for each bit of the portYAPI_Exception
- on errorpublic int setPortOpenDrain(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the electrical interface for each bit of the portYAPI_Exception
- on errorpublic int get_portPolarity() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPortPolarity() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_portPolarity(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the polarity of all the bits of the port: For each bit
set to 0, the matching I/O works the regular,
intuitive way; for each bit set to 1, the I/O works in reverse modeYAPI_Exception
- on errorpublic int setPortPolarity(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the polarity of all the bits of the port: For each bit
set to 0, the matching I/O works the regular,
intuitive way; for each bit set to 1, the I/O works in reverse modeYAPI_Exception
- on errorpublic int get_portSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPortSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_outputVoltage() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getOutputVoltage() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_outputVoltage(int newval) throws YAPI_Exception
newval
- : a value among YDigitalIO.OUTPUTVOLTAGE_USB_5V, YDigitalIO.OUTPUTVOLTAGE_USB_3V and
YDigitalIO.OUTPUTVOLTAGE_EXT_V corresponding to the voltage source used to drive output bitsYAPI_Exception
- on errorpublic int setOutputVoltage(int newval) throws YAPI_Exception
newval
- : a value among Y_OUTPUTVOLTAGE_USB_5V, Y_OUTPUTVOLTAGE_USB_3V and
Y_OUTPUTVOLTAGE_EXT_V corresponding to the voltage source used to drive output bitsYAPI_Exception
- on errorpublic String get_command() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getCommand() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_command(String newval) throws YAPI_Exception
YAPI_Exception
public int setCommand(String newval) throws YAPI_Exception
YAPI_Exception
public static YDigitalIO FindDigitalIO(String func)
func
- : a string that uniquely characterizes the digital IO portpublic static YDigitalIO FindDigitalIOInContext(YAPIContext yctx, String func)
yctx
- : a YAPI contextfunc
- : a string that uniquely characterizes the digital IO portpublic int registerValueCallback(YDigitalIO.UpdateCallback callback)
callback
- : the callback function to call, or a null pointer. The callback function should take two
arguments: the function object of which the value has changed, and the character string describing
the new advertised value.public int _invokeValueCallback(String value)
_invokeValueCallback
in class YFunction
public int set_bitState(int bitno, int bitstate) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0bitstate
- : the state of the bit (1 or 0)YAPI_Exception
- on errorpublic int get_bitState(int bitno) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0YAPI_Exception
- on errorpublic int toggle_bitState(int bitno) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0YAPI_Exception
- on errorpublic int set_bitDirection(int bitno, int bitdirection) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0bitdirection
- : direction to set, 0 makes the bit an input, 1 makes it an output.
Remember to call the saveToFlash() method to make sure the setting is kept after a reboot.YAPI_Exception
- on errorpublic int get_bitDirection(int bitno) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0YAPI_Exception
- on errorpublic int set_bitPolarity(int bitno, int bitpolarity) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0.bitpolarity
- : polarity to set, 0 makes the I/O work in regular mode, 1 makes the I/O works
in reverse mode.
Remember to call the saveToFlash() method to make sure the setting is kept after a reboot.YAPI_Exception
- on errorpublic int get_bitPolarity(int bitno) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0YAPI_Exception
- on errorpublic int set_bitOpenDrain(int bitno, int opendrain) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0opendrain
- : 0 makes a bit a regular input/output, 1 makes
it an open-drain (open-collector) input/output. Remember to call the
saveToFlash() method to make sure the setting is kept after a reboot.YAPI_Exception
- on errorpublic int get_bitOpenDrain(int bitno) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0YAPI_Exception
- on errorpublic int pulse(int bitno, int ms_duration) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0ms_duration
- : desired pulse duration in milliseconds. Be aware that the device time
resolution is not guaranteed up to the millisecond.YAPI_Exception
- on errorpublic int delayedPulse(int bitno, int ms_delay, int ms_duration) throws YAPI_Exception
bitno
- : the bit number; lowest bit has index 0ms_delay
- : waiting time before the pulse, in millisecondsms_duration
- : desired pulse duration in milliseconds. Be aware that the device time
resolution is not guaranteed up to the millisecond.YAPI_Exception
- on errorpublic YDigitalIO nextDigitalIO()
public static YDigitalIO FirstDigitalIO()
public static YDigitalIO FirstDigitalIOInContext(YAPIContext yctx)
yctx
- : a YAPI context.Copyright © 2017. All rights reserved.