void SOMClusteringSpace::getPartitionConfiguration() {
  vector<int> indices;
  //Create equivalent indices
  for ( int i = 0; i < (int)assignation.size();i++) {
    int val = assignation.at(i);
    if ( belongs_to( val, indices ) == -1 ) {
      indices.push_back( val );
    }
  }
  for ( int i = 0; i < (int)indices.size(); i++ ) {
    string group_name("");
    group_name.append(patterns_prop_name).append("_");
    group_name.append(static_cast<ostringstream*>(&(ostringstream()<<i))->str() );
    pGraph->addSubGraph(group_name);
  }
  //Now, define the groups
  //IntegerProperty* group = theGraph->getLocalProperty<IntegerProperty>(patterns_prop_name);
  string group_name("");
  Iterator<node>* node_iter = pGraph->getNodes();
  while ( node_iter->hasNext() ) {
    node n = node_iter->next();
    int id = n.id;
    int val = assignation.at(id);
    int new_index = belongs_to( val, indices );
    group_name.append(patterns_prop_name).append("_").append(static_cast<ostringstream*>(&(ostringstream()<<new_index))->str() );
    pGraph->getSubGraph(group_name)->addNode(n);
  	//group->setNodeValue(n,new_index);
    //group_name = "";
  }
  delete node_iter;
}
Exemple #2
0
struct name_list *get_list(const struct stat *st, acl_t acl)
{
	struct name_list *first = NULL, *last = NULL;
	acl_entry_t ent;
	int ret = 0;

	if (acl != NULL)
		ret = acl_get_entry(acl, ACL_FIRST_ENTRY, &ent);
	if (ret != 1)
		return NULL;
	while (ret > 0) {
		acl_tag_t e_type;
		const id_t *id_p;
		const char *name = "";
		int len;

		acl_get_tag_type(ent, &e_type);
		switch(e_type) {
			case ACL_USER_OBJ:
				name = user_name(st->st_uid, opt_numeric);
				break;

			case ACL_USER:
				id_p = acl_get_qualifier(ent);
				if (id_p != NULL)
					name = user_name(*id_p, opt_numeric);
				break;

			case ACL_GROUP_OBJ:
				name = group_name(st->st_gid, opt_numeric);
				break;

			case ACL_GROUP:
				id_p = acl_get_qualifier(ent);
				if (id_p != NULL)
					name = group_name(*id_p, opt_numeric);
				break;
		}
		name = xquote(name, "\t\n\r");
		len = strlen(name);
		if (last == NULL) {
			first = last = (struct name_list *)
				malloc(sizeof(struct name_list) + len + 1);
		} else {
			last->next = (struct name_list *)
				malloc(sizeof(struct name_list) + len + 1);
			last = last->next;
		}
		if (last == NULL) {
			free_list(first);
			return NULL;
		}
		last->next = NULL;
		strcpy(last->name, name);

		ret = acl_get_entry(acl, ACL_NEXT_ENTRY, &ent);
	}
	return first;
}
void CommunitySpace::getFinalAssignation( string group_prop_name ) {
    int i;
    int level = 1;
    IntegerProperty* g_assignation = originalGraph->getLocalProperty<IntegerProperty>(group_prop_name);
    ColorProperty* color = originalGraph->getLocalProperty<ColorProperty>("viewColor");
    int communities = theGraph->numberOfNodes();
    //cout << "Calculating final assignation for " << communities << " communities." << endl;
    string group_name("");
    for ( i = 0; i < communities; i++ ) {
        group_name.append(group_prefix).append("_").append(static_cast<ostringstream*>(&(ostringstream()<<i))->str() );
        hierarchy[i] = originalGraph->addSubGraph(group_name);
        group_name = "";
    }
    calculateColorTable(communities);
    color->setAllEdgeValue(Color(0,0,0,5));
    Iterator<node>* nodes = originalGraph->getNodes();
    while ( nodes->hasNext() ) {
        node n = nodes->next();
        i = n.id;
        int index = finalAssignation[0][i];
        while ( level < (int)finalAssignation.size() ) {
            int nindex = finalAssignation[level][index];
            index = nindex;
            level++;
        }
        level = 1;
        addNodeToGroup(index, n, g_assignation, color);
    }
    delete nodes;
}
Exemple #4
0
    // static
    bool FieldTrialList::CreateTrialsInChildProcess(
        const std::string& parent_trials)
    {
        DCHECK(global_);
        if(parent_trials.empty() || !global_)
        {
            return true;
        }

        size_t next_item = 0;
        while(next_item < parent_trials.length())
        {
            size_t name_end = parent_trials.find(kPersistentStringSeparator, next_item);
            if(name_end==parent_trials.npos || next_item==name_end)
            {
                return false;
            }
            size_t group_name_end = parent_trials.find(kPersistentStringSeparator,
                name_end+1);
            if(group_name_end==parent_trials.npos || name_end+1==group_name_end)
            {
                return false;
            }
            std::string name(parent_trials, next_item, name_end-next_item);
            std::string group_name(parent_trials, name_end+1,
                group_name_end-name_end-1);
            next_item = group_name_end + 1;

            if(!CreateFieldTrial(name, group_name))
            {
                return false;
            }
        }
        return true;
    }
