Skip to content

Commit

Permalink
[docs] Fixing the documentation to reflect the last changes in the SA…
Browse files Browse the repository at this point in the history
…RL API.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Mar 12, 2020
1 parent 7e0e7ba commit 93bbbd9
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 3,296 deletions.
Expand Up @@ -266,7 +266,7 @@ be handled, say by a coordinator, to know the agent is now alive! For example:
[:On]
on [:agspawnedevt](AgentSpawned) {
info("Agent {0} of type {1} has been created successfully and is now alive!",
occurrence.agentIdentifiers, occurrence.agentType)
occurrence.agentID, occurrence.agentType)
}
[:Off]
}
Expand Down
4 changes: 0 additions & 4 deletions docs/io.sarl.docs.markdown/src/main/documentation/index.md
Expand Up @@ -33,10 +33,6 @@

* [English Auction with Holons](./tutorials/HolonicAuction.md)

### Creating a SARL Run-time Environment

* [Creating a SARL Run-time Environment for the tinyMAS platform](./tutorials/CreateSREWithTinyMAS.md)

## Best Practices with SARL

* [Event Creation with a Builder](./bestpractices/EventBuilder.md)
Expand Down
Expand Up @@ -640,7 +640,7 @@ When the function [:setskillfct:] is returning, the agent becomes able to use th


If some cases, you may want to set the skill if one was not set up before. The specific behavior
is supported by `[:setskillifabsfctfull]{[:setskillifabsfct](setSkillIfabsent)(Skill, Class<? extends Capacity>*)}`.
is supported by `[:setskillifabsfctfull]{[:setskillifabsfct](setSkillIfAbsent)(Skill, Class<? extends Capacity>*)}`.

[:Success:]
package io.sarl.docs.reference.ar
Expand Down
Expand Up @@ -34,7 +34,6 @@ Therefore, it is actually created on top of the other built-in capacities.
"[:getdefaultaddress](getDefaultAddress) : io.sarl.lang.core.Address",
"[:emit](emit)(io.sarl.lang.core.Event)",
"emit(io.sarl.lang.core.Event, io.sarl.lang.core.Scope)",
"[:willreceive](willReceive)(java.util.UUID, io.sarl.lang.core.Event)",
"[:isdefaultcontext](isDefaultContext)(io.sarl.lang.core.AgentContext) : boolean",
"isDefaultContext(java.util.UUID) : boolean",
"[:isdefaultspace](isDefaultSpace)(io.sarl.lang.core.Space) : boolean",
Expand Down Expand Up @@ -264,45 +263,6 @@ In the previous code, the receiver of the event is given by the formal parameter
The scope restricts the receiver according to this identifier.


For an abstract point of view, the previous emitting call may be explained with "the event is emitted to the receiver".
Sometimes, the developer would like to write a code that corresponds to the sentence "the receiver will receive the event".
In order to enable this approach to the developer, the SARL API provides the function:

[:Success:]
package io.sarl.docs.reference.bic
import io.sarl.lang.core.Event
import io.sarl.lang.core.Scope
import io.sarl.lang.core.Address
import java.util.UUID
interface Tmp {
def [:emit!](e : Event, scope : Scope<Address>)
[:On]
def [:willreceive!]([:receiverid!] : UUID, ^event : Event) {
emit(^event) [ it.UUID == [:receiverid!] ]
}
[:Off]
}
[:End:]

The initial example in this section becomes:

[:Success:]
package io.sarl.docs.reference.bic
import io.sarl.core.DefaultContextInteractions
import io.sarl.lang.core.Event
import java.util.UUID
event MyEvent
[:On]
agent A {
uses DefaultContextInteractions
def myaction([:receiverid](receiverId) : UUID) {
var ^event : Event = new MyEvent
[:receiverid!].willReceive(^event)
}
}
[:End:]



## Testing if an element is related to the default context
Expand Down
Expand Up @@ -9,11 +9,11 @@ the inner context, as well as the `killMe` action to stop the execution of an ag
documented -->
[:Fact:]{typeof(io.sarl.core.[:lifecyclecap!]).shouldHaveMethods(
"[:fctkillme](killMe)",
"[:fctspawn](spawn)(java.lang.Class, java.lang.Object[]) : java.util.UUID",
"spawn(int, java.lang.Class, java.lang.Object[]) : java.lang.Iterable",
"[:fctspawnincontext](spawnInContext)(java.lang.Class, io.sarl.lang.core.AgentContext, java.lang.Object[]) : java.util.UUID",
"spawnInContext(int, java.lang.Class, io.sarl.lang.core.AgentContext, java.lang.Object[]) : java.lang.Iterable",
"spawnInContextWithID(java.lang.Class, java.util.UUID, io.sarl.lang.core.AgentContext, java.lang.Object[]) : java.util.UUID")
"[:fctspawn](spawn)(java.lang.Class, java.lang.Object[])",
"spawn(int, java.lang.Class, java.lang.Object[])",
"[:fctspawnincontext](spawnInContext)(java.lang.Class, io.sarl.lang.core.AgentContext, java.lang.Object[])",
"spawnInContext(int, java.lang.Class, io.sarl.lang.core.AgentContext, java.lang.Object[])",
"spawnInContextWithID(java.lang.Class, java.util.UUID, io.sarl.lang.core.AgentContext, java.lang.Object[])")
}


