Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
YLightSensor Class Reference

#include <yocto_lightsensor.h>

Inheritance diagram for YLightSensor:
Inheritance graph
[legend]

Public Member Functions

virtual int _invokeTimedReportCallback (YMeasure value)
 
virtual int _invokeValueCallback (string value)
 
int calibrate (double calibratedVal)
 
Y_MEASURETYPE_enum get_measureType (void)
 
Y_MEASURETYPE_enum measureType (void)
 
YLightSensornext (void)
 
YLightSensornextLightSensor (void)
 
virtual int registerTimedReportCallback (YLightSensorTimedReportCallback callback)
 
virtual int registerValueCallback (YLightSensorValueCallback callback)
 
int set_currentValue (double newval)
 
int set_measureType (Y_MEASURETYPE_enum newval)
 
int setCurrentValue (double newval)
 
int setMeasureType (Y_MEASURETYPE_enum newval)
 
 ~YLightSensor ()
 
- Public Member Functions inherited from YSensor
virtual double _applyCalibration (double rawValue)
 
virtual double _decodeAvg (int dw)
 
virtual YMeasure _decodeTimedReport (double timestamp, vector< int > report)
 
virtual double _decodeVal (int w)
 
virtual string _encodeCalibrationPoints (vector< double > rawValues, vector< double > refValues)
 
virtual int _parserHelper (void)
 
Y_ADVMODE_enum advMode (void)
 
virtual int calibrateFromPoints (vector< double > rawValues, vector< double > refValues)
 
string calibrationParam (void)
 
double currentRawValue (void)
 
double currentValue (void)
 
Y_ADVMODE_enum get_advMode (void)
 
string get_calibrationParam (void)
 
double get_currentRawValue (void)
 
double get_currentValue (void)
 
virtual YDataLoggerget_dataLogger (void)
 
double get_highestValue (void)
 
string get_logFrequency (void)
 
double get_lowestValue (void)
 
virtual YDataSet get_recordedData (s64 startTime, s64 endTime)
 
string get_reportFrequency (void)
 
double get_resolution (void)
 
int get_sensorState (void)
 
string get_unit (void)
 
double highestValue (void)
 
virtual bool isSensorReady (void)
 
virtual int loadCalibrationPoints (vector< double > &rawValues, vector< double > &refValues)
 
string logFrequency (void)
 
double lowestValue (void)
 
YSensornext (void)
 
YSensornextSensor (void)
 
virtual int registerTimedReportCallback (YSensorTimedReportCallback callback)
 
virtual int registerValueCallback (YSensorValueCallback callback)
 
string reportFrequency (void)
 
double resolution (void)
 
int sensorState (void)
 
int set_advMode (Y_ADVMODE_enum newval)
 
int set_calibrationParam (const string &newval)
 
int set_highestValue (double newval)
 
int set_logFrequency (const string &newval)
 
int set_lowestValue (double newval)
 
int set_reportFrequency (const string &newval)
 
int set_resolution (double newval)
 
int setAdvMode (Y_ADVMODE_enum newval)
 
int setCalibrationParam (const string &newval)
 
int setHighestValue (double newval)
 
int setLogFrequency (const string &newval)
 
int setLowestValue (double newval)
 
int setReportFrequency (const string &newval)
 
int setResolution (double newval)
 
virtual int startDataLogger (void)
 
virtual int stopDataLogger (void)
 
string unit (void)
 
 ~YSensor ()
 
- Public Member Functions inherited from YFunction
void _clearDataStreamCache ()
 
string _decode_json_string (const string &json)
 
string _download (const string &url)
 
YDataStream_findDataStream (YDataSet &dataset, const string &def)
 
string _get_json_path (const string &json, const string &path)
 
vector< string > _json_get_array (const string &json)
 
string _json_get_key (const string &json, const string &data)
 
string _json_get_string (const string &json)
 
int _parseEx (yJsonStateMachine &j)
 
string _parseString (yJsonStateMachine &j)
 
string _request (const string &request)
 
string _requestEx (int tcpchan, const string &request, yapiRequestProgressCallback callback, void *context)
 
void _throw (YRETCODE errType, string errMsg)
 
YRETCODE _upload (const string &path, const string &content)
 
