public class YSensor extends YFunction
Modifier and Type | Class and Description |
---|---|
static interface |
YSensor.TimedReportCallback
TimedReportCallback for Sensor
|
static interface |
YSensor.UpdateCallback
Deprecated UpdateCallback for Sensor
|
Modifier and Type | Field and Description |
---|---|
protected int |
_advMode |
protected YAPI.CalibrationHandlerCallback |
_calhdl |
protected String |
_calibrationParam |
protected ArrayList<Integer> |
_calpar |
protected ArrayList<Double> |
_calraw |
protected ArrayList<Double> |
_calref |
protected int |
_caltyp |
protected double |
_currentRawValue |
protected double |
_currentValue |
protected double |
_decexp |
protected double |
_highestValue |
protected double |
_iresol |
protected String |
_logFrequency |
protected double |
_lowestValue |
protected double |
_offset |
protected double |
_prevTimedReport |
protected String |
_reportFrequency |
protected double |
_resolution |
protected double |
_scale |
protected int |
_sensorState |
protected YSensor.TimedReportCallback |
_timedReportCallbackSensor |
protected String |
_unit |
protected YSensor.UpdateCallback |
_valueCallbackSensor |
static int |
ADVMODE_IMMEDIATE
invalid advMode value
|
static int |
ADVMODE_INVALID |
static int |
ADVMODE_PERIOD_AVG |
static int |
ADVMODE_PERIOD_MAX |
static int |
ADVMODE_PERIOD_MIN |
static String |
CALIBRATIONPARAM_INVALID
invalid calibrationParam value
|
static double |
CURRENTRAWVALUE_INVALID
invalid currentRawValue value
|
static double |
CURRENTVALUE_INVALID
invalid currentValue value
|
static double |
HIGHESTVALUE_INVALID
invalid highestValue value
|
static String |
LOGFREQUENCY_INVALID
invalid logFrequency value
|
static double |
LOWESTVALUE_INVALID
invalid lowestValue value
|
static String |
REPORTFREQUENCY_INVALID
invalid reportFrequency value
|
static double |
RESOLUTION_INVALID
invalid resolution value
|
static int |
SENSORSTATE_INVALID
invalid sensorState value
|
static String |
UNIT_INVALID
invalid unit 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 |
YSensor(String func) |
protected |
YSensor(YAPIContext yctx,
String func) |
Modifier and Type | Method and Description |
---|---|
double |
_applyCalibration(double rawValue) |
double |
_decodeAvg(int dw) |
YMeasure |
_decodeTimedReport(double timestamp,
double duration,
ArrayList<Integer> report) |
double |
_decodeVal(int w) |
String |
_encodeCalibrationPoints(ArrayList<Double> rawValues,
ArrayList<Double> refValues) |
int |
_invokeTimedReportCallback(YMeasure value) |
int |
_invokeValueCallback(String value) |
protected void |
_parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) |
int |
_parserHelper() |
int |
calibrateFromPoints(ArrayList<Double> rawValues,
ArrayList<Double> refValues)
Configures error correction data points, in particular to compensate for
a possible perturbation of the measure caused by an enclosure.
|
static YSensor |
FindSensor(String func)
Retrieves a sensor for a given identifier.
|
static YSensor |
FindSensorInContext(YAPIContext yctx,
String func)
Retrieves a sensor for a given identifier in a YAPI context.
|
static YSensor |
FirstSensor()
Starts the enumeration of sensors currently accessible.
|
static YSensor |
FirstSensorInContext(YAPIContext yctx)
Starts the enumeration of sensors currently accessible.
|
int |
get_advMode()
Returns the measuring mode used for the advertised value pushed to the parent hub.
|
String |
get_calibrationParam() |
double |
get_currentRawValue()
Returns the uncalibrated, unrounded raw value returned by the
sensor, in the specified unit, as a floating point number.
|
double |
get_currentValue()
Returns the current value of the measure, in the specified unit, as a floating point number.
|
YDataLogger |
get_dataLogger()
Returns the YDatalogger object of the device hosting the sensor.
|
double |
get_highestValue()
Returns the maximal value observed for the measure since the device was started.
|
String |
get_logFrequency()
Returns the datalogger recording frequency for this function, or "OFF"
when measures are not stored in the data logger flash memory.
|
double |
get_lowestValue()
Returns the minimal value observed for the measure since the device was started.
|
YDataSet |
get_recordedData(double startTime,
double endTime)
Retrieves a YDataSet object holding historical data for this
sensor, for a specified time interval.
|
String |
get_reportFrequency()
Returns the timed value notification frequency, or "OFF" if timed
value notifications are disabled for this function.
|
double |
get_resolution()
Returns the resolution of the measured values.
|
int |
get_sensorState()
Returns the sensor health state code, which is zero when there is an up-to-date measure
available or a positive code if the sensor is not able to provide a measure right now.
|
String |
get_unit()
Returns the measuring unit for the measure.
|
int |
getAdvMode()
Returns the measuring mode used for the advertised value pushed to the parent hub.
|
double |
getCurrentRawValue()
Returns the uncalibrated, unrounded raw value returned by the
sensor, in the specified unit, as a floating point number.
|
double |
getCurrentValue()
Returns the current value of the measure, in the specified unit, as a floating point number.
|
double |
getHighestValue()
Returns the maximal value observed for the measure since the device was started.
|
String |
getLogFrequency()
Returns the datalogger recording frequency for this function, or "OFF"
when measures are not stored in the data logger flash memory.
|
double |
getLowestValue()
Returns the minimal value observed for the measure since the device was started.
|
String |
getReportFrequency()
Returns the timed value notification frequency, or "OFF" if timed
value notifications are disabled for this function.
|
double |
getResolution()
Returns the resolution of the measured values.
|
int |
getSensorState()
Returns the sensor health state code, which is zero when there is an up-to-date measure
available or a positive code if the sensor is not able to provide a measure right now.
|
String |
getUnit()
Returns the measuring unit for the measure.
|
boolean |
isSensorReady()
Checks if the sensor is currently able to provide an up-to-date measure.
|
int |
loadCalibrationPoints(ArrayList<Double> rawValues,
ArrayList<Double> refValues)
Retrieves error correction data points previously entered using the method
calibrateFromPoints.
|
YSensor |
nextSensor()
Continues the enumeration of sensors started using yFirstSensor().
|
int |
registerTimedReportCallback(YSensor.TimedReportCallback callback)
Registers the callback function that is invoked on every periodic timed notification.
|
int |
registerValueCallback(YSensor.UpdateCallback callback)
Registers the callback function that is invoked on every change of advertised value.
|
int |
set_advMode(int newval)
Changes the measuring mode used for the advertised value pushed to the parent hub.
|
int |
set_calibrationParam(String newval) |
int |
set_highestValue(double newval)
Changes the recorded maximal value observed.
|
int |
set_logFrequency(String newval)
Changes the datalogger recording frequency for this function.
|
int |
set_lowestValue(double newval)
Changes the recorded minimal value observed.
|
int |
set_reportFrequency(String newval)
Changes the timed value notification frequency for this function.
|
int |
set_resolution(double newval)
Changes the resolution of the measured physical values.
|
int |
setAdvMode(int newval)
Changes the measuring mode used for the advertised value pushed to the parent hub.
|
int |
setHighestValue(double newval)
Changes the recorded maximal value observed.
|
int |
setLogFrequency(String newval)
Changes the datalogger recording frequency for this function.
|
int |
setLowestValue(double newval)
Changes the recorded minimal value observed.
|
int |
setReportFrequency(String newval)
Changes the timed value notification frequency for this function.
|
int |
setResolution(double newval)
Changes the resolution of the measured physical values.
|
int |
startDataLogger()
Starts the data logger on the device.
|
int |
stopDataLogger()
Stops the datalogger on the device.
|
_AddToCache, _clearDataStreamCache, _download, _escapeAttr, _FindFromCache, _FindFromCacheInContext, _get_json_path_struct, _get_json_path, _json_get_array, _json_get_key, _json_get_string, _parse, _setAttr, _throw, _UpdateTimedReportCallbackList, _UpdateValueCallbackList, _upload, _upload, _uploadEx, 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_serialNumber, get_userData, getAdvertisedValue, getErrorMessage, getErrorType, getFriendlyName, getFunctionDescriptor, getFunctionId, getHardwareId, getLogicalName, getModule, getUserData, isOnline, isReadOnly, load, loadAttribute, module, muteValueCallbacks, nextFunction, registerValueCallback, set_advertisedValue, set_logicalName, set_userData, setLogicalName, setUserData, toString, unmuteValueCallbacks, userData
public static final String UNIT_INVALID
public static final double CURRENTVALUE_INVALID
public static final double LOWESTVALUE_INVALID
public static final double HIGHESTVALUE_INVALID
public static final double CURRENTRAWVALUE_INVALID
public static final String LOGFREQUENCY_INVALID
public static final String REPORTFREQUENCY_INVALID
public static final int ADVMODE_IMMEDIATE
public static final int ADVMODE_PERIOD_AVG
public static final int ADVMODE_PERIOD_MIN
public static final int ADVMODE_PERIOD_MAX
public static final int ADVMODE_INVALID
public static final String CALIBRATIONPARAM_INVALID
public static final double RESOLUTION_INVALID
public static final int SENSORSTATE_INVALID
protected String _unit
protected double _currentValue
protected double _lowestValue
protected double _highestValue
protected double _currentRawValue
protected String _logFrequency
protected String _reportFrequency
protected int _advMode
protected String _calibrationParam
protected double _resolution
protected int _sensorState
protected YSensor.UpdateCallback _valueCallbackSensor
protected YSensor.TimedReportCallback _timedReportCallbackSensor
protected double _prevTimedReport
protected double _iresol
protected double _offset
protected double _scale
protected double _decexp
protected int _caltyp
protected YAPI.CalibrationHandlerCallback _calhdl
protected YSensor(YAPIContext yctx, String func)
func
- : functionidprotected YSensor(String func)
protected void _parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) throws Exception
_parseAttr
in class YFunction
Exception
public String get_unit() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getUnit() throws YAPI_Exception
YAPI_Exception
- on errorpublic double get_currentValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic double getCurrentValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_lowestValue(double newval) throws YAPI_Exception
newval
- : a floating point number corresponding to the recorded minimal value observedYAPI_Exception
- on errorpublic int setLowestValue(double newval) throws YAPI_Exception
newval
- : a floating point number corresponding to the recorded minimal value observedYAPI_Exception
- on errorpublic double get_lowestValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic double getLowestValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_highestValue(double newval) throws YAPI_Exception
newval
- : a floating point number corresponding to the recorded maximal value observedYAPI_Exception
- on errorpublic int setHighestValue(double newval) throws YAPI_Exception
newval
- : a floating point number corresponding to the recorded maximal value observedYAPI_Exception
- on errorpublic double get_highestValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic double getHighestValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic double get_currentRawValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic double getCurrentRawValue() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_logFrequency() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getLogFrequency() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_logFrequency(String newval) throws YAPI_Exception
newval
- : a string corresponding to the datalogger recording frequency for this functionYAPI_Exception
- on errorpublic int setLogFrequency(String newval) throws YAPI_Exception
newval
- : a string corresponding to the datalogger recording frequency for this functionYAPI_Exception
- on errorpublic String get_reportFrequency() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getReportFrequency() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_reportFrequency(String newval) throws YAPI_Exception
newval
- : a string corresponding to the timed value notification frequency for this functionYAPI_Exception
- on errorpublic int setReportFrequency(String newval) throws YAPI_Exception
newval
- : a string corresponding to the timed value notification frequency for this functionYAPI_Exception
- on errorpublic int get_advMode() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getAdvMode() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_advMode(int newval) throws YAPI_Exception
newval
- : a value among YSensor.ADVMODE_IMMEDIATE, YSensor.ADVMODE_PERIOD_AVG,
YSensor.ADVMODE_PERIOD_MIN and YSensor.ADVMODE_PERIOD_MAX corresponding to the measuring mode used
for the advertised value pushed to the parent hubYAPI_Exception
- on errorpublic int setAdvMode(int newval) throws YAPI_Exception
newval
- : a value among YSensor.ADVMODE_IMMEDIATE, YSensor.ADVMODE_PERIOD_AVG,
YSensor.ADVMODE_PERIOD_MIN and YSensor.ADVMODE_PERIOD_MAX corresponding to the measuring mode used
for the advertised value pushed to the parent hubYAPI_Exception
- on errorpublic String get_calibrationParam() throws YAPI_Exception
YAPI_Exception
public int set_calibrationParam(String newval) throws YAPI_Exception
YAPI_Exception
public int set_resolution(double newval) throws YAPI_Exception
newval
- : a floating point number corresponding to the resolution of the measured physical valuesYAPI_Exception
- on errorpublic int setResolution(double newval) throws YAPI_Exception
newval
- : a floating point number corresponding to the resolution of the measured physical valuesYAPI_Exception
- on errorpublic double get_resolution() throws YAPI_Exception
YAPI_Exception
- on errorpublic double getResolution() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_sensorState() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getSensorState() throws YAPI_Exception
YAPI_Exception
- on errorpublic static YSensor FindSensor(String func)
func
- : a string that uniquely characterizes the sensor, for instance
MyDevice..public static YSensor FindSensorInContext(YAPIContext yctx, String func)
yctx
- : a YAPI contextfunc
- : a string that uniquely characterizes the sensor, for instance
MyDevice..public int registerValueCallback(YSensor.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 _parserHelper()
_parserHelper
in class YFunction
public boolean isSensorReady()
public YDataLogger get_dataLogger() throws YAPI_Exception
YAPI_Exception
public int startDataLogger() throws YAPI_Exception
YAPI_Exception
public int stopDataLogger() throws YAPI_Exception
YAPI_Exception
public YDataSet get_recordedData(double startTime, double endTime) throws YAPI_Exception
startTime
- : the start of the desired measure time interval,
as a Unix timestamp, i.e. the number of seconds since
January 1, 1970 UTC. The special value 0 can be used
to include any measure, without initial limit.endTime
- : the end of the desired measure time interval,
as a Unix timestamp, i.e. the number of seconds since
January 1, 1970 UTC. The special value 0 can be used
to include any measure, without ending limit.YAPI_Exception
public int registerTimedReportCallback(YSensor.TimedReportCallback 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 an YMeasure object describing
the new advertised value.public int _invokeTimedReportCallback(YMeasure value)
public int calibrateFromPoints(ArrayList<Double> rawValues, ArrayList<Double> refValues) throws YAPI_Exception
rawValues
- : array of floating point numbers, corresponding to the raw
values returned by the sensor for the correction points.refValues
- : array of floating point numbers, corresponding to the corrected
values for the correction points.YAPI_Exception
- on errorpublic int loadCalibrationPoints(ArrayList<Double> rawValues, ArrayList<Double> refValues) throws YAPI_Exception
rawValues
- : array of floating point numbers, that will be filled by the
function with the raw sensor values for the correction points.refValues
- : array of floating point numbers, that will be filled by the
function with the desired values for the correction points.YAPI_Exception
- on errorpublic String _encodeCalibrationPoints(ArrayList<Double> rawValues, ArrayList<Double> refValues) throws YAPI_Exception
YAPI_Exception
public double _applyCalibration(double rawValue)
public YMeasure _decodeTimedReport(double timestamp, double duration, ArrayList<Integer> report)
public double _decodeVal(int w)
public double _decodeAvg(int dw)
public YSensor nextSensor()
public static YSensor FirstSensor()
public static YSensor FirstSensorInContext(YAPIContext yctx)
yctx
- : a YAPI context.Copyright © 2023. All rights reserved.