private static void GenerateScopesAndExit(IEditableExperiment experiment, SerializedVertexData data, ExperimentDecisionNode decisionNode) { ExitDecisionNode exitDecisionNode = GenerateExitDecisionNode(data.X, data.Y + 240); experiment.AddVertex(exitDecisionNode); //add invisible fixed connection between decision and exit - so that if scope can be skipped upon condition experiment.AddFixedConnection(decisionNode, exitDecisionNode, true); //set the log settings of all new nodes experiment.SetLogLevelSettings(decisionNode); experiment.SetLogLevelSettings(exitDecisionNode); AddScopeToDecision("Scope 1", data.X - 90, data.Y + 120, decisionNode, exitDecisionNode, experiment); AddScopeToDecision("Scope 2", data.X + 90, data.Y + 120, decisionNode, exitDecisionNode, experiment); }
/// <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); }
/// <summary> /// Adds the scope to decision. /// Default scope size is 160 by 160 /// </summary> /// <param name="label">The label.</param> /// <param name="positionX">The center X position of the scope.</param> /// <param name="positionY">The center Y position of the scope.</param> /// <param name="decisionNode">The decision node.</param> /// <param name="exitDecisionNode">The exit decision node.</param> /// <param name="experiment">The experiment.</param> public static void AddScopeToDecision(string label, double positionX, double positionY, ExperimentDecisionNode decisionNode, ExitDecisionNode exitDecisionNode, IEditableExperiment experiment, double width = 160, double height = 160) { ScopeNode scopeNode = GenerateScopeNode(label, experiment, positionX, positionY, width, height); //set decision and exit decision references //(also note that ExperimentFactory also sets it when deseralizing experiment) scopeNode.DecisionNode = decisionNode; scopeNode.ExitDecisionNode = exitDecisionNode; experiment.AddVertex(scopeNode); experiment.AddFixedConnection(decisionNode, scopeNode, true); experiment.AddFixedConnection(scopeNode, exitDecisionNode, true); experiment.SetLogLevelSettings(scopeNode); }
/// <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; }
// 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> /// Sets the log level current experiment settings on the node. /// </summary> /// <param name="node">The node which log level setting are set.</param> public void SetLogLevelSettings(ExperimentNode node) { m_experiment.SetLogLevelSettings(node); }
// 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; }