Exemplo n.º 1
0
/*
	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();
}
Exemplo n.º 2
0
RTDB_API void PMC_API uninit_rtdb(void)
{
	lock_rtdb(__true, INFINITE);
	RTK_CURSOR hNode;	
	
	close_handle(g_hLocalNode);
	g_hLocalNode = 0;
	
	hNode = open_first_node();
	while( !cursor_is_end(hNode) ){
		cursor_delete(hNode);
		hNode = open_first_node();
	}
	close_handle(hNode);
	unlock_rtdb();
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
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);
}