示例#1
0
        public override async Task <ModelSimulation> MapToModel(SnapshotSimulation snapshot, PKSimProject project)
        {
            _logger.AddDebug(PKSimConstants.Information.LoadingSimulation(snapshot.Name), project.Name);

            var simulation = await createSimulationFrom(snapshot, project);

            simulation.Solver = await _solverSettingsMapper.MapToModel(snapshot.Solver);

            simulation.OutputSchema = await _outputSchemaMapper.MapToModel(snapshot.OutputSchema);

            simulation.OutputSelections = await _outputSelectionsMapper.MapToModel(snapshot.OutputSelections, simulation);

            await updateParameters(simulation, snapshot.Parameters);
            await updateAdvancedParameters(simulation, snapshot.AdvancedParameters);

            updateUsedObservedData(simulation, snapshot.ObservedData, project);

            await runSimulation(snapshot, simulation);

            simulation.AddAnalyses(await individualAnalysesFrom(simulation, snapshot.IndividualAnalyses, project));
            simulation.AddAnalyses(await populationAnalysesFrom(simulation, snapshot.PopulationAnalyses, project));

            _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation);
            return(simulation);
        }
        public override async Task <ModelSimulation> MapToModel(SnapshotSimulation snapshot, SimulationContext snapshotContext)
        {
            var project = snapshotContext.Project;

            _logger.AddInfo(PKSimConstants.Information.LoadingSimulation(snapshot.Name, snapshotContext.NumberOfSimulationsLoaded, snapshotContext.NumberOfSimulationsToLoad), project.Name);

            //Local cache of ids' that will be used to retrieve original building block parameters as the project is only registered
            //in global context once the whole snapshot mapping process is completed

            var withIdRepository    = new WithIdRepository();
            var registrationVisitor = new RegisterObjectVisitor(withIdRepository);

            var simulation = await createSimulationFrom(snapshot, snapshotContext);

            var contextWithSimulation = new SnapshotContextWithSimulation(simulation, snapshotContext);

            simulation.Solver = await _solverSettingsMapper.MapToModel(snapshot.Solver, snapshotContext);

            simulation.OutputSchema = await _outputSchemaMapper.MapToModel(snapshot.OutputSchema, snapshotContext);

            simulation.OutputSelections = await _outputSelectionsMapper.MapToModel(snapshot.OutputSelections, contextWithSimulation);

            registrationVisitor.Register(simulation);

            await updateParameters(simulation, snapshot.Parameters, withIdRepository, snapshotContext);

            await updateAdvancedParameters(simulation, snapshot.AdvancedParameters, snapshotContext);

            updateUsedObservedData(simulation, snapshot.ObservedData, project);

            updateAlteredBuildingBlock(simulation, snapshot.AlteredBuildingBlocks);

            if (snapshotContext.Run)
            {
                await runSimulation(snapshot, simulation);
            }

            simulation.AddAnalyses(await individualAnalysesFrom(simulation, snapshot.IndividualAnalyses, snapshotContext));
            simulation.AddAnalyses(await populationAnalysesFrom(simulation, snapshot.PopulationAnalyses, snapshotContext));

            _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation);
            return(simulation);
        }