示例#1
0
        public async Task SeedAsync()
        {
            var robots = await _robotService.BrowseAsync();

            if (robots.Any())
            {
                return;
            }

            const string basicIPAddress = "192.168.0.";

            await _robotService.CreateAsync("127.0.0.1");

            for (uint i = 0; i < 10; i++)
            {
                await _robotService.CreateAsync(basicIPAddress + Convert.ToString(i + 30));
            }

            robots = await _robotService.BrowseAsync();

            foreach (var robot in robots)
            {
                await robot.ConnectAsync();
            }
        }
示例#2
0
 public async Task HandleAsync(UnbindAllRobots command, string clientIP)
 {
     var robots = await _robotService.BrowseAsync();
     var boundRobots = robots.Where(robot => robot.BoundTo == clientIP);
     foreach (var robot in boundRobots)
     {
         robot.Unbind();
     }
 }
示例#3
0
        public async Task HandleAsync(BindManyRobots command, string clientIP)
        {
            var robots = await _robotService.BrowseAsync();

            var robotsToBind = robots.Where(robot => command.robotIDs.Contains(robot.ID));

            foreach (var robot in robotsToBind)
            {
                robot.Bind(clientIP);
            }
        }
        public async Task HandleAsync(BrowseAvailableRobots command, string clientIP)
        {
            var robots = await _robotService.BrowseAsync();

            var availableRobots = robots.Where(robot => robot.BoundTo == string.Empty && robot.Connected);

            // Print out for now
            Debug.WriteLine("Available robots:");
            foreach (var robot in availableRobots)
            {
                Debug.WriteLine($"IP: {robot.IPAddress} ID: {robot.ID}");
            }
        }