41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "colorledcluster" 53 ,_activeLedCount(ACTIVELEDCOUNT_INVALID)
54 ,_maxLedCount(MAXLEDCOUNT_INVALID)
55 ,_blinkSeqMaxCount(BLINKSEQMAXCOUNT_INVALID)
56 ,_blinkSeqMaxSize(BLINKSEQMAXSIZE_INVALID)
57 ,_command(COMMAND_INVALID)
58 ,_valueCallbackColorLedCluster(NULL)
75 if(json_val->
has(
"activeLedCount")) {
78 if(json_val->
has(
"maxLedCount")) {
81 if(json_val->
has(
"blinkSeqMaxCount")) {
84 if(json_val->
has(
"blinkSeqMaxSize")) {
87 if(json_val->
has(
"command")) {
115 }
catch (std::exception) {
138 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
139 res =
_setAttr(
"activeLedCount", rest_val);
140 }
catch (std::exception) {
169 }
catch (std::exception) {
198 }
catch (std::exception) {
227 }
catch (std::exception) {
249 }
catch (std::exception) {
264 res =
_setAttr(
"command", rest_val);
265 }
catch (std::exception) {
313 }
catch (std::exception) {
335 if (callback != NULL) {
342 if (callback != NULL && this->
isOnline()) {
772 listlen = (int)rgbList.size();
773 buff = string(3*listlen, (
char)0);
775 while (idx < listlen) {
777 buff[3*idx] = (char)(((((rgb) >> (16))) & (255)));
778 buff[3*idx+1] = (char)(((((rgb) >> (8))) & (255)));
779 buff[3*idx+2] = (char)(((rgb) & (255)));
807 listlen = (int)rgbList.size();
808 buff = string(3*listlen, (
char)0);
810 while (idx < listlen) {
812 buff[3*idx] = (char)(((((rgb) >> (16))) & (255)));
813 buff[3*idx+1] = (char)(((((rgb) >> (8))) & (255)));
814 buff[3*idx+2] = (char)(((rgb) & (255)));
878 listlen = (int)hslList.size();
879 buff = string(3*listlen, (
char)0);
881 while (idx < listlen) {
883 buff[3*idx] = (char)(((((hsl) >> (16))) & (255)));
884 buff[3*idx+1] = (char)(((((hsl) >> (8))) & (255)));
885 buff[3*idx+2] = (char)(((hsl) & (255)));
933 listlen = (int)hslList.size();
934 buff = string(3*listlen, (
char)0);
936 while (idx < listlen) {
938 buff[3*idx] = (char)(((((hsl) >> (16))) & (255)));
939 buff[3*idx+1] = (char)(((((hsl) >> (8))) & (255)));
940 buff[3*idx+2] = (char)(((hsl) & (255)));
989 while (idx < count) {
990 r = ((u8)buff[3*idx]);
991 g = ((u8)buff[3*idx+1]);
992 b = ((u8)buff[3*idx+2]);
993 res.push_back(r*65536+g*256+b);
1023 while (idx < count) {
1024 r = ((u8)buff[3*idx]);
1025 g = ((u8)buff[3*idx+1]);
1026 b = ((u8)buff[3*idx+2]);
1027 res.push_back(r*65536+g*256+b);
1055 while (idx < count) {
1056 seq = ((u8)buff[idx]);
1088 while (idx < count) {
1089 hh = ((u8)buff[4*idx]);
1090 hl = ((u8)buff[4*idx+1]);
1091 lh = ((u8)buff[4*idx+2]);
1092 ll = ((u8)buff[4*idx+3]);
1093 res.push_back(((hh) << (24))+((hl) << (16))+((lh) << (8))+ll);
1120 while (idx < count) {
1121 lh = ((u8)buff[2*idx]);
1122 ll = ((u8)buff[2*idx+1]);
1123 res.push_back(((lh) << (8))+ll);
1149 while (idx < count) {
1150 started = ((u8)buff[idx]);
1151 res.push_back(started);
1177 while (idx < count) {
1178 started = ((u8)buff[idx]);
1179 res.push_back(started);
1197 vector<YFUN_DESCR> v_fundescr;
1199 string serial, funcId, funcName, funcVal, errmsg;
1202 v_fundescr.size() == 0 ||
yCRITICAL_SECTION _this_cs
virtual vector< int > get_rgbColorArray(int ledIndex, int count)
virtual int set_hslColorBuffer(int ledIndex, string buff)
YRETCODE _load_unsafe(int msValidity)
virtual string get_rgbColorBuffer(int ledIndex, int count)
virtual vector< int > get_blinkSeqStateSpeed(int seqIndex, int count)
virtual int set_hslColorArray(int ledIndex, vector< int > hslList)
virtual int hsl_move(int ledIndex, int count, int hslValue, int delay)
virtual int linkLedToBlinkSeq(int ledIndex, int count, int seqIndex, int offset)
virtual int addRgbMoveToBlinkSeq(int seqIndex, int rgbValue, int delay)
int get_blinkSeqMaxSize(void)
virtual int resetBlinkSeq(int seqIndex)
YRETCODE _upload(const string &path, const string &content)
static int DefaultCacheValidity
string getString(const string &key)
void(* YColorLedClusterValueCallback)(YColorLedCluster *func, const string &functionValue)
int get_blinkSeqMaxCount(void)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
virtual int addJumpToBlinkSeq(int seqIndex, int linkSeqIndex)
string _download(const string &url)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
virtual int _parseAttr(YJSONObject *json_val)
virtual int addUnlinkToBlinkSeq(int seqIndex)
virtual vector< int > get_blinkSeqStateAtPowerOn(int seqIndex, int count)
virtual int addMirrorToBlinkSeq(int seqIndex)
virtual int unlinkLedFromBlinkSeq(int ledIndex, int count)
virtual int set_blinkSeqSpeed(int seqIndex, int speed)
virtual int hslArray_move(vector< int > hslList, int delay)
#define YAPI_INVALID_STRING
virtual int saveLedsConfigAtPowerOn(void)
virtual int rgbArray_move(vector< int > rgbList, int delay)
virtual int sendCommand(string command)
virtual int _parseAttr(YJSONObject *json_val)
virtual int addHslMoveToBlinkSeq(int seqIndex, int hslValue, int delay)
virtual int set_rgbColorBuffer(int ledIndex, string buff)
virtual int set_rgbColorArray(int ledIndex, vector< int > rgbList)
int getInt(const string &key)
virtual int saveBlinkSeq(int seqIndex)
static u64 GetTickCount(void)
static const int BLINKSEQMAXCOUNT_INVALID
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
virtual int set_rgbColor(int ledIndex, int count, int rgbValue)
virtual int linkLedToBlinkSeqAtPowerOn(int ledIndex, int count, int seqIndex, int offset)
static YColorLedCluster * FirstColorLedCluster(void)
int set_activeLedCount(int newval)
static YFunction * _FindFromCache(const string &classname, const string &func)
static string ysprintf(const char *fmt,...)
virtual vector< int > get_linkedSeqArray(int ledIndex, int count)
virtual vector< int > get_blinkSeqState(int seqIndex, int count)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
YColorLedCluster * nextColorLedCluster(void)
static yCRITICAL_SECTION _global_cs
virtual int rgbArrayOfs_move(int ledIndex, vector< int > rgbList, int delay)
int get_activeLedCount(void)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
virtual int linkLedToPeriodicBlinkSeq(int ledIndex, int count, int seqIndex, int periods)
static const int BLINKSEQMAXSIZE_INVALID
virtual int hslArrayOfs_move(int ledIndex, vector< int > hslList, int delay)
virtual int stopBlinkSeq(int seqIndex)
virtual vector< int > get_rgbColorArrayAtPowerOn(int ledIndex, int count)
static const int ACTIVELEDCOUNT_INVALID
virtual vector< int > get_blinkSeqSignatures(int seqIndex, int count)
virtual int set_blinkSeqStateAtPowerOn(int seqIndex, int autostart)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static const int MAXLEDCOUNT_INVALID
virtual int rgb_move(int ledIndex, int count, int rgbValue, int delay)
virtual int set_rgbColorAtPowerOn(int ledIndex, int count, int rgbValue)
static void _UpdateValueCallbackList(YFunction *func, bool add)
int get_maxLedCount(void)
virtual int saveLedsState(void)
bool has(const string &key)
virtual int _invokeValueCallback(string value)
virtual int set_hslColor(int ledIndex, int count, int hslValue)
YRETCODE _setAttr(string attrname, string newvalue)
static YColorLedCluster * FindColorLedCluster(string func)
YColorLedCluster(const string &func)
virtual int registerValueCallback(YColorLedClusterValueCallback callback)
virtual int startBlinkSeq(int seqIndex)
int set_command(const string &newval)
virtual int _invokeValueCallback(string value)
YColorLedClusterValueCallback _valueCallbackColorLedCluster
static const string COMMAND_INVALID