[docs]classReceiveACLBehaviour(CyclicBehaviour):""" This class implements the behaviour that handles all the ACL messages that the SMIA HI will receive from the others SMIAs in the I4.0 System. """def__init__(self,agent_object):""" The constructor method is rewritten to add the object of the agent Args: agent_object (spade.Agent): the SPADE agent object of the SMIA agent. """# The constructor of the inherited class is executed.super().__init__()# The SPADE agent object is stored as a variable of the behaviour classself.myagent=agent_object
[docs]asyncdefon_start(self):""" This method implements the initialization process of this behaviour. """_logger.info("ReceiveACLBehaviour starting...")
[docs]asyncdefrun(self):""" This method implements the logic of the behaviour. """# Wait for a message with the standard ACL template to arrive.msg=awaitself.receive(timeout=10)# Timeout set to 10 seconds so as not to continuously execute the behavior.ifmsg:# This method will receive all ACL messages to the SMIA HI_logger.aclinfo("Analyzing ACL message... Checking if it is a message for SMIA HI ... ")# TODOelse:_logger.info(" - No message received within 10 seconds on SMIA HI (ReceiveACLBehaviour)")