コード例 #1
0
 public GameEngine(FormInput input, SimulationEngine simulationEngine)
 {
     _input            = input;
     _monitor          = new PerformanceMonitor();
     _simulationEngine = simulationEngine;
     PreUpdate        += _monitor.CaptureFrame;
 }
コード例 #2
0
ファイル: OutputPin.cs プロジェクト: Jath1024/DangrLib
 public OutputPin(SimulationEngine engine, int dataBitWidth)
     : base(engine)
 {
     this.DataBitWidth         = dataBitWidth;
     this.In                   = new ReadConnection(this.DataBitWidth);
     this.In.DataValueChanged += this.OnInputDataValueChanged;
 }
コード例 #3
0
ファイル: Probe.cs プロジェクト: Jath1024/DangrLib
 public Probe(SimulationEngine engine, int dataBitWidth)
     : base(engine)
 {
     this.DataBitWidth         = dataBitWidth;
     this.DataValue            = DataValue.Floating(this.DataBitWidth);
     this.In                   = new ReadConnection(this.DataBitWidth);
     this.In.DataValueChanged += this.OnInputDataValueChanged;
 }
コード例 #4
0
        public NotGate(SimulationEngine engine, int bitWidth)
            : base(engine)
        {
            this.DataBitWidth = bitWidth;

            this.In = new ReadConnection(bitWidth);
            this.In.DataValueChanged += this.OnInputDataValueChanged;

            this.Out = new WriteConnection(bitWidth);
        }
コード例 #5
0
        public void Initialize(Configuration theConfiguration)
        {
            initCommands();

            mySimulation = new SimulationEngine();
            mySimulation.Initialize(UniverseFactory.CreateUniverse(theConfiguration));

            configureVisualization(theConfiguration);
            displayUniverse(mySimulation.Universe);
        }
コード例 #6
0
        public GameEngine(IRenderer renderer, FormInput input, SimulationEngine simulationEngine) : this(input, simulationEngine)
        {
            _renderer = renderer;

            // TODO: There's probably a better way to achieve event propogation.
            // Or perhaps event in renderer is unnecessary.
            renderer.OnFrame += (object sender, FrameEventArgs e) => {
                OnFrame(this, e);
            };
        }
コード例 #7
0
        public StandardSimulation()
        {
            _random           = new Random();
            _simulationEngine = new SimulationEngine(_random);

            _bitmapEngine            = new BitmapEngine(_simulationEngine);
            _inclusionsEngine        = new InclusionsEngine(_random, _simulationEngine);
            _CAEngine                = new CAEngine(_random, _simulationEngine);
            _MCEngine                = new MCEngine(_random, _simulationEngine);
            _fileEngine              = new FileEngine(_simulationEngine);
            _recrystallizationEngine = new RecrystallizationEngine(_random, _simulationEngine);
        }
コード例 #8
0
ファイル: Standalone.cs プロジェクト: igaray/iaj
    static void Start()
    {
        quit = false;

        ss = new SimulationState("config.xml");
        se = new SimulationEngine(ss);

        Console.WriteLine("Press press any key to stop the simulation engine.");
        Console.WriteLine("Note: there is no ANY key on your keyboard.");

        se.start();
    }
コード例 #9
0
ファイル: AndGateTests.cs プロジェクト: Jath1024/DangrLib
        public TestOutput(SimulationEngine engine, params int[] bitWidths)
        {
            this.engine = engine;
            int numOutputs = bitWidths.Length;

            this.connections = new ReadConnection[numOutputs];

            for (var i = 0; i < numOutputs; i++)
            {
                this.connections[i] = new ReadConnection(bitWidths[i]);
            }
        }
コード例 #10
0
ファイル: Wire.cs プロジェクト: Jath1024/DangrLib
        public static void Connect(SimulationEngine engine, params IConnection[] connections)
        {
            if (connections.Length == 0)
            {
                return;
            }

            int bitWidth = connections[0].DataBitWidth;
            var wire     = new Wire(engine, bitWidth);

            Wire.Connect(wire, connections);
        }
