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 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 boolean |
_isScal |
protected boolean |
_isScal32 |
protected String |
_logFrequency |
protected double |
_lowestValue |
protected double |
_offset |
protected double |
_prevTimedReport |
protected String |
_reportFrequency |
protected double |
_resolution |
protected double |
_scale |
protected YSensor.TimedReportCallback |
_timedReportCallbackSensor |
protected String |
_unit |
protected YSensor.UpdateCallback |
_valueCallbackSensor |
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 String |
UNIT_INVALID
invalid unit value
|
_advertisedValue, _cacheExpiration, _className, _dataStreams, _func, _funId, _hwId, _lastErrorMsg, _lastErrorType, _logicalName, _serial, _userData, _valueCallbackFunction, ADVERTISEDVALUE_INVALID, FUNCTIONDESCRIPTOR_INVALID, LOGICALNAME_INVALID
Modifier | Constructor and Description |
---|---|
protected |
YSensor(String func) |
Modifier and Type | Method and Description |
---|---|
double |
_applyCalibration(double rawValue) |
double |
_decodeAvg(int dw) |
YMeasure |
_decodeTimedReport(double timestamp,
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(org.json.JSONObject 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 |
FirstSensor()
Starts the enumeration of sensors currently accessible.
|
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.
|
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(long startTime,
long endTime)
Retrieves a DataSet 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.
|
String |
get_unit()
Returns the measuring unit for the measure.
|
String |
getCalibrationParam() |
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.
|
String |
getUnit()
Returns the measuring unit for the 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_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 |
setCalibrationParam(String newval) |
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, _devRequest, _download, _escapeAttr, _FindFromCache, _json_get_array, _json_get_key, _json_get_string, _parse, _setAttr, _throw, _UpdateTimedReportCallbackList, _UpdateValueCallbackList, _upload, _upload, describe, errMessage, errorMessage, errorType, errType, FindFunction, FirstFunction, 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, module, nextFunction, registerValueCallback, set_logicalName, set_userData, setLogicalName, setUserData, toString, 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 String CALIBRATIONPARAM_INVALID
public static final double RESOLUTION_INVALID
protected String _unit
protected double _currentValue
protected double _lowestValue
protected double _highestValue
protected double _currentRawValue
protected String _logFrequency
protected String _reportFrequency
protected String _calibrationParam
protected double _resolution
protected YSensor.UpdateCallback _valueCallbackSensor
protected YSensor.TimedReportCallback _timedReportCallbackSensor
protected double _prevTimedReport
protected double _iresol
protected double _offset
protected double _scale
protected double _decexp
protected boolean _isScal
protected boolean _isScal32
protected int _caltyp
protected YAPI.CalibrationHandlerCallback _calhdl
protected YSensor(String func)
func
- : functionidprotected void _parseAttr(org.json.JSONObject json_val) throws org.json.JSONException
_parseAttr
in class YFunction
org.json.JSONException
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 String get_calibrationParam() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getCalibrationParam() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_calibrationParam(String newval) throws YAPI_Exception
YAPI_Exception
public int setCalibrationParam(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 static YSensor FindSensor(String func)
func
- : a string that uniquely characterizes the sensorpublic 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 int startDataLogger() throws YAPI_Exception
YAPI_Exception
public int stopDataLogger() throws YAPI_Exception
YAPI_Exception
public YDataSet get_recordedData(long startTime, long 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 meaasure, 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 meaasure, 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 double _decodeVal(int w)
public double _decodeAvg(int dw)
public YSensor nextSensor()
public static YSensor FirstSensor()
Copyright © 2015. All rights reserved.