private void exportToDirectory(ISimulation simulation, string exportDirectory)
        {
            var fileName            = createFilePathFor(simulation, exportDirectory, Constants.Filter.XML_EXTENSION);
            var modelCoreSimulation = _simulationToModelCoreSimulationMapper.MapFrom(simulation, shouldCloneModel: false);

            _simModelExporter.Export(modelCoreSimulation, fileName);
        }
        protected override void Context()
        {
            _dataFactory               = A.Fake <IDataFactory>();
            _simModelExporter          = A.Fake <ISimModelExporter>();
            _simModelSimulationFactory = A.Fake <ISimModelSimulationFactory>();
            _simModelSimulation        = A.Fake <ISimulation>();

            sut = new SimModelBatch(_simModelExporter, _simModelSimulationFactory, _dataFactory);

            A.CallTo(() => _simModelSimulationFactory.Create()).Returns(_simModelSimulation);
            _modelCoreSimulation = A.Fake <IModelCoreSimulation>();
            _simModelXmlString   = "SimModelXml";
            A.CallTo(() => _simModelExporter.Export(_modelCoreSimulation, SimModelExportMode.Optimized)).Returns(_simModelXmlString);

            _parameterProperties1 = A.Fake <IParameterProperties>();
            _parameterProperties2 = A.Fake <IParameterProperties>();
            _parameterProperties3 = A.Fake <IParameterProperties>();

            A.CallTo(() => _parameterProperties1.Path).Returns("ParameterPath1");
            A.CallTo(() => _parameterProperties2.Path).Returns("ParameterPath2");
            A.CallTo(() => _parameterProperties3.Path).Returns("ParameterPath3");

            _allSimModelParameters = new List <IParameterProperties> {
                _parameterProperties1, _parameterProperties2, _parameterProperties3
            };
            A.CallTo(() => _simModelSimulation.ParameterProperties).Returns(_allSimModelParameters);

            _variableParameterPaths = new List <string> {
                _parameterProperties1.Path, _parameterProperties2.Path
            };
        }
示例#3
0
        public void ExportSimModelXml(IMoBiSimulation simulation)
        {
            var fileName = _dialogCreator.AskForFileToSave(AppConstants.Captions.Save, AppConstants.Filter.SIM_MODEL_FILE_FILTER, Constants.DirectoryKey.SIM_MODEL_XML, simulation.Name);

            if (fileName.IsNullOrEmpty())
            {
                return;
            }
            _simModelExporter.Export(simulation, fileName);
        }
示例#4
0
        public void ExportForCluster(PopulationSimulation populationSimulation)
        {
            _lazyLoadTask.Load(populationSimulation);

            if (settingsRequired(populationSimulation))
            {
                var outputSelections = _simulationSettingsRetriever.SettingsFor(populationSimulation);
                if (outputSelections == null)
                {
                    return;
                }

                populationSimulation.OutputSelections.UpdatePropertiesFrom(outputSelections, _cloner);
            }

            FileSelection populationExport;

            using (var presenter = _applicationController.Start <ISelectFilePresenter>())
            {
                populationExport = presenter.SelectDirectory(PKSimConstants.UI.ExportForClusterSimulationTitle, Constants.DirectoryKey.SIM_MODEL_XML);
            }
            if (populationExport == null)
            {
                return;
            }

            var populationFolder = populationExport.FilePath;
            var existingFiles    = Directory.GetFiles(populationFolder);

            if (existingFiles.Any())
            {
                if (_dialogCreator.MessageBoxYesNo(PKSimConstants.UI.DeleteFilesIn(populationFolder)).Equals(ViewResult.No))
                {
                    return;
                }

                existingFiles.Each(FileHelper.DeleteFile);
            }

            var fileName                      = populationSimulation.Name;
            var modelFileFullPath             = Path.Combine(populationFolder, $"{fileName}.xml");
            var agingFileFullPath             = Path.Combine(populationFolder, $"{fileName}{CoreConstants.Population.TableParameterExport}.csv");
            var outputDeffinitionFileFullPath = Path.Combine(populationFolder, $"{fileName}{CoreConstants.Population.OutputDefinitionExport}.csv");

            //Model
            _simModelExporter.Export(_modelCoreSimulationMapper.MapFrom(populationSimulation, shouldCloneModel: false), modelFileFullPath);
            // Outputs

            var outputSelection = populationSimulation.OutputSelections;

            exportOutputDefiniton(outputSelection, outputDeffinitionFileFullPath);

            //all values
            var dataTable = CreatePopulationDataFor(populationSimulation);

            dataTable.ExportToCSV(Path.Combine(populationFolder, $"{fileName}.csv"), comments: getProjectMetaInfo(populationExport.Description));

            //all aging data
            var agingData = populationSimulation.AgingData.ToDataTable();

            if (agingData.Rows.Count > 0)
            {
                agingData.ExportToCSV(agingFileFullPath, comments: getProjectMetaInfo(populationExport.Description));
            }
        }
示例#5
0
 public Task ExportSimulationToSimModelXmlAsync(Simulation simulation, string fileName)
 {
     return(Task.Run(() => _simModelExporter.Export(_coreSimulationMapper.MapFrom(simulation, shouldCloneModel: false), fileName)));
 }
示例#6
0
        public void SaveToSimModelXmlFile(string pkmlFileFullPath, string simModelXmlFileFullPath)
        {
            var simulationTransfer = _simulationTransferLoader.Load(pkmlFileFullPath);

            _simModelExporter.Export(simulationTransfer.Simulation, simModelXmlFileFullPath);
        }
 /// <summary>
 ///    Create the xml for simmodel based on the <paramref name="simulation" />
 /// </summary>
 protected string CreateSimulationExport(IModelCoreSimulation simulation, SimModelExportMode simModelExportMode)
 {
     return(_simModelExporter.Export(simulation, simModelExportMode));
 }