/// <summary> /// Called when vertex is removed from experiment /// When vertex is removed the experiment should be set to be modified. /// </summary> /// <param name="args">The args.</param> protected override void OnVertexRemoved(ExperimentNode args) { base.OnVertexRemoved(args); m_isModified = true; IsModified = true; args.PropertyChanged -= ExperimentNode_PropertyChanged; }
// HERZUM SPRINT 1.0 private static bool TryCreateComment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; CommentMetadataDefinition commentMetadataDefinition = metadataDefinition as CommentMetadataDefinition; if (commentMetadataDefinition != null) { data.Metadata = new CommentMetadata(commentMetadataDefinition.Label); string commentNodeId = Guid.NewGuid().ToString(); // HERZUM SPRINT 1.2 COMMENT // newCreatedNode = new CommentNode(commentNodeId, data); var data_with_size = new SerializedVertexDataWithSize(); data_with_size.X = data.X; data_with_size.Y = data.Y; data_with_size.Metadata = data.Metadata; data_with_size.Width = 160; data_with_size.Height = 160; data_with_size.WidgetStatus = "normal"; newCreatedNode = new CommentNode(commentNodeId, data_with_size); // END SPRINT 1.2 COMMENT experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return isCreated; }
/// <summary> /// Helper method, that sets the scope decision entry and exit nodes. /// If source vertex is scope and target vertex is exit decision node, it sets that source scope vertex ExitDecisionNode property to the given target exit node. /// Similarly, if target vertex is a scope node, and source vertex is decision, it sets that target scope vertex Decision property to the given source decision node. /// </summary> /// <param name="sourceVert">The source vert.</param> /// <param name="targetVert">The target vert.</param> public static void TryFixScopeDecisionEntryAndExitNodes(ExperimentNode sourceVert, ExperimentNode targetVert) { //case 1: sourceVert is ScopeNode, and target is ExitDecisionNode ScopeNode scopeNode = sourceVert as ScopeNode; if (scopeNode != null) { ExitDecisionNode exitDecisionNode = targetVert as ExitDecisionNode; if (exitDecisionNode != null) { scopeNode.ExitDecisionNode = exitDecisionNode; } } else { //case 2: targetNode is ScopeNode, and source is DecisionNode scopeNode = targetVert as ScopeNode; if (scopeNode != null) { ExperimentDecisionNode decisionNode = sourceVert as ExperimentDecisionNode; if (decisionNode != null) { scopeNode.DecisionNode = decisionNode; } } } }
public CommentNodeControl(ExperimentNode node, ApplicationContext applicationContext) : base(node, applicationContext) { // HERZUM SPRINT 2.4: TLAB-156 /* info = this.ExperimentNode.Data as SerializedVertexDataWithSize; double widthMeta = info.Width; double heightMeta = info.Height; PaddingTop = 7.0; PaddingLeft= widthMeta/2; PaddingRight= widthMeta/2; PaddingBottom= heightMeta; MoveTo (info.X, info.Y); */ // END HERZUM SPRINT 2.4: TLAB-156 // HERZUM SPRINT 1.0 cw.Comment = ((CommentMetadata) node.Data.Metadata).Comment; cw.ExposeEvent += delegate { ((CommentMetadata) node.Data.Metadata).Comment = cw.Comment; }; // END HERZUM SPRINT 1.0 //HERZUM SPRINT 2.0 TLAB-136 ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad (m_applicationContext, this); //END HERZUM SPRINT 2.0 TLAB-136 }
private void AttachListenerToIOSpecHighlights(ExperimentNode node) { // HERZUM SPRINT 4: TLAB-238 ComponentMetadata meta = ExperimentNode.Data.Metadata as ComponentMetadata; if (meta != null) { TraceLab.Core.Components.ConfigWrapper configWrapper = meta.ConfigWrapper as TraceLab.Core.Components.ConfigWrapper; if (configWrapper != null){ TraceLab.Core.Components.ConfigPropertyObject value = new TraceLab.Core.Components.ConfigPropertyObject(); // HERZUM SPRINT 4.3: TLAB-238 TLAB-243 // ADD configWrapper.ConfigValues.TryGetValue ("ConfigurationFile", out value) if (configWrapper.ConfigValues.TryGetValue ("Directory", out value) || configWrapper.ConfigValues.TryGetValue ("ConfigurationFile", out value)) if (value!=null){ value.SetExperimentLocationRoot (System.IO.Path.GetDirectoryName(m_applicationContext.Application.Experiment.ExperimentInfo.FilePath), true); } // END HERZUM SPRINT 4.2: TLAB-202 } } // HERZUM SPRINT 4: TLAB-238 //set convenience metadata field m_componentMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable; if(m_componentMetadata != null) { m_componentMetadata.IOSpec.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => { if(e.PropertyName.Equals("IsInputHighlighted") || e.PropertyName.Equals("IsOutputHighlighted")) { //redraw component Invalidate(); } }; } }
public BasicNodeControl CreateNodeControl(ExperimentNode node) { BasicNodeControl control; if (node is ComponentNode) { control = new ComponentControl(node, m_applicationContext); } else if (node is ExperimentStartNode) { control = new StartNodeControl(node, m_applicationContext); } else if (node is ExperimentEndNode) { control = new EndNodeControl(node, m_applicationContext); } else if (node is ExperimentDecisionNode) { control = new DecisionNodeControl(node, m_applicationContext); } else if (node is CompositeComponentNode) { control = new CompositeComponentControl(node, m_applicationContext); } else { control = new BasicNodeControl(node, m_applicationContext); } m_mapNodesToControls.Add(node, control); return control; }
/// <summary> /// Attempts to create the composite component. Component is created only if definition is a CompositeComponentMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a CompositeComponentMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a CompositeComponentMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateCompositeComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; CompositeComponentMetadataDefinition compositeComponentMetadataDefinition = metadataDefinition as CompositeComponentMetadataDefinition; if (compositeComponentMetadataDefinition != null) { data.Metadata = new CompositeComponentMetadata(compositeComponentMetadataDefinition, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath)); string componentNodeId = Guid.NewGuid().ToString(); string componentName = data.Metadata.Label; newCreatedNode = new CompositeComponentNode(componentNodeId, data, experiment.Settings); experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return(isCreated); }
public void DrawComponent(ExperimentNode node, bool editable) { BasicNodeControl componentControl = m_nodeControlFactory.CreateNodeControl(node); m_experimentCanvasWidget.ExperimentCanvas.View.Drawing.Add(componentControl); componentControl.MoveTo(node.Data.X, node.Data.Y); m_experimentCanvasWidget.ExperimentCanvas.View.ClearSelection(); componentControl.IsEditable = editable; }
protected ComponentControl(ExperimentNode node, ApplicationContext applicationContext, double waitForAnyAllHandleXLocation, double waitForAnyAllHandleYLocation) : base(node, applicationContext, waitForAnyAllHandleXLocation, waitForAnyAllHandleYLocation) { InitControlButtons(applicationContext); AttachListenerToIOSpecHighlights(node); }
public DecisionNodeControl(ExperimentNode node, ApplicationContext applicationContext) : base(node, applicationContext, s_waitForAnyAllHandleXLocation, s_waitForAnyAllHandleYLocation) { PaddingLeft = 30.0; PaddingTop = 7.0; PaddingRight = 40.0; PaddingBottom = 7.0; }
public EndNodeControl(ExperimentNode node, ApplicationContext applicationContext) : base(node, applicationContext, s_waitForAnyAllHandleXLocation, s_waitForAnyAllHandleYLocation) { PaddingLeft = 6.0; PaddingTop = 5.0; PaddingRight = 20.0; PaddingBottom = 5.0; }
public StartNodeControl(ExperimentNode node, ApplicationContext applicationContext) : base(node, applicationContext) { PaddingLeft = 5.0; PaddingTop = 5.0; PaddingRight = 5.0; PaddingBottom = 5.0; m_newConnectionHandle = new NewConnectionHandle (this, applicationContext, new QuickActionLocator (15, 0.5, QuickActionPosition.Right)); }
/// <summary> /// Copies data from othe node to this node /// </summary> /// <param name="other">The other.</param> protected override void CopyFrom(ExperimentNode other) { if (other == null) throw new ArgumentNullException("other"); base.CopyFrom(other); InitializeComponentGraph(); }
protected override void CopyFrom(ExperimentNode other) { if (other == null) throw new ArgumentNullException("other"); base.CopyFrom(other); ComponentNode otherNode = (ComponentNode)other; }
/// <summary> /// Copies data from another node to this /// </summary> /// <param name="other">The other.</param> protected override void CopyFrom(ExperimentNode other) { if (other == null) throw new ArgumentNullException("other"); base.CopyFrom(other); InitializeComponentGraph(); //references to decision node and exit node have to be set outside - as these nodes are also cloned }
/// <summary> /// Copies data from othe node to this node /// </summary> /// <param name="other">The other.</param> protected override void CopyFrom(ExperimentNode other) { if (other == null) { throw new ArgumentNullException("other"); } base.CopyFrom(other); InitializeComponentGraph(); }
public DecisionNodeControl(ExperimentNode node, ApplicationContext applicationContext) : base(node, applicationContext, s_waitForAnyAllHandleXLocation, s_waitForAnyAllHandleYLocation) { PaddingLeft = 30.0; PaddingTop = 7.0; PaddingRight = 40.0; PaddingBottom = 7.0; m_controlButtons = new NodeControlButtons (this, applicationContext); m_controlButtons.InfoButton.Toggled += OnInfoToggled; }
protected override void CopyFrom(ExperimentNode other) { if (other == null) { throw new ArgumentNullException("other"); } base.CopyFrom(other); ComponentNode otherNode = (ComponentNode)other; }
/// <summary> /// Copies data from another node to this /// </summary> /// <param name="other">The other.</param> protected override void CopyFrom(ExperimentNode other) { if (other == null) { throw new ArgumentNullException("other"); } base.CopyFrom(other); InitializeComponentGraph(); //references to decision node and exit node have to be set outside - as these nodes are also cloned }
private void RetrieveIOSpecAndConfig(ExperimentNode node) { if (node != null) { IConfigurableAndIOSpecifiable metadata = node.Data.Metadata as IConfigurableAndIOSpecifiable; if (metadata != null) { RetrieveIOSpecFromComponent(metadata); RetrieveConfigValuesFromComponent(node.ID, metadata); } } }
private static void DFSVisit(ExperimentNode node, bool pathFromDecision, IExperiment graph, Dictionary<ExperimentNode, GraphNodeStatus> verticesStatuses, ref List<ExperimentNode> vertices, ref List<ExperimentNodeConnection> edges, ref bool noErrors) { verticesStatuses.Add(node, GraphNodeStatus.Visiting); GraphNodeStatus status = GraphNodeStatus.HasNoPathToEnd; bool isDecision = (node.Data.Metadata is DecisionMetadata); bool comingFromDecision = isDecision || pathFromDecision; if (graph.OutEdges(node).Count<ExperimentNodeConnection>() > 0) { foreach (ExperimentNodeConnection edge in graph.OutEdges(node)) { if (verticesStatuses.ContainsKey(edge.Target) == false) { DFSVisit(edge.Target, comingFromDecision, graph, verticesStatuses, ref vertices, ref edges, ref noErrors); } if (verticesStatuses[edge.Target].Equals(GraphNodeStatus.Visiting) == true && comingFromDecision == false) { noErrors = false; SetErrorOnNode(node, "Circular link detected."); } else if (verticesStatuses[edge.Target].Equals(GraphNodeStatus.HasPathToEnd) == true || (verticesStatuses[edge.Target].Equals(GraphNodeStatus.Visiting) == true && comingFromDecision == true)) { // Add EDGE and its SOURCE and TARGET vertices only if Path was completed to END. // or if it is circular link that is coming from the decision status = GraphNodeStatus.HasPathToEnd; if (vertices.Contains(edge.Target) == false) vertices.Add(edge.Target); if (vertices.Contains(edge.Source) == false) //current node, ie. node == edge.Source vertices.Add(edge.Source); edges.Add(edge); } } } else { if (node.Data.Metadata is EndNodeMetadata) { status = GraphNodeStatus.HasPathToEnd; } else { noErrors = false; SetErrorOnNode(node, "Unable to detect path to the END node."); } } verticesStatuses[node] = status; }
private void AttachListenerToIOSpecHighlights(ExperimentNode node) { //set convenience metadata field m_componentMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable; if(m_componentMetadata != null) { m_componentMetadata.IOSpec.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => { if(e.PropertyName.Equals("IsInputHighlighted") || e.PropertyName.Equals("IsOutputHighlighted")) { //redraw component Invalidate(); } }; } }
/// <summary> /// Attempts to create the composite component. Component is created only if definition is a DecisionMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a DecisionMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a DecisionMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateDecisionComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; DecisionMetadataDefinition decisionMetadataDefinition = metadataDefinition as DecisionMetadataDefinition; if (decisionMetadataDefinition != null) { newCreatedNode = CreateDecisionComponent(experiment, decisionMetadataDefinition, data); isCreated = true; } return(isCreated); }
// END HERZUM 0.0 // HERZUM SPRINT 2.0: TLAB-65 CLASS /// <summary> /// Attempts to create the composite component. Component is created only if definition is a ChallengeMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a ChallengeMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateChallengeComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; ChallengeMetadataDefinition challengeMetadataDefinition = metadataDefinition as ChallengeMetadataDefinition; if (challengeMetadataDefinition != null) { newCreatedNode = CreateChallengeNode(challengeMetadataDefinition.Label, experiment, data.X, data.Y); isCreated = true; } return(isCreated); }
/// <summary> /// Attempts to create the composite component. Component is created only if definition is a LoopMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a LoopMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateLoopComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; LoopMetadataDefinition loopMetadataDefinition = metadataDefinition as LoopMetadataDefinition; if (loopMetadataDefinition != null) { newCreatedNode = CreateLoopScopeNode(loopMetadataDefinition.Label, experiment, data.X, data.Y); isCreated = true; } return(isCreated); }
/// <summary> /// Constructs experiment node connection from given xml xpath navigator to the edge. /// </summary> /// <param name="reader">The reader with edge root.</param> /// <returns>experiment node connection</returns> public ExperimentNodeConnection EdgeFactory(XPathNavigator reader) { string id = reader.GetAttribute("id", String.Empty); string source = reader.GetAttribute("source", String.Empty); string target = reader.GetAttribute("target", String.Empty); //try read is fixed attribute string isFixedAttrib = reader.GetAttribute("isFixed", String.Empty); bool isFixed; if (!Boolean.TryParse(isFixedAttrib, out isFixed)) { isFixed = false; } //try read is visible attribute string isVisibleAttrib = reader.GetAttribute("isVisible", String.Empty); bool isVisible; if (!Boolean.TryParse(isVisibleAttrib, out isVisible)) { isVisible = true; } //validate if (m_vertices.ContainsKey(source) == false || m_vertices.ContainsKey(target) == false) { throw new TraceLab.Core.Exceptions.ExperimentLoadException("The experiment is corrupted and could not be loaded. Experiment xml contains edge that refers to non-existing nodes."); } ExperimentNode sourceVert = m_vertices[source]; ExperimentNode targetVert = m_vertices[target]; ExperimentNodeConnection edge = new ExperimentNodeConnection(id, sourceVert, targetVert, isFixed, isVisible); edge.IsModified = false; m_edges[id] = edge; //read in route points from xml edge.RoutePoints.ReadXml(reader.ReadSubtree()); //perform fixes for scopes ScopeNodeHelper.TryFixScopeDecisionEntryAndExitNodes(sourceVert, targetVert); return(edge); }
/// <summary> /// Validates if the list of outputs from incoming vertices satisfies all the inputs for the current node /// </summary> /// <param name="node">Node to be validated</param> /// <param name="incomingOutputs">List of incoming outputs from the previous nodes</param> /// <param name="noErrors">assigns false if error has been detected, otherwise keep it as it was</param> private static bool ValidateInputMapping(ExperimentNode node, Dictionary<string, string> incomingOutputs) { bool noErrors = true; IConfigurableAndIOSpecifiable ioSpecMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable; if (ioSpecMetadata != null) { //check if the list of outputs from incoming vertices satisfies all the inputs for the current node foreach (IOItem inputItem in ioSpecMetadata.IOSpec.Input.Values) { if (incomingOutputs.ContainsKey(inputItem.MappedTo) == false) { noErrors = false; GraphValidator.SetErrorOnNode(node, String.Format(CultureInfo.CurrentCulture, "The component attempts to load '{0}' from the Workspace. However, none of the previous components outputs '{1}' to the Workspace.", inputItem.MappedTo, inputItem.MappedTo)); } } } return noErrors; }
private void DoCopyFrom(ExperimentNode other) { if (other == null) { throw new ArgumentNullException("other"); } m_owner = null; ID = other.ID; Data = other.Data.Clone(); IsInfoPaneExpanded = other.IsInfoPaneExpanded; IsExecuting = other.IsExecuting; IsSelected = other.IsSelected; if (other.HasError) { this.Error = new ExperimentNodeError(other.Error.ErrorMessage, other.Error.ErrorType); } }
/// <summary> /// Compiles the code of the single decision node or loop scope node. It handles DecisionNode and LoopScopeNode slightly differently. /// Method. /// </summary> /// <param name="node">The node.</param> /// <param name="experiment">The experiment.</param> /// <param name="workspaceTypesDirectories">The workspace types directories.</param> /// <param name="loggerNameRoot">The logger name root.</param> public static void CompileDecision(ExperimentNode node, IExperiment experiment, List<string> workspaceTypesDirectories, LoggerNameRoot loggerNameRoot) { ExperimentDecisionNode decisionNode = node as ExperimentDecisionNode; if (decisionNode != null) { Dictionary<string, string> successorNodeLabelIdLookup = PrepareSuccessorNodesLabelIdLookup(node, experiment); CompileDecisionInternal(decisionNode, experiment, workspaceTypesDirectories, loggerNameRoot, successorNodeLabelIdLookup); } else { LoopScopeNode loopScopeNode = node as LoopScopeNode; if (loopScopeNode != null) { //loop scope does not need successor nodes lookups, so pass in empty dictionary Dictionary<string, string> successorNodeLabelIdLookup = new Dictionary<string, string>(); CompileDecisionInternal(loopScopeNode, experiment, workspaceTypesDirectories, loggerNameRoot, successorNodeLabelIdLookup); } } }
protected BasicNodeControl(ExperimentNode node, ApplicationContext applicationContext, double waitForAnyAllHandleXLocation, double waitForAnyAllHandleYLocation) : base(node.Data.Metadata.Label) { m_node = node; m_applicationContext = applicationContext; //if error changes invalidate figure so that it is redraw m_node.ErrorChanged += (sender, e) => { Invalidate(); }; InitWaitForAnyHandle(waitForAnyAllHandleXLocation, waitForAnyAllHandleYLocation); PaddingLeft = 15.0; PaddingTop = 7.0; PaddingRight = 24.0; PaddingBottom = 7.0; }
/// <summary> /// Constructs experiment node from given xml xpath navigator to the node. /// </summary> /// <param name="reader">The reader with a root to the node.</param> /// <returns>Experiment Node</returns> public ExperimentNode NodeFactory(XPathNavigator reader) { string id = reader.GetAttribute("id", String.Empty); SerializedVertexData nodeData = null; XPathNavigator serializedNodeData = reader.SelectSingleNode("SerializedVertexData"); if (serializedNodeData != null) { nodeData = (SerializedVertexData)m_nodeSerializer.Deserialize(serializedNodeData.ReadSubtree()); nodeData.PostProcessReadXml(m_library, m_experimentLocationRoot); } else { //it may be serialized vertex data with size serializedNodeData = reader.SelectSingleNode("SerializedVertexDataWithSize"); if (serializedNodeData != null) { nodeData = (SerializedVertexDataWithSize)m_nodeSerializerWithSize.Deserialize(serializedNodeData.ReadSubtree()); nodeData.PostProcessReadXml(m_library, m_experimentLocationRoot); } } ExperimentNode vert = null; if (nodeData != null) { vert = NodeGenerator(id, nodeData); if (nodeData.Metadata != null) { if (nodeData.Metadata.HasDeserializationError) { vert.SetError(nodeData.Metadata.DeserializationErrorMessage); } } m_vertices[id] = vert; } return(vert); }
/// <summary> /// Attempts to create the primitive component. Component is created only if definition is a ComponentMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a ComponentMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a ComponentMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; ComponentMetadataDefinition componentMetadataDefinition = metadataDefinition as ComponentMetadataDefinition; if (componentMetadataDefinition != null) { data.Metadata = new ComponentMetadata(componentMetadataDefinition, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath)); string componentNodeId = Guid.NewGuid().ToString(); newCreatedNode = new ComponentNode(componentNodeId, data); experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return isCreated; }
/// <summary> /// Selects the scopes and ExitDecisionNode connected to given decision node /// </summary> /// <param name="originalExperiment">The original experiment.</param> /// <param name="decisionNode">The decision node.</param> private static void SelectDecisionsScopes(BaseExperiment originalExperiment, ExperimentNode decisionNode) { //iterate throught all outcoming edges and delete successor nodes IEnumerable <ExperimentNodeConnection> edges; if (originalExperiment.TryGetOutEdges(decisionNode, out edges)) { //iterate over the copy of edges, as edges itself are going to be delete when nodes are deleted foreach (ExperimentNodeConnection edge in new List <ExperimentNodeConnection>(edges)) { //check if target is scope or exit, as there are might be old Decision nodes from old experiments //that do not have fixed connections to scopes if (edge.Target is ScopeNode || edge.Target is ExitDecisionNode) { if (!edge.Target.IsSelected) { edge.Target.IsSelected = true; } } } } }
/// <summary> /// Adds the component from definition to experiment. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition that defines newly added component.</param> /// <param name="positionX">The position X at where new component is added</param> /// <param name="positionY">The position Y at where new comopnent is added</param> /// <returns>The newly constucted node</returns> public static ExperimentNode AddComponentFromDefinitionToExperiment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, double positionX, double positionY) { if (metadataDefinition == null) { throw new ArgumentNullException("metadataDefinition"); } ExperimentNode newNode = null; SerializedVertexData data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; // case 1. Primitive Component bool isCreated = TryCreateComponent(experiment, metadataDefinition, data, out newNode); // case 2. Composite Component if (!isCreated) { isCreated = TryCreateCompositeComponent(experiment, metadataDefinition, data, out newNode); } // case 3. Decision if (!isCreated) { isCreated = TryCreateDecisionComponent(experiment, metadataDefinition, data, out newNode); } // case 4. Loop if (!isCreated) { isCreated = TryCreateLoopComponent(experiment, metadataDefinition, data, out newNode); } return(newNode); }
internal static void BFSTraverseExperiment(IExperiment experiment, ExperimentNode startFromNode, TraverseTask Task) { //traverse graph down from the node Queue<ExperimentNode> traversingQueue = new Queue<ExperimentNode>(); HashSet<ExperimentNode> foundVertices = new HashSet<ExperimentNode>(); traversingQueue.Enqueue(startFromNode); while (traversingQueue.Count > 0) { ExperimentNode currentNode = traversingQueue.Dequeue(); //do some stuff Task(currentNode); foreach (ExperimentNodeConnection edge in experiment.OutEdges(currentNode)) { if (foundVertices.Contains(edge.Target) == false) { traversingQueue.Enqueue(edge.Target); foundVertices.Add(edge.Target); } } } }
// HERZUM SPRINT 1.0 private static bool TryCreateComment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; CommentMetadataDefinition commentMetadataDefinition = metadataDefinition as CommentMetadataDefinition; if (commentMetadataDefinition != null) { data.Metadata = new CommentMetadata(commentMetadataDefinition.Label); string commentNodeId = Guid.NewGuid().ToString(); // HERZUM SPRINT 1.2 COMMENT // newCreatedNode = new CommentNode(commentNodeId, data); var data_with_size = new SerializedVertexDataWithSize(); data_with_size.X = data.X; data_with_size.Y = data.Y; data_with_size.Metadata = data.Metadata; data_with_size.Width = 160; data_with_size.Height = 160; data_with_size.WidgetStatus = "normal"; newCreatedNode = new CommentNode(commentNodeId, data_with_size); // END SPRINT 1.2 COMMENT experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return(isCreated); }
protected override void CopyFrom(ExperimentNode other) { base.CopyFrom(other); }
/// <summary> /// Writes the node attributes. /// </summary> /// <param name="writer">The writer.</param> /// <param name="flow">The flow.</param> public void WriteNodeAttributes(XmlWriter writer, ExperimentNode flow) { WriteXmlAttributesAndElements(writer, flow); }
/// <summary> /// Selects the decision and its scopes connected to the given exit node /// </summary> /// <param name="originalExperiment">The original experiment.</param> /// <param name="node">The exit decision node.</param> private static void SelectDecisionsScopesConnectedToExitNode(BaseExperiment originalExperiment, ExperimentNode exitDecisionNode) { //iterate throught all outcoming edges and delete successor nodes IEnumerable<ExperimentNodeConnection> edges; if (originalExperiment.TryGetInEdges(exitDecisionNode, out edges)) { //iterate over the copy of edges, as edges itself are going to be delete when nodes are deleted foreach (ExperimentNodeConnection edge in new List<ExperimentNodeConnection>(edges)) { //check if target is scope or exit, as there are might be old Decision nodes from old experiments //that do not have fixed connections to scopes if (edge.Source is ScopeNode || edge.Source is ExperimentDecisionNode) { if (!edge.Source.IsSelected) edge.Source.IsSelected = true; } } } }
protected override void CopyFrom(ExperimentNode other) { base.CopyFrom(other); InitializeComponentGraph(); }
public bool TryGetNodeControl(ExperimentNode node, out BasicNodeControl nodeControl) { return m_mapNodesToControls.TryGetValue(node, out nodeControl); }
/// <summary> /// Adds a new component at the specified coordinates /// </summary> /// <exception cref="System.ArgumentNullException">Thrown if the component definition is null</exception> public ExperimentNode AddComponentFromDefinition(MetadataDefinition metadataDefinition, double positionX, double positionY) { ExperimentNode newNode = ComponentFactory.AddComponentFromDefinitionToExperiment(this, metadataDefinition, positionX, positionY); return(newNode); }
public CompositeComponentControl(ExperimentNode node, ApplicationContext applicationContext) : base(node, applicationContext) { m_displayComponentSubGraph = new PixButtonHandle(this, new QuickActionLocator (35, 0.8, QuickActionPosition.Right), s_magnifierGlassIcon, DisplayComponentSubGraph); }
protected virtual void CopyFrom(ExperimentNode other) { DoCopyFrom(other); }
public BasicNodeControl(ExperimentNode node, ApplicationContext applicationContext) : this(node, applicationContext, s_waitForAnyAllHandleXLocation, s_waitForAnyAllHandleYLocation) { }
// HERZUM SPRINT 2.3 TLAB-60 private ScopeNodeBase GetScopeUp(ExperimentNode experimentNode, BaseExperiment experiment, double x, double y){ BasicNodeControl componentControl; foreach (ExperimentNode node in experiment.Vertices) if (node is ScopeNodeBase && !node.Equals(experimentNode)) if(m_applicationContext.NodeControlFactory.TryGetNodeControl(node, out componentControl)){ ScopeNodeControl scopeNodeControl = componentControl as ScopeNodeControl; if (scopeNodeControl.ContainsPoint (x, y)) return node as ScopeNodeBase; } return null; }
public bool RemoveFromLookup(ExperimentNode node) { return m_mapNodesToControls.Remove(node); }
/// <summary> /// Extracts the components/types assemblies from the given vertex. /// </summary> /// <param name="pVertex">Vertex from the experiment graph.</param> private void ExtractFilesFromNode(ExperimentNode pVertex) { if (pVertex is ComponentNode) // Regular component { ComponentMetadata metaData = (ComponentMetadata)pVertex.Data.Metadata; if (metaData != null) { ComponentMetadataDefinition metaDataDef = metaData.ComponentMetadataDefinition; if (metaDataDef != null) { bool include; if (m_config.IncludeOtherPackagesAssemblies) { include = true; } else { //determine if component is independent or is coming from another package include = !IsAssemblyInAnotherPackage(metaDataDef.Assembly); } if (include) { // Component assembly this.m_componentAssemblies.Add(Path.GetFullPath(metaDataDef.Assembly)); // Extracting types from IOSpec ExtractTypesFromIOSpec(metaDataDef.IOSpecDefinition); } } ConfigWrapper config = metaData.ConfigWrapper; if (config != null) { // Extracting paths for files/directories from components' configuration foreach (ConfigPropertyObject configValue in config.ConfigValues.Values) { // Files if (configValue.Type == "TraceLabSDK.Component.Config.FilePath" && configValue.Value != null) { // Independent files if (configValue.Value is TraceLab.Core.Components.TraceLabFilePath == false) { if (this.m_config.IncludeIndependentFilesDirs) { var filePath = (TraceLabSDK.Component.Config.FilePath)configValue.Value; if (File.Exists(filePath.Absolute)) { PackageFileInfo packageFileInfo = new PackageFileInfo(filePath); m_files.Add(packageFileInfo); //Change config value relative path -> this path is saved within experiment (note, we operate on the experiment clone) //so that relative path is in the subfolder of Experiment folder filePath.Relative = packageFileInfo.RelativeLocation; } } } // Files contained in a package else { if (this.m_config.IncludeOtherPackagesFilesDirs) { //TraceLabFilePath represents the file reference located in the package var packageFilePath = (TraceLabFilePath)configValue.Value; if (File.Exists(packageFilePath.Absolute)) { PackageFileInfo packageFileInfo = new PackageFileInfo(packageFilePath); m_files.Add(packageFileInfo); //change the configValue to basic FilePath, (not TraceLabFilePath in the package), with updated Relative Path //so that relative path is in the subfolder of Experiment folder TraceLabSDK.Component.Config.FilePath basicFilePath = new TraceLabSDK.Component.Config.FilePath(); basicFilePath.Init(packageFilePath.Absolute, packageFilePath.DataRoot); basicFilePath.Relative = packageFileInfo.RelativeLocation; configValue.Value = basicFilePath; } } } } // Directories else if (configValue.Type == "TraceLabSDK.Component.Config.DirectoryPath" && configValue.Value != null) { // Independent directories if (configValue.Value is TraceLab.Core.Components.TraceLabDirectoryPath == false) { if (this.m_config.IncludeIndependentFilesDirs) { var dirPath = (TraceLabSDK.Component.Config.DirectoryPath)configValue.Value; if (Directory.Exists(dirPath.Absolute)) { PackageFileInfo packageDirectoryInfo = new PackageFileInfo(dirPath); m_directories.Add(packageDirectoryInfo); //Change config value relative path -> this path is saved within experiment (note, we operate on the experiment clone) //so that relative path is in the subfolder of Experiment folder dirPath.Relative = packageDirectoryInfo.RelativeLocation; } } } // Directories contained in a package else { if (this.m_config.IncludeOtherPackagesFilesDirs) { var packageDirPath = (TraceLabDirectoryPath)configValue.Value; if (Directory.Exists(packageDirPath.Absolute)) { PackageFileInfo packageDirInfo = new PackageFileInfo(packageDirPath); m_directories.Add(packageDirInfo); //change the configValue to basic FilePath, (not TraceLabFilePath in the package), with updated Relative Path //so that relative path is in the subfolder of Experiment folder TraceLabSDK.Component.Config.DirectoryPath basicFilePath = new TraceLabSDK.Component.Config.DirectoryPath(); basicFilePath.Init(packageDirPath.Absolute, packageDirPath.DataRoot); basicFilePath.Relative = packageDirInfo.RelativeLocation; configValue.Value = basicFilePath; } } } } } } } } else if (pVertex is CompositeComponentNode) // Composite Components, Loops & Scopes { CompositeComponentBaseMetadata metaData = (CompositeComponentBaseMetadata)pVertex.Data.Metadata; if (metaData != null) { foreach (var vertex in metaData.ComponentGraph.Vertices) { ExtractFilesFromNode(vertex); } // Only composite components have MetadataDefinition if (pVertex.Data.Metadata is CompositeComponentMetadata) { CompositeComponentMetadataDefinition metaDataDefinition = ((CompositeComponentMetadata)pVertex.Data.Metadata).ComponentMetadataDefinition; this.m_componentAssemblies.Add(Path.GetFullPath(metaDataDefinition.Assembly)); // Extracting types from IOSpec ExtractTypesFromIOSpec(metaDataDefinition.IOSpecDefinition); } } } }
public ExperimentNodeEventArgs(ExperimentNode node) { Node = node; }