/* determine which tags should be saved to history database. */ void CInMemoryBuffer::buildStreamList() { RTK_CURSOR hNode; RTK_CURSOR hGroup; RTK_CURSOR hTag; PCRTK_TAG pTag; TAG_NAME tn; char nodeName[rtkm_node_key_length + 1]; GetPrivateProfileString( "PMC", "ServerName", "LocalServer", nodeName, sizeof(nodeName), get_config_file() ); CNodeName nodeKey(nodeName); //utils_debug("wlock 3\n"); WriteLock(); if(!lock_rtdb(__false, 100)){ //utils_debug("release 6\n"); Release(); return; } // clear list clearStreamList(); hNode = open_node(nodeKey); if(hNode){ hGroup = cursor_open_first_subitem(hNode); while(!cursor_is_end(hGroup)){ hTag = cursor_open_first_subitem(hGroup); while(!cursor_is_end(hTag)){ pTag = (PCRTK_TAG)cursor_get_item(hTag); if(pTag->s.Flags & TF_SaveToHistory){ tn.node = pTag->node; tn.sname.group = pTag->group; tn.sname.tag = pTag->key; addTag(&tn); } cursor_move_next(hTag); } close_handle(hTag); cursor_move_next(hGroup); } close_handle(hGroup); } unlock_rtdb(); //utils_debug("release 7\n"); Release(); }
void attach_device_tags(PDEVICE_INFO d) { RTK_CURSOR handle; PRTK_GROUP p; handle = cursor_open_first_subitem(HNODE_LOCAL_MACHINE); while(!cursor_is_end(handle)){ p = (PRTK_GROUP)cursor_get_item(handle); RTK_CURSOR hTag; PRTK_TAG pTag; hTag = cursor_open_first_subitem(handle); while(pTag = (PRTK_TAG)cursor_get_item(hTag)){ if(pTag->s.Device == d->k){ attach_tag_to_device(pTag, d); } cursor_move_next(hTag); } close_handle(hTag); cursor_move_next(handle); } close_handle(handle); }
void CDCSItem::ReloadContents() { RTK_CURSOR hNode; PRTK_NODE pNode; CNodeItem *item; RemoveChildren(); // discover all running nodes // discover_nodes(1000); hNode = open_first_node(); pNode = (PRTK_NODE)cursor_get_item(hNode); while( pNode ){ item = new CNodeItem(&pNode->key); AddChild(item); cursor_move_next(hNode); pNode = (PRTK_NODE)cursor_get_item(hNode); } close_handle(hNode); }
void CDBItem::ReloadContents() { CConfigurableItem *item; // discover_groups(&key, 2000); RTK_CURSOR hNode, hGroup; PRTK_GROUP pGroup; hNode = open_node(&key); if(!hNode){ return; } hGroup = cursor_open_first_subitem(hNode); pGroup = (PRTK_GROUP)cursor_get_item(hGroup); while(pGroup){ item = new CGroupItem(&key, &pGroup->key); AddChild(item); cursor_move_next(hGroup); pGroup = (PRTK_GROUP)cursor_get_item(hGroup); } close_handle(hGroup); close_handle(hNode); }
void TframDB::UpdateView() { int nGroups; int nTags; RTK_CURSOR hNode; hNode = open_node(&key); if(!hNode){ nGroups = 0; }else{ nGroups = cursor_get_subitem_count(hNode); } RTK_CURSOR hGroup; hGroup = cursor_open_first_subitem(hNode); nTags = 0; while(!cursor_is_end(hGroup)){ nTags += cursor_get_subitem_count(hGroup); cursor_move_next(hGroup); } close_handle(hGroup); close_handle(hNode); lblHint->Caption = "分组总数: " + AnsiString(nGroups); lblTagCount->Caption = "标签总数:" + AnsiString(nTags); }