public WorkspaceViewModel(TraceLab.Core.Workspaces.Workspace workspace, string experimentId)
        {
            if (workspace == null)
                throw new ArgumentNullException("workspace");
            if (String.IsNullOrEmpty(experimentId))
                throw new ArgumentException("Experiment id cannot be null or empty", "experimentId");

            m_workspace = workspace;
            m_workspace.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(workspace_PropertyChanged);

            m_experimentId = experimentId;

            //init observable collections
            m_experimentWorkspaceUnits = new ObservableCollection<WorkspaceUnit>();
            m_readonlyExperimentWorkspaceUnits = new ReadOnlyObservableCollection<WorkspaceUnit>(m_experimentWorkspaceUnits);

            //prefill local units with units of this experiment
            foreach (WorkspaceUnit unit in m_workspace.Units)
            {
                AddUnit(unit);
            }

            INotifyCollectionChanged workspaceUnitCollection = m_workspace.Units;
            workspaceUnitCollection.CollectionChanged += WorkspaceCollectionCollectionChanged;

            (new TraceLab.Core.Components.LibraryHelper(m_workspace.TypeDirectories)).PreloadWorkspaceTypes(System.AppDomain.CurrentDomain);
        }
Exemple #2
0
        public WorkspaceViewModel(TraceLab.Core.Workspaces.Workspace workspace, string experimentId)
        {
            if (workspace == null)
            {
                throw new ArgumentNullException("workspace");
            }
            if (String.IsNullOrEmpty(experimentId))
            {
                throw new ArgumentException("Experiment id cannot be null or empty", "experimentId");
            }

            m_workspace = workspace;
            m_workspace.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(workspace_PropertyChanged);

            m_experimentId = experimentId;

            //init observable collections
            m_experimentWorkspaceUnits         = new ObservableCollection <WorkspaceUnit>();
            m_readonlyExperimentWorkspaceUnits = new ReadOnlyObservableCollection <WorkspaceUnit>(m_experimentWorkspaceUnits);

            //prefill local units with units of this experiment
            foreach (WorkspaceUnit unit in m_workspace.Units)
            {
                AddUnit(unit);
            }

            INotifyCollectionChanged workspaceUnitCollection = m_workspace.Units;

            workspaceUnitCollection.CollectionChanged += WorkspaceCollectionCollectionChanged;

            (new TraceLab.Core.Components.LibraryHelper(m_workspace.TypeDirectories)).PreloadWorkspaceTypes(System.AppDomain.CurrentDomain);
        }
        public BenchmarkWizard(string benchmarkDirectory, ComponentsLibrary library, Workspace workspace,
                               List<string> workspaceTypeDirectories, string dataRoot, TraceLab.Core.Settings.Settings settings)
        {
            m_workspace = workspace;
            m_componentsLibrary = library;
            m_dataRoot = dataRoot;
            m_settings = settings;
            BenchmarksDirectory = benchmarkDirectory;

        }
        private static TraceLab.Core.Workspaces.Workspace InitWorkspace(IEnumerable <string> typeDirectories, string workspaceDirectory, string cacheDirectory)
        {
            //Init workspace
            //TODO pass IEnumerable instead of List into workspaces...
            WorkspaceManager.InitWorkspace(new List <string>(typeDirectories), workspaceDirectory, cacheDirectory);
            TraceLab.Core.Workspaces.Workspace workspace = (TraceLab.Core.Workspaces.Workspace)WorkspaceManager.WorkspaceInstance;

            System.Reflection.Assembly sdk = System.Reflection.Assembly.GetAssembly(typeof(TraceLabSDK.IWorkspace));

            foreach (Type type in sdk.GetTypes())
            {
                if (type.Namespace.Equals("TraceLabSDK.Types"))
                {
                    workspace.RegisterType(type);
                }
            }

            return(workspace);
        }
        public BenchmarkWizardViewModel(BenchmarkWizard benchmarkWizard, Workspace workspace, ComponentsLibrary library)
        {
            if (benchmarkWizard == null)
                throw new ArgumentNullException("benchmarkWizard", "Wrapped benchmark wizard cannot be null");
            if (workspace == null)
                throw new ArgumentNullException("workspace");
            if (library == null)
                throw new ArgumentNullException("library");

            AdvanceState = new DelegateCommand(DoAdvanceState, CanAdvanceState);
            BacktrackState = new DelegateCommand(DoBacktrackState, CanBacktrackState);
            Process = new DelegateCommand(DoProcess, DoCanProcess);
            DownloadContestPackage = new DelegateCommand(ExecuteDownloadContestPackage);
           
            m_benchmarkWizard = benchmarkWizard;
            m_workspace = workspace;
            m_library = library;

            m_benchmarkWizard.PropertyChanged += OnWrappedBenchmarkWizardPropertyChanged;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefiningBenchmark"/> class.
        /// </summary>
        /// <param name="baseExperiment">The base experiment represents experiment based on which the benchmark is being defined.</param>
        public DefiningBenchmark(Experiment baseExperiment, ComponentsLibrary library,
                                 Workspace workspace, PackageSystem.PackageManager manager, 
                                 IEnumerable<string> workspaceTypeDirectories, string webserviceAddress)
        {
            if (baseExperiment == null)
                throw new ArgumentNullException("baseExperiment");
            if (library == null)
                throw new ArgumentNullException("library");
            if (workspace == null)
                throw new ArgumentNullException("workspace");
            if (workspaceTypeDirectories == null)
                throw new ArgumentNullException("workspaceTypeDirectories");

            // these are needed to create experiment serializing in Define method
            m_packageManager = manager;
            m_library = library;
            WebserviceAddress = webserviceAddress;
            if (webserviceAddress != null)
            {
                m_webService = new WebserviceAccessor(webserviceAddress, true);
            }

            m_baseExperiment = baseExperiment;

            m_workspace = workspace;
            //wrap the workspace into experiment workspace wrapper, so that we can load units only from experiment namespace
            m_experimentWorkspaceWrapper = new ExperimentWorkspaceWrapper(workspace, m_baseExperiment.ExperimentInfo.Id);

            //prefil benchmark info
            PrefillBenchmarkInfo();

            //get nodes that can be selected as template 
            GetTemplatizableComponents();

            //get the ExperimentResults variables that can be selected as publishable results
            //from the ExperimentResults all metric names, their descriptions and dataset names are going to be extracted 
            //when contest is going to be published
            GetPublishableExperimentResults();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationViewModel"/> class.
 /// Each application view model needs to have access to the actual workspace (not a wrapper), so that
 /// other application models could be created.
 /// The WorkspaceViewModel wrapper exists only if application view model contains the experiment.
 /// </summary>
 /// <param name="workspace">The workspace.</param>
 /// <param name="username">The name of the user from the license file (to be displayed by the application).</param>
 public ApplicationViewModel(Workspace workspace)
 {
     Version = Assembly.GetCallingAssembly().GetName().Version.ToString();
     System.AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
     Workspace = workspace;
 }
        /// <summary>
        /// Runs the experiment asynchronously... it will wait till the experiment runner thread completes before returning.
        /// </summary>
        /// <param name="experiment">The experiment.</param>
        /// <param name="progress">The progress.</param>
        private void RunExperimentAsync(Experiment experiment, IProgress progress, Workspace workspace, ComponentsLibrary library)
        {
            using (var waiter = new System.Threading.ManualResetEventSlim())
            {
                experiment.RunExperiment(progress, workspace, library);
                experiment.ExperimentCompleted += (sender, args) =>
                {
                    waiter.Set();
                };

                waiter.Wait();
            }
        }
        private static IExperimentRunner CreateExperiment(Experiment experiment, Workspace workspace, ComponentsLibrary library)
        {
            RunnableExperimentBase graph = null;

            ExperimentWorkspaceWrapper experimentWorkspaceWrapper = WorkspaceWrapperFactory.CreateExperimentWorkspaceWrapper(workspace, experiment.ExperimentInfo.Id);
            RunnableNodeFactory templateGraphNodesFactory = new RunnableNodeFactory(experimentWorkspaceWrapper);
            graph = GraphAdapter.Adapt(experiment, templateGraphNodesFactory, library, workspace.TypeDirectories);

            //clear Workspace
            workspace.DeleteUnits(experiment.ExperimentInfo.Id);

            IExperimentRunner dispatcher = ExperimentRunnerFactory.CreateExperimentRunner(graph);

            return dispatcher;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExperimentWorkspaceWrapper"/> class.
 /// </summary>
 /// <param name="workspaceInstance">The workspace instance.</param>
 /// <param name="workspaceNamespaceId">The workspace namespace id.</param>
 internal ExperimentWorkspaceWrapper(Workspace workspaceInstance, string workspaceNamespaceId)
 {
     m_workspaceInstance = workspaceInstance;
     m_workspaceNamespaceId = workspaceNamespaceId;
 }
 public static ExperimentWorkspaceWrapper CreateExperimentWorkspaceWrapper(Workspace workspaceInstance, string experimentId)
 {
     return new ExperimentWorkspaceWrapper(workspaceInstance, experimentId);
 }