41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "colorled" 53 ,_rgbColor(RGBCOLOR_INVALID)
54 ,_hslColor(HSLCOLOR_INVALID)
55 ,_rgbMove(RGBMOVE_INVALID)
56 ,_hslMove(HSLMOVE_INVALID)
57 ,_rgbColorAtPowerOn(RGBCOLORATPOWERON_INVALID)
58 ,_blinkSeqSize(BLINKSEQSIZE_INVALID)
59 ,_blinkSeqMaxSize(BLINKSEQMAXSIZE_INVALID)
60 ,_blinkSeqSignature(BLINKSEQSIGNATURE_INVALID)
61 ,_command(COMMAND_INVALID)
62 ,_valueCallbackColorLed(NULL)
81 if(json_val->
has(
"rgbColor")) {
84 if(json_val->
has(
"hslColor")) {
87 if(json_val->
has(
"rgbMove")) {
89 if (subjson->
has(
"moving")) {
92 if (subjson->
has(
"target")) {
95 if (subjson->
has(
"ms")) {
99 if(json_val->
has(
"hslMove")) {
101 if (subjson->
has(
"moving")) {
104 if (subjson->
has(
"target")) {
107 if (subjson->
has(
"ms")) {
111 if(json_val->
has(
"rgbColorAtPowerOn")) {
114 if(json_val->
has(
"blinkSeqSize")) {
117 if(json_val->
has(
"blinkSeqMaxSize")) {
120 if(json_val->
has(
"blinkSeqSignature")) {
123 if(json_val->
has(
"command")) {
151 }
catch (std::exception) {
174 char buf[32]; sprintf(buf,
"0x%06x",newval); rest_val = string(buf);
175 res =
_setAttr(
"rgbColor", rest_val);
176 }
catch (std::exception) {
205 }
catch (std::exception) {
228 char buf[32]; sprintf(buf,
"0x%06x",newval); rest_val = string(buf);
229 res =
_setAttr(
"hslColor", rest_val);
230 }
catch (std::exception) {
252 }
catch (std::exception) {
266 char buff[64]; sprintf(buff,
"%d:%d",newval.
target,newval.
ms); rest_val = string(buff);
267 res =
_setAttr(
"rgbMove", rest_val);
268 }
catch (std::exception) {
289 char buff[64]; sprintf(buff,
"%d:%d",rgb_target,ms_duration); rest_val = string(buff);
290 return _setAttr(
"rgbMove", rest_val);
307 }
catch (std::exception) {
321 char buff[64]; sprintf(buff,
"%d:%d",newval.
target,newval.
ms); rest_val = string(buff);
322 res =
_setAttr(
"hslMove", rest_val);
323 }
catch (std::exception) {
344 char buff[64]; sprintf(buff,
"%d:%d",hsl_target,ms_duration); rest_val = string(buff);
345 return _setAttr(
"hslMove", rest_val);
369 }
catch (std::exception) {
393 char buf[32]; sprintf(buf,
"0x%06x",newval); rest_val = string(buf);
394 res =
_setAttr(
"rgbColorAtPowerOn", rest_val);
395 }
catch (std::exception) {
424 }
catch (std::exception) {
453 }
catch (std::exception) {
485 }
catch (std::exception) {
507 }
catch (std::exception) {
522 res =
_setAttr(
"command", rest_val);
523 }
catch (std::exception) {
571 }
catch (std::exception) {
593 if (callback != NULL) {
600 if (callback != NULL && this->
isOnline()) {
701 vector<YFUN_DESCR> v_fundescr;
703 string serial, funcId, funcName, funcVal, errmsg;
706 v_fundescr.size() == 0 ||
static const int HSLCOLOR_INVALID
yCRITICAL_SECTION _this_cs
int set_hslMove(YMove newval)
int set_rgbColor(int newval)
static const int RGBCOLOR_INVALID
static const YMove HSLMOVE_INVALID
YColorLedValueCallback _valueCallbackColorLed
static const int RGBCOLORATPOWERON_INVALID
YRETCODE _load_unsafe(int msValidity)
virtual int startBlinkSeq(void)
int set_rgbMove(YMove newval)
virtual int addHslMoveToBlinkSeq(int HSLcolor, int msDelay)
int get_blinkSeqSize(void)
virtual int stopBlinkSeq(void)
virtual int _parseAttr(YJSONObject *json_val)
int get_blinkSeqSignature(void)
int set_command(const string &newval)
static int DefaultCacheValidity
string getString(const string &key)
YJSONObject * getYJSONObject(const string &key)
virtual int registerValueCallback(YColorLedValueCallback callback)
virtual int sendCommand(string command)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
int get_blinkSeqMaxSize(void)
virtual int resetBlinkSeq(void)
#define YAPI_INVALID_STRING
static const YMove RGBMOVE_INVALID
virtual int _parseAttr(YJSONObject *json_val)
static const int BLINKSEQSIGNATURE_INVALID
int getInt(const string &key)
static u64 GetTickCount(void)
int set_hslColor(int newval)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
static YFunction * _FindFromCache(const string &classname, const string &func)
int get_rgbColorAtPowerOn(void)
static YColorLed * FirstColorLed(void)
static string ysprintf(const char *fmt,...)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
YColorLed * nextColorLed(void)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
static YColorLed * FindColorLed(string func)
static const int BLINKSEQSIZE_INVALID
static const int BLINKSEQMAXSIZE_INVALID
static bool _apiInitialized
virtual int addRgbMoveToBlinkSeq(int RGBcolor, int msDelay)
YRETCODE _nextFunction(string &hwId)
int set_rgbColorAtPowerOn(int newval)
static void _UpdateValueCallbackList(YFunction *func, bool add)
bool has(const string &key)
static const string COMMAND_INVALID
YRETCODE _setAttr(string attrname, string newvalue)
virtual int _invokeValueCallback(string value)
YColorLed(const string &func)
void(* YColorLedValueCallback)(YColorLed *func, const string &functionValue)
virtual int _invokeValueCallback(string value)