Ejemplo n.º 1
0
        public void DefineCompositeComponentBasicTestSelectSubraphWithNoEndAndStart()
        {
            // load the experiment to be exported
            string     experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_define_composite_component_basic_test.teml");
            Experiment experiment         = ExperimentManager.Load(experimentFilename, AppContext.Components);

            experiment.Settings = AppContext.Settings; //assure that we apply global settings

            //select just one node
            foreach (ExperimentNode node in experiment.Vertices)
            {
                if (node.ID == TestImporterID)
                {
                    node.IsSelected = true;
                }
            }

            DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment);

            Assert.IsNotNull(setup);

            Assert.AreEqual(1, setup.InputSettings.Count);
            Assert.AreEqual(1, setup.OutputSettings.Count);
            Assert.AreEqual(0, setup.ConfigSettings.Count);
            Assert.IsTrue(setup.InputSettings["test1"].Include);
            Assert.IsTrue(setup.OutputSettings["test2"].Include);

            //rescan library to be sure it is fresh scan
            int numberOfComponentsInLibrary = GetCountOfComponentsInLibrary();

            //let's export the experiment as composite component
            setup.CompositeComponentLocationFilePath = exportFile;

            Assert.IsFalse(File.Exists(exportFile));
            setup.DefineComponent();

            Assert.IsTrue(File.Exists(exportFile));

            int updatedNumberOfComponents = GetCountOfComponentsInLibrary();

            //after rescan there should be one more component in the library
            Assert.AreEqual(numberOfComponentsInLibrary + 1, updatedNumberOfComponents);

            //iterate through all components until find new composite component
            CompositeComponentMetadataDefinition compositeComponentDefinition = FindCompositeComponent(exportFile);

            //assure that composite component definition has been found
            Assert.IsNotNull(compositeComponentDefinition); //if fails, composite component has not been found

            Assert.AreEqual(setup.Name, compositeComponentDefinition.Label);
            Assert.AreEqual(setup.Description, compositeComponentDefinition.Description);
            Assert.AreEqual(setup.Author, compositeComponentDefinition.Author);
            Assert.IsNotNull(compositeComponentDefinition.ComponentGraph);

            //the number of configuration properties should be the same
            Assert.AreEqual(setup.ConfigSettings.Count, compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count);

            Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Input.Count);  //one input was included
            Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Output.Count); //one output was included
        }
Ejemplo n.º 2
0
        public ComponentInfoPage(DefiningCompositeComponentSetup setup,
                                 IEnumerable <SettingsPath> componentDirectories) : this()
        {
            m_setup = setup;
            this.descriptionTextView.Buffer.Changed += DescriptionEntryChanged;

            InitComponentDirsComboBox(componentDirectories);
        }
Ejemplo n.º 3
0
        // END HERZUM SPRINT 3.0: TLAB-176

        public DefineCompositeComponentWizard(ApplicationContext context) : this()
        {
            //setup extracts selected nodes from current experiment and constructs composite component
            m_setup = new DefiningCompositeComponentSetup(context.Application.Experiment);

            // HERZUM SPRINT 3.0: TLAB-176
            if (IncludeChallenge(m_setup.CompositeComponentGraph))
            {
                ShowMessageDialog("Challenge Component Removed",
                                  "Define Composite", Gtk.ButtonsType.Ok, Gtk.MessageType.Warning);
            }
            // END HERZUM SPRINT 3.0: TLAB-176

            // HERZUM SPRINT 2.4 TLAB-157
            //create new experiment drawer with own factories

            /*
             * ExperimentDrawer drawer = new ExperimentDrawer(this.experimentcanvaswidget1,
             *                                             new NodeControlFactory(context),
             *                                             new NodeConnectionControlFactory(context));
             * //draw composite component that is being defined into canvas
             * drawer.DrawExperiment(m_setup.CompositeComponentGraph, false);
             */

            ExperimentCanvasPadFactory.CreateCompositeExperimentCanvasPad(context, this.experimentcanvaswidget1, m_setup.CompositeComponentGraph);
            // END HERZUM SPRINT 2.4 TLAB-157

            //zoom to fit moves view to display entire graph in the visible canvas
            //rather part that is not visible
            this.experimentcanvaswidget1.ZoomToFit();

            //if experiment is smaller than than the view scale it to original
            if (this.experimentcanvaswidget1.ZoomScale > 1)
            {
                this.experimentcanvaswidget1.ZoomToOriginal();
            }

            m_ioSpecSetupPage   = new IOSpecSetupPage(m_setup);
            m_configPage        = new ConfigSetupPage(m_setup);
            m_componentInfoPage = new ComponentInfoPage(m_setup, context.Application.Settings.ComponentPaths);
            m_confirmationPage  = new ConfirmationPage();

            this.mainVBox.Add(m_ioSpecSetupPage);
            this.mainVBox.Add(m_configPage);
            this.mainVBox.Add(m_componentInfoPage);
            this.mainVBox.Add(m_confirmationPage);

            m_componentInfoPage.ComponentNameChanged += delegate {
                RefreshDefineButton();
            };

            m_currentState = WizardState.IOSpec;

            DisplayCurrentPage();
        }
