Пример #1
0
        private void StartSimulation(bool oneStepOnly)
        {
            if (SimulationHandler.State == MySimulationHandler.SimulationState.STOPPED)
            {
                MyLog.INFO.WriteLine("--------------");
                bool anyOutputChanged = UpdateMemoryModel();

                MyValidator validator = ValidationView.Validator;
                validator.Simulation = SimulationHandler.Simulation;

                validator.ClearValidation();

                Project.World.ValidateWorld(validator);
                Project.Network.Validate(validator);

                validator.AssertError(!anyOutputChanged, Project.Network, "Possible infinite loop in memory block sizes.");

                ValidationView.UpdateListView();
                validator.Simulation = null;

                ResetObservers();

                if (validator.ValidationSucessfull)
                {
                    try
                    {
                        SimulationHandler.StartSimulation(oneStepOnly);
                    }
                    catch (Exception e)
                    {
                        MyLog.ERROR.WriteLine("Simulation cannot be started! Exception occured: " + e.Message);
                    }
                }
                else
                {
                    MyLog.ERROR.WriteLine("Simulation cannot be started! Validation failed.");
                    OpenFloatingOrActivate(ValidationView);
                }
            }
            else
            {
                try
                {
                    SimulationHandler.StartSimulation(oneStepOnly);
                }
                catch (Exception e)
                {
                    MyLog.ERROR.WriteLine("Simulation cannot be started! Exception occured: " + e.Message);
                }
            }
        }