[docs]classSMIAHIAgentServices:def__init__(self,agent_object):""" The constructor method adds the object of the agent to have access to its information. Args: agent_object (spade.Agent): the SPADE agent object of the SMIA agent. """# The SPADE agent object is stored as a variable of the behaviour classself.myagent=agent_objectself.services_map={'HumanTransportGUI':self.human_transport_gui,'VisuallyInspectGUI':self.visually_inspect_gui,}#: This object maps the service identifiers with its associated execution methods
[docs]asyncdefhuman_transport_gui(self,Initial,Final):""" This method realizes the agent service related to the HumanTransport skill of the SMIA HI. Args: Initial: the skill input parameter of the initial position of the transport. Final: the skill input parameter of the final position of the transport. """_logger.info("Running the transport service using the human through SPADE web GUI")# First, a new received CSS task will be added in the GUI Agentrandom_task_id=awaitacl_smia_messages_utils.create_random_thread(self.myagent)self.myagent.received_css_tasks[random_task_id]={'capName':'Transportation','requestedTime':str(GeneralUtils.get_current_date_time()),'skillParams':{'Initial':Initial,'Final':Final}}# Then, it will wait until the task is completedwhilerandom_task_id+'-done'notinself.myagent.completed_css_tasks:awaitasyncio.sleep(1)# wait for 1 second# Here the task has been completed, so it will return OKreturn{'status':'success'}
[docs]asyncdefvisually_inspect_gui(self):""" This method realizes the agent service related to the VisuallyInspect skill of the SMIA HI. """_logger.info("Running the transport service using the human through SPADE web GUI")# First, a new received CSS task will be added in the GUI Agentrandom_task_id=awaitacl_smia_messages_utils.create_random_thread(self.myagent)self.myagent.received_css_tasks[random_task_id]={'capName':'VisualInspection','requestedTime':str(GeneralUtils.get_current_date_time())}# Then, it will wait until the task is completedwhilerandom_task_id+'-done'notinself.myagent.completed_css_tasks:awaitasyncio.sleep(1)# wait for 1 second# Here the task has been completed, so it will return OKreturn{'status':'success'}