How to use the spade.Behaviour.ACLTemplate function in spade

To help you get started, we’ve selected a few spade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github javipalanca / spade / examples / unittests / p2pTestCase.py View on Github external
def testSendMsgP2PPY(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(p2pRecvMsgBehav("p2ppy"),t)
        self.a.addBehaviour(p2pSendMsgBehav("p2ppy"),None)
        counter = 0
        while self.b.msg == None and counter < 10:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.b.msg,None)
        self.assertEqual(self.b.msg.getContent(),"testSendMsg")
        self.assertEqual(self.b.msg.getSender(), self.Aaid)
        self.assertEqual(len(self.b.msg.getReceivers()),1)
        self.assertEqual(self.b.msg.getReceivers()[0], self.Baid)
        self.assertEqual(self.b.msg._attrs["method"],"p2ppy")
github javipalanca / spade / examples / unittests / p2pTestCase.py View on Github external
def testSendAndRecvMsgP2PPY(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(p2pAnswerMsgBehav("p2ppy"),t)
        template.setSender(self.Baid)
        t = spade.Behaviour.MessageTemplate(template)
        self.a.addBehaviour(p2pSendAndRecvMsgBehav("p2ppy"),t)
        counter = 0
        while self.a.msg == None and counter < 20:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.a.msg,None)
        self.assertEqual(self.a.msg.getContent(),"testSendAndRecvMsg")
        self.assertEqual(self.a.msg._attrs["method"],"p2ppy")
github javipalanca / spade / examples / unittests / p2pTestCase.py View on Github external
def testSendMultiMsgP2P(self):
        nmsg=100
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(p2pRecvMultiMsgBehav("p2p",nmsg),t)
        self.a.addBehaviour(p2pSendMultiMsgBehav("p2p",nmsg),None)
        counter = 0
        while self.b.msg == None and counter < 10:
            time.sleep(1)
            counter += 1

        self.assertEqual(self.b.receivedmsg,nmsg)
        self.assertNotEqual(self.b.msg,None)
        self.assertEqual(self.b.msg._attrs["method"],"p2p")
        self.assertEqual(self.b.errorTag,[])
        self.assertEqual(self.a.routeTag,[])
github javipalanca / spade / examples / unittests / p2pTestCase.py View on Github external
def testSendMultiMsgP2PPY(self):
        nmsg=100
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(p2pRecvMultiMsgBehav("p2ppy",nmsg),t)
        self.a.addBehaviour(p2pSendMultiMsgBehav("p2ppy",nmsg),None)
        counter = 0
        while self.b.msg == None and counter < 10:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.b.msg,None)

        self.assertEqual(self.b.msg._attrs["method"],"p2ppy")
        self.assertEqual(self.b.receivedmsg,nmsg)
        self.assertEqual(self.b.errorTag,[])
        self.assertEqual(self.a.routeTag,[])
github javipalanca / spade / examples / unittests / basicTestCase.py View on Github external
def testSendAndRecvMsg(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(AnswerMsgBehav(),t)
        template.setSender(self.Baid)
        t = spade.Behaviour.MessageTemplate(template)
        self.a.addBehaviour(SendAndRecvMsgBehav(),t)
        counter = 0
        while self.a.msg == None and counter < 20:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.a.msg,None)
        self.assertEqual(self.a.msg.getContent(),"testSendAndRecvMsg")
github javipalanca / spade / examples / unittests / p2pTestCase.py View on Github external
def testSendAndRecvMsgP2P(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(p2pAnswerMsgBehav("p2p"),t)
        template.setSender(self.Baid)
        t = spade.Behaviour.MessageTemplate(template)
        self.a.addBehaviour(p2pSendAndRecvMsgBehav("p2p"),t)
        counter = 0
        while self.a.msg == None and counter < 20:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.a.msg,None)
        self.assertEqual(self.a.msg.getContent(),"testSendAndRecvMsg")
        self.assertEqual(self.a.msg._attrs["method"],"p2p")
github javipalanca / spade / examples / unittests / basicTestCase.py View on Github external
def testSendMsg(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(RecvMsgBehav(),t)
        self.a.addBehaviour(SendMsgBehav(),None)
        counter = 0
        while self.b.msg == None and counter < 10:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.b.msg,None)
        self.assertEqual(self.b.msg.getContent(),"testSendMsg")
        self.assertEqual(self.b.msg.getSender(), self.Aaid)
        self.assertEqual(len(self.b.msg.getReceivers()),1)
        self.assertEqual(self.b.msg.getReceivers()[0], self.Baid)
github javipalanca / spade / examples / dalmuti / gameManager.py View on Github external
def _setup(self):
        self.crearBaraja()
        self.revolucion = False

        # Preparamos la plantilla para el comportamiento inicial
        template = spade.Behaviour.ACLTemplate()
        template.setOntology("Dalmuti")
        template.setPerformative("request")
        template.setConversationId("Inicio")

        mt = spade.Behaviour.MessageTemplate(template)

        insBhv = self.inscripcionBehav()
        self.addBehaviour(insBhv, mt)

        # Preparamos la plantilla para asignar roles
        template.setConversationId("Carta")
        mt = spade.Behaviour.MessageTemplate(template)

        rolBhv = self.rolInicialBehav()
        self.addBehaviour(rolBhv, mt)