コード例 #1
0
ファイル: Logic.cs プロジェクト: bursson/Drinkkirobotti_4_1
        public void InitClasses()
        {
            ser = new ServiceLayer.ServiceLayer();
            rob = new RobotCellLayer.RobotCellLayer();
            da  = new DataAccess.DataAccess();
            rob.AddRobot("SIM", "SIM");
            logic = new LogicLayer.LogicLayer(ser, rob, da);

            var shelf = new Bottleshelf(10, 0);

            shelf.AddBottle(new Bottle("Vodka"));
            shelf.AddBottle(new Bottle("Vesi"));
            shelf.AddBottle(new Bottle("Mehu"));
            var queue = new OrderQueue();

            var kv = new Drink("Kossuvissy");

            Assert.IsTrue(kv.AddPortion("Vodka", 4));
            Assert.IsTrue(kv.AddPortion("Vesi", 10));

            var mehu = new Drink("Mehu");

            Assert.IsTrue(mehu.AddPortion("Mehu", 10));

            queue.Add(new Tuple <Order, int>(new Order(OrderType.Drink, 1, 1, kv), 10));
            queue.Add(new Tuple <Order, int>(new Order(OrderType.Drink, 2, 4, mehu), 10));
            queue.Add(new Tuple <Order, int>(new Order(OrderType.Drink, 3, 3, kv), 10));
            queue.Add(new Tuple <Order, int>(new Order(OrderType.Drink, 4, 1, kv), 10));

            var startarg = new StartArguments();

            startarg.BackupShelf  = shelf;
            startarg.Mode         = RunMode.Simulation;
            startarg.Beer         = false;
            startarg.Drinks       = true;
            startarg.Sparkling    = false;
            startarg.IdleActivity = new Activity(ActivityType.ProcessOrders);
            startarg.BacckupQueue = queue;

            var init = Task.Run(() => logic.Initialize(startarg, new CancellationToken()));

            init.Wait();
            Assert.IsTrue(init.Result);
        }
コード例 #2
0
        private static async Task MainLogic(CancellationToken ct)
        {
            // Main logic here
            await DA.InitializeDB();

            await DA.AddAnotherJalluToDBTest();

            NLogExtensions.InitializeLogConnection(ct, IPAddress.Parse("127.0.0.1"), 9999);

            var serviceLayer = new CommService();

            serviceLayer.Run(ct);

            var delayTask = Task.Delay(-1, ct);
            // Test.
            var bll = new BusinessLogic(serviceLayer, new RobotCell(), new DA());

            var done = await Task.WhenAny(delayTask);

            ct.ThrowIfCancellationRequested();
        }