YRETCODE _uploadWithProgress (const string &path, const string &content, yapiRequestProgressCallback callback, void *context)
 
string advertisedValue (void)
 
void clearCache ()
 
string describe (void)
 
string errMessage (void)
 
string errorMessage (void)
 
YRETCODE errorType (void)
 
YRETCODE errType (void)
 
YFUN_DESCR functionDescriptor (void)
 
string get_advertisedValue (void)
 
string get_errorMessage (void)
 
YRETCODE get_errorType (void)
 
virtual string get_friendlyName (void)
 
YFUN_DESCR get_functionDescriptor (void)
 
string get_functionId (void)
 
string get_hardwareId (void)
 
string get_hubSerial ()
 
string get_logicalName (void)
 
YModuleget_module (void)
 
void * get_userData (void)
 
bool isOnline (void)
 
YRETCODE load (int msValidity)
 
virtual string loadAttribute (string attrName)
 
string logicalName (void)
 
YModulemodule (void)
 
virtual int muteValueCallbacks (void)
 
YFunctionnext (void)
 
YFunctionnextFunction (void)
 
virtual int registerValueCallback (YFunctionValueCallback callback)
 
int set_advertisedValue (const string &newval)
 
int set_logicalName (const string &newval)
 
void set_userData (void *data)
 
int setAdvertisedValue (const string &newval)
 
int setLogicalName (const string &newval)
 
void setUserData (void *data)
 
virtual int unmuteValueCallbacks (void)
 
void * userData (void)
 
virtual ~YFunction ()
 

Static Public Member Functions

static YLightSensorFind (string func)
 
static YLightSensorFindLightSensor (string func)
 
static YLightSensorFirst (void)
 
static YLightSensorFirstLightSensor (void)
 
- Static Public Member Functions inherited from YSensor
static YSensorFind (string func)
 
static YSensorFindSensor (string func)
 
static YSensorFirst (void)
 
static YSensorFirstSensor (void)
 
- Static Public Member Functions inherited from YFunction
static void _ClearCache (void)
 
static YFunctionFind (string func)
 
static YFunctionFindFunction (string func)
 
static YFunctionFirst (void)
 
static YFunctionFirstFunction (void)
 

Static Public Attributes

static const Y_MEASURETYPE_enum MEASURETYPE_HIGH_ENERGY = Y_MEASURETYPE_HIGH_ENERGY
 
static const Y_MEASURETYPE_enum MEASURETYPE_HIGH_RATE = Y_MEASURETYPE_HIGH_RATE
 
static const Y_MEASURETYPE_enum MEASURETYPE_HUMAN_EYE = Y_MEASURETYPE_HUMAN_EYE
 
static const Y_MEASURETYPE_enum MEASURETYPE_INFRARED = Y_MEASURETYPE_INFRARED
 
static const Y_MEASURETYPE_enum MEASURETYPE_INVALID = Y_MEASURETYPE_INVALID
 
static const Y_MEASURETYPE_enum MEASURETYPE_WIDE_SPECTRUM = Y_MEASURETYPE_WIDE_SPECTRUM
 
- Static Public Attributes inherited from YSensor
static const Y_ADVMODE_enum ADVMODE_IMMEDIATE = Y_ADVMODE_IMMEDIATE
 
static const Y_ADVMODE_enum ADVMODE_INVALID = Y_ADVMODE_INVALID
 
static const Y_ADVMODE_enum ADVMODE_PERIOD_AVG = Y_ADVMODE_PERIOD_AVG
 
static const Y_ADVMODE_enum ADVMODE_PERIOD_MAX = Y_ADVMODE_PERIOD_MAX
 
static const Y_ADVMODE_enum ADVMODE_PERIOD_MIN = Y_ADVMODE_PERIOD_MIN
 
static const string CALIBRATIONPARAM_INVALID = YAPI_INVALID_STRING
 
static const double CURRENTRAWVALUE_INVALID = YAPI_INVALID_DOUBLE
 
static const double CURRENTVALUE_INVALID = YAPI_INVALID_DOUBLE
 
static const double HIGHESTVALUE_INVALID = YAPI_INVALID_DOUBLE
 
static const string LOGFREQUENCY_INVALID = YAPI_INVALID_STRING
 
