/*********************************************************************/ /* */ /* AgentService Framework */ /* www.agentservice.it */ /* */ /* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */ /* GNU Lesser General Public License */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation, */ /* version 2.1 of the License. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the */ /* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ /* Boston, MA 02111-1307, USA. */ /* */ /*********************************************************************/ using System; using System.Reflection; using AgentService.Platform; using AgentService.Platform.DF; using AgentService.Platform.AMS; using AgentService.Platform.MTS; using AgentService.Platform.Modules; using AgentService.Agent.Behaviour; using AgentService.Agent.Knowledge; using AgentService.Agent.Runtime; // using AgentService.Interop; namespace AgentService.Agent { /// //// Interface IAgent. Defines the internal interface /// used by the AMS and the platform instance to access /// to software agent data. The IAgent interface exposes /// all the API required to control a software agent /// instance. /// public interface IAgent { # region Members #region Agent Events /// /// Thrown when the agent is activated. /// event AgentDelegate OnActivateAgent; /// /// Fires every time an agent has terminated /// its activity either because it has been /// stopped by the platform or because it has /// terminated. /// event AgentDelegate OnReleaseAgent; /// /// thrown when the agent is stopped /// event AgentDelegate OnStopAgent; /// /// thrown when the agent temrminates its execution /// event AgentDelegate OnTerminateAgent; event PersistAgentDelegate OnPersistAgent; #endregion #region Behaviour related events /// /// Fires every time a new behaviour is created. /// event BehaviourDelegate OnNewBehaviour; /// /// Fires every time a behaviour is started. /// event BehaviourDelegate OnStartBehaviour; /// /// Fires every time a behaviour is terminated. /// event BehaviourDelegate OnTerminateBehaviour; /// /// Fires every time a behaviour is suspended. /// event BehaviourDelegate OnSuspendBehaviour; /// /// Fires every time a behaviour is woken up. /// event BehaviourDelegate OnWakeUpBehaviour; #endregion /// /// Unique Agent-IDentifier. /// AID AID { get; set; } /// /// Life cycle state of the Agent. AgentState State { get; set; } /// /// Persistence flag. /// bool IsPersistent { get; } AgentPersistent Persistent { get; set; } /// /// Collection of KnowledgeManager objects. /// AgentService.Agent.Knowledge.KnowledgeCollection Knowledges { get; } /// /// Collection of Behaviour objects belonging to the Agent. /// AgentService.Agent.Behaviour.BehaviourCollection Behaviours { get; } /// /// Collection of Knowledge type objects handled by the agent. /// TypeDescriptorCollection KnowledgeTypes { get; } /// /// Collection of Behaviour type objects handled by the agent. /// TypeDescriptorCollection BehaviourTypes { get; } /// /// Profile of the agent /// AgentProfile Profile { get; } /// /// Name of agent's config file /// string ConfigFileName { get; } #endregion # region Agent Activity /// /// Initialize the internal Agent's data structures. /// /// configuration file for agent initialization including the full path void Initiate(string configFile); /// /// Starts the agent activity. /// void Activate(); /// /// Assigns an AgentTemplate to the Agent and gives him an AID. /// /// full template name of the corresponding AgentTemplate subtype /// name of the containing assembly of the AgentTemplate subtype void SetTemplate(AgentTemplate template); /// /// Commits the agent migration process /// /// flag used to distinguish the source /// and the target platform void CommitMove(bool bIsSourceInstance); # endregion # region Manage Platform Services /// /// Binds the agent to the runtime environemt of the platform. /// /// gives access to the runtime services of the platform void Bind(AgentService.Agent.Runtime.IRuntimeEx runtime); /// /// Loads agent data from its persisted version. /// /// persisted version of the agent void ResumeFrom(AgentPersistent agentPersistent); /// /// Creates the persistent version of the agent. /// /// persisted version of the agent AgentPersistent GetPersistent(); #endregion #region Manage Agent Behaviours /// /// Adds a new behaviour to the agent and starts it. /// /// The Behaviour to be added to the Agent /// if true starts the behaviour void SubmitBehaviour(Behaviour.Behaviour behaviour, bool bStart); /// /// Suspends a behaviour instance. /// /// behaviour instances that will be suspended void SuspendBehaviour(AgentService.Agent.Behaviour.Behaviour behaviour); /// /// Suspends all the behaviour instances. /// void SuspendAllBehaviours(); /// /// Resumes a suspended behaviour instance. /// /// suspended behaviour instance that will be resumed void WakeUpBehaviour(AgentService.Agent.Behaviour.Behaviour behaviour); /// /// Resumes all suspended behaviour instances. /// void WakeUpAllBehaviours(); /// /// Removes a behaviour instance. /// /// behaviour instance that will be removed void RemoveBehaviour(AgentService.Agent.Behaviour.Behaviour behaviour); /// /// Removes all behaviours instances. /// void RemoveAllBehaviours(); /// /// Starts a collection of behaviours instances. /// /// list of behaviour instances names that will be started void StartBehaviours(params string[] behaviourNames); /// /// Starts all the behaviour instances previously added. /// void StartAllBehaviours(); /// /// Kills all the threads belonging to the agent. /// void Stop(); /// /// Kills all the threads belonging to the agent. /// /// stop reason, if true the agent terminated abnormally void Stop(bool bAbort); # endregion # region Manage Agent Knowledges /// /// Locks a knowledge instance to be used by a behaviour instance. /// /// behaviour instance that wants to use the knowledge instances /// list of knowledge instancess to be locked void LockKnowledge(AgentService.Agent.Behaviour.Behaviour lockingBehaviour, params Knowledge.Knowledge[] myKnowledgeList); /// /// Persists the changes for a given Knowledge's item. /// ///knowledge object which fired the update event void PersistChanges(object sender); /// /// Releases the knowledge instances previously locked by a behaviour instance. /// /// behaviour instance that releases the Knowledge void ReleaseKnowledge(AgentService.Agent.Behaviour.Behaviour releaseBehaviour); # endregion } }