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 |
protected YAPIContext |
_yapi |
static String |
ADVERTISEDVALUE_INVALID
invalid advertisedValue value
|
static String |
FUNCTIONDESCRIPTOR_INVALID |
static String |
LOGICALNAME_INVALID
invalid logicalName value
|
Modifier | Constructor and Description |
---|---|
|
YFunction(String func) |
protected |
YFunction(YAPIContext yctx,
String func) |
Modifier and Type | Method and Description |
---|---|
protected static void |
_AddToCache(String className,
String func,
YFunction obj) |
void |
_clearDataStreamCache() |
protected com.yoctopuce.YoctoAPI.YJSONObject |
_devRequest(String extra) |
protected byte[] |
_download(String url) |
protected String |
_escapeAttr(String newval) |
protected static YFunction |
_FindFromCache(String className,
String func) |
protected static YFunction |
_FindFromCacheInContext(YAPIContext yctx,
String className,
String func) |
protected String |
_get_json_path_struct(com.yoctopuce.YoctoAPI.YJSONObject jsonObject,
String[] paths,
int ofs) |
protected String |
_get_json_path(String json,
String path) |
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(com.yoctopuce.YoctoAPI.YJSONObject json,
long msValidity) |
protected void |
_parseAttr(com.yoctopuce.YoctoAPI.YJSONObject 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) |
void |
clearCache()
Invalidates the cache.
|
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 |
FindFunctionInContext(YAPIContext yctx,
String func)
Retrieves a function for a given identifier in a YAPI context.
|
static YFunction |
FirstFunction()
comment from .yc definition
|
static YFunction |
FirstFunctionInContext(YAPIContext yctx)
comment from .yc definition
|
String |
functionDescriptor() |
String |
get_advertisedValue()
Returns a short string representing the current state of the function.
|
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 a short string representing the current state of the function.
|
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.
|
String |
loadAttribute(String attrName)
Returns the current value of a single function attribute, as a text string, as quickly as
possible but without using the cached value.
|
YModule |
module() |
int |
muteValueCallbacks()
Disables the propagation of every new advertised value to the parent hub.
|
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_advertisedValue(String newval) |
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() |
int |
unmuteValueCallbacks()
Re-enables the propagation of every new advertised value to the parent hub.
|
Object |
userData() |
public static final String FUNCTIONDESCRIPTOR_INVALID
protected final YAPIContext _yapi
protected String _className
protected final 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(YAPIContext yctx, String func)
func
- : functionidpublic YFunction(String func)
protected void _throw(int error, String message) throws YAPI_Exception
YAPI_Exception
protected static YFunction _FindFromCacheInContext(YAPIContext yctx, String className, String func)
protected static void _UpdateValueCallbackList(YFunction func, boolean add)
protected static void _UpdateTimedReportCallbackList(YFunction func, boolean add)
protected void _parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) throws Exception
Exception
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 int set_advertisedValue(String newval) throws YAPI_Exception
YAPI_Exception
public static YFunction FindFunction(String func)
func
- : a string that uniquely characterizes the functionpublic static YFunction FindFunctionInContext(YAPIContext yctx, String func)
yctx
- : a YAPI contextfunc
- : 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 muteValueCallbacks() throws YAPI_Exception
YAPI_Exception
- on errorpublic int unmuteValueCallbacks() throws YAPI_Exception
YAPI_Exception
- on errorpublic String loadAttribute(String attrName) throws YAPI_Exception
attrName
- : the name of the requested attributeYAPI_Exception
- on errorpublic int _parserHelper()
public YFunction nextFunction()
public static YFunction FirstFunction()
public static YFunction FirstFunctionInContext(YAPIContext yctx)
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(com.yoctopuce.YoctoAPI.YJSONObject json, long msValidity) throws YAPI_Exception
YAPI_Exception
protected String _escapeAttr(String newval) 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 String _get_json_path_struct(com.yoctopuce.YoctoAPI.YJSONObject jsonObject, String[] paths, int ofs)
protected com.yoctopuce.YoctoAPI.YJSONObject _devRequest(String extra) throws YAPI_Exception
YAPI_Exception
public void _clearDataStreamCache()
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 void clearCache()
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 © 2017. All rights reserved.