コード例 #11
0
ファイル: Standalone.cs プロジェクト: igaray/iaj
    static void Start()
    {
        quit = false;

        ss = new SimulationState("config.xml");
        se = new SimulationEngine(ss);

        Console.WriteLine("Press press any key to stop the simulation engine.");
        Console.WriteLine("Note: there is no ANY key on your keyboard.");

        se.start();
    }
コード例 #12
0
        public ControlledBuffer(SimulationEngine engine, int bitWidth)
            : base(engine)
        {
            this.DataBitWidth = bitWidth;

            this.In = new ReadConnection(bitWidth);
            this.In.DataValueChanged += this.OnInputDataValueChanged;

            this.Enabled = new ReadConnection(1);
            this.Enabled.DataValueChanged += this.OnInputDataValueChanged;

            this.Out = new WriteConnection(bitWidth);
        }
コード例 #13
0
        /// <summary>
        /// Factory providing simulated dependency instances.
        /// </summary>
        public SimulationDependencyFactory(SimulationEngine engine)
        {
            _engine = engine;

            BitcoinMarketApi = new SimulatedMarketApi {
                SubstractAmountsFromBooks = true
            };
            TimerFactory     = new SimulatedTimerFactory(_engine);
            PricingEngine    = new Pricing.PricingEngine(this);
            HedgingEngine    = new Hedger.HedgingEngine(this);
            DateTimeProvider = new SimulatedDateTimeProvider(_engine);

            SolarisBank = new SimulatedBankApi(_engine);
        }
コード例 #14
0
        public static ChemicalComposition generateComposites(int _numberOfIterations, ChemicalComposition _composition)
        {
            List <ChemicalElement> chemicalElements, validElements, validMolecules;
            ChemicalComposition    moleculeComposition = null;
            List <double>          moleculeDistList    = new List <double>();

            validMolecules = new List <ChemicalElement>();

            if (_numberOfIterations <= 0)
            {
                return(null);
            }
            validElements    = new List <ChemicalElement>();
            chemicalElements = PeriodicTable.getListOfElementsByState(ElementState.Molecule);
            chemicalElements.AddRange(PeriodicTable.getListOfElementsByState(ElementState.Gas, true));

            foreach (ChemicalElement molecule in chemicalElements)
            {
                foreach (string _component in molecule.components)
                {
                    ChemicalElement chemicalElement = _composition.getElementFromName(_component);
                    if (chemicalElement == null)
                    {
                        validElements.Clear();
                        break;
                    }

                    validElements.Add(chemicalElement);
                }

                if (validElements.Count > 0)
                {
                    validMolecules.Add(molecule);
                }
            }

            if (validMolecules.Count > 0)
            {
                moleculeDistList = SimulationEngine.generateDistributionList(4, 1, validMolecules.Count);
                DataEngine.Shuffle <ChemicalElement>(validMolecules, new Random());
                moleculeComposition = new ChemicalComposition(validMolecules, moleculeDistList);
            }



            return(moleculeComposition);
            //get distribuzione a partire dal totale di elementi che devo generare
        }
コード例 #15
0
ファイル: EngineTests.cs プロジェクト: Zazcallabah/Sysmod
        public void EngineCallsReplication()
        {
            uint repcount = 10;
            var reps = _mocks.DynamicMock<IReplicationFactory>();
            var rands = _mocks.DynamicMock<IRandomFactory>();
            var rep = _mocks.DynamicMock<IReplication>();
            SetupResult.For( rep.ReplicationData ).Return( new DataGatherer( 0 ) );
            Expect.Call( reps.Create( null, null ) ).IgnoreArguments().Repeat.Times( (int) repcount ).Return( rep );
            Expect.Call( rep.Run ).Repeat.Times( (int) repcount );
            _mocks.ReplayAll();

            var se = new SimulationEngine( 5, 1000, repcount, 10, 2, o => { }, rands, reps, 1 );
            se.Start();

            _mocks.VerifyAll();
        }
