Example #1
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            outputBox.Clear();
            SimCore core   = SimCore.GetSimCore(codeBox.Text);
            var     result = core.Run();

            if (result != null)
            {
                byte[][] bytes = core.GetBytes();
                outputBox.Text += "Code: ";
                for (int i = 0; i < bytes.Length; i++)
                {
                    for (int j = 0; j < bytes[i].Length; j++)
                    {
                        outputBox.Text += (bytes[i][j].ToString("x2") + " ");
                    }
                }
                outputBox.Text += "\n";

                if ((int)ptr != -1)
                {
                    outputBox.Text += "Sending ...\n";

                    new Thread(new ThreadStart(() =>
                    {
                        Report report; int index = 0;
                        List <byte> buf          = new List <byte>();
                        while (index < bytes.Length)
                        {
                            if (buf.Count + bytes[index].Length < BUF_SIZE)
                            {
                                buf.AddRange(bytes[index]);
                                index += 1;
                                if (index >= bytes.Length)
                                {
                                    report = new Report(0x55, buf.ToArray());
                                    hid.Write(report);
                                    buf.Clear();
                                    break;
                                }
                            }
                            else
                            {
                                report = new Report(0x55, buf.ToArray());
                                hid.Write(report);
                                Thread.Sleep(500);
                                buf.Clear();
                            }
                        }
                    })).Start();
                }
            }
        }
        public override void Set(object item, SimCore.Entities.Entity ent)
        {
            base.Set(item, ent);
            TheTank = item as FluidTankSystem;

            if (TheTank == null)
                return;

            FluidType.SelectedItem = TheTank.TankType;
            MaxFlowRate.Value = (decimal)TheTank.MaxFlowRate;
            Capacity.Value = (decimal)TheTank.MaxCapacity;
            Quantity.Value = (decimal)TheTank.Quantity;
        }
Example #3
0
 public SimEngine()
 {
     simCore          = new SimCore();
     logPlayer        = null;
     coordinator      = null;
     simModelFile     = null;
     serverPortNumber = null;
     replayLogger     = null;
     textChatServer   = null;
     whiteboardServer = null;
     voiceServer      = null;
     //handshakeManager = null;
     viewManager = null;
 }
Example #4
0
 public SimEngine()
 {
     simCore = new SimCore();
     logPlayer = null;
     coordinator = null;
     simModelFile = null;
     serverPortNumber = null;
     replayLogger = null;
     textChatServer = null;
     whiteboardServer = null;
     voiceServer = null;
     //handshakeManager = null;
     viewManager = null;
 }
        public override void Set(object item, SimCore.Entities.Entity ent)
        {
            base.Set(item, ent);
            TheComputer = item as ComputerSystem;

            if (TheComputer == null)
                return;

            foreach (ComputerSystem.ComputerTypes compType in Enum.GetValues(typeof(ComputerSystem.ComputerTypes)))
                ComputerType.Items.Add(compType);

            ComputerType.SelectedItem = TheComputer.ComputerType;

            CompSpeed.Value = (decimal)TheComputer.ComputationFactor;
        }
Example #6
0
        public void Stop()
        {
            if (coordinator != null)
            {
                coordinator.Stop();
                coordinator = null;
            }
            //Thread.Sleep(100);
            if (simCore != null)
            {
                simCore.Stop();
            }
            if (logPlayer != null)
            {
                logPlayer.Stop();
                logPlayer = null;
            }

            if (viewManager != null)
            {
                viewManager.ResetViewManager();
            }
            simCore = new SimCore();
        }
        public override void Set(object item, SimCore.Entities.Entity ent)
        {
            base.Set(item, ent);
            TheGenerator = item as GenerationSystem;

            if (TheGenerator == null)
                return;

            foreach (GenerationSystem.GenerationTypes genType in Enum.GetValues(typeof(GenerationSystem.GenerationTypes)))
                GeneratorType.Items.Add(genType);

            GeneratorType.SelectedItem = TheGenerator.GenerationType;

            PowerGeneration.Value = (decimal)TheGenerator.PowerGeneration;

            FuelList.Items.Clear();
            ByproductList.Items.Clear();

            foreach (GenerationSystem.FuelConsumption fuel in TheGenerator.FuelConsumptions)
                FuelList.Items.Add(fuel);

            foreach (GenerationSystem.FuelConsumption byproduct in TheGenerator.Byproducts)
                ByproductList.Items.Add(byproduct);
        }
Example #8
0
 //customer1, druhy, zakaznik, auto a pdodobne
 protected AutoserviceEvent(double eventTime, SimCore simulation, Zakaznik aktualnyZakaznik)
     : base(eventTime, simulation)
 {
     AktualnyZakaznik = aktualnyZakaznik;
 }
