コード例 #1
0
ファイル: standard.py プロジェクト: dykesk/WEIS
def load_material(vessel, mass, **kwargs):
    """
    A wrapper for simpy.Container.put that checks VesselStorageContainer
    constraints and triggers self.put() if successful.

    Items put into the instance should be a dictionary with the following
    attributes:
        - name
        - mass (t)
        - length (km)

    Parameters
    ----------
    item : dict
        Dictionary of item properties.
    """

    if vessel.rock_storage.level + mass > vessel.rock_storage.max_mass:
        raise CargoMassExceeded(
            vessel.rock_storage.max_mass,
            vessel.rock_storage.level,
            "Scour Protection",
        )

    key = "load_rocks_time"
    load_time = kwargs.get(key, pt[key])

    vessel.rock_storage.put(mass)
    yield vessel.task(
        "Load SP Material",
        load_time,
        constraints=vessel.transit_limits,
        **kwargs,
    )
コード例 #2
0
    def put_item(self, item):
        """
        Checks VesselStorage specific constraints and triggers self.put()
        if successful.

        Items put into the instance should be a dictionary with the following
        attributes:
        - name
        - mass (t)
        - deck_space (m2)

        Parameters
        ----------
        item : dict
            Dictionary of item properties.
        """

        # if any(x not in item.keys() for x in self.required_keys):
        #     raise ItemPropertyNotDefined(item, self.required_keys)

        if self.current_deck_space + item.deck_space > self.max_deck_space:
            raise DeckSpaceExceeded(self.max_deck_space,
                                    self.current_deck_space, item)

        if self.current_cargo_mass + item.mass > self.max_cargo_mass:
            raise CargoMassExceeded(self.max_cargo_mass,
                                    self.current_cargo_mass, item)

        self.put(item)