static const double LOWESTVALUE_INVALID = YAPI_INVALID_DOUBLE
 
static const string REPORTFREQUENCY_INVALID = YAPI_INVALID_STRING
 
static const double RESOLUTION_INVALID = YAPI_INVALID_DOUBLE
 
static const int SENSORSTATE_INVALID = YAPI_INVALID_INT
 
static const string UNIT_INVALID = YAPI_INVALID_STRING
 
- Static Public Attributes inherited from YFunction
static const string ADVERTISEDVALUE_INVALID = YAPI_INVALID_STRING
 
static const string FRIENDLYNAME_INVALID = YAPI_INVALID_STRING
 
static const YFUN_DESCR FUNCTIONDESCRIPTOR_INVALID = Y_FUNCTIONDESCRIPTOR_INVALID
 
static const string FUNCTIONID_INVALID = YAPI_INVALID_STRING
 
static const string HARDWAREID_INVALID = YAPI_INVALID_STRING
 
static const string LOGICALNAME_INVALID = YAPI_INVALID_STRING
 

Protected Member Functions

virtual int _parseAttr (YJSONObject *json_val)
 
 YLightSensor (const string &func)
 
- Protected Member Functions inherited from YSensor
 YSensor (const string &func)
 
- Protected Member Functions inherited from YFunction
YRETCODE _buildSetRequest (const string &changeattr, const string *changeval, string &request, string &errmsg)
 
string _escapeAttr (const string &changeval)
 
YRETCODE _getDescriptor (YFUN_DESCR &fundescr, string &errMsg)
 
YRETCODE _getDevice (YDevice *&dev, string &errMsg)
 
YRETCODE _load_unsafe (int msValidity)
 
YRETCODE _nextFunction (string &hwId)
 
int _parse (YJSONObject *j)
 
YRETCODE _setAttr (string attrname, string newvalue)
 
 YFunction (const string &func)
 

Protected Attributes

Y_MEASURETYPE_enum _measureType
 
YLightSensorTimedReportCallback _timedReportCallbackLightSensor
 
YLightSensorValueCallback _valueCallbackLightSensor
 
- Protected Attributes inherited from YSensor
Y_ADVMODE_enum _advMode
 
yCalibrationHandler _calhdl
 
string _calibrationParam
 
vector< int > _calpar
 
vector< double > _calraw
 
vector< double > _calref
 
int _caltyp
 
double _currentRawValue
 
double _currentValue
 
double _decexp
 
double _highestValue
 
double _iresol
 
bool _isScal
 
bool _isScal32
 
string _logFrequency
 
double _lowestValue
 
double _offset
 
double _prevTimedReport
 
string _reportFrequency
 
double _resolution
 
double _scale
 
int _sensorState
 
YSensorTimedReportCallback _timedReportCallbackSensor
 
string _unit
 
YSensorValueCallback _valueCallbackSensor
 
- Protected Attributes inherited from YFunction
string _advertisedValue
 
u64 _cacheExpiration
 
string _className
 
std::map< string, YDataStream * > _dataStreams
 
string _func
 
YFUN_DESCR _fundescr
 
string _funId
 
string _hwId
 
string _lastErrorMsg
 
YRETCODE _lastErrorType
 
string _logicalName
 
string _serial
 
yCRITICAL_SECTION _this_cs
 
void * _userData
 
YFunctionValueCallback _valueCallbackFunction
 

Friends

YLightSensoryFindLightSensor (const string &func)
 
YLightSensoryFirstLightSensor (void)
 

Additional Inherited Members

- Static Protected Member Functions inherited from YFunction
static void _AddToCache (const string &classname, const string &func, YFunction *obj)
 
static YFunction_FindFromCache (const string &classname, const string &func)
 
static void _UpdateTimedReportCallbackList (YFunction *func, bool add)
 
static void _UpdateValueCallbackList (YFunction *func, bool add)
 
- Static Protected Attributes inherited from YFunction
static std::map< string, YFunction * > _cache
 

Detailed Description

YLightSensor Class: LightSensor function interface

