private void Execute(IStageSimulation stageSimulation) { try { //logger.Info("Inicio Ejecutar"); foreach (var variable in stageSimulation.GetVariables().Where(v => v.Name != "T")) { if (variable is StageVariableArray) { foreach (var variableItem in ((StageVariableArray)variable).Variables) { variableItem.ActualValue = variableItem.InitialValue; } } else { variable.ActualValue = variable.InitialValue; } } var timeVariable = stageSimulation.GetVariables().First(v => v.Name == "T"); timeVariable.ActualValue = timeVariable.InitialValue; this.GetActor(stageSimulation).Tell(stageSimulation.GetMainDiagram()); //logger.Info("Fin Ejecutar"); } catch (Exception ex) { logger.Error(ex.Source + " - " + ex.Message + ": " + ex.StackTrace); throw ex; } }
public void Update(IStageSimulation stageSimulation) { try { //logger.Info("Inicio Actualizar"); foreach (var variable in stageSimulation.GetVariables()) { if (variable is StageVariableArray) { var stageVariableArray = (StageVariableArray)variable; var variableArray = (VariableArray)this.variables.First(v => v.Name == variable.Name); foreach (var v in stageVariableArray.Variables) { variableArray.Variables.First(x => x.Name == v.Name).ActualValue = v.ActualValue; } } else { this.variables.First(v => v.Name == variable.Name).ActualValue = variable.ActualValue; } } this.stopExecution = stageSimulation.GetExecutionStatus(); if (this.stopExecution) { this.ChangeStatus(SimulationStatus.Stoped); if (this.simulationStatus == SimulationStatus.Stoped) { logger.Info("Simulación Detenida (Listado de Variables): " + VariablesToString()); } } //logger.Info("Fin Actualizar"); } catch (Exception ex) { logger.Error(ex.Source + " - " + ex.Message + ": " + ex.StackTrace); throw ex; } }