def defineBuffers(): process=G.CMSDData.getElementsByTagName('Process') #loop through the processes for proc in process: try: #read the scrap quantity Property=proc.getElementsByTagName('Property') for prop in Property: name=prop.getElementsByTagName('Name') name=name[0].toxml().replace('<Name>','').replace('</Name>','') if name=='BufferIn': id=prop.getElementsByTagName('Identifier') id=id[0].toxml().replace('<Identifier>','').replace('</Identifier>','') capacity=prop.getElementsByTagName('Capacity') capacity=capacity[0].toxml().replace('<Capacity>','').replace('</Capacity>','') capacity=int(capacity) else: continue #read the id of the station resource ResourcesRequired=proc.getElementsByTagName('ResourcesRequired') for res in ResourcesRequired: Resource=res.getElementsByTagName('Resource') ResourceIdentifier=Resource[0].getElementsByTagName('ResourceIdentifier') ResourceIdentifier=ResourceIdentifier[0].toxml().replace('<ResourceIdentifier>','').replace('</ResourceIdentifier>','') #loop through to find the machine of the process and connect them M=None for obj in G.ObjList: if obj.id==ResourceIdentifier: M=obj if M==None: continue #if the Queue already exists find it if id in G.QueueIds: for item in G.QueueIds: for queue in G.QueueList: if id==queue.id: Q=queue #else create the Queue else: Q=Queue(id=id, name=id, capacity=capacity) Q.resourceIdentifier=[] G.ObjList.append(Q) G.QueueList.append(Q) G.QueueIds.append(id) #set the Queue as predecessor of the Machine and vice versa Q.next.append(M) M.previous.append(Q) Q.resourceIdentifier.append(M.resourceIdentifier) except IndexError: continue
def defineBuffers(): process = G.CMSDData.getElementsByTagName('Process') #loop through the processes for proc in process: try: #read the scrap quantity Property = proc.getElementsByTagName('Property') for prop in Property: name = prop.getElementsByTagName('Name') name = name[0].toxml().replace('<Name>', '').replace('</Name>', '') if name == 'BufferIn': id = prop.getElementsByTagName('Identifier') id = id[0].toxml().replace('<Identifier>', '').replace( '</Identifier>', '') capacity = prop.getElementsByTagName('Capacity') capacity = capacity[0].toxml().replace( '<Capacity>', '').replace('</Capacity>', '') capacity = int(capacity) else: continue #read the id of the station resource ResourcesRequired = proc.getElementsByTagName( 'ResourcesRequired') for res in ResourcesRequired: Resource = res.getElementsByTagName('Resource') ResourceIdentifier = Resource[0].getElementsByTagName( 'ResourceIdentifier') ResourceIdentifier = ResourceIdentifier[0].toxml().replace( '<ResourceIdentifier>', '').replace('</ResourceIdentifier>', '') #loop through to find the machine of the process and connect them M = None for obj in G.ObjList: if obj.id == ResourceIdentifier: M = obj if M == None: continue #if the Queue already exists find it if id in G.QueueIds: for item in G.QueueIds: for queue in G.QueueList: if id == queue.id: Q = queue #else create the Queue else: Q = Queue(id=id, name=id, capacity=capacity) Q.resourceIdentifier = [] G.ObjList.append(Q) G.QueueList.append(Q) G.QueueIds.append(id) #set the Queue as predecessor of the Machine and vice versa Q.next.append(M) M.previous.append(Q) Q.resourceIdentifier.append(M.resourceIdentifier) except IndexError: continue