You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
974 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

class Machine:
def __init__(self):
self.processing = -1 # 当前正在处理的工件索引 -1代表空闲 比如索引是12调度顺序中12位置上的值比如是7那就意味着第13个加工的工件是7号工件
self.left_time = 0 # 剩余加工时间 0时表示该工件在该机器上的处理已完成。
def left_time(self):
"""获取当前剩余处理时间"""
return self.left_time
def process(self):
"""获取当前正在处理的工件索引"""
return self.processing
def next_time(self):
"""减少剩余处理时间(模拟时间流逝)"""
if self.left_time > 0:
self.left_time -= 1
def next_wp(self, time):
"""切换到下一个工件并设置处理时间"""
self.processing += 1
self.left_time = time
def reset(self):
"""重置机器状态"""
self.processing = -1
self.left_time = 0