"""This is the SMIA launch file for CLI, which executes the program logic from the command and gets the AAS model from thearguments."""importloggingimportosimportsys# sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) # To run in CLI (executing in 'src' folder)importsmiafromsmia.agents.smia_agentimportSMIAAgentfromsmia.agents.smia_app_agentimportSMIAAppAgentfromsmia.agents.smia_resource_agentimportSMIAResourceAgentfromsmia.utilitiesimportsmia_archive_utilsfromsmia.utilitiesimportproperties_file_utilsfromsmia.utilities.general_utilsimportCLIUtils# XMPP_SERVER = 'worker4'# XMPP_SERVER = 'ejabberd'_logger=logging.getLogger(__name__)
[docs]defmain():# First, the command line arguments are obtainedinit_config,aas_model=CLIUtils.get_information_from_cli(sys.argv[1:])smia_archive_utils.save_cli_added_files(init_config,aas_model)# It is checked and saved the command line argumentsCLIUtils.check_and_save_cli_information(init_config,aas_model)# The AAS_ID will be set in the associated ConfigMap, within the general-information of the AASaas_id=properties_file_utils.get_dt_general_property('agentID')passwd=properties_file_utils.get_dt_general_property('password')# The XMPP server of the MAS will also be set in the associated ConfiMapxmpp_server=properties_file_utils.get_dt_general_property('xmpp-server')# Build the agent jid and passwordagent_jid=aas_id+'@'+xmpp_server# Depending on the asset type, the associated SPADE agent will be createdaas_type=''# For testing (TODO Get the type of the asset)matchaas_type:case"physical":_logger.info("The asset is physical")smia_agent=SMIAResourceAgent(agent_jid,passwd)case"digital":_logger.info("The asset is logical")smia_agent=SMIAAppAgent(agent_jid,passwd)case_:_logger.info("The asset is not defined, so it is a generic SMIA")# Create the agent objectsmia_agent=SMIAAgent(agent_jid,passwd)smia.run(smia_agent)
if__name__=='__main__':# First, the initial configuration must be executedsmia.initial_self_configuration()_logger.info("Initializing SMIA software...")# Run main program with SPADEmain()