The Yoctopuce class YLightSensor allows you to read and configure Yoctopuce light sensors. It inherits from YSensor class the core functions to read measurements, to register callback functions, to access the autonomous datalogger. This class adds the ability to easily perform a one-point linear calibration to compensate the effect of a glass or filter placed in front of the sensor. For some light sensors with several working modes, this class can select the desired working mode.

Definition at line 82 of file yocto_lightsensor.h.

Constructor & Destructor Documentation

YLightSensor::YLightSensor ( const string &  func)
protected

Definition at line 51 of file yocto_lightsensor.cpp.

YLightSensor::~YLightSensor ( )

Definition at line 61 of file yocto_lightsensor.cpp.

Member Function Documentation

int YLightSensor::_invokeTimedReportCallback ( YMeasure  value)
virtual

Reimplemented from YSensor.

Definition at line 287 of file yocto_lightsensor.cpp.

int YLightSensor::_invokeValueCallback ( string  value)
virtual

Reimplemented from YSensor.

Definition at line 253 of file yocto_lightsensor.cpp.

int YLightSensor::_parseAttr ( YJSONObject json_val)
protectedvirtual

Reimplemented from YSensor.

Definition at line 69 of file yocto_lightsensor.cpp.

int YLightSensor::calibrate ( double  calibratedVal)

Changes the sensor-specific calibration parameter so that the current value matches a desired target (linear scaling).

Parameters
calibratedVal: the desired target value.

Remember to call the saveToFlash() method of the module if the modification must be kept.

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 107 of file yocto_lightsensor.cpp.

static YLightSensor* YLightSensor::Find ( string  func)
inlinestatic

Definition at line 228 of file yocto_lightsensor.h.

YLightSensor * YLightSensor::FindLightSensor ( string  func)
static

Retrieves a light sensor for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

This function does not require that the light sensor is online at the time it is invoked. The returned object is nevertheless valid. Use the method YLightSensor.isOnline() to test if the light sensor is indeed online at a given time. In case of ambiguity when looking for a light sensor by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.

If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string that uniquely characterizes the light sensor
Returns
a YLightSensor object allowing you to drive the light sensor.

Definition at line 202 of file yocto_lightsensor.cpp.

static YLightSensor* YLightSensor::First ( void  )
inlinestatic

Definition at line 252 of file yocto_lightsensor.h.

YLightSensor * YLightSensor::FirstLightSensor ( void  )
static

Starts the enumeration of light sensors currently accessible. Use the method YLightSensor.nextLightSensor() to iterate on next light sensors.

Returns
a pointer to a YLightSensor object, corresponding to the first light sensor currently online, or a NULL pointer if there are none.

Definition at line 307 of file yocto_lightsensor.cpp.

Y_MEASURETYPE_enum YLightSensor::get_measureType ( void  )

Returns the type of light measure.

Returns
a value among Y_MEASURETYPE_HUMAN_EYE, Y_MEASURETYPE_WIDE_SPECTRUM, Y_MEASURETYPE_INFRARED, Y_MEASURETYPE_HIGH_RATE and Y_MEASURETYPE_HIGH_ENERGY corresponding to the type of light measure

On failure, throws an exception or returns Y_MEASURETYPE_INVALID.

Definition at line 122 of file yocto_lightsensor.cpp.

Y_MEASURETYPE_enum YLightSensor::measureType ( void  )
inline

Definition at line 144 of file yocto_lightsensor.h.

YLightSensor* YLightSensor::next ( void  )
inline

Definition at line 239 of file yocto_lightsensor.h.

YLightSensor * YLightSensor::nextLightSensor ( void  )

Continues the enumeration of light sensors started using yFirstLightSensor().

Returns
a pointer to a YLightSensor object, corresponding to a light sensor currently online, or a NULL pointer if there are no more light sensors to enumerate.

Definition at line 297 of file yocto_lightsensor.cpp.

int YLightSensor::registerTimedReportCallback ( YLightSensorTimedReportCallback  callback)
virtual

Registers the callback function that is invoked on every periodic timed notification. The callback is invoked only during the execution of ySleep or yHandleEvents. This provides control over the time when the callback is triggered. For good responsiveness, remember to call one of these two functions periodically. To unregister a callback, pass a NULL pointer as argument.

Parameters
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.

Definition at line 274 of file yocto_lightsensor.cpp.

