Вот базовый пример кода того, как элементы перемещаются по маршруту в желтый цвет, сохраняя при этом там:
Код: Выделить всё
import salabim as sim
class Route(sim.Component):
def setup(self, x1, y1, x2, y2):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
self.line = sim.AnimateLine(
spec=(x1, y1, x2, y2),
linewidth=30,
linecolor='white'
)
class ConnectionPoint(sim.Component):
def setup(self, x, y, color, layer):
self.x = x
self.y = y
sim.AnimateRectangle(
spec=(-15, -15, 15, 15),
x=x,
y=y,
fillcolor=color,
layer=layer
)
class Item(sim.Component):
nr = 0
def setup(self, routes):
self.routes = routes
self.current_route_index = 0
self.has_been_stored = False
self.x, self.y = routes[0].x1, routes[0].y1
sim.AnimateRectangle(
spec=lambda: (self.x - 12, self.y - 12, self.x + 12, self.y + 12),
fillcolor="green"
)
Item.nr += 1
self.id = Item.nr
def process(self):
# route 0
if self.current_route_index == 0:
while self.x != routes[0].x2:
self.hold(0.1)
self.x += (routes[0].x2 - routes[0].x1) / abs(routes[0].x2 - routes[0].x1) * 2
self.current_route_index += 1
if self not in yellow:
self.enter(yellow)
env = sim.Environment()
env.background_color('20%gray')
yellow = sim.Store("yellow", capacity=float('inf'))
# Define list of routes
routes = [
Route(x1=0, y1=700, x2=800, y2=700), #
]
connection_points = [
ConnectionPoint(x=800, y=700, color='yellow', layer=0),
]
# generates the item output
items = sim.ComponentGenerator(Item, routes=routes, iat=2, number=20)
env.animate(True)
env.run(till=200)
yellow.print_info()
- Визуальное представление очереди :
Элементы должны отображаться в линию, четко показывая порядок очереди. - Перемещение >:
Когда предмет выделен желтым цветом, например, после через пять секунд предмет должен исчезнуть, а затем станет доступным пятно желтого цвета. Следующий элемент в строке должен стать желтым на маршруте. - Бесшовная адаптация:
Как элементы перемещаются из очереди в желтое состояние, очередь должна динамически корректироваться.
Подробнее здесь: https://stackoverflow.com/questions/786 ... ge-unit-is