Ejemplo n.º 4
0
        public void DefineCompositeComponentSerializeDeserializeTest()
        {
            // load the experiment to be exported
            string     experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "Preprocessor.gml");
            Experiment experiment         = ExperimentManager.Load(experimentFilename, AppContext.Components);

            experiment.Settings = AppContext.Settings; //applying these settings was causing the bug #74

            //select all nodes
            foreach (ExperimentNode node in experiment.Vertices)
            {
                node.IsSelected = true;
            }

            DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment);

            setup.CompositeComponentLocationFilePath = exportFile;

            var tmpCompositeComponentDefinition = setup.GenerateCompositeComponentDefinition();

            XmlSerializer serializer = new XmlSerializer(typeof(TraceLab.Core.Components.CompositeComponentMetadataDefinition));

            Assert.IsFalse(File.Exists(exportFile));

            using (TextWriter writer = new StreamWriter(exportFile))
            {
                serializer.Serialize(writer, tmpCompositeComponentDefinition);
                writer.Close();
            }

            //check if file has been created
            Assert.IsTrue(System.IO.File.Exists(exportFile));

            //deserialize the file to CompositeComponentMetadataDefinition
            CompositeComponentMetadataDefinition compositeComponentDefinition;

            using (XmlReader reader = XmlReader.Create(exportFile))
            {
                compositeComponentDefinition = (CompositeComponentMetadataDefinition)serializer.Deserialize(reader);
                compositeComponentDefinition.PostProcessReadXml(AppContext.Components, AppContext.BaseTestDirectory);
            }
            Assert.IsNotNull(compositeComponentDefinition);
            Assert.AreEqual(compositeComponentDefinition.ID, tmpCompositeComponentDefinition.ID);
            Assert.AreEqual(compositeComponentDefinition.Version, tmpCompositeComponentDefinition.Version);
            Assert.AreEqual(compositeComponentDefinition.Classname, tmpCompositeComponentDefinition.Classname); //NAME
            Assert.AreEqual(compositeComponentDefinition.Author, tmpCompositeComponentDefinition.Author);
            Assert.AreEqual(compositeComponentDefinition.Label, tmpCompositeComponentDefinition.Label);
            Assert.AreEqual(compositeComponentDefinition.Description, tmpCompositeComponentDefinition.Description);
            Assert.AreEqual(compositeComponentDefinition.IOSpecDefinition, tmpCompositeComponentDefinition.IOSpecDefinition);
            Assert.AreEqual(compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count, tmpCompositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count);
            Assert.AreEqual(compositeComponentDefinition.ComponentGraph.VertexCount, tmpCompositeComponentDefinition.ComponentGraph.VertexCount);
            Assert.AreEqual(compositeComponentDefinition.ComponentGraph.EdgeCount, tmpCompositeComponentDefinition.ComponentGraph.EdgeCount);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Builds the list of candidate inputs and outputs used by the experiment that is being benchmarked
        /// </summary>
        /// <param name="experimentToBeBenchmarked">The experiment to be benchmarked.</param>
        public void PrepareMatchingIOByType(Experiment experimentToBeBenchmarked)
        {
            // Make sure to reset and previous state.
            ClearIO();

            m_setup = new DefiningCompositeComponentSetup(experimentToBeBenchmarked);

            //PROCESS INPUTS
            ProcessIO(ComponentTemplate.IOSpec.Input, m_setup.InputSettings, BenchmarkInputSetting);

            //PROCESS OUTPUTS
            ProcessIO(ComponentTemplate.IOSpec.Output, m_setup.OutputSettings, BenchmarkOutputsSetting);

            ProcessConfig(m_setup.ConfigSettings);
        }
        public DefiningCompositeComponentSetupViewModel(ExperimentViewModel experiment, ObservableCollection <SettingsPathViewModel> componentsPaths,
                                                        Action <TraceLab.Core.Components.CompositeComponentMetadataDefinition> howToAddToComponentsLibrary)
        {
            m_wrappedSetup          = new DefiningCompositeComponentSetup((Experiment)experiment.TopLevel, howToAddToComponentsLibrary);
            CompositeComponentGraph = new ExperimentViewModel(m_wrappedSetup.CompositeComponentGraph);

            //propagate notify on wrapped properties changes
            m_wrappedSetup.PropertyChanged += WrappedPropertyChanged;

            ComponentPaths = componentsPaths;
            SelectedComponentsDirectory = ComponentPaths.First <SettingsPathViewModel>();

            AdvanceState    = new DelegateCommand(DoAdvanceState, CanAdvanceState);
            BacktrackState  = new DelegateCommand(DoBacktrackState, CanBacktrackState);
            DefineComponent = new DelegateCommand(ExecuteDefineComponent, CanExecuteDefineComponent);
        }
        public DefineCompositeComponentWizard(ApplicationContext context) : this()
        {
            //setup extracts selected nodes from current experiment and constructs composite component
            m_setup = new DefiningCompositeComponentSetup(context.Application.Experiment);

            //create new experiment drawer with own factories
            ExperimentDrawer drawer = new ExperimentDrawer(this.experimentcanvaswidget1,
                                                           new NodeControlFactory(context),
                                                           new NodeConnectionControlFactory(context));

            //draw composite component that is being defined into canvas
            drawer.DrawExperiment(m_setup.CompositeComponentGraph, false);

            //zoom to fit moves view to display entire graph in the visible canvas
            //rather part that is not visible
            this.experimentcanvaswidget1.ZoomToFit();

            //if experiment is smaller than than the view scale it to original
            if (this.experimentcanvaswidget1.ZoomScale > 1)
            {
                this.experimentcanvaswidget1.ZoomToOriginal();
            }

            m_ioSpecSetupPage   = new IOSpecSetupPage(m_setup);
            m_configPage        = new ConfigSetupPage(m_setup);
            m_componentInfoPage = new ComponentInfoPage(m_setup, context.Application.Settings.ComponentPaths);
            m_confirmationPage  = new ConfirmationPage();

            this.mainVBox.Add(m_ioSpecSetupPage);
            this.mainVBox.Add(m_configPage);
            this.mainVBox.Add(m_componentInfoPage);
            this.mainVBox.Add(m_confirmationPage);

            m_componentInfoPage.ComponentNameChanged += delegate {
                RefreshDefineButton();
            };

            m_currentState = WizardState.IOSpec;

            DisplayCurrentPage();
        }