コード例 #16
0
        protected LogicGate(SimulationEngine engine, int numberOfInputs, int bitWidth)
            : base(engine)
        {
            this.NumberOfInputs = numberOfInputs;
            this.DataBitWidth   = bitWidth;

            this.In          = new ReadConnection[this.NumberOfInputs];
            this.InvertInput = new bool[this.NumberOfInputs];
            for (var i = 0; i < this.NumberOfInputs; i++)
            {
                this.In[i] = new ReadConnection(this.DataBitWidth);
                this.In[i].DataValueChanged += this.OnInputDataValueChanged;
                this.InvertInput[i]          = false;
            }

            this.Out = new WriteConnection(this.DataBitWidth);
        }
コード例 #17
0
 public ApplicationContext()
 {
     //Setting up asset cache
     AssetCache.DefaultInstance = new AssetCache();
     MessageHub      = new TinyMessengerHub();
     Scene           = new SceneGraph();
     Scene.Messenger = MessageHub;
     SaveLoadHandler = new PersistenceHandler();
     //Adding specific persisters
     SaveLoadHandler.AddPersister(new ScenePersister()
     {
         Graph = Scene
     });
     //Set up Engine
     Engine           = new SimulationEngine(Scene);
     Engine.Messenger = MessageHub;
 }
コード例 #18
0
ファイル: MainWindow.xaml.cs プロジェクト: jcol27/HCDESLib
        } // end of ActionsAfterFinishingSimulationRun

        #endregion

        #region NonVisualizationLoop

        public void NonVisualizationLoop()
        {
            DateTime originalTimerTime = CurrentTime;

            while (BackgroundWorkerNonVisualization.CancellationPending == false &&
                   !SimulationModel.StopSimulation(CurrentTime))
            {
                DateTime newTime;
                bool     modelRunning = SimulationEngine.RunSingleStepSimulationModel(_currentTime, out newTime);

                if (modelRunning)
                {
                    BackgroundWorkerNonVisualization.ReportProgress(SimulationEngine.SimulationModel.GetSimulationProgress(newTime));
                    _currentTime = newTime;
                } // end if
            }     // end while
        }         // end of
コード例 #19
0
        public void EngineCallsReplication()
        {
            uint repcount = 10;
            var  reps     = _mocks.DynamicMock <IReplicationFactory>();
            var  rands    = _mocks.DynamicMock <IRandomFactory>();
            var  rep      = _mocks.DynamicMock <IReplication>();

            SetupResult.For(rep.ReplicationData).Return(new DataGatherer(0));
            Expect.Call(reps.Create(null, null)).IgnoreArguments().Repeat.Times((int)repcount).Return(rep);
            Expect.Call(rep.Run).Repeat.Times((int)repcount);
            _mocks.ReplayAll();

            var se = new SimulationEngine(5, 1000, repcount, 10, 2, o => { }, rands, reps, 1);

            se.Start();

            _mocks.VerifyAll();
        }
コード例 #20
0
        public static void Main(string[] Args)
        {
            SimulationEngine.mustShowInfo = true;

            PeriodicTable.init();
            TestClass.createEarth();
            TestClass.createSun();
            List <double> percentageList = new List <double>();

            createEarth();
            ChemicalElement        element;
            List <ChemicalElement> chemicalElements = DataEngine.starSeed;

            PeriodicTable.findElementByName("Water").getMolality();
            percentageList = SimulationEngine.generateDistributionList(90, 70, chemicalElements.Count);


            ChemicalComposition chemicalComposition = new ChemicalComposition(chemicalElements, percentageList);

            StarSystem system = new StarSystem();

            system.InitSystemParams(new Double[] { 1, ParametriUtente.Science.r_sun, 1 }, chemicalComposition);
            system.createStarSystem();

            string outputFile = system.toString();

            system.InitSystemParams(new Double[] { 1, ParametriUtente.Science.r_sun * 1.71, 2.02 }, chemicalComposition);
            system.createStarSystem();


            PlanetColor color = new PlanetColor(System.Drawing.Color.Blue);
            double      ggg   = color.getAlbedo();

            outputFile = string.Concat(outputFile, system.toString());
            int x = 0;

            while (x < 1000)
            {
                x++;
            }

            printToFile(outputFile);
            int i = 0;
        }
