Exemplo n.º 1
0
Arquivo: AMS.cs Projeto: armysick/mOch
 /// <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());
     }
 }
Exemplo n.º 2
0
Arquivo: AMS.cs Projeto: armysick/mOch
 /// <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;
     }
 }
Exemplo n.º 3
0
Arquivo: AMS.cs Projeto: armysick/mOch
        /// <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);
        }
Exemplo n.º 4
0
Arquivo: AMS.cs Projeto: armysick/mOch
        /// <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());
        }
Exemplo n.º 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));
        }