public override structMessage messageBusReceive(structMessage m) { if (m.toTipo == tipo && enabled == true) { if (state == "idle") { state = "intercorrência"; local = m.fromIdx; timeAtendimento = 0; timeAtendimentoMax = Utils.rnd.Next(60, 60 * 60); m.ret = "atendido"; utils.loga(String.Format("{0,6:000000} - {1} {2,2:00} atendendo {3} {4,2:00} por {5,3:000} minutos.", Utils.minutesToTimeBr(m.tempo), tipo, idx, m.fromTipo, m.fromIdx, timeAtendimentoMax / 60 )); redraw = true; message = m; } } return(m); }
public void sendMessage(structMessage m) { // vai mandando as msgs até alguém atender structMessage mr; if (m.toAgent != null) { m.toAgent.messageBusReceive(m); return; } foreach (Agent a in agents.agentList) { //utils.loga("sendMessage: " + a.tipo + " " + a.idx); mr = a.messageBusReceive(m); if (mr.ret == "atendido") { //utils.loga("sendMessage: Atendido " + a.tipo + " " + a.idx); break; } } }
public override void tick(int tempo, int interval) { if (enabled == true && state != "idle") { if (local > 0) { timeAtendimento += interval; } if (timeAtendimento >= timeAtendimentoMax) { local = 0; state = "idle"; redraw = true; utils.loga(String.Format("{0,6:000000} - {1} {2,2:00} finalizou atendimento.", Utils.minutesToTimeBr(tempo), tipo, idx)); structMessage m = new structMessage(); m.fromAgent = this; m.toAgent = message.fromAgent; m.fromIdx = idx; m.fromTipo = tipo; m.toIdx = message.fromIdx; m.toTipo = "paciente"; m.text = "fim atendimento"; m.tempo = tempo; messageBus.sendMessage(m); } } }
public override structMessage messageBusReceive(structMessage m) { if (m.toAgent == this) { if (m.text == "atendido") { utils.loga(String.Format("{0,6:000000} - {1} {2,2:00} recebeu atendimento.", Utils.minutesToTimeBr(m.tempo), tipo, idx)); state = "recebe atendimento"; atendimentoInicio = m.tempo; } if (m.text == "fim atendimento") { int tempoAtendimento = m.tempo - atendimentoInicio; if (!atendimentos.ContainsKey(tempoAtendimento.ToString())) { atendimentos.Add(tempoAtendimento.ToString(), tempoAtendimento); } utils.loga(String.Format("{0,6:000000} - {1} {2,2:00} finalizou atendimento por {3,3:000} minutos.", Utils.minutesToTimeBr(m.tempo), tipo, idx, tempoAtendimento / 60)); state = "idle"; agentLink = null; tempoAguardandoAtendimento = 0; } } return(new structMessage()); }
public override structMessage messageBusReceive(structMessage m) { if (m.toAgent == this && agentLink == null && m.text == "requisita atendimento" && m.fromAgent != null && state == "chamado") { agentLink = m.fromAgent; timerTimoutIdle.Stop(); state = "intercorrência"; local = agentLink.idx; timeAtendimento = 0; timeAtendimentoMax = Utils.rnd.Next(60, 60 * 60); utils.loga(String.Format("{0,6:000000} - {1} {2,2:00} atendendo {3} {4,2:00} por {5,3:000} minutos.", Utils.minutesToTimeBr(m.tempo), tipo, idx, agentLink.tipo, agentLink.idx, timeAtendimentoMax / 60 )); redraw = true; structMessage mr = new structMessage(); mr.fromAgent = this; mr.toAgent = agentLink; mr.text = "atendido"; mr.tempo = m.tempo; messageBus.sendMessage(mr); } return(new structMessage()); }
public override void tick(int tempo, int interval) { if (state == "requisita atendimento") { string toTipo = "enfermeiro"; tempoAguardandoAtendimento += interval; if (Utils.rnd.Next(0, 1000) % 2 == 0) { toTipo = "tecnico"; } agentLink = messageBus.requestAgent(toTipo); if (agentLink != null) { structMessage m = new structMessage(); m.tempo = tempo; m.fromAgent = this; m.toAgent = agentLink; m.text = state; messageBus.sendMessage(m); } } }
public abstract structMessage messageBusReceive(structMessage m);