📄 swarm.objectbase.sgml.reference.html
字号:
></H2><P> It is completely reasonable to assume that explicit control can be had over all the activities in a simulation. However, at present, this control is limited because the context in which an activity runs determines how it behaves. To understand how an <ICLASS="EMPHASIS">ActivityControl</I> is to be used, we will have to explore the behavior of activities in context. (For a more complete explanation of the behavior of activities, see the <ICLASS="EMPHASIS"><AHREF="swarm.activity.sgml.reference.html">activity library</A></I> documentation.) </P><P>There are two ways to get an activity started, one can activate the activity in <TTCLASS="LITERAL">nil</TT> or in some other activity. So called "top-level" activities are activated in <TTCLASS="LITERAL">nil</TT> and are intended to be independent of the sophisticated scheduling activity that dictates the execution of actions in any other context in the simulation. I.e. the only activities that should be activated in <TTCLASS="LITERAL">nil</TT> are those sets of events that are expected to preserve the same behavior no matter what goes on in any other part of the simulation. </P><P>The other type of activity, those activated in some other activity, is intended to be an integral part of its owner activity. However, this doesn't mean that it <ICLASS="EMPHASIS">must</I> depend on the outcome of actions happening in the owner activity. In fact, an <ICLASS="EMPHASIS">ActionPlan</I> can be designated as containing actions that are capable of being processed in parallel, via code like the following:<TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">[anActionPlan setDefaultOrder: Concurrent];</PRE></TD></TR></TABLE> But these activities are <ICLASS="EMPHASIS">still</I> intended to be meshed with their owner activities. In other words, they are part and parcel of the same model or simulation.</P><P>Now, the operational effect of activating an activity in <TTCLASS="LITERAL">nil</TT> is that it will not be meshed with the rest of the Swarm activity structure. This gives the user (or process) complete control over the execution of that activity. A <TTCLASS="LITERAL">run</TT> on that activity will run either to completion or until a stop flag is set by a sequence of events purely internal to that activity. Or, one can stop it from the outside with a message from something like an <ICLASS="EMPHASIS">ActivityControl</I>. </P><P>What all this means is that, while one can attach an <ICLASS="EMPHASIS">ActivityControl</I> to <ICLASS="EMPHASIS">any</I> activity, only the "top-level" activities (those having been activated in <TTCLASS="LITERAL">nil</TT>) are going to respond well to it. Any sub-activity will respond half-heartedly, if at all. For example, in the <ICLASS="EMPHASIS">Mousetrap</I> demo distributed with Swarm, an <ICLASS="EMPHASIS">ActivityControl</I> has been placed on both the <ICLASS="EMPHASIS">ObserverSwarm</I> and the <ICLASS="EMPHASIS">ModelSwarm</I> activities. Now, if one sends a <TTCLASS="LITERAL">run</TT> message to the <ICLASS="EMPHASIS">ActivityControl</I> that is attached to the <TTCLASS="LITERAL">observerSwarm</TT>'s activity, the entire model continues to run to completion, unless the user sends a <TTCLASS="LITERAL">stop</TT> message. However, if the sim is stopped at some point, a <TTCLASS="LITERAL">run</TT> message to the <TTCLASS="LITERAL">modelSwarm</TT>'s activity will have no effect at all. (<ICLASS="EMPHASIS">Note:</I> If you do this via the activity controllers, you see the <TTCLASS="LITERAL">currentTime</TT> variable get updated; but, the actual <TTCLASS="LITERAL">run</TT> message to the activity, itself, has no effect.) </P><P>So, the rule of thumb, for the present, is to attach <ICLASS="EMPHASIS">ActivityControl</I> objects only to "top-level" activities, like the <ICLASS="EMPHASIS">ObserverSwarm</I>. </P></DIV></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.OBJECTBASE.SGML.SECT1.SUBCLASS">5. Subclassing Reference</A></H1><P>The main classes defined here that are intended to be subclassed by users are Swarm and SwarmObject. The probing functionality provided here is mainly for use within the <ICLASS="EMPHASIS">Swarm</I> kernel. However, this probe machinery should be used when designing any interface between <ICLASS="EMPHASIS">Swarm</I> and any other agent or device. </P><DIVCLASS="FORMALPARA"><P><B>SwarmObject. </B><ICLASS="EMPHASIS">SwarmObject</I> is the base class for all interactive agents in <ICLASS="EMPHASIS">Swarm</I>. It defines the standard behavior for Swarmstyle agents, which includes hooks for creation, probing, zoned memory allocation, and destruction.</P></DIV><DIVCLASS="FORMALPARA"><P><B>Swarm. </B>The <ICLASS="EMPHASIS">Swarm</I> class encapsulates all of the abstract execution machinery in the <ICLASS="EMPHASIS">activity</I> library, as well as the notion of a group of related objects. Metaphorically, a "Swarm" is a combination of a collection of objects and a schedule of activity over those objects. Hence, the <ICLASS="EMPHASIS">Swarm</I> class provides the behavior necessary for creating such an object and starting up the schedule.</P></DIV><P>Further details on subclassing are also described in the <AHREF="swarm.objectbase.sgml.reference.html#SWARM.OBJECTBASE.SGML.SECT1.USAGE">Usage Guide</A></P></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.OBJECTBASE.SGML.SECT1.DESIGN">6. Interface Design Notes</A></H1><P>Unfortunately, this interface has not undergone a rigorous design review. As such it is subject to change in the future. However, there are rumours that this library will be integrated into the <ICLASS="EMPHASIS"><AHREF="swarm.defobj.sgml.reference.html">defobj library</A></I> anyway. So, even though little thought was given to the design of this interface (and it is not likely to be worthwhile designing a robust interface at this time), it was implemented in order to provide a first step towards bringing all the various libraries in line with the standard set by <ICLASS="EMPHASIS">defobj</I>.</P><P>Along these lines, a few notes are relevant. <P></P><OLTYPE="1"><LI><P><ICLASS="EMPHASIS">Probe</I>s may become an inherent part of any object.</P></LI><LI><P><ICLASS="EMPHASIS">ActivityControl</I>s will become a part of a larger set of tools used for debugging Swarm models. </P></LI></OL> </P></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.OBJECTBASE.SGML.SECT1.IMPL">7. Implementation Notes</A></H1><P></P><OLTYPE="1"><LI><P>Right now, <ICLASS="EMPHASIS">Probe</I>'s rely on a special method, <TTCLASS="LITERAL">getInstanceName</TT>, that has to be implemented in any probe-able object in order to get anything other than the class name of that object into the object designation widget. However, a more general capability has been added to <ICLASS="EMPHASIS">defobj</I> to give a meaningful name to any object. <ICLASS="EMPHASIS">Probe</I>s will be changed to take advantage of this new capability. </P></LI><LI><P>In the <ICLASS="EMPHASIS">ActivityControl</I> the frequency of the message <TTCLASS="LITERAL">updateStateVar</TT> is very high. It is sent at least once every cycle and <ICLASS="EMPHASIS">every</I> time a message is sent to the <ICLASS="EMPHASIS">ActivityControl</I>. This is unsatisfactory. Some of these messages can be pruned out of the object.</P></LI><LI><P>The <TTCLASS="LITERAL">probeMap</TT> designed for use with an <ICLASS="EMPHASIS">ActivityControl</I> was chosen fairly arbitrarily. Right now, it serves as a default for the class. A user can override it by designing a new one and inserting it into the <TTCLASS="LITERAL">probeLibrary</TT>. </P></LI><LI><P>Errors specific to objects in the <ICLASS="EMPHASIS">objectbase</I> library need to be gathered and initialized like those in the <ICLASS="EMPHASIS">defobj</I> library.</P></LI></OL></DIV></DIV><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT><AHREF="swarm.objectbase.activitycontrol.protocol.html">ActivityControl</A> — A class that provides an object interface to an activity.</DT><DT><AHREF="swarm.objectbase.completeprobemap.protocol.html">CompleteProbeMap</A> — A subclass of ProbeMap whose initial state contains the VarProbes and MessageProbes of the requested target class but also those of all its subclasses.</DT><DT><AHREF="swarm.objectbase.completevarmap.protocol.html">CompleteVarMap</A> — A subclass of ProbeMap, whose initial state contains no MessageProbes.</DT><DT><AHREF="swarm.objectbase.customprobemap.protocol.html">CustomProbeMap</A> — A subclass of ProbeMap, whose initial state is empty unlike the default probeMap initial state which contains all the VarProbes of the requested target class.</DT><DT><AHREF="swarm.objectbase.defaultprobemap.protocol.html">DefaultProbeMap</A> — A subclass of ProbeMap, whose initial state contains all the VarProbes of the requested target class and also those of all its superclasses.</DT><DT><AHREF="swarm.objectbase.emptyprobemap.protocol.html">EmptyProbeMap</A> — A CustomProbeMap to be used for building up ProbeMaps from scratch.</DT><DT><AHREF="swarm.objectbase.messageprobe.protocol.html">MessageProbe</A> — A class that allows the user to call a given message on any candidate that is an instance of, or inherits from, a given class.</DT><DT><AHREF="swarm.objectbase.probe.protocol.html">Probe</A> — An abstract superclass of both VarProbe and MessageProbe.</DT><DT><AHREF="swarm.objectbase.probeconfig.protocol.html">ProbeConfig</A> — Protocol for configuration of Probes, ProbeMaps, and the ProbeLibrary.</DT><DT><AHREF="swarm.objectbase.probelibrary.protocol.html">ProbeLibrary</A> — A (singleton) Class, whose instance is used as a container for a global mapping between classnames and their 'default' ProbeMaps. These defaults can be changed by the user, thus allowing him/her to customize the default contents of the ProbeDisplays generated when probing objects.</DT><DT><AHREF="swarm.objectbase.probemap.protocol.html">ProbeMap</A> — A container class for Probes used to specify the contents of a ProbeDisplay.</DT><DT><AHREF="swarm.objectbase.swarm.protocol.html">Swarm</A> — A temporal container.</DT><DT><AHREF="swarm.objectbase.swarmobject.protocol.html">SwarmObject</A> — A superclass of most objects in a Swarm simulation that provides support for probing.</DT><DT><AHREF="swarm.objectbase.varprobe.protocol.html">VarProbe</A> — A class that allows the user to inspect a given variable in any candidate that is an instance of, or inherits from, a given class.</DT><DT><AHREF="swarm.objectbase.generic.module.html">General</A> — Support for Swarm objects and probing</DT></DL></DIV></DIV><DIVCLASS="TITLEPAGE"><DIVCLASS="ABSTRACT"><P><B>Documentation and Implementation Status</B></P><P></P></DIV><AHREF="swarm.objectbase.generic.revhistory.html">Revision History (objectbase)</A></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="swarm.activity.generic.module.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="set.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="swarm.objectbase.activitycontrol.protocol.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">General</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="book930.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">ActivityControl</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -