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

#include <yocto_servo.h>

Inheritance diagram for YServo:
Inheritance graph
[legend]

Public Member Functions

virtual int _invokeValueCallback (string value)
 
Y_ENABLED_enum enabled (void)
 
Y_ENABLEDATPOWERON_enum enabledAtPowerOn (void)
 
Y_ENABLED_enum get_enabled (void)
 
Y_ENABLEDATPOWERON_enum get_enabledAtPowerOn (void)
 
YMove get_move (void)
 
int get_neutral (void)
 
int get_position (void)
 
int get_positionAtPowerOn (void)
 
int get_range (void)
 
YMove move (void)
 
int move (int target, int ms_duration)
 
int neutral (void)
 
YServonext (void)
 
YServonextServo (void)
 
int position (void)
 
int positionAtPowerOn (void)
 
int range (void)
 
virtual int registerValueCallback (YServoValueCallback callback)
 
int set_enabled (Y_ENABLED_enum newval)
 
int set_enabledAtPowerOn (Y_ENABLEDATPOWERON_enum newval)
 
int set_move (YMove newval)
 
int set_neutral (int newval)
 
int set_position (int newval)
 
int set_positionAtPowerOn (int newval)
 
int set_range (int newval)
 
int setEnabled (Y_ENABLED_enum newval)
 
int setEnabledAtPowerOn (Y_ENABLEDATPOWERON_enum newval)
 
int setMove (YMove newval)
 
int setNeutral (int newval)
 
int setPosition (int newval)
 
int setPositionAtPowerOn (int newval)
 
int setRange (int newval)
 
 ~YServo ()
 
- 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)
 
virtual int _parserHelper (void)
 
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 YServoFind (string func)
 
static YServoFindServo (string func)
 
static YServoFirst (void)
 
static YServoFirstServo (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_ENABLED_enum ENABLED_FALSE = Y_ENABLED_FALSE
 
static const Y_ENABLED_enum ENABLED_INVALID = Y_ENABLED_INVALID
 
static const Y_ENABLED_enum ENABLED_TRUE = Y_ENABLED_TRUE
 
static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_FALSE = Y_ENABLEDATPOWERON_FALSE
 
static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_INVALID = Y_ENABLEDATPOWERON_INVALID
 
static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_TRUE = Y_ENABLEDATPOWERON_TRUE
 
static const YMove MOVE_INVALID = YMove()
 
static const int NEUTRAL_INVALID = YAPI_INVALID_UINT
 
static const int POSITION_INVALID = YAPI_INVALID_INT
 
static const int POSITIONATPOWERON_INVALID = YAPI_INVALID_INT
 
static const int RANGE_INVALID = YAPI_INVALID_UINT
 
- 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)
 
 YServo (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_ENABLED_enum _enabled
 
Y_ENABLEDATPOWERON_enum _enabledAtPowerOn
 
YMove _move
 
int _neutral
 
int _position
 
int _positionAtPowerOn
 
int _range
 
YServoValueCallback _valueCallbackServo
 
- 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

YServoyFindServo (const string &func)
 
YServoyFirstServo (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

YServo Class: Servo function interface

Yoctopuce application programming interface allows you not only to move a servo to a given position, but also to specify the time interval in which the move should be performed. This makes it possible to synchronize two servos involved in a same move.

Definition at line 103 of file yocto_servo.h.

Constructor & Destructor Documentation

YServo::YServo ( const string &  func)
protected

Definition at line 51 of file yocto_servo.cpp.

YServo::~YServo ( )

Definition at line 66 of file yocto_servo.cpp.

Member Function Documentation

int YServo::_invokeValueCallback ( string  value)
virtual

Reimplemented from YFunction.

Definition at line 583 of file yocto_servo.cpp.

int YServo::_parseAttr ( YJSONObject json_val)
protectedvirtual

Reimplemented from YFunction.

Definition at line 75 of file yocto_servo.cpp.

Y_ENABLED_enum YServo::enabled ( void  )
inline

Definition at line 180 of file yocto_servo.h.

Y_ENABLEDATPOWERON_enum YServo::enabledAtPowerOn ( void  )
inline

Definition at line 315 of file yocto_servo.h.

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

Definition at line 378 of file yocto_servo.h.

YServo * YServo::FindServo ( string  func)
static

Retrieves a servo 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 servo is online at the time it is invoked. The returned object is nevertheless valid. Use the method YServo.isOnline() to test if the servo is indeed online at a given time. In case of ambiguity when looking for a servo 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 servo
Returns
a YServo object allowing you to drive the servo.

Definition at line 532 of file yocto_servo.cpp.

static YServo* YServo::First ( void  )
inlinestatic

Definition at line 402 of file yocto_servo.h.

YServo * YServo::FirstServo ( void  )
static

Starts the enumeration of servos currently accessible. Use the method YServo.nextServo() to iterate on next servos.

Returns
a pointer to a YServo object, corresponding to the first servo currently online, or a NULL pointer if there are none.

Definition at line 603 of file yocto_servo.cpp.

Y_ENABLED_enum YServo::get_enabled ( void  )

Returns the state of the servos.

Returns
either Y_ENABLED_FALSE or Y_ENABLED_TRUE, according to the state of the servos

On failure, throws an exception or returns Y_ENABLED_INVALID.

Definition at line 172 of file yocto_servo.cpp.

Y_ENABLEDATPOWERON_enum YServo::get_enabledAtPowerOn ( void  )

Returns the servo signal generator state at power up.

Returns
either Y_ENABLEDATPOWERON_FALSE or Y_ENABLEDATPOWERON_TRUE, according to the servo signal generator state at power up

On failure, throws an exception or returns Y_ENABLEDATPOWERON_INVALID.

Definition at line 457 of file yocto_servo.cpp.

YMove YServo::get_move ( void  )

Definition at line 339 of file yocto_servo.cpp.

int YServo::get_neutral ( void  )

Returns the duration in microseconds of a neutral pulse for the servo.

Returns
an integer corresponding to the duration in microseconds of a neutral pulse for the servo

On failure, throws an exception or returns Y_NEUTRAL_INVALID.

Definition at line 286 of file yocto_servo.cpp.

int YServo::get_position ( void  )

Returns the current servo position.

Returns
an integer corresponding to the current servo position

On failure, throws an exception or returns Y_POSITION_INVALID.

Definition at line 118 of file yocto_servo.cpp.

int YServo::get_positionAtPowerOn ( void  )

Returns the servo position at device power up.

Returns
an integer corresponding to the servo position at device power up

On failure, throws an exception or returns Y_POSITIONATPOWERON_INVALID.

Definition at line 401 of file yocto_servo.cpp.

int YServo::get_range ( void  )

Returns the current range of use of the servo.

Returns
an integer corresponding to the current range of use of the servo

On failure, throws an exception or returns Y_RANGE_INVALID.

Definition at line 226 of file yocto_servo.cpp.

YMove YServo::move ( void  )
inline

Definition at line 260 of file yocto_servo.h.

int YServo::move ( int  target,
int  ms_duration 
)

Performs a smooth move at constant speed toward a given position.

Parameters
target: new position at the end of the move
ms_duration: total duration of the move, in milliseconds
Returns
YAPI_SUCCESS if the call succeeds.

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

Definition at line 387 of file yocto_servo.cpp.

int YServo::neutral ( void  )
inline

Definition at line 236 of file yocto_servo.h.

YServo* YServo::next ( void  )
inline

Definition at line 389 of file yocto_servo.h.

YServo * YServo::nextServo ( void  )

Continues the enumeration of servos started using yFirstServo().

Returns
a pointer to a YServo object, corresponding to a servo currently online, or a NULL pointer if there are no more servos to enumerate.

Definition at line 593 of file yocto_servo.cpp.

int YServo::position ( void  )
inline

Definition at line 155 of file yocto_servo.h.

int YServo::positionAtPowerOn ( void  )
inline

Definition at line 288 of file yocto_servo.h.

int YServo::range ( void  )
inline

Definition at line 205 of file yocto_servo.h.

int YServo::registerValueCallback ( YServoValueCallback  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 564 of file yocto_servo.cpp.

int YServo::set_enabled ( Y_ENABLED_enum  newval)

Stops or starts the servo.

Parameters
newval: either Y_ENABLED_FALSE or Y_ENABLED_TRUE
Returns
YAPI_SUCCESS if the call succeeds.

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

Definition at line 203 of file yocto_servo.cpp.

int YServo::set_enabledAtPowerOn ( Y_ENABLEDATPOWERON_enum  newval)

Configure the servo signal generator state at power up. Remember to call the matching module saveToFlash() method, otherwise this call will have no effect.

Parameters
newval: either Y_ENABLEDATPOWERON_FALSE or Y_ENABLEDATPOWERON_TRUE
Returns
YAPI_SUCCESS if the call succeeds.

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

Definition at line 489 of file yocto_servo.cpp.

int YServo::set_move ( YMove  newval)

Definition at line 361 of file yocto_servo.cpp.

int YServo::set_neutral ( int  newval)

Changes the duration of the pulse corresponding to the neutral position of the servo. The duration is specified in microseconds, and the standard value is 1500 [us]. This setting makes it possible to shift the range of use of the servo. Be aware that using a range higher than what is supported by the servo is likely to damage the servo. Remember to call the matching module saveToFlash() method, otherwise this call will have no effect.

Parameters
newval: an integer corresponding to the duration of the pulse corresponding to the neutral position of the servo
Returns
YAPI_SUCCESS if the call succeeds.

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

Definition at line 323 of file yocto_servo.cpp.

int YServo::set_position ( int  newval)

Changes immediately the servo driving position.

Parameters
newval: an integer corresponding to immediately the servo driving position
Returns
YAPI_SUCCESS if the call succeeds.

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

Definition at line 149 of file yocto_servo.cpp.

int YServo::set_positionAtPowerOn ( int  newval)

Configure the servo position at device power up. Remember to call the matching module saveToFlash() method, otherwise this call will have no effect.

Parameters
newval: an integer
Returns
YAPI_SUCCESS if the call succeeds.

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

Definition at line 433 of file yocto_servo.cpp.

int YServo::set_range ( int  newval)

Changes the range of use of the servo, specified in per cents. A range of 100% corresponds to a standard control signal, that varies from 1 [ms] to 2 [ms], When using a servo that supports a double range, from 0.5 [ms] to 2.5 [ms], you can select a range of 200%. Be aware that using a range higher than what is supported by the servo is likely to damage the servo. Remember to call the matching module saveToFlash() method, otherwise this call will have no effect.

Parameters
newval: an integer corresponding to the range of use of the servo, specified in per cents
Returns
YAPI_SUCCESS if the call succeeds.

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

Definition at line 263 of file yocto_servo.cpp.

int YServo::setEnabled ( Y_ENABLED_enum  newval)
inline

Definition at line 193 of file yocto_servo.h.

int YServo::setEnabledAtPowerOn ( Y_ENABLEDATPOWERON_enum  newval)
inline

Definition at line 329 of file yocto_servo.h.

int YServo::setMove ( YMove  newval)
inline

Definition at line 264 of file yocto_servo.h.

int YServo::setNeutral ( int  newval)
inline

Definition at line 255 of file yocto_servo.h.

int YServo::setPosition ( int  newval)
inline

Definition at line 168 of file yocto_servo.h.

int YServo::setPositionAtPowerOn ( int  newval)
inline

Definition at line 302 of file yocto_servo.h.

int YServo::setRange ( int  newval)
inline

Definition at line 224 of file yocto_servo.h.

Friends And Related Function Documentation

YServo* yFindServo ( const string &  func)
friend

Retrieves a servo 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 servo is online at the time it is invoked. The returned object is nevertheless valid. Use the method YServo.isOnline() to test if the servo is indeed online at a given time. In case of ambiguity when looking for a servo 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 servo
Returns
a YServo object allowing you to drive the servo.

Definition at line 439 of file yocto_servo.h.

YServo* yFirstServo ( void  )
friend

Starts the enumeration of servos currently accessible. Use the method YServo.nextServo() to iterate on next servos.

Returns
a pointer to a YServo object, corresponding to the first servo currently online, or a NULL pointer if there are none.

Definition at line 450 of file yocto_servo.h.

Member Data Documentation

Y_ENABLED_enum YServo::_enabled
protected

Definition at line 112 of file yocto_servo.h.

Y_ENABLEDATPOWERON_enum YServo::_enabledAtPowerOn
protected

Definition at line 117 of file yocto_servo.h.

YMove YServo::_move
protected

Definition at line 115 of file yocto_servo.h.

int YServo::_neutral
protected

Definition at line 114 of file yocto_servo.h.

int YServo::_position
protected

Definition at line 111 of file yocto_servo.h.

int YServo::_positionAtPowerOn
protected

Definition at line 116 of file yocto_servo.h.

int YServo::_range
protected

Definition at line 113 of file yocto_servo.h.

YServoValueCallback YServo::_valueCallbackServo
protected

Definition at line 118 of file yocto_servo.h.

const Y_ENABLED_enum YServo::ENABLED_FALSE = Y_ENABLED_FALSE
static

Definition at line 135 of file yocto_servo.h.

const Y_ENABLED_enum YServo::ENABLED_INVALID = Y_ENABLED_INVALID
static

Definition at line 137 of file yocto_servo.h.

const Y_ENABLED_enum YServo::ENABLED_TRUE = Y_ENABLED_TRUE
static

Definition at line 136 of file yocto_servo.h.

const Y_ENABLEDATPOWERON_enum YServo::ENABLEDATPOWERON_FALSE = Y_ENABLEDATPOWERON_FALSE
static

Definition at line 142 of file yocto_servo.h.

const Y_ENABLEDATPOWERON_enum YServo::ENABLEDATPOWERON_INVALID = Y_ENABLEDATPOWERON_INVALID
static

Definition at line 144 of file yocto_servo.h.

const Y_ENABLEDATPOWERON_enum YServo::ENABLEDATPOWERON_TRUE = Y_ENABLEDATPOWERON_TRUE
static

Definition at line 143 of file yocto_servo.h.

const YMove YServo::MOVE_INVALID = YMove()
static

Definition at line 140 of file yocto_servo.h.

const int YServo::NEUTRAL_INVALID = YAPI_INVALID_UINT
static

Definition at line 139 of file yocto_servo.h.

const int YServo::POSITION_INVALID = YAPI_INVALID_INT
static

Definition at line 134 of file yocto_servo.h.

const int YServo::POSITIONATPOWERON_INVALID = YAPI_INVALID_INT
static

Definition at line 141 of file yocto_servo.h.

const int YServo::RANGE_INVALID = YAPI_INVALID_UINT
static

Definition at line 138 of file yocto_servo.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:14