예제 #1
0
        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;
            }
        }
예제 #2
0
 private IActorRef GetActor(IStageSimulation stageSimulation)
 {
     try
     {
         //logger.Info("Inicio Obtener Actor");
         var akkaConfiguration = ((AkkaConfigurationSection)ConfigurationManager.GetSection("akka")).AkkaConfig;
         var system            = ActorSystem.Create("MySystem", akkaConfiguration);
         //logger.Info("Fin Obtener Actor");
         return(system.ActorOf(NodeActor.Props(stageSimulation), "nodeActor_" + stageSimulation.GetHashCode()));
     }
     catch (Exception ex)
     {
         logger.Error(ex.Source + " - " + ex.Message + ": " + ex.StackTrace);
         throw ex;
     }
 }
예제 #3
0
        public NodeActor(IStageSimulation stageSimulation)
        {
            try
            {
                //log.Info("Inicio Nodo Actor");
                this.stageSimulation = stageSimulation;

                Receive <Diagram>(diagram => this.Execute(diagram));
                Receive <Node>(node => this.Execute(node));
                //log.Info("Fin Nodo Actor");
            }
            catch (Exception ex)
            {
                logger.Error(ex.Source + " - " + ex.Message + ": " + ex.StackTrace);
                throw ex;
            }
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
 public static Props Props(IStageSimulation stageSimulation)
 {
     return(Akka.Actor.Props.Create(() => new NodeActor(stageSimulation)));
 }
예제 #6
0
 private void UpdateSimulation(IStageSimulation stageSimulation)
 {
     //logger.Info("Inicio Actualizar Simulacion");
     stageSimulation.GetSimulation().Update(stageSimulation);
     //logger.Info("Fin Actualizar Simulacion");
 }