Exemple #5
0
 /**
  *  获取群信息
  *
  *  @param pPdu      收到的packet包指针
  *  @param conn_uuid 该包过来的socket 描述符
  */
 void getGroupInfo(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Group::IMGroupInfoListReq msg;
     IM::Group::IMGroupInfoListRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         CImPdu* pPduRes = new CImPdu;
         uint32_t nUserId = msg.user_id();
         uint32_t nGroupCnt = msg.group_version_list_size();
         
         map<uint32_t, IM::BaseDefine::GroupVersionInfo> mapGroupId;
         for(uint32_t i=0; i<nGroupCnt; ++i)
         {
             IM::BaseDefine::GroupVersionInfo groupInfo = msg.group_version_list(i);
             if(CGroupModel::getInstance()->isValidateGroupId(groupInfo.group_id()))
             {
                 mapGroupId[groupInfo.group_id()] = groupInfo;
             }
         }
         list<IM::BaseDefine::GroupInfo> lsGroupInfo;
         CGroupModel::getInstance()->getGroupInfo(mapGroupId, lsGroupInfo);
         
         msgResp.set_user_id(nUserId);
         for(auto it=lsGroupInfo.begin(); it!=lsGroupInfo.end(); ++it)
         {
             IM::BaseDefine::GroupInfo* pGroupInfo = msgResp.add_group_info_list();
 //            *pGroupInfo = *it;
             pGroupInfo->set_group_id(it->group_id());
             pGroupInfo->set_version(it->version());
             pGroupInfo->set_group_name(it->group_name());
             pGroupInfo->set_group_avatar(it->group_avatar());
             pGroupInfo->set_group_creator_id(it->group_creator_id());
             pGroupInfo->set_group_type(it->group_type());
             pGroupInfo->set_shield_status(it->shield_status());
             uint32_t nGroupMemberCnt = it->group_member_list_size();
             for (uint32_t i=0; i<nGroupMemberCnt; ++i)
             {
                 uint32_t userId = it->group_member_list(i);
                 pGroupInfo->add_group_member_list(userId);
             }
         }
         
         log("userId=%u, requestCount=%u", nUserId, nGroupCnt);
         
         msgResp.set_attach_data(msg.attach_data());
         pPduRes->SetPBMsg(&msgResp);
         pPduRes->SetSeqNum(pPdu->GetSeqNum());
         pPduRes->SetServiceId(IM::BaseDefine::SID_GROUP);
         pPduRes->SetCommandId(IM::BaseDefine::CID_GROUP_INFO_RESPONSE);
         CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
     }
     else
     {
         log("parse pb failed");
     }
 }