Example #9
0
 public ZaciatokSpracovaniaObjednavkyEvent(double eventTime, SimCore simulation, Zakaznik aktualnyZakaznik)
     : base(eventTime, simulation, aktualnyZakaznik)
 {
 }
Example #10
0
 public StartPayment(double eventTime, SimCore simulation, Customer currentCustomer) : base(eventTime, currentCustomer, simulation)
 {
 }
Example #11
0
 public Arrival(double eventTime, SimCore simulation, Customer currentCustomer) : base(eventTime, currentCustomer, simulation)
 {
 }
 public ZaciatokReplikacieEvent(double eventTime, SimCore simulation, Zakaznik aktualnyZakaznik)
     : base(eventTime, simulation, aktualnyZakaznik)
 {
 }
Example #13
0
        public void Stop()
        {
            

            if (coordinator != null)
            {
                coordinator.Stop();
                coordinator = null;
            }
            //Thread.Sleep(100);
            if (simCore != null)
            {
                simCore.Stop();
            }
            if (logPlayer != null)
            {
                logPlayer.Stop();
                logPlayer = null;
            }

            if (viewManager != null)
            {
                viewManager.ResetViewManager();
            }
            simCore = new SimCore();
            
        }
 public KoniecSpracovaniaObjednavky(double eventTime, SimCore simulation, Zakaznik aktualnyZakaznik)
     : base(eventTime, simulation, aktualnyZakaznik)
 {
 }
 public PrevzatieAutaOdZakaznikaEvent(double eventTime, SimCore simulation, Zakaznik aktualnyZakaznik)
     : base(eventTime, simulation, aktualnyZakaznik)
 {
 }
 public KoniecDnaEvent(double eventTime, SimCore simulation, Zakaznik aktualnyZakaznik)
     : base(eventTime, simulation, aktualnyZakaznik)
 {
 }
Example #17
0
 public PreparkovanieAutaSpatEvent(double eventTime, SimCore simulation, Zakaznik aktualnyZakaznik)
     : base(eventTime, simulation, aktualnyZakaznik)
 {
 }
 public OdchodZakaznikaEvent(double eventTime, SimCore simulation, Zakaznik aktualnyZakaznik)
     : base(eventTime, simulation, aktualnyZakaznik)
 {
 }
        public void RunTest()
        {
            const int RUNS   = 10;
            int       _numIt = RUNS;
            var       _rnd   = new Random();
            int       _exec  = 0;
            SimCore   target = SimCore_Accessor.Instance; // TODO: Initialize to an appropriate value

            for (int i = 0; i < _numIt; i++)
            {
                Event _event = new Event("test", _rnd.NextDouble() * 1000d); // TODO: Initialize to an appropriate value
                _event.OnEventExecutionPreEdges += (o, e) =>
                {
                    _exec++;
                };
                //target.ScheduleEvent(_event);
                _event.Schedule();
            }

            // Test edges
            int _numEvtFrom = RUNS;
            int _numEvtTo   = RUNS;

            Event _eventTo   = new Event("testWithEdge");                            // TODO: Initialize to an appropriate value
            Event _eventFrom = new Event("testWithEdge", _rnd.NextDouble() * 1000d); // TODO: Initialize to an appropriate value
            Edge  _edge      = new Edge(_eventFrom, _eventTo);

            _edge.Distribution = new GenerateExponential();
            _eventFrom.OnEventExecutionPostEdges += (o, e) =>
            {
                _numEvtFrom++;
            };

            _eventTo.OnEventExecutionPostEdges += (o, e) =>
            {
                _numEvtTo++;
            };
            //target.ScheduleEvent(_eventFrom);
            _eventFrom.Schedule();

            target.Run();
            Assert.IsTrue(_exec == _numIt);
            Assert.IsTrue(_numEvtFrom == _numEvtTo);

            // Test self edges
            int _numSelf = 0;

            Event _eventFromTo = new Event("testWithEdge", 0); // TODO: Initialize to an appropriate value

            Edge _edgeSelf = new Edge(_eventFromTo, _eventFromTo);

            _edge.Distribution = new GenerateNormal(20, 0.1);
            _eventFromTo.OnEventExecutionPreEdges += (o, e) =>
            {
                _numSelf++;
                if (_numSelf > RUNS)
                {
                    ((Event)o).Edges.Clear();
                }
            };
            //target.ScheduleEvent(_eventFromTo);
            _eventFromTo.Schedule();
            target.Run();
            Assert.IsTrue(_numSelf == RUNS + 1);
        }
 public SimEventShop(double eventTime, Customer currentCustomer, SimCore simulation) : base(eventTime, simulation)
 {
     CurrentCustomer = currentCustomer;
 }