Coverage for C:\Git\TUDelft-CITG\Hydraulic-Infrastructure-Realisation\digital_twin\model.py : 79%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""The LevelCondition class can be used to specify the start level and stop level conditions for an Activity.
container: an object which extends HasContainer, the container whose level needs to be >= or <= a certain value min_level: the minimum level the container is required to have max_level: the maximum level the container is required to have """
*args, **kwargs): """Initialization"""
"""The AndCondition class can be used to combine several different conditions into a single condition for an Activity.
conditions: a list of condition objects that need to all be satisfied for the condition to be satisfied each object should have a satisfied method that returns whether the condition is satisfied or not """
super().__init__(*args, **kwargs) """Initialization"""
self.conditions = conditions
for condition in self.conditions: if not condition.satisfied(): return False return True
"""The AndCondition class can be used to combine several different conditions into a single condition for an Activity.
conditions: a list of condition objects, one of which needs to be satisfied for the condition to be satisfied each object should have a satisfied method that returns whether the condition is satisfied or not """
"""Initialization"""
"""The TrueCondition class defines a condition which is always satisfied."""
"""The Activity Class forms a specific class for a single activity within a simulation. It deals with a single origin container, destination container and a single combination of equipment to move substances from the origin to the destination. It will initiate and suspend processes according to a number of specified conditions. To run an activity after it has been initialized call env.run() on the Simpy environment with which it was initialized.
To check when a transportation of substances can take place, the Activity class uses three different condition arguments: start_condition, stop_condition and condition. These condition arguments should all be given a condition object which has a satisfied method returning a boolean value. True if the condition is satisfied, False otherwise.
start_condition: the activity will start as soon as this condition is satisfied by default will always be True stop_condition: the activity will stop (terminate) as soon as this condition is no longer satisfied after the activity has started by default will always be for the destination container to be full or the source container to be empty condition: after the activity has started (start_condition was satisfied), this condition will be checked as long as the stop_condition is not satisfied, if the condition returns True, the activity will complete exactly one transportation of substances, of the condition is False the activity will wait for the condition to be satisfied again by default will always be True origin: object inheriting from HasContainer, HasResource, Locatable, Identifiable and Log destination: object inheriting from HasContainer, HasResource, Locatable, Identifiable and Log loader: object which will get units from 'origin' Container and put them into 'mover' Container should inherit from Processor, HasResource, Identifiable and Log after the simulation is complete, its log will contain entries for each time it started loading and stopped loading mover: moves to 'origin' if it is not already there, is loaded, then moves to 'destination' and is unloaded should inherit from Movable, HasContainer, HasResource, Identifiable and Log after the simulation is complete, its log will contain entries for each time it started moving, stopped moving, started loading / unloading and stopped loading / unloading unloader: gets amount from 'mover' Container and puts it into 'destination' Container should inherit from Processor, HasResource, Identifiable and Log after the simulation is complete, its log will contain entries for each time it started unloading and stopped unloading """
# todo should loader and unloader also inherit from Locatable and Activity include checks if the loader / unloader is at the correct location?
origin, destination, loader, mover, unloader, start_condition=None, stop_condition=None, condition=None, show=False, *args, **kwargs): """Initialization"""
[LevelCondition(origin, max_level=0), LevelCondition(destination, min_level=destination.container.capacity)])
self.process_control(self.start_condition, self.stop_condition, self.condition, self.origin, self.destination, self.loader, self.mover, self.unloader) )
origin, destination, loader, mover, unloader): """Installation process control"""
# wait for the start condition to be satisfied # checking the general condition and move
# stand by until the start condition is satisfied if not shown: print('T=' + '{:06.2f}'.format(self.env.now) + ' ' + self.name + ' to ' + destination.name + ' suspended') self.log_entry("suspended", self.env.now, -1, origin.geometry) shown = True yield self.env.timeout(3600) # step 3600 time units ahead
# todo add nice printing to the conditions, then print them here + self.name + ' transporting from ' + origin.name + ' to ' + destination.name + ' started')
# keep moving substances until the stop condition is satisfied else: yield self.env.timeout(3600)
+ self.name + ' transporting from ' + origin.name + ' to ' + destination.name + ' complete')
loader, mover, unloader): """Installation process""" # estimate amount that should be transported mover.container.capacity - mover.container.level, origin.container.level, origin.container.capacity - origin.total_requested, destination.container.capacity - destination.container.level, destination.container.capacity - destination.total_requested)
# request access to the transport_resource
print('Using ' + mover.name + ' to process ' + str(amount))
# move to the origin if necessary
# load the mover
# move the mover to the destination
# unload the mover
else: print('Nothing to move') yield self.env.timeout(3600)
origin_resource_request=None, destination_resource_request=None): id(destination) == id(processor) and destination_resource_request is not None:
destination_resource_request=destination_resource_request) else:
origin_resource_request=origin_resource_request, destination_resource_request=destination_resource_request)
print('Processed {}:'.format(amount)) print(' from: ' + origin.name + ' contains: ' + str(origin.container.level)) print(' by: ' + processor.name) print(' to: ' + destination.name + ' contains: ' + str(destination.container.level))
print('Moved:') print(' object: ' + mover.name + ' contains: ' + str(mover.container.level)) print(' from: ' + format(old_location.x, '02.5f') + ' ' + format(old_location.y, '02.5f')) print(' to: ' + format(mover.geometry.x, '02.5f') + ' ' + format(mover.geometry.y, '02.5f')) |