41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "hubport" 53 ,_enabled(ENABLED_INVALID)
54 ,_portState(PORTSTATE_INVALID)
55 ,_baudRate(BAUDRATE_INVALID)
56 ,_valueCallbackHubPort(NULL)
72 if(json_val->
has(
"enabled")) {
75 if(json_val->
has(
"portState")) {
78 if(json_val->
has(
"baudRate")) {
107 }
catch (std::exception) {
131 rest_val = (newval>0 ?
"1" :
"0");
132 res =
_setAttr(
"enabled", rest_val);
133 }
catch (std::exception) {
163 }
catch (std::exception) {
194 }
catch (std::exception) {
242 }
catch (std::exception) {
264 if (callback != NULL) {
271 if (callback != NULL && this->
isOnline()) {
302 vector<YFUN_DESCR> v_fundescr;
304 string serial, funcId, funcName, funcVal, errmsg;
307 v_fundescr.size() == 0 ||
yCRITICAL_SECTION _this_cs
YRETCODE _load_unsafe(int msValidity)
Y_ENABLED_enum get_enabled(void)
static const Y_PORTSTATE_enum PORTSTATE_INVALID
static int DefaultCacheValidity
static const int BAUDRATE_INVALID
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
YHubPortValueCallback _valueCallbackHubPort
static const Y_ENABLED_enum ENABLED_INVALID
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)
void(* YHubPortValueCallback)(YHubPort *func, const string &functionValue)
static YHubPort * FindHubPort(string func)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
static YFunction * _FindFromCache(const string &classname, const string &func)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
virtual int registerValueCallback(YHubPortValueCallback callback)
YHubPort * nextHubPort(void)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
virtual int _invokeValueCallback(string value)
Y_PORTSTATE_enum get_portState(void)
YHubPort(const string &func)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
int set_enabled(Y_ENABLED_enum newval)
static void _UpdateValueCallbackList(YFunction *func, bool add)
static YHubPort * FirstHubPort(void)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
virtual int _parseAttr(YJSONObject *json_val)
Y_PORTSTATE_enum _portState
virtual int _invokeValueCallback(string value)