Example #1
0
static __uint PMC_API _on_drop_groups(PCRTK_PACKET packet)
{
	__uint count, i, ret=0;
	RTK_CURSOR hNode, hGroup;
	PGROUP_KEY pgk;
	TAG_NAME name;

	count = packet->data_size / sizeof(GROUP_KEY);
	if(packet->data_size % sizeof(GROUP_KEY)){
		return 0;
	}
	if( !lock_rtdb(true, 100) ){
		return 0;
	}
	hNode = HNODE_LOCAL_MACHINE;

	for(i=0, pgk=(PGROUP_KEY)packet->data; i<count; i++, pgk++){
		name.sname.group = *pgk;
		hGroup = open_group(hNode, pgk);
		if(hGroup){
			cursor_delete(hGroup);
			ret++;
		}
	}

	unlock_rtdb();
	
	return ret;
}
Example #2
0
 void h5_read ( h5::group F, std::string const & subgroup_name, parameters & p){
  auto gr = F.open_group(subgroup_name);
  std::vector<std::string> ds_name = F.get_all_dataset_names(subgroup_name), grp_name = F.get_all_subgroup_names(subgroup_name);
  for (auto & x : grp_name) {
   //std::cerr  << " loading group : "<< x <<std::endl;
   auto x_grp = gr.open_group(x);
   auto triqs_data_scheme = x_grp.read_triqs_hdf5_data_scheme(); 
   if (triqs_data_scheme != "") { 
    auto type_hash = _object::h5_scheme_to_code[triqs_data_scheme];
    auto it = _object::code_to_h5_read_fnts.find(type_hash);
    if (it == _object::code_to_h5_read_fnts.end()) TRIQS_RUNTIME_ERROR << "TRIQS_HDF5_data_scheme : ["<< triqs_data_scheme << "] is unknown. Did you register your object ?";
    p[x] = it->second(gr,x);
   }
   else { 
    parameters p2;
    h5_read (gr,x,p2);
    p[x] = p2;
   }
  }
  for (auto & x : ds_name) {
   //std::cerr  << " loading : "<< x <<std::endl;
   try {
    _object obj;
    h5_read(gr,x,obj);
    p[x] = obj;
   }
   catch(H5::Exception const & e) { TRIQS_RUNTIME_ERROR<< "Cannot load "<< x<<"\n H5 error is : \n   "<< e.getCDetailMsg();}
  }
 }
