protected override void ExecuteRole(Role role) { // This is only called if the current Container comes from another station. // The only valid role is thus an empty one (no CapabilitiesToApply) and represents // a simple forwarding to the next station. if (role.HasCapabilitiesToApply()) throw new InvalidOperationException("Unsupported capability configuration in ContainerLoader"); }
protected override void ExecuteRole(Role role) { foreach (var capability in role.CapabilitiesToApply) { var ingredient = capability as Ingredient; if (ingredient == null) throw new InvalidOperationException($"Invalid capability in ParticulateDispenser: {capability}"); _ingredientTanks[(int)ingredient.Type].Dispense(Container, ingredient); } }
protected override void ExecuteRole(Role role) { // unless role is transport only, it will always be { ConsumeCapability } if (role.HasCapabilitiesToApply()) { Container.Recipe.RemoveContainer(Container); if (Container.Recipe.ProcessingComplete) { RemoveRecipeConfigurations(Container.Recipe); } Container = null; } }
/// <summary> /// Executes the specified role on the current <see cref="Container" />. /// When this method is called, <see cref="Container" /> must not be null. /// </summary> protected abstract void ExecuteRole(Role role);
/// <summary> /// Get a fresh role from the <see cref="RolePool" />. /// </summary> /// <param name="recipe">The recipe the role will belong to.</param> /// <param name="input">The station the role declares as input port. May be null.</param> /// <param name="previous">The previous condition (postcondition of the previous role). May be null.</param> /// <returns>A <see cref="Role" /> instance with the given data.</returns> protected Role GetRole(Recipe recipe, Station input, Condition? previous) { var role = new Role(); // update precondition role.PreCondition.Recipe = recipe; role.PreCondition.Port = input; role.PreCondition.ResetState(); if (previous != null) role.PreCondition.CopyStateFrom(previous.Value); // update postcondition role.PostCondition.Recipe = recipe; role.PostCondition.Port = null; role.PostCondition.ResetState(); role.PostCondition.CopyStateFrom(role.PreCondition); role.ResetCapabilitiesToApply(); return role; }