public SearchForTargetDetails(Protocol protocol, Process process, MaterialDestination destination, Int32 procedureIndex) { this.protocol = protocol; this.process = process; this.destination = destination; this.procedureIndex = procedureIndex; }
public SearchForPathDetails(ProcessingPath path, Int32 tagLevel, MaterialDestination destination, List <Procedure> procedures) { this.tagLevel = tagLevel; this.destination = destination; this.path = path; this.procedures = procedures; this.endOfBranch = false; }
/// <summary> /// Searches for target procedure below a specified material destination. /// </summary> /// <param name="searchTarget">The search target's procedure.</param> /// <param name="parentDestination">The material destination to begin searching from.</param> /// <returns>Details describing the requested procedure</returns> private SearchForTargetDetails SearchForTargetProcedure(ProcessingTarget searchTarget, MaterialDestination parentDestination) { // Is there a destination to search ? if (parentDestination == null || parentDestination.Target == null || !parentDestination.Target.HasProcedure()) { return(null); } // Search each procedure for a match for (Int32 i = 0; i < parentDestination.Target.Procedure.Length; i++) { // If this procedure matches then return it as the jump point if (String.Equals(parentDestination.Target.Procedure[i].Id, searchTarget.ProcedureRef)) { return(new SearchForTargetDetails(parentDestination, i)); } // Otherwise recursively search for the requested procedure List <MaterialDestination> destinations = parentDestination.Target.Procedure[i].GetDestinations(); foreach (MaterialDestination destination in destinations) { SearchForTargetDetails match = SearchForTargetProcedure(searchTarget, destination); if (match != null) { return(match); } } } return(null); }
/// <summary> /// Expands all the processing (i.e. ProcessRefs, ProcedureRef, etc...) under this destination into procedures. By converting all processing into procedures, searching and tracing is considerably easier. /// </summary> /// <param name="parentDestination">The parent destination to convert into procedures.</param> /// <param name="startProcedureIndex">The start procedure within the material target on the parent destination from which to begin converting.</param> /// <param name="defaultTarget">The default target describing the current procotol and process.</param> /// <returns>The expanded list of procedures</returns> private List <Procedure> ExpandToProcedures(MaterialDestination parentDestination, Int32 startProcedureIndex, ProcessingTarget defaultTarget) { List <Procedure> procedures = new List <Procedure>(); // Does this destination have a target to expand ? if not then just return an empty procedure list if (parentDestination == null || !parentDestination.HasTarget) { return(procedures); } // Invalid target ? if (!parentDestination.IsValidTarget) { this.OnValidationEvent(new ValidationResult(ErrorCodes.SampleProcessingHistory, ErrorLevel.Error, String.Format(Languages.Strings.valResultInvalidMaterialTarget, parentDestination.Target == null ? "?" : parentDestination.Target.ToString()))); } // Does this destination have a list of procedures as its target ? if so then expand each procedure if (parentDestination.Target.HasProcedure()) { // Add each procedure in the target and expand the procedure's destinations for (Int32 i = startProcedureIndex; i < parentDestination.Target.Procedure.Length; i++) { procedures.Add(parentDestination.Target.Procedure[i]); // Expand each destination into procedures List <MaterialDestination> destinations = parentDestination.Target.Procedure[i].GetDestinations(); foreach (MaterialDestination destination in destinations) { MaterialTarget target = new MaterialTarget(); target.Procedure = this.ExpandToProcedures(destination, 0, defaultTarget).ToArray(); destination.Target = target; } } } // Does the destination have references to a protocol, process or procedure name instead? // if so then set the default target to the current protocol etc... and expand the reference else if (parentDestination.Target.IsSpecified) { ProcessingTarget searchTarget = new ProcessingTarget(defaultTarget); // Is there a protocol reference ? if (parentDestination.Target.HasProtocol()) { searchTarget.ProtocolRef = parentDestination.Target.ProtocolRef; } // Is there a process reference ? if (parentDestination.Target.HasProcessName()) { searchTarget.ProcessRef = parentDestination.Target.ProcessRef; } // Is there a procedure reference ? if (parentDestination.Target.HasProcedureName()) { searchTarget.ProcedureRef = parentDestination.Target.ProcedureRef; } // Is there a material source reference ? if (parentDestination.Target.HasMaterialSourceName()) { searchTarget.MaterialSourceRef = parentDestination.Target.MaterialSourceRef; } // Is the current target's references valid (i.e. is there a protocol or process that matches the specified protocol or process, etc...). SearchForTargetDetails match = this.SearchForTarget(searchTarget); // If the target is valid and points to another position in the ADX document then jump to that place and continue expanding into procedures if (match != null && match.destination != null) { searchTarget.DefaultProcess = match.process; searchTarget.DefaultProtocol = match.protocol; procedures.AddRange(this.ExpandToProcedures(match.destination.Clone(), match.procedureIndex, searchTarget)); } } return(procedures); }
public SearchForTargetDetails(MaterialDestination destination, Int32 procedureIndex) { this.destination = destination; this.procedureIndex = procedureIndex; }
/// <summary> /// Appends the processing history onto the end of the specified processing path. /// </summary> /// <param name="parentPath">The parent processing path to append onto.</param> /// <param name="processing">The processing history.</param> internal void AppendProcessingHistory(ProcessingPath parentPath, ADX4.Process processing) { // Any processing history to append ? if (processing == null || processing.Destination == null) { return; } // Expand the processing history into a procedures (i.e. replaces ProcessRef, ProcedureRef, etc... for the actual procedures). MaterialDestination clonedDestination = processing.Destination.Clone(); Debug.Assert(clonedDestination != null); List <Procedure> expandedProcedures = ExpandToProcedures(clonedDestination, 0, new ProcessingTarget()); Debug.Assert(expandedProcedures != null); // Any procedures to append ? if (expandedProcedures.Count == 0) { return; } // Do we have a root destination at the top of the process tree ? MaterialDestination leafDestination; if (this.Root == null) { this.Root = new MaterialDestination(); leafDestination = this.Root; } // Or do we trace the processing path through the current tree. else { leafDestination = SearchForDestination(parentPath); // Find the destination at the end of this processing path ! if (leafDestination == null) { this.OnValidationEvent(new ValidationResult(ErrorCodes.SampleProcessingHistory, ErrorLevel.Error, String.Format(Languages.Strings.valResultPathNotFoundInProcessingHistory, parentPath.ToString(), this.ToString()))); return; } } Debug.Assert(leafDestination != null); // Add a target to the destination at the end of the processing path (if not one there already) if (leafDestination.Target == null) { leafDestination.Target = new MaterialTarget(); } // Add the procedures onto the target (if no procedures have been set on the target yet!) if (leafDestination.Target.Procedure == null) { leafDestination.Target.Procedure = expandedProcedures.ToArray(); } // Otherwise extend the target's procedure list and append the processing history's procedures else { Procedure[] curProcedures = leafDestination.Target.Procedure; leafDestination.Target.Procedure = new Procedure[curProcedures.Length + expandedProcedures.Count]; for (int i = 0; i < curProcedures.Length; i++) { leafDestination.Target.Procedure[i] = curProcedures[i]; } for (int i = 0; i < expandedProcedures.Count; i++) { leafDestination.Target.Procedure[curProcedures.Length + i] = expandedProcedures[i]; } } }