コード例 #21
0
ファイル: MainWindow.xaml.cs プロジェクト: jcol27/HCDESLib
        }     // end of StopSimulation

        #endregion

        #region PlaySimulationTick

        public void PlaySimulationTick(object sender, EventArgs e)
        {
            // security call in case the timer ticks bfore
            // it disabled by stop simulation
            if (!VisualizationEnabled)
            {
                return;
            }

            DateTime timeOfCall;

            if (TickCallIsSimulationCall)
            {
                timeOfCall = CurrentTime;

                DateTime newTime;
                bool     modelRunning = SimulationEngine.RunSingleStepSimulationModel(CurrentTime, out newTime);

                // in case end of model is reached the simulation is stopped
                if (!modelRunning)
                {
                    StopSimulation(false);
                    return;
                } // end if

                SimulationDisplayClock.SetDateTime(CurrentTime);
                SimulationModel.SimulationDrawingEngine.CreateModelVisualization(CurrentTime, SimulationModel, SimulationEngine.CurrentlyTriggeredEvents);
                ProgressBarSimulationProgress.Value = SimulationModel.GetSimulationProgress(CurrentTime);

                _nextSimulationTime = newTime;
                _currentTime        = newTime;
            }
            else
            {
                timeOfCall = NextTimerTime;

                SimulationDisplayClock.SetDateTime(NextTimerTime);
                SimulationModel.SimulationDrawingEngine.CreateModelVisualization(NextTimerTime, SimulationModel, new List <Event>());
                ProgressBarSimulationProgress.Value = SimulationModel.GetSimulationProgress(CurrentTime);
                _nextTimerTime += ConstantTimerStep;
            } // end if

            SimulationTimer.Interval = TimeSpan.FromMilliseconds(Math.Max((int)(((NextTime - timeOfCall).Ticks / ConstantTimerStep.Ticks) * SimulationSpeed), 1));
        } // end of PlaySimulationTick
コード例 #22
0
        public MainPage()
        {
            InitializeComponent();

            renderer = new Renderer(MainCanvas);
            renderer.SelectedBotChanged += SelectedBotChanged;
            engine = new SimulationEngine(async a => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => a()))
            {
                CycleCallback  = renderer.DrawBots,
                AddBotCallback = renderer.AddBot
            };
            engine.CyclePerSecondChanged += Engine_CyclePerSecondChanged;
            MainCanvas.Width              = engine.Field.Size.X;
            MainCanvas.Height             = engine.Field.Size.Y;
            MainCanvas.Clip = new RectangleGeometry()
            {
                Rect = new Rect(0, 0, engine.Field.Size.X, engine.Field.Size.Y)
            };
            DataContext = this;
        }
コード例 #23
0
ファイル: MainWindow.xaml.cs プロジェクト: jcol27/HCDESLib
        }         // end of

        #endregion

        #region CreateModel

        public void CreateModel()
        {
            //_simulationModel = new SimulationModelQueuing((DateTime)DatePickerStartDate.SelectedDate,
            //    (DateTime)DatePickerEndDate.SelectedDate,
            //    2,
            //    3,
            //    5,
            //    10);

            DrawingSystem.ClearSystem();


            _simulationModel = new HospitalSimulationModelWithVisualization((DateTime)DatePickerStartDate.SelectedDate,
                                                                            (DateTime)DatePickerEndDate.SelectedDate);

            _simulationEngine = new SimulationEngine();
            SimulationEngine.LoggingEngine   = new BaseLoggingEngine(SimulationModel);
            SimulationEngine.CreateEventLog  = true;
            SimulationEngine.SimulationModel = SimulationModel;
            SimulationModel.Initialize(SimulationEngine);
            SimulationModel.InitializeVisualization(DrawingSystem);
        } // end of CreateModel