Exemple #6
0
void	format_long(char *name, t_stat st, t_env *e)
{
	ino_number(st, e);
	file_mode(st);
	number_of_link(st, e);
	owner_name(st, e);
	group_name(st, e);
	number_of_bytes(st, e);
	last_modif(e, st);
	path_name(name, st, e);
}
Exemple #7
0
int			max_group(char **tab, char *option)
{
	int			max;
	t_stat		*buf;
	int			j;

	j = 0;
	max = 0;
	(!(buf = (t_stat*)malloc(sizeof(t_stat)))) ? perror_malloc() : 0;
	while (tab[j])
	{
		if ((IS_A_2 && !is_main(tab[j]))
				|| IS_A || IS_F || !(is_hidden(tab[j])))
		{
			init_buf(tab[j], &buf);
			if ((int)ft_strlen(group_name(buf->st_gid)) > max)
				max = ft_strlen(group_name(buf->st_gid));
		}
		++j;
	}
	ft_tstatdel(&buf);
	return (max);
}
Exemple #8
0
herr_t fetch_pixel_name(hid_t loc_id, const char *name, void *opdata) {
	std::vector<std::string> *pix_name = reinterpret_cast<std::vector<std::string>*>(opdata);
	
	std::string group_name(name);
	//group_name << name;
	
	//std::string tmp_name;
	try {
		//group_name >> tmp_name;
		pix_name->push_back(group_name);
	} catch(...) {
		// pass
	}
	
	return 0;
}
Exemple #9
0
static void	disp_all(char *file, t_stat *buf, t_max *max, char *option)
{
	disp_permit(buf->st_mode);
	disp_xattr(file);
	disp_link(buf, max->max_lnk);
	if (!(IS_G))
		disp_owner(owner_name(buf->st_uid), max->max_user);
	if (!(IS_O))
		disp_group(group_name(buf->st_gid), max->max_group);
	if (IS_O && IS_G)
		write(1, "  ", 2);
	disp_size(buf, max->max_size, max->is_b_c_file);
	ft_putstr(s_time(buf));
	write(1, " ", 1);
	(is_lnk(file)) ? disp_lnk_name(file) : 0;
	if (!(is_lnk(file)))
		ft_putstr_name(file);
	if (IS_P && is_file_or_dir(file) == 2)
		write(1, "/", 1);
	if (!(is_lnk(file)))
		write(1, "\n", 1);
}
Exemple #10
0
static void group_target(tree_t t, group_nets_ctx_t *ctx)
{
   switch (tree_kind(t)) {
   case T_REF:
      group_ref(t, ctx, 0, -1);
      break;

   case T_ARRAY_REF:
   case T_ARRAY_SLICE:
   case T_RECORD_REF:
      {
         type_t type = tree_type(t);
         if (!type_known_width(type))
            ungroup_name(t, ctx);
         else if (!group_name(t, ctx, 0, type_width(type)))
            ungroup_name(t, ctx);
      }
      break;

   case T_LITERAL:
   case T_OPEN:
      // Constant folding can cause this to appear
      break;

   case T_AGGREGATE:
      {
         const int nassocs = tree_assocs(t);
         for (int i = 0; i < nassocs; i++)
            group_target(tree_value(tree_assoc(t, i)), ctx);
      }
      break;

   default:
      fmt_loc(stdout, tree_loc(t));
      fatal_trace("Cannot handle tree kind %s in group_target",
                  tree_kind_str(tree_kind(t)));
   }
}
Exemple #11
0
static bool group_name(tree_t target, group_nets_ctx_t *ctx, int start, int n)
{
   switch (tree_kind(target)) {
   case T_REF:
      group_ref(target, ctx, start, n);
      return true;

   case T_ARRAY_REF:
      {
         tree_t value = tree_value(target);

         type_t type = tree_type(value);
         if (type_is_unconstrained(type))
            return false;

         int offset = 0;
         const int nparams = tree_params(target);
         for (int i = 0; i < nparams; i++) {
            tree_t index = tree_value(tree_param(target, i));
            const int stride = type_width(type_elem(type));

            if (tree_kind(index) != T_LITERAL) {
               if (i > 0)
                  return false;

               const int twidth = type_width(type);
               for (int j = 0; j < twidth; j += stride)
                  group_name(value, ctx, start + j, n);
               return true;
            }
            else {
               if (i > 0) {
                  range_t type_r = range_of(type, i);
                  int64_t low, high;
                  range_bounds(type_r, &low, &high);
                  offset *= high - low + 1;
               }

               offset += stride * rebase_index(type, i, assume_int(index));
            }
         }

         return group_name(value, ctx, start + offset, n);
      }

   case T_ARRAY_SLICE:
      {
         tree_t value = tree_value(target);
         type_t type  = tree_type(value);

         if (type_is_unconstrained(type))
            return false;    // Only in procedure

         range_t slice = tree_range(target, 0 );

         if (tree_kind(slice.left) != T_LITERAL
             || tree_kind(slice.right) != T_LITERAL)
            return false;

         int64_t low, high;
         range_bounds(slice, &low, &high);

         const int64_t low0 = rebase_index(type, 0, assume_int(slice.left));
         const int stride   = type_width(type_elem(type));

         return group_name(value, ctx, start + low0 * stride, n);
      }

   case T_RECORD_REF:
      {
         tree_t value = tree_value(target);
         type_t rec = tree_type(value);
         const int offset = record_field_to_net(rec, tree_ident(target));

         return group_name(value, ctx, start + offset, n);
      }

   case T_AGGREGATE:
   case T_LITERAL:
      // This can appear due to assignments to open ports with a
      // default value
      return true;

   default:
      fatal_at(tree_loc(target), "tree kind %s not yet supported for offset "
               "calculation", tree_kind_str(tree_kind(target)));
   }
}
Exemple #12
0
int do_print(const char *path_p, const struct stat *st, int walk_flags, void *unused)
{
	const char *default_prefix = NULL;
	acl_t acl = NULL, default_acl = NULL;
	int error = 0;

	if (walk_flags & WALK_TREE_FAILED) {
		fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p, "\n\r"),
			strerror(errno));
		return 1;
	}

	/*
	 * Symlinks can never have ACLs, so when doing a physical walk, we
	 * skip symlinks altogether, and when doing a half-logical walk, we
	 * skip all non-toplevel symlinks. 
	 */
	if ((walk_flags & WALK_TREE_SYMLINK) &&
	    ((walk_flags & WALK_TREE_PHYSICAL) ||
	     !(walk_flags & (WALK_TREE_TOPLEVEL | WALK_TREE_LOGICAL))))
		return 0;

	if (opt_print_acl) {
		acl = acl_get_file(path_p, ACL_TYPE_ACCESS);
		if (acl == NULL && (errno == ENOSYS || errno == ENOTSUP))
			acl = acl_get_file_mode(path_p);
		if (acl == NULL)
			goto fail;
	}

	if (opt_print_default_acl && S_ISDIR(st->st_mode)) {
		default_acl = acl_get_file(path_p, ACL_TYPE_DEFAULT);
		if (default_acl == NULL) {
			if (errno != ENOSYS && errno != ENOTSUP)
				goto fail;
		} else if (acl_entries(default_acl) == 0) {
			acl_free(default_acl);
			default_acl = NULL;
		}
	}

	if (opt_skip_base &&
	    (!acl || acl_equiv_mode(acl, NULL) == 0) && !default_acl)
		return 0;

	if (opt_print_acl && opt_print_default_acl)
		default_prefix = "default:";

	if (opt_strip_leading_slash) {
		if (*path_p == '/') {
			if (!absolute_warning) {
				fprintf(stderr, _("%s: Removing leading "
					"'/' from absolute path names\n"),
				        progname);
				absolute_warning = 1;
			}
			while (*path_p == '/')
				path_p++;
		} else if (*path_p == '.' && *(path_p+1) == '/')
			while (*++path_p == '/')
				/* nothing */ ;
		if (*path_p == '\0')
			path_p = ".";
	}

	if (opt_tabular)  {
		if (do_show(stdout, path_p, st, acl, default_acl) != 0)
			goto fail;
	} else {
		if (opt_comments) {
			printf("# file: %s\n", xquote(path_p, "\n\r"));
			printf("# owner: %s\n",
			       xquote(user_name(st->st_uid, opt_numeric), " \t\n\r"));
			printf("# group: %s\n",
			       xquote(group_name(st->st_gid, opt_numeric), " \t\n\r"));
			if ((st->st_mode & (S_ISVTX | S_ISUID | S_ISGID)) && !posixly_correct)
				printf("# flags: %s\n", flagstr(st->st_mode));
		}
		if (acl != NULL) {
			char *acl_text = acl_to_any_text(acl, NULL, '\n',
							 print_options);
			if (!acl_text)
				goto fail;
			if (puts(acl_text) < 0) {
				acl_free(acl_text);
				goto fail;
			}
			acl_free(acl_text);
		}
		if (default_acl != NULL) {
			char *acl_text = acl_to_any_text(default_acl, 
							 default_prefix, '\n',
							 print_options);
			if (!acl_text)
				goto fail;
			if (puts(acl_text) < 0) {
				acl_free(acl_text);
				goto fail;
			}
			acl_free(acl_text);
		}
	}
	if (acl || default_acl || opt_comments)
		printf("\n");