Ejemplo n.º 8
0
 public ConfigSetupPage(DefiningCompositeComponentSetup setup) : this()
 {
     m_setup = setup;
     InitializeConfigListView();
 }
Ejemplo n.º 9
0
        public void DefineCompositeComponentBasicTestSelectAllNodes()
        {
            // load the experiment to be exported
            string     experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_define_composite_component_basic_test.teml");
            Experiment experiment         = ExperimentManager.Load(experimentFilename, AppContext.Components);

            experiment.Settings = AppContext.Settings; //assure that we apply global settings

            //in first basic test select all nodes
            foreach (ExperimentNode node in experiment.Vertices)
            {
                node.IsSelected = true;
            }

            DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment);

            Assert.IsNotNull(setup);

            Assert.AreEqual(1, setup.InputSettings.Count);
            Assert.AreEqual(2, setup.OutputSettings.Count);
            Assert.AreEqual(1, setup.ConfigSettings.Count);

            Assert.IsTrue(setup.InputSettings["test1"].Include);
            Assert.IsTrue(setup.OutputSettings["test1"].Include);
            Assert.IsTrue(setup.OutputSettings["test2"].Include);

            //note, if there are two components with the same label and same config name, the expected behaviour is to add
            Assert.IsTrue(setup.ConfigSettings["Test writer Value"].Include);

            //get real names of the config values
            string configName1 = setup.ConfigSettings["Test writer Value"].PropertyObject.Name;

            //change settings to sth different values
            setup.Name        = "Test Composite Component";
            setup.Author      = "Author XYZ";
            setup.Description = "Composite Component to test export";

            //don't include following in the export
            setup.InputSettings["test1"].Include  = false;
            setup.OutputSettings["test1"].Include = false;

            //rescan library to be sure it is fresh scan
            int numberOfComponentsInLibrary = GetCountOfComponentsInLibrary();

            //set file path to composite component
            setup.CompositeComponentLocationFilePath = exportFile;
            Assert.IsFalse(File.Exists(setup.CompositeComponentLocationFilePath));

            setup.DefineComponent();

            Assert.IsTrue(File.Exists(exportFile));

            //rescan the library
            int updatedNumberOfComponents = GetCountOfComponentsInLibrary();

            //after rescan there should be one more component in the library
            Assert.AreEqual(numberOfComponentsInLibrary + 1, updatedNumberOfComponents);

            //iterate through all components until find new composite component
            CompositeComponentMetadataDefinition compositeComponentDefinition = FindCompositeComponent(exportFile);

            //assure that composite component definition has been found
            Assert.IsNotNull(compositeComponentDefinition); //if fails, composite component has not been found

            Assert.AreEqual(setup.Name, compositeComponentDefinition.Label);
            Assert.AreEqual(setup.Description, compositeComponentDefinition.Description);
            Assert.AreEqual(setup.Author, compositeComponentDefinition.Author);
            Assert.IsNotNull(compositeComponentDefinition.ComponentGraph);

            //the number of configuration properties should be the same
            Assert.AreEqual(setup.ConfigSettings.Count, compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count);

            ConfigPropertyObject config1 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName1];

            Assert.AreEqual("Test writer Value", config1.DisplayName);

            Assert.IsTrue(config1.Visible);                                                 //config1 should  be visible, because Include was set to false

            Assert.AreEqual(0, compositeComponentDefinition.IOSpecDefinition.Input.Count);  //no input was included
            Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Output.Count); //only one output was included
        }