コード例 #24
0
ファイル: AndGateTests.cs プロジェクト: Jath1024/DangrLib
        public void TestMethod1()
        {
            var engine = new SimulationEngine();

            var input = new TestInput(engine, 2, 2);

            var output = new TestOutput(engine, 2);

            var gate = new AndGate(engine, 2, 2);

            input.Connect(gate.In);
            output.Connect(gate.Out);

            input.SetValues(DataValue.Unsigned(1, 2), DataValue.Unsigned(1, 2));

            for (var i = 0; i < 10; i++)
            {
                engine.Tick();
            }

            output.ValidateValues(DataValue.Unsigned(1, 2));
        }
コード例 #25
0
    // Use this for initialization
    void Awake()
    {
        ss = new SimulationState("C:\\config.xml", goldPrefab, potionPrefab);
        SimulationState.getInstance().stdout.Send("entro Awake Sim Engine");
        se = new SimulationEngine(ss);

        //ss.initialize();

        InvokeRepeating( "DoWork", 0, 0.1f );

        // Instantiate dummy agent for testing purposes
        /*
        se.instantiateDummyAgent("dummy1", agentPrefab);
        AgentState dummy1AgState = se.simulationState.agents[se.simulationState.agentIDs["dummy1"]];
        dummy1AgState.agentController.pickupPosCon(Gold.Create(new Vector3(0,0,0)));
        dummy1AgState.agentController.pickupPosCon(Gold.Create(new Vector3(0,0,0)));
        dummy1AgState.agentController.pickupPosCon(Potion.Create(new Vector3(0,0,0)));
        dummy1AgState.agentController.pickupPosCon(Potion.Create(new Vector3(0,0,0)));
        dummy1AgState.agentController.pickupPosCon(Potion.Create(new Vector3(0,0,0)));
        //se.instantiateDummyAgent("dummy2", agentPrefab);
        */
        se.start();
    }
コード例 #26
0
    // Use this for initialization
    void Awake()
    {
        ss = new SimulationState("C:\\config.xml", goldPrefab, potionPrefab);
        SimulationState.getInstance().stdout.Send("entro Awake Sim Engine");
        se = new SimulationEngine(ss);

        //ss.initialize();

        InvokeRepeating("DoWork", 0, 0.1f);

        // Instantiate dummy agent for testing purposes

        /*
         * se.instantiateDummyAgent("dummy1", agentPrefab);
         * AgentState dummy1AgState = se.simulationState.agents[se.simulationState.agentIDs["dummy1"]];
         * dummy1AgState.agentController.pickupPosCon(Gold.Create(new Vector3(0,0,0)));
         * dummy1AgState.agentController.pickupPosCon(Gold.Create(new Vector3(0,0,0)));
         * dummy1AgState.agentController.pickupPosCon(Potion.Create(new Vector3(0,0,0)));
         * dummy1AgState.agentController.pickupPosCon(Potion.Create(new Vector3(0,0,0)));
         * dummy1AgState.agentController.pickupPosCon(Potion.Create(new Vector3(0,0,0)));
         * //se.instantiateDummyAgent("dummy2", agentPrefab);
         */
        se.start();
    }
コード例 #27
0
ファイル: Wire.cs プロジェクト: Jath1024/DangrLib
 public Wire(SimulationEngine engine, int bitWidth)
     : base(engine)
 {
     this.BitWidth         = bitWidth;
     this.inputConnections = new Dictionary <WriteConnection, DataValue>();
 }
