Ejemplo n.º 1
0
 public void PlaceStaticModules(List <StaticDeclarationBlock> staticDeclarations)
 {
     foreach (var staticDeclaration in staticDeclarations)
     {
         if (staticDeclaration is DropletDeclaration dropletDeclaration)
         {
             throw new NotImplementedException();
             BoardFluid fluidType     = RecordCompletlyNewFluidType(dropletDeclaration);
             Droplet    droplet       = (Droplet)dropletDeclaration.getAssociatedModule();
             bool       couldBePlaced = board.FastTemplatePlace(droplet);
             if (!couldBePlaced)
             {
                 throw new RuntimeException("The input module couldn't be placed. The module is: " + droplet.ToString());
             }
             //It is not really static, and thus must does not need to be registered as such.
         }
         else if (staticDeclaration is InputDeclaration input)
         {
             BoardFluid  fluidType     = RecordCompletlyNewFluidType(input);
             InputModule inputModule   = new InputModule(fluidType, (int)input.Amount);
             bool        couldBePlaced = board.FastTemplatePlace(inputModule);
             if (!couldBePlaced)
             {
                 throw new RuntimeException("The input module couldn't be placed. The module is: " + inputModule.ToString());
             }
             input.BoundModule = inputModule;
             inputModule.RepositionLayout();
             StaticModules.Add(staticDeclaration.ModuleName, inputModule);
             NameOfInputFluids.Add(fluidType.FluidName);
         }
         else
         {
             Module staticModule = getAndPlaceFirstPlaceableModule(staticDeclaration, board);
             StaticModules.Add(staticDeclaration.ModuleName, staticModule);
         }
     }
     if (SHOULD_DO_GARBAGE_COLLECTION)
     {
         WasteModule waste         = new WasteModule();
         bool        couldBePlaced = board.FastTemplatePlace(waste);
         if (!couldBePlaced)
         {
             throw new RuntimeException("The waste module couldn't be placed. The module is: " + waste.ToString());
         }
         waste.GetInputLayout().Reposition(waste.Shape.x, waste.Shape.y);
         StaticModules.Add(WASTE_MODULE_NAME, waste);
     }
 }
Ejemplo 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);
        }