def __init__(self): self.cnc = CNC() self.undoredo = undo.UndoRedo() self.probe = Probe.Probe() self.orient = Orient() self.vars = {} # local variables self.init()
def __init__(self, group, task_type, mode='FIFO', cncs_type='00000000', fault=False, print_info=False): ''' group: cnc机器类型组别 task_type: 1/2,1表示一道工序模式,2表示两道工序模式。 cncs_type: 八位二进制0/1字符串,0表示处理第一道工序,1表示处理第二道工序。 ''' self.group = group self.group_1 = [20, 33, 46, 560, 400, 378, 28, 31, 25] self.group_2 = [23, 41, 59, 580, 280, 500, 30, 35, 30] self.group_3 = [18, 32, 46, 545, 455, 182, 27, 32, 25] self.groups_para = [self.group_1, self.group_2, self.group_3] # 各组cnc,rgv机器参数 self.task_type = task_type # self.T = 8 * 60 * 60 # 一次加工总时间,单位:秒 self.time = 0 # 计时器 self.cnt = 0 # 时间 self.cncs_type = cncs_type if self.task_type == 1: self.cnc_ls = [ CNC(i + 1, group, self.task_type - 1, self.groups_para, fault) for i in range(8) ] # task 1 else: self.cnc_ls = [ CNC( int(i) + 1, group, int(cncs_type[i]) + 1, self.groups_para, fault) for i in range(8) ] # task 2 self.rgv = RGV(0, group, self.task_type, self.groups_para) # 初始化rgv self.wait_queue = [] # 任务等待队列,按照任务先后顺序 self.wait_queue_task1 = [] # 第一阶段等待队列 self.wait_queue_task2 = [] # 第二阶段等待队列 self.wait_set = set() # 任务等待集合 self.wait_set_task1 = set() # 第一阶段等待集合 self.wait_set_task2 = set() # 第二阶段等待集合 self.mode = mode self.select_ls = [] self.print_info = print_info
def handler(s, f): print("Program interrupted. Cleaning up.") cnc.shutdown() exit(0) def error(e): print(e) if __name__ == "__main__": signal.signal(signal.SIGINT, handler) # Define cnc cnc = CNC(200, error_handler=error) # Input filename filename = 'ct/' + input('File: ') # Load the svg into the cnc # cnc.load_svg(filename) cnc.load_mstp(filename) # Draw loaded svg cnc.run() # Shutdown cnc cnc.shutdown()
elif truediff == 6: rgvmovement(3) oddup(choice) elif truediff == -2: rgvmovement(-1) oddup(choice) elif truediff == -4: rgvmovement(-2) oddup(choice) elif truediff == -6: rgvmovement(-3) oddup(choice) for i in range(0, 8 + 1): cnc = CNC(i, False, workingtime[1], workingtime[2]) cnclist.append(cnc) express() while time <= (8 * 3600): twoprooperation() relativeloca = [ 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000 ] relativeloca2 = [ 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000 ] print("%-10s" % "CNC1", "%-10s" % "Uptime1", "%-10s" % "Downtime1", "%-10s" % "CNC2", "%-10s" % "Uptime2", "%-10s" % "Downtime2") for i in range(1, len(updowntsequence2)): print("%-10d" % sequence1[i], "%-10d" % uptsequence1[i], "%-10d" % updowntsequence1[i], "%-10d" % sequence2[i],
elif truediff == 6: rgvmovement(3) oddup(choice) elif truediff == -2: rgvmovement(-1) oddup(choice) elif truediff == -4: rgvmovement(-2) oddup(choice) elif truediff == -6: rgvmovement(-3) oddup(choice) for i in range(0, 8 + 1): cnc = CNC(i, False, workingtime, 0) cnclist.append(cnc) while time <= (8*3600): opration() print("%-8s" % "CNC", "%-8s" % "Uptime", "%-8s" % "Downtime") for i in range(1, len(updowntsequence)): print("%-8d" % sequence[i], "%-8d" % uptsequence[i], "%-8d" % updowntsequence[i]) print("Total goods number: ", goodsnum)