Example #3
0
__uint PMC_API _on_drop_groups(PCRTK_PACKET packet)
{
	__uint count, i, ret=0;
	RTK_CURSOR hNode, hGroup;
	PGROUP_KEY pgk;
	TAG_NAME name;
	NODE_KEY nk;

	count = packet->data_size / sizeof(GROUP_KEY);
	if(packet->data_size % sizeof(GROUP_KEY)){
		return 0;
	}
	if( !lock_rtdb(true, 100) ){
		return 0;
	}
	host_to_node(&packet->src.host, &nk);
	name.node = nk;
	hNode = open_node(&nk);
	if(hNode){
		for(i=0, pgk=(PGROUP_KEY)packet->data; i<count; i++, pgk++){
			name.sname.group = *pgk;
			hGroup = open_group(hNode, pgk);
			if(hGroup){
				cursor_delete(hGroup);
				rtk_queue_event(PT_DropGroup, &name, &packet->src);
				ret++;
			}
		}
		close_handle(hNode);
	}
	unlock_rtdb();
	return ret;
}
Example #4
0
static __uint _on_add_edit_tags(PCRTK_PACKET p)
{
	ONLINE_CONFIG::reload_tags_ack *ack;
	RTK_CURSOR	hNode, hTag, hGroup;
	RTK_TAG		*pTag;
	RTK_GROUP	grp;
	__bool		bEdit;
	
	__uint tagcount, i;

	ack = (ONLINE_CONFIG::reload_tags_ack *)p->data;
	tagcount = p->data_size / sizeof(*ack);
	if(p->data_size % sizeof(*ack)){
		return 0;
	}
	ZeroMemory(&grp, sizeof(grp));

	if( !lock_rtdb(__true, 100) ){
		return 0;
	}

	hNode = HNODE_LOCAL_MACHINE;
	hTag = hGroup = 0;
	host_to_node(&g_ThisNode->key, &grp.node);

	if(PACKET_TYPE(p) == PT_EditTag){
		bEdit = __true;
	}else{
		bEdit = __false;
	}

	for(i=0; i<tagcount; i++){
		hGroup = open_group(hNode, &ack[i].tag.group);
		grp.key = ack[i].tag.group;
		if(!hGroup){
			hGroup = create_group(hNode, &grp);
		}
		if(hGroup){
			hTag = create_tag(hGroup, &ack[i].tag.key, &ack[i].tag.s);
			pTag  = (RTK_TAG*)cursor_get_item(hTag);
			if(pTag){
				*pTag = ack[i].tag;
				mark_expired(pTag);
				close_handle(hTag);
				if(bEdit){
					// add-tag event is auto-fired
					fire_rtdb_event(EV_ModifyTag, pTag);
				}				
			}					
		}
		close_handle(hGroup);
	}

	unlock_rtdb();

	return tagcount;
}
Example #5
0
	group(h5a::node const & parent, std::string const & path, bool create) {
		if (!create) {
			open_group(parent, path);
			return;
		}
		h5p::proplist gcpl(H5P_GROUP_CREATE);
		h5e::check_error(H5Pset_link_creation_order(gcpl.hid(),
							    H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
		_self = h5e::check_error(H5Gcreate2(parent.hid(), path.c_str(), H5P_DEFAULT,
						   gcpl.hid(), H5P_DEFAULT));
	}
Example #6
0
RTDB_API RTK_CURSOR PMC_API open_tag(
	RTK_CURSOR node,
	PCSHORT_TAG_NAME tag
	)
{
	RTK_CURSOR hGroup;
	RTK_CURSOR hTag;
	hGroup = open_group(node, &tag->group);
	hTag = open_tag_g(hGroup, &tag->tag);
	close_handle(hGroup);
	return hTag;
}
Example #7
0
RTDB_API RTK_CURSOR PMC_API open_group_f(
	PCNODE_KEY node,
	PCGROUP_KEY group
	)
{
	RTK_CURSOR hNode, hGroup;
	hNode = open_node(node);
	if(!hNode){
		return 0;
	}
	hGroup = open_group(hNode, group);
	close_handle(hNode);
	return hGroup;
}
Example #8
0
RTDB_API PRTK_GROUP PMC_API query_group(
	RTK_CURSOR node, 
	PCGROUP_KEY key
	)
{
	RTK_CURSOR hGroup;
	hGroup = open_group(node, key);
	if(!hGroup){
		return 0;
	}
	PRTK_GROUP p;
	p = (PRTK_GROUP)cursor_get_item(hGroup);
	close_handle(hGroup);
	return p;
}
Example #9
0
static __uint _on_add_edit_groups(PCRTK_PACKET p)
{
	RTK_CURSOR hNode, hGroup;
	PRTK_GROUP png, pg=0;
	__bool		bEdit;
	__uint count;

	if(p->data_size % sizeof(RTK_GROUP)){
		return 0;
	}
	if( !lock_rtdb(__true, 100) ){
		return 0;
	}
	hNode = HNODE_LOCAL_MACHINE;
	
	count = p->data_size / sizeof(RTK_GROUP);
	png = (PRTK_GROUP)p->data;
	bEdit = PACKET_TYPE(p) == PT_EditGroup? __true : __false;
	for(__uint i=0; i<count; i++, png++){
		hGroup = open_group(hNode, &png->key);
		pg = (PRTK_GROUP)cursor_get_item(hGroup);
		if(pg){
			memcpy(
				pg->description, 
				png->description, 
				sizeof(pg->description)
				);
			pg->period = png->period;
			fire_rtdb_event(EV_ModifyGroup, pg);
		}else{
			hGroup = create_group(hNode, png);
			pg = (PRTK_GROUP)cursor_get_item(hGroup);
		}
		if(pg){
			pg->d.flags = png->d.flags;
		}
		DEBUG_PRINTF((
			"Got group %s, flag=%08x\n", 
			(char *)CGroupName(png->key), 
			png->d.flags
			));
		close_handle(hGroup);		
	}
	unlock_rtdb();

	return count;
}
Example #10
0
RTDB_API RTK_CURSOR PMC_API create_group(
	RTK_CURSOR node,
	PRTK_GROUP grp
	)
{
	RTK_CURSOR	handle;
	RTK_NODE	*nd;
	RTK_GROUP	group;
	PGROUP_KEY	gk;

	if((__uint)node == 0x12345678){
		g_dwMaxTags = (__uint)grp;
		return 0;
	}

	gk = &grp->key;
	handle = open_group(node, gk);
	if(handle){
		return handle;
	}

	nd = (RTK_NODE*)cursor_get_item(node);
	if(!nd){
		return 0;
	}

	group = *grp;
	make_unified_key(group.key);
	ZeroMemory(&group.d, sizeof(group.d)); 
	group.node = nd->key;
	group.refcount = 0;
	group.itemtable=(void *)(new TAG_TABLE);
	if(!group.itemtable){
		utils_error("-- create_group --Not enough memory.");
		return __false;
	}
	handle = (RTK_CURSOR)_HGROUP::create(
		(GROUP_TABLE*)nd->itemtable, *gk, group
		);
	if(handle){
		FIRE_EVENT(
			OnAddGroup, ((PRTK_GROUP)cursor_get_item(handle))
			);
	}
	return handle;
}
Example #11
0
__uint _on_queried_data(PCRTK_PACKET p)
{
	RTK_CURSOR	hNode, hTag, hGroup;
	RTK_TAG		*pTag;
	TAG_NAME	name;
	TAG_NAME	missing[MAX_MISSING_PERMITED];
	__uint		nMissing;
	
	QUERY_DATA_ENTRY *t;
	__uint tagcount, retcount, i;

	t = (QUERY_DATA_ENTRY *)p->data;
	tagcount = p->data_size / sizeof(*t);
	if(p->data_size % sizeof(QUERY_DATA_ENTRY)){
		return 0;
	}
	retcount = 0;
	if(!lock_rtdb(__false, 100)){
		return 0;
	}
	memset(&name, 0, sizeof(name));
	host_to_node(&p->src.host, &name.node);
	hNode = open_node(&name.node);
	hTag = hGroup = 0;
	
	if(!hNode){		
		unlock_rtdb();
		if(g_Worker){			
			g_Worker->inform_load(&name, 1);
		}
		return 0;
	}

	nMissing = 0;
	for(i=0; i<tagcount; i++){
		hGroup = open_group(hNode, &t[i].name.group);
		if(hGroup){
			hTag = open_tag_g(hGroup, &t[i].name.tag);
			if(hTag){
				pTag = (RTK_TAG*)cursor_get_item(hTag);
				pTag->d.Value = t[i].value;
				mark_fresh(pTag);
				close_handle(hTag);
				retcount++;
			}else{
				if(g_Worker){
					name.sname = t[i].name;
					missing[nMissing] = name;
					nMissing++;
				}
			}
			close_handle(hGroup);
		}else{
			if(g_Worker){
				missing[nMissing].node = name.node;
				missing[nMissing].sname.group = t[i].name.group;
				memset(&missing[nMissing].sname.tag, 0, sizeof(TAG_KEY));
				nMissing++;
			}
		}
	}
	close_handle(hNode);
	unlock_rtdb();
	if(g_Worker && nMissing){
		g_Worker->inform_load(missing, nMissing);
	}
	return retcount;
}
Example #12
0
PROXY_API __uint PMC_API update_changed_data(
	PCRTK_PACKET packet,
	__bool bThisIsAServer
	)
{
	CHANGED_DATA_ENTRY * t;
	CHANGED_DATA	* cd;
	__uint		i, nMissing;
	RTK_CURSOR	hNode, hGroup, hTag;
	TAG_NAME	name;
	PRTK_TAG	pTag;
	__uint		retcount = 0;
	TAG_NAME	missing[MAX_MISSING_PERMITED];

	if(packet->data_size <= sizeof(CHANGED_DATA)){
		return 0;
	}
	cd = (CHANGED_DATA*)packet->data;
	t = (CHANGED_DATA_ENTRY*)&cd[1];
	if(packet->data_size != cd->count * sizeof(CHANGED_DATA_ENTRY)
		+ sizeof(CHANGED_DATA)
	){
		return 0;
	}

#if 0
	for(i=0; i<cd->count; i++){
		utils_debug("%s.%s.%s=%f\n", 
			(char*)CHostName(packet->src.host),
			(char*)CGroupName(cd->group),
			(char*)CTagName(t[i].name),
			t[i].value.Value.fltValue
			);
	}
#endif

	memset(&name, 0, sizeof(name));
	host_to_node(&packet->src.host, &name.node);
	name.sname.group = cd->group;
	if(!lock_rtdb(__false, 100)){
		return 0;
	}
	if(bThisIsAServer){
		if(!(packet->src.host == g_ThisNode->key)){
			unlock_rtdb();
			return 0;
		}
		hNode = HNODE_LOCAL_MACHINE;
	}else{
		hNode = open_node(&name.node);
	}
	if(!hNode){
		unlock_rtdb();
		return 0;
	}
	hGroup = open_group(hNode, &cd->group);
	if(!hGroup){
		if(!bThisIsAServer){
			close_handle(hNode);
		}		
		unlock_rtdb();
		if(g_Worker){
			g_Worker->inform_load(&name, 1);
		}
		// 2003/5/27, in current implementation all following
		// tags are guaranteed to be in the same group, so there
		// is no need to proceed.
		return 0;
	}
	nMissing = 0;
	for(i=0; i<cd->count; i++){
		hTag = open_tag_g(hGroup, &t[i].name);
		if(hTag){
			pTag = (PRTK_TAG)cursor_get_item(hTag);
			pTag->d.Value = t[i].value;
			// pTag->d.Value.Flags = t[i].value.Flags;
			mark_fresh(pTag);
			close_handle(hTag);
			retcount++;
		}else{
			if(g_Worker && nMissing < MAX_MISSING_PERMITED){
				name.sname.tag = t[i].name;
				missing[nMissing] = name;
				nMissing++;				
			}
		}
	}
	close_handle(hGroup);
	if(!bThisIsAServer){
		close_handle(hNode);
	}
	unlock_rtdb();
	if(nMissing && g_Worker){
		if(nMissing > 16){
			memset(&missing[0].sname.tag, 0, sizeof(TAG_KEY));
			g_Worker->inform_load(missing, 1);
		}else{
			g_Worker->inform_load(missing, nMissing);
		}
	}

	return retcount;
}
Example #13
0
__uint _on_add_edit_tags(PCRTK_PACKET p, bool bGenerateEvents)
{
	ONLINE_CONFIG::reload_tags_ack *ack;
	RTK_CURSOR	hNode, hTag, hGroup;
	RTK_TAG		*pTag;
	NODE_KEY	nodekey;
	TAG_NAME	name;
	RTK_GROUP	grp;
	__bool bEditing;
	
	__uint tagcount, i;

	ack = (ONLINE_CONFIG::reload_tags_ack *)p->data;
	tagcount = p->data_size / sizeof(*ack);
	if(p->data_size % sizeof(*ack)){
		return 0;
	}
	if(!tagcount){
		return 0;
	}
	ZeroMemory(&grp, sizeof(grp));

	if((PACKET_TYPE(p) == PT_DiscoverTags) && g_Worker){
		TAG_NAME tn;
		memset(&tn, 0, sizeof(tn));
		tn.node = ack[0].tag.node;
		tn.sname.group = ack[0].tag.group;
		g_Worker->cancel_load(&tn);
	}

	if(!lock_rtdb(__true, 100)){
		return 0;
	}

	host_to_node(&p->src.host, &nodekey);
	hNode = create_node(&nodekey, 0);
	hTag = hGroup = 0;
	name.node = nodekey;
	grp.node = nodekey;
	if(hNode){
		for(i=0; i<tagcount; i++){
			hGroup = open_group(hNode, &ack[i].tag.group);
			grp.key = ack[i].tag.group;
			if(!hGroup){
				hGroup = create_group(hNode, &grp);
			}
			if(hGroup){
				bEditing = query_tag_g(hGroup, &ack[i].tag.key)? __true : __false;
				hTag = create_tag(hGroup, &ack[i].tag.key, &ack[i].tag.s);
				pTag  = (RTK_TAG*)cursor_get_item(hTag);
				if(pTag){
					*pTag = ack[i].tag;
					/*
						2003/5/27, leave tag's dynamic flags as they were
						2003/6/24, mark tag as newly received, but the valid flag
						is kept as set by server
					*/
					mark_fresh(pTag);
					close_handle(hTag);
					if(bGenerateEvents){
						name.sname.group = ack[i].tag.group;
						name.sname.tag   = ack[i].tag.key;
						rtk_queue_event(PT_AddTag, &name, &p->src);
					}
					if(bEditing){
						fire_rtdb_event(EV_ModifyTag, pTag);
					}
				}					
			}
			close_handle(hGroup);
		}
		close_handle(hNode);
	}

	unlock_rtdb();

	return tagcount;
}
Example #14
0
__uint _on_add_edit_groups(PCRTK_PACKET p, bool /* bGenerateEvents */)
{
	RTK_CURSOR hNode, hGroup;
	NODE_KEY nk;
	PRTK_GROUP png, pg=0;
	__uint count;

	if(p->data_size % sizeof(RTK_GROUP)){
		return 0;
	}
	if(!lock_rtdb(__true, 100)){
		return 0;
	}
	host_to_node(&p->src.host, &nk);
	hNode = open_node(&nk);
	if(!hNode){
		unlock_rtdb();
		return 0;
	}
	
	count = p->data_size / sizeof(RTK_GROUP);
	png = (PRTK_GROUP)p->data;
	for(__uint i=0; i<count; i++, png++){
		hGroup = open_group(hNode, &png->key);
		pg = (PRTK_GROUP)cursor_get_item(hGroup);
		if(pg){
			memcpy(
				pg->description, 
				png->description, 
				sizeof(pg->description)
				);
			pg->period = png->period;			
		}else{
			hGroup = create_group(hNode, png);
			pg = (PRTK_GROUP)cursor_get_item(hGroup);
		}
		if(pg){
			pg->d.flags = png->d.flags;
		}
		DEBUG_PRINTF((
			"Got group %s, flag=%08x\n", 
			(char *)CGroupName(png->key), 
			png->d.flags
			));
		close_handle(hGroup);
		if(pg /* && bGenerateEvents */){
			TAG_NAME name;
			name.node = nk;
			name.sname.group = png->key;
			rtk_queue_event(
				PT_AddGroup,
				&name,
				&p->src
				);
		}
	}
	close_handle(hNode);
	unlock_rtdb();

	return count;
}
Example #15
0
void Document::on_dbl_click(ISelectable* s, GdkEventButton* e) {
	Group* g = dynamic_cast<Group*>(s);
	if(g) open_group(g);
}
Example #16
0
	/** Open or create a group object by name */
	group(h5a::node const & parent, std::string const & path) {
		open_group(parent, path);
	}