Beispiel #1
0
 /// <summary>
 /// Deregister an active agent on the platform.
 /// For now, it will not return an error in case of the specified agent
 /// is already innactive.
 /// </summary>
 /// <returns></returns>
 /// <param name="agent">Agent AID</param>
 public void Deregister(AMSAgentDescription agent)
 {
     if (_activeAgents.ContainsKey(agent.GetAgentAID()))
     {
         _activeAgents.Remove(agent.GetAgentAID());
     }
 }
Beispiel #2
0
 /// <summary>
 /// Modify the specified agent description with a newly passed
 /// </summary>
 /// <returns></returns>
 /// <param name="agent">Agent's AID</param>
 /// <param name="newDscrAgent">New agent description</param>
 public void Modify(AID agent, AMSAgentDescription newDscrAgent)
 {
     if (_activeAgents.ContainsKey(agent))
     {
         _activeAgents[agent] = newDscrAgent;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Register an Agent as active on the platform
        /// For now, it will accept and register. In the future, In case of an
        /// already registered agent having the same name, it will return an error.
        /// </summary>
        /// <returns>True if added, False otherwise</returns>
        /// <param name="agent">AMS Agent description</param>
        public bool Register(AMSAgentDescription agent)
        {
            if (_activeAgents.ContainsKey(agent.GetAgentAID()))
            {
                return(false);
            }

            _activeAgents.Add(agent.GetAgentAID(), agent);
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Search for a specific agent in AMS.
        /// </summary>
        /// <param name="agentTmpl">An agent description template</param>
        /// <param name="cstrnts">Search constraints</param>
        /// <returns>Array of results or null</returns>
        public AMSAgentDescription[] Search(AMSAgentDescription agentTmpl, SearchConstraints cstrnts)
        {
            List <AMSAgentDescription> similarAgents = new List <AMSAgentDescription>();

            // TODO: Make use of search constraints

            foreach (AMSAgentDescription existingAgent in _activeAgents.Values)
            {
                if (existingAgent.GetAgentAID() == agentTmpl.GetAgentAID())
                {
                    similarAgents.Add(existingAgent);
                }
            }

            // TODO: Make use of services and other parameters

            return(similarAgents.ToArray());
        }
Beispiel #5
0
        /// <summary>
        /// Register an agent on AMS
        /// </summary>
        /// <param name="agentId">The unique Agent's AID</param>
        /// <param name="ownership">Agent's ownership; Set to empty string if no parameter is passed.</param>
        /// <param name="agentState">Agent's current state. Set to NONE if no parameter is passed.</param>
        /// <returns>True if registered, False otherwise</returns>
        public bool RegisterOnAMS(AID agentId, string ownership = "", AgentState agentState = AgentState.None)
        {
            AMSAgentDescription agentDescription = new AMSAgentDescription(agentId, ownership, agentState);

            return(this._ams.Register(agentDescription));
        }