예제 #1
0
 public Simulation(
     ILogger logger,
     ISimulations simulations,
     ISimulationRunner runner)
 {
     this.log         = logger;
     this.simulations = simulations;
     this.runner      = runner;
 }
        protected override Task Context()
        {
            _simulationAnalysisCreator = A.Fake <ISimulationAnalysisCreator>();
            _cloner = A.Fake <ICloner>();
            _simulationSettingsRetriever = A.Fake <ISimulationSettingsRetriever>();
            _simulationRunner            = A.Fake <ISimulationRunner>();

            sut = new InteractiveSimulationRunner(_simulationSettingsRetriever, _simulationRunner, _cloner, _simulationAnalysisCreator);
            return(_completed);
        }
 public SimulationRunnerResultDecorator(
     ISimulationRunner simulationRunner,
     IWindow mainWindow,
     SimulationResultViewModelFactory vmFactory)
     : base(simulationRunner)
 {
     this.mainWindow = mainWindow;
     this.vmFactory = vmFactory;
     this.simulationRunner.SimulationEnded += ShowResult;
 }
예제 #4
0
        private void AssertScenario(ScenarioBase scenario, ISimulationRunner <SimulationEnvironment> runner)
        {
            var expected = scenario.GetExpectedEvents().ToList();
            var actual   = new List <Event>();

            runner.Events.Subscribe(actual.Add);
            var result = runner.Run(_maxDuration);

            Assert.SequenceEqual(expected, actual.ToList());
            AssertEnvironmentState(result.Environment);
        }
예제 #5
0
        protected override Task Context()
        {
            _simulationRunner = A.Fake <ISimulationRunner>();
            _logger           = A.Fake <IOSPSuiteLogger>();
            sut = new RunSimulationQualificationStepRunner(_simulationRunner, _logger);

            _simulation = new IndividualSimulation();
            _runSimulationQualificationStep = new RunSimulationQualificationStep {
                Simulation = _simulation
            };
            return(_completed);
        }
        public SimulationRunnerProgressDecorator(ISimulationRunner simulationRunner, IWindow mainWindow)
            : base(simulationRunner)
        {
            this.mainWindow = mainWindow;
            this.statusViewModel = new SimulationProgressViewModel(new DelegateCommand(this.Cancel));

            simulationRunner.IsRunningChanged += isRunning =>
            {
                if (isRunning) ShowProgress();
                else           HideProgress();
            };
            simulationRunner.ProgressStatus += ProgressStatusChanged;
        }
        public InteractiveSimulationRunner(ISimulationSettingsRetriever simulationSettingsRetriever, ISimulationRunner simulationRunner, ICloner cloner, ISimulationAnalysisCreator simulationAnalysisCreator)
        {
            _simulationSettingsRetriever = simulationSettingsRetriever;
            _simulationRunner            = simulationRunner;
            _cloner = cloner;
            _simulationAnalysisCreator = simulationAnalysisCreator;

            _simulationRunOptions = new SimulationRunOptions
            {
                CheckForNegativeValues = true,
                RaiseEvents            = true,
                RunForAllOutputs       = false,
                SimModelExportMode     = SimModelExportMode.Optimized
            };
        }
예제 #8
0
        // Append additional Hub properties and Statistics
        private async Task AppendHubPropertiesAndStatisticsAsync(
            IServicesConfig servicesConfig,
            IDeploymentConfig deploymentConfig,
            IIotHubConnectionStringManager connectionStringManager,
            ISimulationRunner simulationRunner,
            IRateLimiting rateReporter)
        {
            var isRunning = this.Running == true;

            foreach (var iotHub in this.IotHubs)
            {
                // Preprovisioned IoT hub status
                var isHubPreprovisioned = this.IsHubConnectionStringConfigured(servicesConfig);

                if (isHubPreprovisioned && isRunning)
                {
                    iotHub.PreprovisionedIoTHubInUse = await this.IsPreprovisionedIoTHubInUseAsync(servicesConfig, connectionStringManager);

                    iotHub.PreprovisionedIoTHubMetricsUrl = await this.GetIoTHubMetricsUrlAsync(servicesConfig, deploymentConfig, connectionStringManager);
                }
            }

            if (isRunning)
            {
                // Average messages per second frequency in the last minutes
                this.Statistics.AverageMessagesPerSecond = rateReporter.GetThroughputForMessages();

                // Total messages count
                this.Statistics.TotalMessagesSent = simulationRunner.TotalMessagesCount;

                // Active devices count
                this.Statistics.ActiveDevicesCount = simulationRunner.ActiveDevicesCount;

                // Failed telemetry messages count
                this.Statistics.FailedMessagesCount = simulationRunner.FailedMessagesCount;

                // Failed device connections count
                this.Statistics.FailedDeviceConnectionsCount = simulationRunner.FailedDeviceConnectionsCount;

                // Failed device connections count
                this.Statistics.FailedDeviceTwinUpdatesCount = simulationRunner.FailedDeviceTwinUpdatesCount;

                // Simulation errors count
                this.Statistics.SimulationErrorsCount = simulationRunner.SimulationErrorsCount;
            }
        }
