def run(self, model, cellname): self.name = cellname inObs = model.modules["obs_in"+self.name] inObs_report = inObs.create_report_socket(multiple_observation = True) workObs = model.modules["obs_work"+self.name] workObs_report = workObs.create_report_socket() trans = model.modules["load"+self.name] machine = model.modules["machine"+self.name] machine_report = machine.create_report_socket() while True: ##attente de l'arrivée d'un pièce yield get, self, inObs_report, 1 ev = self.got[0] rq = Request("load"+self.name,"move",params={'program':'load'}) yield put, self, trans.request_socket, [rq] ##pièce prête yield get, self, workObs_report, 1 ev = self.got[0] ##get program from product type p = ev.how['productType'] yield put, self, machine.request_socket, [Request(self.name,"setup", params={"program":"p"+str(p)})] ##début process yield put, self, machine.request_socket, [Request(self.name,"make")] ##attente fin process fin = False while not fin: yield get, self, machine_report, 1 fin = self.got[0].what=="idle" ##déchargement yield put, self, trans.request_socket, [Request("load"+self.name, "move", params={"program":'unload'})]
def run(self, model): sp = model.modules["space1"] obs1 = model.modules["observer1"] rp_obs1 = obs1.create_report_socket() while True: yield get, self, rp_obs1, 1 rq = Request("space1", "move", params={'program': 'p1'}) yield put, self, sp.request_socket, [rq]
def run(self, model, a): n = 0 createModule = model.modules["create1"] while True: m = Request("create1", "create") yield put, self, createModule.request_socket, [m] yield hold, self, model.rng.expovariate(a) n += 1
def run(self, model): outObs_report = model.modules["obs_outSf"].create_report_socket() trans = model.modules["transSt"] while True: yield get, self, outObs_report, 1 ev = self.got[0] p = ev.how['productType'] yield put, self, trans.request_socket, [Request("transSt", "move", params={'program': "load_st"+str(p)})]
def run(self, model, name): out = model.get_module('out'+name) rp_out = out.create_report_socket() dispose = model.get_module('dispose'+name) rp_dispose = dispose.create_report_socket() obs_out = model.get_module('obs_out'+name) rp_obs_out = obs_out.create_report_socket() while True: yield get, self, rp_obs_out, 1 yield put, self, dispose.request_socket, [Request('dispose'+name, 'dispose')]
def run(self, model, ordo = Schedule()): #initialize products struct create = model.modules["create"] obs = model.modules["obs_inSf"] inObs_report = obs.create_report_socket(multiple_observation = True) while not ordo.sf_finished(): p_type = ordo.sf_get_next() yield put, self, create.request_socket, [Request("create", "create", params={'productType':p_type})] yield get, self, inObs_report, 1 ordo.sf_report_done()
def run(self, model, sched = Schedule()): """observe inventory holders, and input buffers, act on """ product_registry = [] trans = model.modules["transSt"] report_hub = Store() for i in range(1, 13): model.modules['obs_st'+str(i)].attach_report_socket(report_hub) trans.attach_report_socket(report_hub) #st: list of types that have been memorized st = list() idle = True while True: #get event yield get, self, report_hub, 1 rp = self.got[0] #triage event if 'productType' in rp.how: #event from a product obs p_type = rp.how['productType'] #change product presence array st.append(p_type) else: #come from trans actuator #update state idle = (rp.what == 'idle') #if actuator is idle : find a routable product and process it #trans op finished if idle: routable = [t for t in st if sched.routable(t)] if len(routable) > 0: prod_type = routable[0] dest = sched.route(prod_type) rq = Request('transSt', 'move', params = {'program': 'unload_st%sto%s' % (prod_type, dest)}) yield put, self, trans.request_socket, [rq] idle = False sched.report_routed(prod_type, dest) st.remove(prod_type)
def on_start_emu_activate(self, data=None): """Called when the user request emulation to start""" self.add_status("starting emulation...") self.sendRequest(Request('emulator', 'start'))
def on_finish_emu_activate(self, data=None): """Called when the user request emulation to finish""" self.add_status("ending emulation...") self.sendRequest(Request('emulator', 'stop'))