Expand Down Expand Up @@ -72,20 +72,18 @@ functions are provided for this task:
[:Success:]
package io.sarl.docs.reference.bic
import io.sarl.lang.core.Agent
import java.util.UUID
interface Tmp {
[:On]
def [:fctspawn!](agentType : Class<? extends Agent>, [:parameters](parameters) : Object*) : UUID
def [:fctspawn!]([:nbagents](nbAgents): int, agentType : Class<? extends Agent>, [:parameters!] : Object*) : Iterable<UUID>
def [:fctspawn!](agentType : Class<? extends Agent>, [:parameters](parameters) : Object*)
def [:fctspawn!]([:nbagents](nbAgents): int, agentType : Class<? extends Agent>, [:parameters!] : Object*)
[:Off]
}
[:End:]

This action creates one to [:nbagents:] instance(s) of the given agent type, and launches the agent(s)
into the default context.
The first [:fctspawn:] function above is spawning a single agent and replies the identifier of the spawned agent.
The second [:fctspawn:] function is spawning the given number of agents and replies the identifiers of the
spawned agents.
The first [:fctspawn:] function above is spawning a single agent.
The second [:fctspawn:] function is spawning the given number of agents.
The [:parameters:] are passed to the spawned agent inside the [:initializeevent:] event: the [:parameters:] field.

[:Fact:]{typeof(io.sarl.core.Initialize).shouldHaveField("parameters : java.lang.Object[]")}
Expand All @@ -104,21 +102,18 @@ Example:
package io.sarl.docs.reference.bic
import io.sarl.core.Lifecycle
import io.sarl.lang.core.Agent
import java.util.UUID
[:On]
agent A {
uses Lifecycle
def myaction {
var aid : UUID
var listaid : Iterable<UUID>
var type : Class<? extends Agent>
var p1 : Object
var p2 : Object
type = typeof(A)
p1 = new Object
p2 = new Object
aid = spawn(type, p1, p2)
listaid = spawn(5, type, p1, p2)
spawn(type, p1, p2)
spawn(5, type, p1, p2)
}
}
[:End:]
Expand All @@ -133,26 +128,24 @@ could be used for launching the agents:
package io.sarl.docs.reference.bic
import io.sarl.lang.core.Agent
import io.sarl.lang.core.AgentContext
import java.util.UUID
interface Tmp {
[:On]
def [:fctspawnincontext!](agentType : Class<? extends Agent>,
[:agentcontext](context) : AgentContext,
[:parameters!] : Object*) : UUID
[:parameters!] : Object*)
def [:fctspawnincontext!]([:nbagents!] : int,
agentType : Class<? extends Agent>,
context : AgentContext,
[:parameters!] : Object*) : Iterable<UUID>
[:parameters!] : Object*)
[:Off]
}
[:End:]


This action creates one to [:nbagents:] instance(s) of the given agent type, and launches the agent(s)
into the given [:agentcontext:].
The first [:fctspawn:] function is spawning a single agent and replies the identifier of the spawned agent.
The second [:fctspawn:] function is spawning the given number of agents and replies the identifiers of the
spawned agents.
The first [:fctspawn:] function is spawning a single agent.
The second [:fctspawn:] function is spawning the given number of agents.
The [:parameters:] are passed to the spawned agent inside the [:initializeevent:] event: the
[:parameters:] field.

Expand All @@ -168,22 +161,19 @@ Example:
import io.sarl.core.Lifecycle
import io.sarl.lang.core.AgentContext
import io.sarl.lang.core.Agent
import java.util.UUID
[:On]
agent A {
uses Lifecycle
def myaction {
var c : AgentContext
var aid : UUID
var listaid : Iterable<UUID>
var type : Class<? extends Agent>
var p1 : Object
var p2 : Object
type = typeof(A)
p1 = new Object
p2 = new Object
aid = spawnInContext(type, c, p1, p2)
listaid = spawnInContext(5, type, c, p1, p2)
spawnInContext(type, c, p1, p2)
spawnInContext(5, type, c, p1, p2)
}
}
[:End:]
Expand All @@ -204,7 +194,7 @@ with a given identifier in a specific context:
def spawnInContextWithID(agentType : Class<? extends Agent>,
agentId : UUID,
[:agentcontext!] : AgentContext,
[:parameters!] : Object*) : UUID
[:parameters!] : Object*)
[:Off]
}
[:End:]
Expand Down Expand Up @@ -238,7 +228,7 @@ Example:
type = typeof(A)
p1 = new Object
p2 = new Object
aid = spawnInContextWithID(type, aid, c, #[p1, p2])
spawnInContextWithID(type, aid, c, #[p1, p2])
}
}
[:End:]
Expand Down

0 comments on commit 93bbbd9

Please sign in to comment.