예제 #9
0
 public SimulationExporter(
     ISimulationRunner simulationRunner,
     ILogger logger,
     IParametersReportCreator parametersReportCreator,
     ISimulationResultsExporter simulationResultsExporter,
     ISimulationExportTask simulationExportTask,
     IPopulationExportTask populationExportTask,
     IMoBiExportTask moBiExportTask
     )
 {
     _simulationRunner          = simulationRunner;
     _logger                    = logger;
     _parametersReportCreator   = parametersReportCreator;
     _simulationResultsExporter = simulationResultsExporter;
     _simulationExportTask      = simulationExportTask;
     _populationExportTask      = populationExportTask;
     _moBiExportTask            = moBiExportTask;
 }
        public override void GlobalContext()
        {
            base.GlobalContext();
            _simulation       = _simulationPersister.LoadSimulation(HelperForSpecs.DataFile("sc_model_2c.pkml"));
            _simulationRunner = Api.GetSimulationRunner();

            _containerTask = Api.GetContainerTask();
            _containerTask.AddQuantitiesToSimulationOutputByPath(_simulation, "DERMAL_APPLICATION_AREA|permeant|Mass_balance_observer");
            _containerTask.AddQuantitiesToSimulationOutputByPath(_simulation, "DERMAL_APPLICATION_AREA|permeant|Stratum_corneum_observer");
            _containerTask.AddQuantitiesToSimulationOutputByPath(_simulation, "DERMAL_APPLICATION_AREA|permeant|Vehicle_observer");

            _simulationBatch = new ConcurrentRunSimulationBatch
                               (
                _simulation,
                new SimulationBatchOptions
            {
                VariableParameters = new[]
                {
                    "DERMAL_APPLICATION_AREA|skin_compartment|SC_skin_sublayer|SC_total_thickness",
                    "DERMAL_APPLICATION_AREA|skin_compartment|Hydrated SC",
                }
            }
                               );


            _parValues = new SimulationBatchRunValues
            {
                ParameterValues = new[]
                {
                    0.0002, 1
                }
            };


            _simulationBatch.AddSimulationBatchRunValues(_parValues);
            sut.AddSimulationBatch(_simulationBatch);
        }
 public SimulationRunnerDecoratorBase(ISimulationRunner simulationRunner)
 {
     this.simulationRunner = simulationRunner;
 }
예제 #12
0
 public SimulationViewModel(ISimulationRunner simulationRunner)
 {
     this.simulationRunner  = simulationRunner;
     StartSimulationCommand = new RelayCommand(simulationRunner.StartSimulation);
     StopSimulationCommand  = new RelayCommand(simulationRunner.StopSimulation);
 }
예제 #13
0
 public RunSimulationCommand(ISimulationRunner simulationRunner)
     : base("RunSimulation", new DelegateCommand(simulationRunner.Run, () => !simulationRunner.IsRunning))
 {
     simulationRunner.IsRunningChanged += delegate { RaiseCanExecuteChanged(); };
 }
 public RunSimulationCommand(ISimulationRunner simulationRunner, IActiveSubjectRetriever activeSubjectRetriever)
 {
     _simulationRunner = simulationRunner;
 }
예제 #15
0
 public StopSimulationCommand(ISimulationRunner simulationRunnerTask)
 {
     _simulationRunnerTask = simulationRunnerTask;
 }
 public SimulationRunnerErrorDecorator(ISimulationRunner simulationRunner, IErrorReporter errorReporter)
     : base(simulationRunner)
 {
     this.errorReporter = errorReporter;
     this.SimulationEnded += x => errorReporter.AddIfNotNull(x.Error);
 }