Example #1
0
        async def run(self):
            msg = await self.receive()
            if msg:
                gm = json.loads(msg.body)
                gui_jid = str(msg.sender)
                if (gui_jid not in self.agent._executed_orders):
                    self.agent._executed_orders[gui_jid] = 0
                self.agent._executed_orders[gui_jid] += 1
                score = Score(int(gm["real_time"]), int(gm["min_time"]),
                              int(gm["priority"]))
                self.agent._statistics.calculate_avg_time(
                    int(gm["real_time"]), self.agent._executed_orders[gui_jid],
                    gui_jid)
                self.agent._statistics.calculate_tot_score(gui_jid, score)
                self.agent._statistics.calculate_ranking()
                if (self.presence.get_contact(
                        JID.fromstr(gui_jid))["subscription"] == "both"):
                    await self.__notify_gui()

                if (self.presence.get_contact(JID.fromstr(
                        JIDEnum.HIGH.value))["subscription"] == "both"):
                    await self.__notify_highway()

            if (self.agent._time):
                if (self.agent._time["time"] %
                        60 == 0):  # aggiorna lo storico ogni 60 secondi
                    self.agent._historical.set_archive(
                        self.agent._time["time_stamp"],
                        self.agent._statistics._ranking)
Example #2
0
        async def run(self):
            msg = await self.receive(timeout=1)

            if (msg and not self.agent._is_working):
                self._high_message = json.loads(msg.body)
                self.agent._msg_received = True
            elif (self.agent._time != 0 and not self.agent._is_working):
                if (JID.fromstr(JIDEnum.STAT.value)
                        in self.presence.get_contacts()):
                    if ("subscription" in self.presence.get_contact(
                            JID.fromstr(JIDEnum.STAT.value))):
                        if (self.presence.get_contact(
                                JID.fromstr(JIDEnum.STAT.value))
                            ["subscription"] == "both"):
                            await self.__notify_statistics()
                self.agent._time = 0