cleanup:
	if (acl)
		acl_free(acl);
	if (default_acl)
		acl_free(default_acl);
	return error;

fail:
	fprintf(stderr, "%s: %s: %s\n", progname, xquote(path_p, "\n\r"),
		strerror(errno));
	error = -1;
	goto cleanup;
}
Exemple #13
0
void Animal::load_weights_and_thresholds()
{
	if ( !m_initialised )
	{
		TEXEngine::Util::NCF1	config_file;
		std::string				source(PATH_STUFF "data/scripts/ncf/animalModifiers.ncf1");



		config_file.set_source(source.c_str());
		if ( !config_file.parse() )
		{
			if ( config_file.query_group("AnimalStatisticsConfiguration") )
			{
				TEXEngine::Util::NCF1*	animal_statistics = config_file.group("AnimalStatisticsConfiguration");



				if( sscanf(animal_statistics->get("first_threshold_value"),"%f",&m_first_threshold_value) == EOF )
					TEXEngine::Core::LogManager::get().log_error("Could not parse the first threshold value parameter");
				
				if( sscanf(animal_statistics->get("second_threshold_value"),"%f",&m_second_threshold_value) == EOF )
					TEXEngine::Core::LogManager::get().log_error("Could not parse the second threshold value parameter");

				if( sscanf(animal_statistics->get("third_threshold_value"),"%f",&m_third_threshold_value) == EOF )
					TEXEngine::Core::LogManager::get().log_error("Could not parse the third threshold value parameter");


				for ( unsigned int i = 0;  i < 4;  ++i )
				{
					std::string				group_name("");
					TEXEngine::Util::NCF1*	stat_group = NULL;



					if ( i == 0 )
						group_name = "energy";
					else if ( i == 1 )
						group_name = "morale";
					else if ( i == 2 )
						group_name = "discipline";
					else if ( i == 3 )
						group_name = "thrust";

					
					if ( animal_statistics->query_group(group_name.c_str()) )
					{
						TEXEngine::Util::NCF1*	stat_sub_group = NULL;
						float					temp = 0.0f;


						stat_group = animal_statistics->group(group_name.c_str());

						if ( stat_group->query_group("weights") )
						{
							stat_sub_group = stat_group->group("weights");

							if( sscanf(stat_sub_group->get("energy"),"%f",&temp) == EOF )
								TEXEngine::Core::LogManager::get().log_error("Could not parse the energy weight for %s ",group_name.c_str());
							else
								m_weights[i][0] = temp;

							if( sscanf(stat_sub_group->get("morale"),"%f",&temp) == EOF )
								TEXEngine::Core::LogManager::get().log_error("Could not parse the morale weight for %s ",group_name.c_str());
							else
								m_weights[i][1] = temp;

							if( sscanf(stat_sub_group->get("discipline"),"%f",&temp) == EOF )
								TEXEngine::Core::LogManager::get().log_error("Could not parse the discipline weight for %s ",group_name.c_str());
							else
								m_weights[i][2] = temp;

							if( sscanf(stat_sub_group->get("thrust"),"%f",&temp) == EOF )
								TEXEngine::Core::LogManager::get().log_error("Could not parse the thrust weight for %s ",group_name.c_str());
							else
								m_weights[i][3] = temp;
						}
						else
							TEXEngine::Core::LogManager::get().log_error("Weights for %s could not be loaded!",group_name.c_str());


						if ( stat_group->query_group("thresholds") )
						{
							stat_sub_group = stat_group->group("thresholds");

							if( sscanf(stat_sub_group->get("first"),"%f",&temp) == EOF )
								TEXEngine::Core::LogManager::get().log_error("Could not parse the first thershold for %s ",group_name.c_str());
							else
								m_thresholds[i][0] = temp;

							if( sscanf(stat_sub_group->get("second"),"%f",&temp) == EOF )
								TEXEngine::Core::LogManager::get().log_error("Could not parse the second threshold for %s ",group_name.c_str());
							else
								m_thresholds[i][1] = temp;

							if( sscanf(stat_sub_group->get("third"),"%f",&temp) == EOF )
								TEXEngine::Core::LogManager::get().log_error("Could not parse the third threshold for %s ",group_name.c_str());
							else
								m_thresholds[i][2] = temp;
						}
						else
							TEXEngine::Core::LogManager::get().log_error("Thresholds for %s could not be loaded!",group_name.c_str());
					}
					else
						TEXEngine::Core::LogManager::get().log_error("Animal statistic weightings and thresholds for %s was not found!!",group_name.c_str());
				}


				m_initialised = true;
			}
			else
				TEXEngine::Core::LogManager::get().log_error("Animal statistic weightings and thresholds group was not found!");
		}
		else
			TEXEngine::Core::LogManager::get().log_error("Animal statistic weightings and thresholds file could not be loaded!");		
	}
}
Exemple #14
0
/** Executes the algorithm. Reading in the file and creating and populating
*  the output workspace
*
*  @throw Exception::FileError If the Nexus file cannot be found/opened
*  @throw std::invalid_argument If the optional properties are set to invalid
*values
*/
void LoadNexusLogs::exec() {
  std::string filename = getPropertyValue("Filename");
  MatrixWorkspace_sptr workspace = getProperty("Workspace");

  // Find the entry name to use (normally "entry" for SNS, "raw_data_1" for
  // ISIS)
  std::string entry_name = LoadTOFRawNexus::getEntryName(filename);

  ::NeXus::File file(filename);
  // Find the root entry
  try {
    file.openGroup(entry_name, "NXentry");
  } catch (::NeXus::Exception &) {
    throw std::invalid_argument("Unknown NeXus file format found in file '" +
                                filename + "'");
  }

  /// Use frequency start for Monitor19 and Special1_19 logs with "No Time" for
  /// SNAP
  try {
    file.openPath("DASlogs");
    try {
      file.openGroup("frequency", "NXlog");
      try {
        file.openData("time");

        //----- Start time is an ISO8601 string date and time. ------
        try {
          file.getAttr("start", freqStart);

        } catch (::NeXus::Exception &) {
          // Some logs have "offset" instead of start
          try {
            file.getAttr("offset", freqStart);
          } catch (::NeXus::Exception &) {
            g_log.warning() << "Log entry has no start time indicated.\n";
            file.closeData();
            throw;
          }
        }
        file.closeData();
      } catch (::NeXus::Exception &) {
        // No time. This is not an SNS SNAP file
      }
      file.closeGroup();
    } catch (::NeXus::Exception &) {
      // No time. This is not an SNS frequency group
    }
    file.closeGroup();
  } catch (::NeXus::Exception &) {
    // No time. This is not an SNS group
  }
  // print out the entry level fields
  std::map<std::string, std::string> entries = file.getEntries();
  std::map<std::string, std::string>::const_iterator iend = entries.end();
  for (std::map<std::string, std::string>::const_iterator it = entries.begin();
       it != iend; ++it) {
    std::string group_name(it->first);
    std::string group_class(it->second);
    if (group_name == "DASlogs" || group_class == "IXrunlog" ||
        group_class == "IXselog" || group_name == "framelog") {
      loadLogs(file, group_name, group_class, workspace);
    }
    if (group_class == "IXperiods") {
      loadNPeriods(file, workspace);
    }
  }

  // If there's measurement information, load that info as logs.
  loadAndApplyMeasurementInfo(&file, *workspace);

  // Freddie Akeroyd 12/10/2011
  // current ISIS implementation contains an additional indirection between
  // collected frames via an
  // "event_frame_number" array in NXevent_data (which eliminates frames with no
  // events).
  // the proton_log is for all frames and so is longer than the event_index
  // array, so we need to
  // filter the proton_charge log based on event_frame_number
  // This difference will be removed in future for compatibility with SNS, but
  // the code below will allow current SANS2D files to load
  if (workspace->mutableRun().hasProperty("proton_log")) {
    std::vector<int> event_frame_number;
    this->getLogger().notice()
        << "Using old ISIS proton_log and event_frame_number indirection..."
        << std::endl;
    try {
      // Find the bank/name corresponding to the first event data entry, i.e.
      // one with type NXevent_data.
      file.openPath("/" + entry_name);
      std::map<std::string, std::string> entries = file.getEntries();
      std::map<std::string, std::string>::const_iterator it = entries.begin();
      std::string eventEntry;
      for (; it != entries.end(); ++it) {
        if (it->second == "NXevent_data") {
          eventEntry = it->first;
          break;
        }
      }
      this->getLogger().debug()
          << "Opening"
          << " /" + entry_name + "/" + eventEntry + "/event_frame_number"
          << " to find the event_frame_number\n";
      file.openPath("/" + entry_name + "/" + eventEntry +
                    "/event_frame_number");
      file.getData(event_frame_number);
    } catch (const ::NeXus::Exception &) {
      this->getLogger().warning() << "Unable to load event_frame_number - "
                                     "filtering events by time will not work "
                                  << std::endl;
    }
    file.openPath("/" + entry_name);
    if (!event_frame_number.empty()) // ISIS indirection - see above comments
    {
      Kernel::TimeSeriesProperty<double> *plog =
          dynamic_cast<Kernel::TimeSeriesProperty<double> *>(
              workspace->mutableRun().getProperty("proton_log"));
      if (!plog)
        throw std::runtime_error(
            "Could not cast (interpret) proton_log as a time "
            "series property. Cannot continue.");
      Kernel::TimeSeriesProperty<double> *pcharge =
          new Kernel::TimeSeriesProperty<double>("proton_charge");
      std::vector<double> pval;
      std::vector<Mantid::Kernel::DateAndTime> ptime;
      pval.reserve(event_frame_number.size());
      ptime.reserve(event_frame_number.size());
      std::vector<Mantid::Kernel::DateAndTime> plogt = plog->timesAsVector();
      std::vector<double> plogv = plog->valuesAsVector();
      for (auto number : event_frame_number) {
        ptime.push_back(plogt[number]);
        pval.push_back(plogv[number]);
      }
      pcharge->create(ptime, pval);
      pcharge->setUnits("uAh");
      workspace->mutableRun().addProperty(pcharge, true);
    }
  }
  try {
    // Read the start and end time strings
    file.openData("start_time");
    Kernel::DateAndTime start(file.getStrData());
    file.closeData();
    file.openData("end_time");
    Kernel::DateAndTime end(file.getStrData());
    file.closeData();
    workspace->mutableRun().setStartAndEndTime(start, end);
  } catch (::NeXus::Exception &) {
  }

  if (!workspace->run().hasProperty("gd_prtn_chrg")) {
    // Try pulling it from the main proton_charge entry first
    try {
      file.openData("proton_charge");
      std::vector<double> values;
      file.getDataCoerce(values);
      std::string units;
      file.getAttr("units", units);
      double charge = values.front();
      if (units.find("picoCoulomb") != std::string::npos) {
        charge *= 1.e-06 / 3600.;
      }
      workspace->mutableRun().setProtonCharge(charge);
    } catch (::NeXus::Exception &) {
      // Try and integrate the proton logs
      try {
        // Use the DAS logs to integrate the proton charge (if any).
        workspace->mutableRun().getProtonCharge();
      } catch (Exception::NotFoundError &) {
        // Ignore not found property error.
      }
    }
  }

  // Close the file
  file.close();
}