Exemplo n.º 1
0
        public static Route RouteSingleDropletToModule(Module module, Board board, int currentTime, Droplet dropletInput)
        {
            BoardFluid InputFluidType = dropletInput.GetFluidType();

            if (InputFluidType.GetNumberOfDropletsAvailable() < 1)
            {
                throw new RuntimeException("There isn't enough droplets of type " + InputFluidType.FluidName +
                                           " avaiable, to satisfy the requirement of the module: " + module.ToString());
            }
            //Routes a droplet of type InputFluid to the module.
            Route route = DetermineRouteToModule(haveReachedDropletOfTargetType(dropletInput), module, dropletInput, board, currentTime); //Will be included as part of a later step.

            if (route == null)
            {
                throw new InternalRuntimeException("No route found. This should not be possible.");
            }

            //The droplet has been "used up"/it is now inside a module,
            //so it needs to be removed from its original position:
            RemoveRoutedDropletFromBoard(board, route);
            return(route);
        }
Exemplo n.º 2
0
        private int DoGarbageCollection(int currentTime, FluidBlock operation, BoardFluid oldFluidType)
        {
            int         numberOfDropletsToRoute = oldFluidType.GetNumberOfDropletsAvailable();
            WasteModule waste = (WasteModule)StaticModules[WASTE_MODULE_NAME];

            waste.GetInputLayout().Droplets[0].FakeSetFluidType(oldFluidType);
            Droplet dropletInput = waste.GetInputLayout().Droplets[0];

            List <Route> wasteRoutes = new List <Route>();

            for (int i = 0; i < numberOfDropletsToRoute; i++)
            {
                Route route = Router.RouteSingleDropletToModule(waste, board, currentTime, dropletInput);
                wasteRoutes.Add(route);
                //The route is scheduled sequentially, so the end time of the current route (+1) should be the start of the next.
                //This will give an overhead of +1 for the operation starting time, for each droplet routed:
                currentTime = route.getEndTime() + 1;
            }
            if (wasteRoutes.Count > 0)
            {
                operation.WasteRoutes.Add(oldFluidType.FluidName, wasteRoutes);
            }
            return(currentTime);
        }