private string LookupName(ParameterModel reference, ModelSystemStructureModel current) { var param = current.Parameters; if (param != null && param.Parameters != null) { int index = param.Parameters.IndexOf(reference); if (index >= 0) { return(current.Parameters.Parameters[index].Name); } } var childrenList = current.Children; if (childrenList != null) { for (int i = 0; i < childrenList.Count; i++) { var res = LookupName(reference, childrenList[i]); if (res != null) { // make sure to use an escape character before the . to avoid making the mistake of reading it as another index return(string.Concat(current.IsCollection ? i.ToString() : childrenList[i].ParentFieldName.Replace(".", "\\."), '.', res)); } } } return(null); }
/// <summary> /// Create a model system model for a previous run. /// </summary> /// <param name="modelSystemEditingSession">The session to use</param> /// <param name="project">The project the previous run is in.</param> /// <param name="runFile">The path to the run file.</param> public ModelSystemModel(XTMFRuntime runtime, ModelSystemEditingSession modelSystemEditingSession, Project project, string runFile) { Project = project; ModelSystemIndex = -1; Name = Path.GetFileName(runFile); _Description = "Previous run"; Root = new ModelSystemStructureModel(modelSystemEditingSession, runtime.ModelSystemController.LoadFromRunFile(runFile)); }
public ModelSystemModel(ModelSystemEditingSession session, ModelSystem modelSystem) { ModelSystem = modelSystem; Name = modelSystem.Name; _Description = modelSystem.Description; Root = new ModelSystemStructureModel(session, modelSystem.CreateEditingClone(out List <ILinkedParameter> editingLinkedParameters) as ModelSystemStructure); LinkedParameters = new LinkedParametersModel(session, this, editingLinkedParameters); }
public bool Remove(ModelSystemStructureModel selected, ref string error) { if (selected.IsCollection) { return(selected.RemoveAllCollectionMembers(ref error)); } return(Remove(Root, null, selected, ref error)); }
/// <summary> /// Create a model system model for a previous run. /// </summary> /// <param name="modelSystemEditingSession">The session to use</param> /// <param name="project">The project the previous run is in.</param> /// <param name="runFile">The path to the run file.</param> public ModelSystemModel(XTMFRuntime runtime, ModelSystemEditingSession modelSystemEditingSession, Project project, string runFile) { Project = project; ModelSystemIndex = -1; Name = Path.GetFileName(runFile); _Description = "Previous run"; Root = new ModelSystemStructureModel(modelSystemEditingSession, runtime.ModelSystemController.LoadFromRunFile(runFile)); LinkedParameters = new LinkedParametersModel(modelSystemEditingSession, this, new List <ILinkedParameter>()); }
public ModelSystemModel(ModelSystemEditingSession session, ModelSystem modelSystem) { ModelSystem = modelSystem; Name = modelSystem.Name; _Description = modelSystem.Description; List<ILinkedParameter> editingLinkedParameters; Root = new ModelSystemStructureModel(session, modelSystem.CreateEditingClone(out editingLinkedParameters) as ModelSystemStructure); LinkedParameters = new LinkedParametersModel(session, this, editingLinkedParameters); }
/// <summary> /// /// </summary> /// <param name="realParameter"></param> /// <param name="session"></param> /// <param name="belongsTo"></param> public ParameterModel(ModuleParameter realParameter, ModelSystemEditingSession session, ModelSystemStructureModel belongsTo) { IsDirty = false; RealParameter = realParameter; _Session = session; _Value = _Value = RealParameter.Value != null?RealParameter.Value.ToString() : string.Empty; _belongsTo = belongsTo; }
public ModelSystemModel(ModelSystemEditingSession session, Project project, int modelSystemIndex) { _Project = project; _ModelSystemIndex = modelSystemIndex; Name = project.ModelSystemStructure[modelSystemIndex].Name; _Description = project.ModelSystemDescriptions[modelSystemIndex]; Root = new ModelSystemStructureModel(session, (project.CloneModelSystemStructure(out List <ILinkedParameter> editingLinkedParameters, modelSystemIndex) as ModelSystemStructure)); _Description = _Project.ModelSystemDescriptions[modelSystemIndex]; LinkedParameters = new LinkedParametersModel(session, this, editingLinkedParameters); }
public ModelSystemModel(ModelSystemEditingSession session, Project project, int modelSystemIndex) { Project = project; ModelSystemIndex = modelSystemIndex; Name = project.ModelSystemStructure[modelSystemIndex].Name; _Description = project.ModelSystemDescriptions[modelSystemIndex]; List<ILinkedParameter> editingLinkedParameters; Root = new ModelSystemStructureModel(session, (project.CloneModelSystemStructure(out editingLinkedParameters, modelSystemIndex) as ModelSystemStructure)); _Description = Project.ModelSystemDescriptions[modelSystemIndex]; LinkedParameters = new LinkedParametersModel(session, this, editingLinkedParameters); }
public XTMFRun(Project project, int modelSystemIndex, ModelSystemModel root, Configuration config, string runName) { Project = project; ModelSystemStructureModelRoot = root.Root; Configuration = new XTMF.RunProxy.ConfigurationProxy(config, Project); RunName = runName; RunDirectory = Path.Combine(Configuration.ProjectDirectory, Project.Name, RunName); ModelSystemIndex = modelSystemIndex; Project.ModelSystemStructure[ModelSystemIndex] = root.ClonedModelSystemRoot; Project.LinkedParameters[ModelSystemIndex] = root.LinkedParameters.GetRealLinkedParameters(); }
public XTMFRun(Project project, ModelSystemStructureModel root, Configuration configuration, string runName) { // we don't make a clone for this type of run Project = project; ModelSystemStructureModelRoot = root; var index = project.ModelSystemStructure.IndexOf(root.RealModelSystemStructure); if(index >= 0) Configuration = new XTMF.RunProxy.ConfigurationProxy(configuration, Project); RunName = runName; RunDirectory = Path.Combine(Configuration.ProjectDirectory, Project.Name, RunName); }
public bool MoveModeInParent(int deltaPosition, ref string error) { ModelSystemStructureModel parent = Session.GetParent(this); if (!parent.IsCollection) { error = "You can only move the children of a collection!"; return(false); } var ourIndex = parent.Children.IndexOf(this); return(parent.MoveChild(ourIndex, ourIndex + deltaPosition, ref error)); }
private void GetAllChildren(List <ModelSystemStructureModel> list, ModelSystemStructureModel root) { list.Add(root); var children = root.Children; if (children != null) { foreach (var child in children) { GetAllChildren(list, child); } } }
public XTMFRun(Project project, ModelSystemStructureModel root, Configuration configuration, string runName) { // we don't make a clone for this type of run Project = project; ModelSystemStructureModelRoot = root; var index = project.ModelSystemStructure.IndexOf(root.RealModelSystemStructure); if (index >= 0) { Configuration = new XTMF.RunProxy.ConfigurationProxy(configuration, Project); } RunName = runName; RunDirectory = Path.Combine(Configuration.ProjectDirectory, Project.Name, RunName); }
private static List <ParameterModel> CreateParameterModels(ModelSystemStructureModel modelSystemStructure, ModelSystemEditingSession Session) { var realParameters = modelSystemStructure.RealModelSystemStructure.Parameters?.Parameters; if (realParameters == null) { return(null); } var ret = new List <ParameterModel>(realParameters.Count); for (int i = 0; i < realParameters.Count; i++) { ret.Add(new ParameterModel(realParameters[i] as ModuleParameter, Session, modelSystemStructure)); } return(ret); }
private ParameterModel GetParameterModel(ModelSystemStructureModel owner, IModuleParameter moduleParameter) { var parameters = owner.Parameters.Parameters; if (parameters != null) { for (int i = 0; i < parameters.Count; i++) { if (parameters[i].RealParameter == moduleParameter) { return(parameters[i]); } } } return(null); }
private bool Remove(ModelSystemStructureModel current, ModelSystemStructureModel previous, ModelSystemStructureModel selected, ref string error) { if (current == selected) { if (previous == null) { Root.Type = null; return(true); } else { if (previous.IsCollection) { return(previous.RemoveCollectionMember(previous.Children.IndexOf(selected), ref error)); } else { selected.Type = null; return(true); } } } var children = current.Children; if (children != null) { foreach (var child in current.Children) { var success = Remove(child, current, selected, ref error); if (success) { return(true); } } } return(false); }
public ParametersModel(ModelSystemStructureModel modelSystemStructure, ModelSystemEditingSession session) { Session = session; ModelSystemStructure = modelSystemStructure; Parameters = CreateParameterModels(modelSystemStructure, Session); }
public bool Remove(ModelSystemStructureModel selected, ref string error) { if(selected.IsCollection) { return selected.RemoveAllCollectionMembers(ref error); } return Remove(Root, null, selected, ref error); }
private void AddQuickParameters(ObservableCollection <ParameterModel> quickParameters, ModelSystemStructureModel current) { var parameters = current.Parameters.Parameters; if (parameters != null) { foreach (var p in parameters) { if (p.QuickParameter) { quickParameters.Add(p); } } } var children = current.Children; if (children != null) { foreach (var child in children) { AddQuickParameters(quickParameters, child); } } }
private ParameterModel GetParameterFromLink(string[] variableLink, int index, ModelSystemStructureModel current, int indexOffset) { if (index == variableLink.Length - 1) { // search the parameters var parameters = current.Parameters; foreach (var p in parameters.Parameters) { if (p.Name == variableLink[index]) { return(p); } } } else { var descList = current.Children; if (descList == null) { return(null); } if (current.IsCollection) { int collectionIndex; if (int.TryParse(variableLink[index], out collectionIndex)) { // if we are at the first index we need to look at the index offset. // This is needed if we are copying a collection, thus the indexes will // not be starting at the 0th position in the new model system structure. if (index == 0) { collectionIndex += indexOffset; } if (collectionIndex >= 0 && collectionIndex < descList.Count) { return(GetParameterFromLink(variableLink, index + 1, descList[collectionIndex], indexOffset)); } return(null); } } else { foreach (var sub in descList) { if (sub.ParentFieldName == variableLink[index]) { return(GetParameterFromLink(variableLink, index + 1, sub, 0)); } } } } return(null); }
private ParameterModel GetParameterModel(ModelSystemStructureModel owner, IModuleParameter moduleParameter) { var parameters = owner.Parameters.Parameters; if(parameters != null) { for(int i = 0; i < parameters.Count; i++) { if(parameters[i].RealParameter == moduleParameter) { return parameters[i]; } } } return null; }
private static List<ParameterModel> CreateParameterModels(ModelSystemStructureModel modelSystemStructure, ModelSystemEditingSession Session) { if(modelSystemStructure.RealModelSystemStructure.Parameters == null) return null; var realParameters = modelSystemStructure.RealModelSystemStructure.Parameters.Parameters; if(realParameters == null) return null; var ret = new List<ParameterModel>(realParameters.Count); for(int i = 0; i < realParameters.Count; i++) { ret.Add(new ParameterModel(realParameters[i] as ModuleParameter, Session)); } return ret; }
private void GetAllChildren(List<ModelSystemStructureModel> list, ModelSystemStructureModel root) { list.Add(root); var children = root.Children; if(children != null) { foreach(var child in children) { GetAllChildren(list, child); } } }
public ModelSystemStructureModel GetParent(ModelSystemStructureModel currentModule) { return(ModelSystemModel.GetModelFor( currentModule.RealModelSystemStructure.GetParent(ModelSystemModel.Root.RealModelSystemStructure))); }
private void AddQuickParameters(ObservableCollection<ParameterModel> quickParameters, ModelSystemStructureModel current) { var parameters = current.Parameters.Parameters; if(parameters != null) { foreach(var p in parameters) { if(p.QuickParameter) { quickParameters.Add(p); } } } var children = current.Children; if(children != null) { foreach(var child in children) { AddQuickParameters(quickParameters, child); } } }
private string LookupName(ParameterModel reference, ModelSystemStructureModel current) { var param = current.Parameters; if(param != null && param.Parameters != null) { int index = param.Parameters.IndexOf(reference); if(index >= 0) { return current.Parameters.Parameters[index].Name; } } var childrenList = current.Children; if(childrenList != null) { for(int i = 0; i < childrenList.Count; i++) { var res = LookupName(reference, childrenList[i]); if(res != null) { // make sure to use an escape character before the . to avoid making the mistake of reading it as another index return string.Concat(current.IsCollection ? i.ToString() : childrenList[i].ParentFieldName.Replace(".", "\\."), '.', res); } } } return null; }
private List <ParameterModel> GetParametersFromTemp(TempLinkedParameter temp, ModelSystemStructureModel root, int indexOffset) { return((from path in temp.Paths select GetParametersFromTemp(path, root, indexOffset)).ToList()); }
private ModelSystemStructureModel GetModelFor(ModelSystemStructure realStructure, ModelSystemStructureModel current) { if(current.RealModelSystemStructure == realStructure) { return current; } var children = current.Children; if(children != null) { for(int i = 0; i < children.Count; i++) { ModelSystemStructureModel ret; if((ret = GetModelFor(realStructure, children[i])) != null) { return ret; } } } return null; }
/// <summary> /// Check to see if this linked parameter has a reference to the given module. /// </summary> /// <param name="child">The module to test against</param> /// <returns>If the given module is referenced</returns> internal bool HasContainedModule(ModelSystemStructureModel child) { return(RealLinkedParameter.Parameters.Any(p => p.BelongsTo == child.RealModelSystemStructure)); }
private List<ParameterModel> GetParametersFromTemp(TempLinkedParameter temp, ModelSystemStructureModel root, int indexOffset) { return (from path in temp.Paths select GetParametersFromTemp(path, root, indexOffset)).ToList(); }
private ParameterModel GetParametersFromTemp(string path, ModelSystemStructureModel root, int indexOffset) { return(GetParameterFromLink(ParseLinkedParameterName(path), 0, root, indexOffset)); }
public ModelSystemStructureModel GetRoot(ModelSystemStructureModel currentModule) { return ModelSystemModel.GetModelFor(currentModule.RealModelSystemStructure.GetRoot(ModelSystemModel.Root.RealModelSystemStructure)); }
/// <summary> /// Get the available types for the selected module /// </summary> /// <param name="selectedModule">The module to find the valid types for</param> /// <returns>A list of the allowed types.</returns> public List<Type> GetValidModules(ModelSystemStructureModel selectedModule) { return selectedModule.RealModelSystemStructure.GetPossibleModules(ModelSystemModel.Root.RealModelSystemStructure); }
private ParameterModel GetParameterFromLink(string[] variableLink, int index, ModelSystemStructureModel current, int indexOffset) { if(index == variableLink.Length - 1) { // search the parameters var parameters = current.Parameters; foreach(var p in parameters.Parameters) { if(p.Name == variableLink[index]) { return p; } } } else { var descList = current.Children; if(descList == null) { return null; } if(current.IsCollection) { int collectionIndex; if(int.TryParse(variableLink[index], out collectionIndex)) { // if we are at the first index we need to look at the index offset. // This is needed if we are copying a collection, thus the indexes will // not be starting at the 0th position in the new model system structure. if(index == 0) { collectionIndex += indexOffset; } if(collectionIndex >= 0 && collectionIndex < descList.Count) { return GetParameterFromLink(variableLink, index + 1, descList[collectionIndex], indexOffset); } return null; } } else { foreach(var sub in descList) { if(sub.ParentFieldName == variableLink[index]) { return GetParameterFromLink(variableLink, index + 1, sub, 0); } } } } return null; }
private ModelSystemStructureModel GetModelFor(ModelSystemStructure realStructure, ModelSystemStructureModel current) { if (current.RealModelSystemStructure == realStructure) { return(current); } var children = current.Children; if (children != null) { for (int i = 0; i < children.Count; i++) { ModelSystemStructureModel ret; if ((ret = GetModelFor(realStructure, children[i])) != null) { return(ret); } } } return(null); }
private ParameterModel GetParametersFromTemp(string path, ModelSystemStructureModel root, int indexOffset) { return GetParameterFromLink(ParseLinkedParameterName(path), 0, root, indexOffset); }
private bool Remove(ModelSystemStructureModel current, ModelSystemStructureModel previous, ModelSystemStructureModel selected, ref string error) { if(current == selected) { if(previous == null) { Root.Type = null; return true; } else { if(previous.IsCollection) { return previous.RemoveCollectionMember(previous.Children.IndexOf(selected), ref error); } else { selected.Type = null; return true; } } } var children = current.Children; if(children != null) { foreach(var child in current.Children) { var success = Remove(child, current, selected, ref error); if(success) { return true; } } } return false; }
/// <summary> /// Get the available types for the selected module /// </summary> /// <param name="selectedModule">The module to find the valid types for</param> /// <returns>A list of the allowed types.</returns> public List <Type> GetValidModules(ModelSystemStructureModel selectedModule) { return(selectedModule.RealModelSystemStructure.GetPossibleModules(ModelSystemModel.Root .RealModelSystemStructure)); }
public static XTMFRun CreateLocalRun(Project project, ModelSystemStructureModel root, Configuration configuration, string runName, bool overwrite = false) { return(new XTMFRunLocal(project, root, configuration, runName, overwrite)); }
public static XTMFRun CreateRemoteHost(Project project, ModelSystemStructureModel root, Configuration config, string runName, bool overwrite = false) { return(new XTMFRunRemoteHost(config, root, new List <ILinkedParameter>(), runName, Path.Combine(config.ProjectDirectory, project.Name, runName), overwrite)); }
/// <summary> /// Check to see if this linked parameter has a reference to the given module. /// </summary> /// <param name="child">The module to test against</param> /// <returns>If the given module is referenced</returns> internal bool HasContainedModule(ModelSystemStructureModel child) { return RealLinkedParameter.Parameters.Any(p => p.BelongsTo == child.RealModelSystemStructure); }