コード例 #28
0
 public XorGate(SimulationEngine engine, int numberOfInputs, int bitWidth)
     : base(engine, numberOfInputs, bitWidth)
 {
 }
コード例 #29
0
 public ControlledInverter(SimulationEngine engine, int bitWidth)
     : base(engine, bitWidth)
 {
 }
コード例 #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimulationEntity" /> class.
 /// </summary>
 /// <param name="engine">
 /// The <see cref="SimulationEngine" /> this <see cref="SimulationEntity" /> is a part of.
 /// </param>
 protected SimulationEntity(SimulationEngine engine)
 {
     this.Id     = SimulationEntity.IdCounter.GetId();
     this.Engine = engine;
 }
コード例 #31
0
        public void initStar(double _densityMul = 1.0, double rel_mass = 1.0, List <double> percentage = null)
        {
            ChemicalComposition chemicalComposition = new ChemicalComposition(this.stellarCompositionMats, percentage);

            this.starComposition = chemicalComposition;
            elementsDistribution = percentage;
            NumberFormatInfo nfi        = new NumberFormatInfo();
            Random_Extension randomSeed = new Random_Extension();

            nfi.NumberDecimalSeparator = ".";
            Function hydrostaticEquilibrium = ParametriUtente.Science.hydrostaticEquilibrium;
            int      randomGenForBlackHoles;
            //mass in grammi / 18.015 = moles
            //ideal gas law
            double molecularWeight = 0.0;
            double sumofElement    = 0.0;

            double pressione;

            this.meanDensity = 0;


            randomGenForBlackHoles = randomSeed.Next(0, 1);



            foreach (ChemicalElement element in starComposition.get_elements())
            {
                double currentElement = starComposition.get_percentage_per_element(element);

                sumofElement    = sumofElement + currentElement;
                molecularWeight = (molecularWeight + (element.mass)
                                   );
            }
            molecularWeight = molecularWeight / sumofElement;

            this.Volume = ((Math.Pow(this.starRadius, 3) * (4.0 / 3.0)) * Math.PI); //km3

            this.mass = rel_mass * ParametriUtente.Science.m_sun;

            this.luminosity = SimulationEngine.getLuminosityFromMass(this.mass);

            this.meanDensity = (this.mass * 1000 / (Math.Pow(10, 15) * Volume)) * _densityMul;


            pressione = ((ParametriUtente.Science.G
                          * mass
                          * (Converter.gcm3_to_kgm3(this.meanDensity)))
                         / (this.starRadius * 1000));

            this.Core_temperature = ((0.84 * Math.Pow(10, -27)) * pressione)
                                    / ((Converter.gcm3_to_kgm3(this.meanDensity))
                                       * (1.380649 * Math.Pow(10, -23)));

            this.Core_temperature = this.Core_temperature * 1.3;


            this.Surface_temperature = SimulationEngine.getTemperatureFromLumRadiusRatio(this.starRadius, this.luminosity);//this.Core_temperature / (2717.203184);//2543.37;

            if (randomGenForBlackHoles == 0)
            {
                this.starRadius      = this.getSchwarzschildRadius();
                this.Volume          = ((Math.Pow(this.starRadius, 3) * (4.0 / 3.0)) * Math.PI); //km3
                this.meanDensity     = (this.mass * 1000 / (Math.Pow(10, 15) * Volume));
                this.Surface_density = this.meanDensity;
                this.Core_density    = this.meanDensity;
            }


            this.setRelativeValues();

            this.InitStarClassification();

            this.finalizeStar();
        }
コード例 #32
0
 public SimulatedResetEvent(SimulationEngine engine)
 {
     _engine          = engine;
     _blockSimulation = new BlockSimulationEvent(this, _engine);
     _engine.AddEvent(_blockSimulation);
 }
コード例 #33
0
 public BlockSimulationEvent(SimulatedResetEvent resetEvent, SimulationEngine engine)
 {
     SimTime     = engine.CurrentTime;
     _resetEvent = resetEvent;
 }