int YLightSensor::registerValueCallback ( YLightSensorValueCallback  callback)
virtual

Registers the callback function that is invoked on every change of advertised value. The callback is invoked only during the execution of ySleep or yHandleEvents. This provides control over the time when the callback is triggered. For good responsiveness, remember to call one of these two functions periodically. To unregister a callback, pass a NULL pointer as argument.

Parameters
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.

Definition at line 234 of file yocto_lightsensor.cpp.

int YLightSensor::set_currentValue ( double  newval)

Definition at line 78 of file yocto_lightsensor.cpp.

int YLightSensor::set_measureType ( Y_MEASURETYPE_enum  newval)

Changes the light sensor type used in the device. The measure can either approximate the response of the human eye, focus on a specific light spectrum, depending on the capabilities of the light-sensitive cell. Remember to call the saveToFlash() method of the module if the modification must be kept.

Parameters
newval: a value among Y_MEASURETYPE_HUMAN_EYE, Y_MEASURETYPE_WIDE_SPECTRUM, Y_MEASURETYPE_INFRARED, Y_MEASURETYPE_HIGH_RATE and Y_MEASURETYPE_HIGH_ENERGY corresponding to the light sensor type used in the device
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 159 of file yocto_lightsensor.cpp.

int YLightSensor::setCurrentValue ( double  newval)
inline

Definition at line 116 of file yocto_lightsensor.h.

int YLightSensor::setMeasureType ( Y_MEASURETYPE_enum  newval)
inline

Definition at line 163 of file yocto_lightsensor.h.

Friends And Related Function Documentation

YLightSensor* yFindLightSensor ( const string &  func)
friend

Retrieves a light sensor for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

This function does not require that the light sensor is online at the time it is invoked. The returned object is nevertheless valid. Use the method YLightSensor.isOnline() to test if the light sensor is indeed online at a given time. In case of ambiguity when looking for a light sensor by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.

If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string that uniquely characterizes the light sensor
Returns
a YLightSensor object allowing you to drive the light sensor.

Definition at line 289 of file yocto_lightsensor.h.

YLightSensor* yFirstLightSensor ( void  )
friend

Starts the enumeration of light sensors currently accessible. Use the method YLightSensor.nextLightSensor() to iterate on next light sensors.

Returns
a pointer to a YLightSensor object, corresponding to the first light sensor currently online, or a NULL pointer if there are none.

Definition at line 300 of file yocto_lightsensor.h.

Member Data Documentation

Y_MEASURETYPE_enum YLightSensor::_measureType
protected

Definition at line 90 of file yocto_lightsensor.h.

YLightSensorTimedReportCallback YLightSensor::_timedReportCallbackLightSensor
protected

Definition at line 92 of file yocto_lightsensor.h.

YLightSensorValueCallback YLightSensor::_valueCallbackLightSensor
protected

Definition at line 91 of file yocto_lightsensor.h.

const Y_MEASURETYPE_enum YLightSensor::MEASURETYPE_HIGH_ENERGY = Y_MEASURETYPE_HIGH_ENERGY
static

Definition at line 112 of file yocto_lightsensor.h.

const Y_MEASURETYPE_enum YLightSensor::MEASURETYPE_HIGH_RATE = Y_MEASURETYPE_HIGH_RATE
static

Definition at line 111 of file yocto_lightsensor.h.

const Y_MEASURETYPE_enum YLightSensor::MEASURETYPE_HUMAN_EYE = Y_MEASURETYPE_HUMAN_EYE
static

Definition at line 108 of file yocto_lightsensor.h.

const Y_MEASURETYPE_enum YLightSensor::MEASURETYPE_INFRARED = Y_MEASURETYPE_INFRARED
static

Definition at line 110 of file yocto_lightsensor.h.

const Y_MEASURETYPE_enum YLightSensor::MEASURETYPE_INVALID = Y_MEASURETYPE_INVALID
static

Definition at line 113 of file yocto_lightsensor.h.

const Y_MEASURETYPE_enum YLightSensor::MEASURETYPE_WIDE_SPECTRUM = Y_MEASURETYPE_WIDE_SPECTRUM
static

Definition at line 109 of file yocto_lightsensor.h.


The documentation for this class was generated from the following files:


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:13