com.yoctopuce.YoctoAPI
public class YFunction extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
YFunction.TimedReportCallback
TimedReportCallback for Function
|
static interface |
YFunction.UpdateCallback
Deprecated UpdateCallback for Function
|
Modifier and Type | Field and Description |
---|---|
protected String |
_advertisedValue |
protected long |
_cacheExpiration |
protected String |
_className |
protected HashMap<String,YDataStream> |
_dataStreams |
protected String |
_func |
protected String |
_funId |
protected String |
_hwId |
protected String |
_lastErrorMsg |
protected int |
_lastErrorType |
protected String |
_logicalName |
protected String |
_serial |
protected Object |
_userData |
protected YFunction.UpdateCallback |
_valueCallbackFunction |
static String |
ADVERTISEDVALUE_INVALID
invalid advertisedValue value
|
static String |
FUNCTIONDESCRIPTOR_INVALID |
static String |
LOGICALNAME_INVALID
invalid logicalName value
|
Modifier | Constructor and Description |
---|---|
protected |
YFunction(String func) |
Modifier and Type | Method and Description |
---|---|
protected static void |
_AddToCache(String className,
String func,
YFunction obj) |
protected org.json.JSONObject |
_devRequest(String extra) |
protected byte[] |
_download(String url) |
protected static YFunction |
_FindFromCache(String className,
String func) |
int |
_invokeValueCallback(String value) |
protected ArrayList<String> |
_json_get_array(byte[] json) |
protected String |
_json_get_key(byte[] json,
String key) |
protected String |
_json_get_string(byte[] json) |
protected void |
_parse(org.json.JSONObject json,
long msValidity) |
protected void |
_parseAttr(org.json.JSONObject json_val) |
int |
_parserHelper() |
protected int |
_setAttr(String attr,
String newval) |
protected void |
_throw(int error,
String message) |
protected static void |
_UpdateTimedReportCallbackList(YFunction func,
boolean add) |
protected static void |
_UpdateValueCallbackList(YFunction func,
boolean add) |
protected int |
_upload(String path,
byte[] content) |
protected int |
_upload(String pathname,
String content) |
String |
describe()
Returns a short text that describes unambiguously the instance of the function in the form
TYPE(NAME)=SERIAL.FUNCTIONID.
|
String |
errMessage() |
String |
errorMessage() |
int |
errorType() |
int |
errType() |
static YFunction |
FindFunction(String func)
Retrieves a function for a given identifier.
|
static YFunction |
FirstFunction()
comment from .yc definition
|
String |
functionDescriptor() |
String |
get_advertisedValue()
Returns the current value of the function (no more than 6 characters).
|
String |
get_errorMessage()
Returns the error message of the latest error with the function.
|
int |
get_errorType()
Returns the numerical error code of the latest error with the function.
|
String |
get_friendlyName()
Returns a global identifier of the function in the format MODULE_NAME.FUNCTION_NAME.
|
String |
get_functionDescriptor()
Returns a unique identifier of type YFUN_DESCR corresponding to the function.
|
String |
get_functionId()
Returns the hardware identifier of the function, without reference to the module.
|
String |
get_hardwareId()
Returns the unique hardware identifier of the function in the form SERIAL.FUNCTIONID.
|
String |
get_logicalName()
Returns the logical name of the function.
|
YModule |
get_module()
Gets the YModule object for the device on which the function is located.
|
Object |
get_userData()
Returns the value of the userData attribute, as previously stored using method
set_userData.
|
String |
getAdvertisedValue()
Returns the current value of the function (no more than 6 characters).
|
String |
getErrorMessage() |
int |
getErrorType() |
String |
getFriendlyName() |
String |
getFunctionDescriptor() |
String |
getFunctionId() |
String |
getHardwareId() |
String |
getLogicalName()
Returns the logical name of the function.
|
YModule |
getModule() |
Object |
getUserData() |
boolean |
isOnline()
Checks if the function is currently reachable, without raising any error.
|
int |
load(long msValidity)
Preloads the function cache with a specified validity duration.
|
YModule |
module() |
YFunction |
nextFunction()
comment from .yc definition
|
int |
registerValueCallback(YFunction.UpdateCallback callback)
Registers the callback function that is invoked on every change of advertised value.
|
int |
set_logicalName(String newval)
Changes the logical name of the function.
|
void |
set_userData(Object data)
Stores a user context provided as argument in the userData attribute of the function.
|
int |
setLogicalName(String newval)
Changes the logical name of the function.
|
void |
setUserData(Object data) |
String |
toString() |
Object |
userData() |
public static final String FUNCTIONDESCRIPTOR_INVALID
protected String _className
protected String _func
protected int _lastErrorType
protected String _lastErrorMsg
protected Object _userData
protected HashMap<String,YDataStream> _dataStreams
public static final String LOGICALNAME_INVALID
public static final String ADVERTISEDVALUE_INVALID
protected String _logicalName
protected String _advertisedValue
protected YFunction.UpdateCallback _valueCallbackFunction
protected long _cacheExpiration
protected String _serial
protected String _funId
protected String _hwId
protected YFunction(String func)
func
- : functionidprotected void _throw(int error, String message) throws YAPI_Exception
YAPI_Exception
protected static void _UpdateValueCallbackList(YFunction func, boolean add)
protected static void _UpdateTimedReportCallbackList(YFunction func, boolean add)
protected void _parseAttr(org.json.JSONObject json_val) throws org.json.JSONException
org.json.JSONException
public String get_logicalName() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getLogicalName() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_logicalName(String newval) throws YAPI_Exception
newval
- : a string corresponding to the logical name of the functionYAPI_Exception
- on errorpublic int setLogicalName(String newval) throws YAPI_Exception
newval
- : a string corresponding to the logical name of the functionYAPI_Exception
- on errorpublic String get_advertisedValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getAdvertisedValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic static YFunction FindFunction(String func)
func
- : a string that uniquely characterizes the functionpublic int registerValueCallback(YFunction.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)
public int _parserHelper()
public YFunction nextFunction()
public static YFunction FirstFunction()
public String describe()
public String get_hardwareId() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getHardwareId() throws YAPI_Exception
YAPI_Exception
public String get_functionId() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getFunctionId() throws YAPI_Exception
YAPI_Exception
public String get_friendlyName() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getFriendlyName() throws YAPI_Exception
YAPI_Exception
protected void _parse(org.json.JSONObject json, long msValidity) throws YAPI_Exception
YAPI_Exception
protected int _setAttr(String attr, String newval) throws YAPI_Exception
YAPI_Exception
protected int _upload(String path, byte[] content) throws YAPI_Exception
YAPI_Exception
protected int _upload(String pathname, String content) throws YAPI_Exception
YAPI_Exception
protected byte[] _download(String url) throws YAPI_Exception
YAPI_Exception
protected String _json_get_key(byte[] json, String key) throws YAPI_Exception
YAPI_Exception
protected String _json_get_string(byte[] json) throws YAPI_Exception
YAPI_Exception
protected ArrayList<String> _json_get_array(byte[] json) throws YAPI_Exception
YAPI_Exception
protected org.json.JSONObject _devRequest(String extra) throws YAPI_Exception
YAPI_Exception
public boolean isOnline()
public int get_errorType()
public int getErrorType()
public int errorType()
public int errType()
public String get_errorMessage()
public String getErrorMessage()
public String errorMessage()
public String errMessage()
public int load(long msValidity) throws YAPI_Exception
msValidity
- : an integer corresponding to the validity attributed to the
loaded function parameters, in millisecondsYAPI_Exception
- on errorpublic YModule get_module()
public YModule getModule()
public YModule module()
public String get_functionDescriptor()
public String getFunctionDescriptor()
public String functionDescriptor()
public Object get_userData()
public Object getUserData()
public Object userData()
public void set_userData(Object data)
data
- : any kind of object to be storedpublic void setUserData(Object data)
Copyright © 2014. All rights reserved.