public GameEngine(FormInput input, SimulationEngine simulationEngine) { _input = input; _monitor = new PerformanceMonitor(); _simulationEngine = simulationEngine; PreUpdate += _monitor.CaptureFrame; }
public OutputPin(SimulationEngine engine, int dataBitWidth) : base(engine) { this.DataBitWidth = dataBitWidth; this.In = new ReadConnection(this.DataBitWidth); this.In.DataValueChanged += this.OnInputDataValueChanged; }
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; }
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); }
public void Initialize(Configuration theConfiguration) { initCommands(); mySimulation = new SimulationEngine(); mySimulation.Initialize(UniverseFactory.CreateUniverse(theConfiguration)); configureVisualization(theConfiguration); displayUniverse(mySimulation.Universe); }
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); }; }
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); }
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(); }
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]); } }
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); }
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); }
/// <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); }
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 }
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(); }
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); }
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; }
} // 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
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(); }
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; }
} // 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
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; }
} // 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
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)); }
// 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(); }
// 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(); }
public Wire(SimulationEngine engine, int bitWidth) : base(engine) { this.BitWidth = bitWidth; this.inputConnections = new Dictionary <WriteConnection, DataValue>(); }
public XorGate(SimulationEngine engine, int numberOfInputs, int bitWidth) : base(engine, numberOfInputs, bitWidth) { }
public ControlledInverter(SimulationEngine engine, int bitWidth) : base(engine, bitWidth) { }
/// <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; }
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(); }
public SimulatedResetEvent(SimulationEngine engine) { _engine = engine; _blockSimulation = new BlockSimulationEvent(this, _engine); _engine.AddEvent(_blockSimulation); }
public BlockSimulationEvent(SimulatedResetEvent resetEvent, SimulationEngine engine) { SimTime = engine.CurrentTime; _resetEvent = resetEvent; }