Ejemplo n.º 10
0
        public void DefineCompositeComponentFromExperimentWithAnotherCompositeComponentTest()
        {
            // load the experiment to be exported
            string     experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_with_composite_component.teml");
            Experiment experiment         = ExperimentManager.Load(experimentFilename, AppContext.Components);

            experiment.Settings = AppContext.Settings; //applying these settings was causing the bug #74

            //select all nodes
            foreach (ExperimentNode node in experiment.Vertices)
            {
                node.IsSelected = true;
            }

            DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment);

            Assert.IsNotNull(experiment);
            Assert.AreEqual(3, experiment.VertexCount);
            Assert.IsNotNull(setup);

            Assert.AreEqual(0, setup.InputSettings.Count);
            Assert.AreEqual(2, setup.OutputSettings.Count);
            Assert.AreEqual(2, setup.ConfigSettings.Count);

            //check if default name is the same as experiment info
            Assert.IsTrue(setup.OutputSettings["test_x"].Include);
            Assert.IsTrue(setup.OutputSettings["test_y"].Include);
            Assert.IsTrue(setup.ConfigSettings["Composite Component Test writer Value"].Include);
            Assert.IsTrue(setup.ConfigSettings["Composite Component Test writer Value 2"].Include);

            //get real names of the config values
            string configName1 = setup.ConfigSettings["Composite Component Test writer Value"].PropertyObject.Name;
            string configName2 = setup.ConfigSettings["Composite Component Test writer Value 2"].PropertyObject.Name;

            //change settings to sth different values
            setup.Name        = "Complex Composite Component";
            setup.Author      = "Author XYZ";
            setup.Description = "Complex Composite Component to test export";

            //don't include following in the export
            setup.OutputSettings["test_y"].Include = false;

            //change alias
            setup.ConfigSettings["Composite Component Test writer Value"].Alias     = "Config 1";
            setup.ConfigSettings["Composite Component Test writer Value 2"].Alias   = "Config 2";
            setup.ConfigSettings["Composite Component Test writer Value 2"].Include = false;

            //rescan library to be sure it is fresh scan
            int numberOfComponentsInLibrary = GetCountOfComponentsInLibrary();

            //let's export the experiment as composite component
            Assert.IsFalse(File.Exists(exportFile));
            setup.CompositeComponentLocationFilePath = exportFile;

            setup.DefineComponent();

            Assert.IsTrue(File.Exists(exportFile));

            //rescan the library
            int updatedNumberOfComponents = GetCountOfComponentsInLibrary();

            //after rescan there should be one more component in the library
            Assert.AreEqual(numberOfComponentsInLibrary + 1, updatedNumberOfComponents);

            //iterate through all components until find new composite component
            CompositeComponentMetadataDefinition compositeComponentDefinition = FindCompositeComponent(exportFile);

            //assure that composite component definition has been found
            Assert.IsNotNull(compositeComponentDefinition); //if fails, composite component has not been found

            Assert.AreEqual(setup.Name, compositeComponentDefinition.Label);
            Assert.AreEqual(setup.Description, compositeComponentDefinition.Description);
            Assert.AreEqual(setup.Author, compositeComponentDefinition.Author);
            Assert.IsNotNull(compositeComponentDefinition.ComponentGraph);

            //the number of configuration properties should be the same
            Assert.AreEqual(setup.ConfigSettings.Count, compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count);

            ConfigPropertyObject config1 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName1];
            ConfigPropertyObject config2 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName2];

            Assert.AreEqual("Config 1", config1.DisplayName);
            Assert.AreEqual("Config 2", config2.DisplayName);

            Assert.IsTrue(config1.Visible);
            Assert.IsFalse(config2.Visible);                                                //config1 should not be visible, because Include was set to false

            Assert.AreEqual(0, compositeComponentDefinition.IOSpecDefinition.Input.Count);  //none input value were included
            Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Output.Count); //one output value was included
        }
Ejemplo n.º 11
0
 public IOSpecSetupPage(DefiningCompositeComponentSetup setup) : this()
 {
     m_setup = setup;
     InitializeInputsListView();
     InitializeOutputsListView();
 }