diff --git a/dev/Fjage.html b/dev/Fjage.html index 4d5434a..cea66db 100644 --- a/dev/Fjage.html +++ b/dev/Fjage.html @@ -1,2 +1,2 @@ -Fjage · Fjage.jl

Fjage

Fjage.FjageModule

Julia-fjåge gateway, standalone container, and slave container.

Notes:

  • This implementation is not thread-safe.
source
Fjage.default_timeoutMethod
default_timeout(millis)

Set default timeout for requests. This timeout is used when not explicitly specified. The timeout is given in milliseconds.

source
+Fjage · Fjage.jl

Fjage

Fjage.FjageModule

Julia-fjåge gateway, standalone container, and slave container.

Notes:

  • This implementation is not thread-safe.
source
Fjage.default_timeoutMethod
default_timeout(millis)

Set default timeout for requests. This timeout is used when not explicitly specified. The timeout is given in milliseconds.

source
diff --git a/dev/aid.html b/dev/aid.html index 1d09a44..24a2d2a 100644 --- a/dev/aid.html +++ b/dev/aid.html @@ -1,4 +1,4 @@ -AgentIDs · Fjage.jl

AgentIDs

API

Fjage.AgentIDType
aid = AgentID(name[, istopic])
+AgentIDs · Fjage.jl

AgentIDs

API

Fjage.AgentIDType
aid = AgentID(name[, istopic])
 aid = AgentID(name[, owner])
-aid = AgentID(name[, istopic[, owner]])

Create an AgentID, optionally with an owner.

source
Base.:<<Method
rsp = aid << msg

Send a request via the gateway to the specified agent, and wait for a response.

source
Fjage.requestFunction
rsp = request(aid, msg[, timeout])

Send a request via the gateway to the specified agent, and wait for a response. The response is returned. The agentID (aid) specified must be an "owned" agentID obtained from the agent(gw, name) function or returned by the agentforservice(gw, service) function. The timeout is specified in milliseconds, and defaults to 1 second if unspecified.

source
Fjage.sendMethod
send(aid, msg)

Send a message via the gateway to the specified agent. The agentID (aid) specified must be an "owned" agentID obtained from the agent(gw, name) function or returned by the agentforservice(gw, service) function.

source
Fjage.topicMethod
aid = topic([owner,] name[, subtopic])

Creates an AgentID for a named topic, optionally owned by an owner. AgentIDs that are associated with gateways/agents can be used directly in send() and request() calls.

source
+aid = AgentID(name[, istopic[, owner]])

Create an AgentID, optionally with an owner.

source
Base.:<<Method
rsp = aid << msg

Send a request via the gateway to the specified agent, and wait for a response.

source
Fjage.requestFunction
rsp = request(aid, msg[, timeout])

Send a request via the gateway to the specified agent, and wait for a response. The response is returned. The agentID (aid) specified must be an "owned" agentID obtained from the agent(gw, name) function or returned by the agentforservice(gw, service) function. The timeout is specified in milliseconds, and defaults to 1 second if unspecified.

source
Fjage.sendMethod
send(aid, msg)

Send a message via the gateway to the specified agent. The agentID (aid) specified must be an "owned" agentID obtained from the agent(gw, name) function or returned by the agentforservice(gw, service) function.

source
Fjage.topicMethod
aid = topic([owner,] name[, subtopic])

Creates an AgentID for a named topic, optionally owned by an owner. AgentIDs that are associated with gateways/agents can be used directly in send() and request() calls.

source
diff --git a/dev/const.html b/dev/const.html index b47761f..5638961 100644 --- a/dev/const.html +++ b/dev/const.html @@ -1,2 +1,2 @@ -Constants · Fjage.jl
+Constants · Fjage.jl
diff --git a/dev/container.html b/dev/container.html index f14dcf4..1392365 100644 --- a/dev/container.html +++ b/dev/container.html @@ -19,9 +19,9 @@ # when you've had enough, shutdown the container sleep(30) -shutdown(c)

More examples are available in the examples folder for reference.

Agent, Behaviors & Container API

Fjage.AgentIDMethod
AgentID(a::Agent)

Get the AgentID of the agent.

source
Fjage.ContainerType
Container()
+shutdown(c)

More examples are available in the examples folder for reference.

Agent, Behaviors & Container API

Fjage.ContainerType
Container()
 Container(platform::Platform)
-Container(platform::Platform, name)

Create a standalone container running on a real-time platform (if unspecified). If a name is not specified, a unique name is randomly generated.

source
Fjage.CyclicBehaviorMethod
CyclicBehavior(action)

Create a cyclic behavior that runs repeatedly at the earliest available opportunity. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

The running of cyclic behaviors may be controlled using block(b), restart(b) and stop(b).

Examples:

using Fjage
+Container(platform::Platform, name)

Create a standalone container running on a real-time platform (if unspecified). If a name is not specified, a unique name is randomly generated.

source
Fjage.CyclicBehaviorMethod
CyclicBehavior(action)

Create a cyclic behavior that runs repeatedly at the earliest available opportunity. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

The running of cyclic behaviors may be controlled using block(b), restart(b) and stop(b).

Examples:

using Fjage
 
 @agent struct MyAgent end
 
@@ -29,7 +29,7 @@
   add(a, CyclicBehavior() do a, b
     @info "CyclicBehavior running..."
   end)
-end
source
Fjage.MessageBehaviorMethod
MessageBehavior(action, millis)
 MessageBehavior(action, filt, millis)

Create a behavior that runs every time a message arrives. The action(a::Agent, b::Behavior, msg) function is called when a message arrives. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

If a filter filt is specified, only messages matching the filter trigger this behavior. A filter may be a message class or a function that takes the message as an argument and returns true to accept, false to reject.

If multiple MessageBehavior that match a message are active, only one of them will receive the message. The behavior to receive is the message is chosen based on its priority field. Messages with filters are given higher default priority than ones without filters.

The default init() for an agent automatically adds a MessageBehavior to dispatch messages to a processrequest() or processmessage() method. An agent may therefore process messages by providing methods for those functions. However, if an agent provides its own init() method, it should use MessageBehavior to handle incoming messages.

Examples:

using Fjage
 
 const MySpecialNtf = MessageClass(@__MODULE__, "MySpecialNtf")
@@ -43,7 +43,7 @@
   add(a, MessageBehavior() do a, b, msg
     @info "Got a not-so-special message: $msg"
   end)
-end
source
Fjage.OneShotBehaviorMethod
OneShotBehavior(action)

Create a one-shot behavior that runs exactly once at the earliest available opportunity. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

Examples:

using Fjage
+end
source
Fjage.OneShotBehaviorMethod
OneShotBehavior(action)

Create a one-shot behavior that runs exactly once at the earliest available opportunity. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

Examples:

using Fjage
 
 @agent struct MyAgent end
 
@@ -51,7 +51,7 @@
   add(a, OneShotBehavior() do a, b
     @info "OneShotBehavior just ran"
   end)
-end
source
Fjage.PoissonBehaviorMethod
PoissonBehavior(action, millis)

Create a behavior that runs randomly, on an averge once every millis milliseconds. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

Examples:

using Fjage
+end
source
Fjage.PoissonBehaviorMethod
PoissonBehavior(action, millis)

Create a behavior that runs randomly, on an averge once every millis milliseconds. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

Examples:

using Fjage
 
 @agent struct MyAgent end
 
@@ -59,10 +59,10 @@
   add(a, PoissonBehavior(5000) do a, b
     @info "PoissonBehavior ran!"
   end)
-end
source
Fjage.SlaveContainerMethod
SlaveContainer(host, port)
 SlaveContainer(host, port, name)
 SlaveContainer(platform::Platform, host, port)
-SlaveContainer(platform::Platform, host, port, name)

Create a slave container running on a real-time platform (if unspecified), optionally with a specified name. If a name is not specified, a unique name is randomly generated.

source
Fjage.TickerBehaviorMethod
TickerBehavior(action, millis)

Create a behavior that runs periodically every millis milliseconds. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

Examples:

using Fjage
+SlaveContainer(platform::Platform, host, port, name)

Create a slave container running on a real-time platform (if unspecified), optionally with a specified name. If a name is not specified, a unique name is randomly generated.

source
Fjage.TickerBehaviorMethod
TickerBehavior(action, millis)

Create a behavior that runs periodically every millis milliseconds. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

Examples:

using Fjage
 
 @agent struct MyAgent end
 
@@ -70,7 +70,7 @@
   add(a, TickerBehavior(5000) do a, b
     @info "Tick!"
   end)
-end
source
Fjage.WakerBehaviorMethod
WakerBehavior(action, millis)

Create a behavior that runs exactly once after millis milliseconds. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

Examples:

using Fjage
+end
source
Fjage.WakerBehaviorMethod
WakerBehavior(action, millis)

Create a behavior that runs exactly once after millis milliseconds. The action(a::Agent, b::Behavior) function is called when the behavior runs. The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

Examples:

using Fjage
 
 @agent struct MyAgent end
 
@@ -78,9 +78,9 @@
   add(a, WakerBehavior(5000) do a, b
     @info "Awake after 5 seconds!"
   end)
-end
source
Base.killMethod
kill(container::Container, aid::AgentID)
 kill(container::Container, name::String)
-kill(container::Container, agent::Agent)

Stop an agent running in a container.

source
Base.waitMethod
wait(platform::Platform)

Wait for platform to finish running. Blocks until all containers running on the platform have shutdown.

source
Fjage.BackoffBehaviorMethod
BackoffBehavior(action, millis)

Create a behavior that runs after millis milliseconds. The action(a::Agent, b::Behavior) function is called when the behavior runs. The behavior may be scheduled to re-run in t milliseconds by calling backoff(b, t).

The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

The BackoffBehavior constructor is simply syntactic sugar for a WakerBehavior that is intended to be rescheduled often using backoff().

Examples:

using Fjage
+kill(container::Container, agent::Agent)

Stop an agent running in a container.

source
Base.waitMethod
wait(platform::Platform)

Wait for platform to finish running. Blocks until all containers running on the platform have shutdown.

source
Fjage.BackoffBehaviorMethod
BackoffBehavior(action, millis)

Create a behavior that runs after millis milliseconds. The action(a::Agent, b::Behavior) function is called when the behavior runs. The behavior may be scheduled to re-run in t milliseconds by calling backoff(b, t).

The onstart and onend fields in the behavior may be set to functions that are called when the behavior is initialized and terminates. Both functions are called with similar parameters as action.

The BackoffBehavior constructor is simply syntactic sugar for a WakerBehavior that is intended to be rescheduled often using backoff().

Examples:

using Fjage
 
 @agent struct MyAgent end
 
@@ -91,7 +91,7 @@
     @info "Backoff!"
     backoff(b, 2000)
   end)
-end
source
Fjage.ParameterMessageBehaviorMethod
ParameterMessageBehavior()

ParameterMessageBehavior simplifies the task of an agent wishing to support parameters via ParameterReq and ParameterRsp messages. An agent providing parameters can advertise its parameters by providing an implementation for the params(a) method (or params(a, ndx) method for indexed parameters). The method returns a list of name-symbol pairs. Each entry represents a parameter with the specified name, and dispatched using the specified symbol. Get and set requests for the parameter are dispatched to get(a, Val(symbol)) and set(a, Val(symbol), value) methods (or get(a, Val(symbol), ndx) and set(a, Val(symbol), ndx, value) for indexed parameters). If the method isn't defined, and an agent struct field with the same name is present, it is used to back the parameter.

Setters should return the value that is set, so that it can be sent back to the requesting agent. If a setter returns nothing, the actual value is fetched using the getter and then sent to the requesting agent.

An agent may choose to avoid advertising specific parameters by defining isunlisted(Val(symbol)) method for the parameter to return true. Similarly, an agent may choose to mark a parameter as read-only by defining the isreadonly(Val(symbol)) method for the parameter to return true.

Parameter change events may be captured by defining a onparamchange(a::Agent, b::Behavior, param, ndx, value) method for the parameter.

The default init() for an agent automatically adds a ParameterMessageBehavior to dispatch handle parameters for an agent, and so an agent can benefit from this behavior without explicitly adding it. If an agent provides its own init() method and wishes to support parameters, it should add this behavior during init().

Examples:

using Fjage
+end
source
Fjage.ParameterMessageBehaviorMethod
ParameterMessageBehavior()

ParameterMessageBehavior simplifies the task of an agent wishing to support parameters via ParameterReq and ParameterRsp messages. An agent providing parameters can advertise its parameters by providing an implementation for the params(a) method (or params(a, ndx) method for indexed parameters). The method returns a list of name-symbol pairs. Each entry represents a parameter with the specified name, and dispatched using the specified symbol. Get and set requests for the parameter are dispatched to get(a, Val(symbol)) and set(a, Val(symbol), value) methods (or get(a, Val(symbol), ndx) and set(a, Val(symbol), ndx, value) for indexed parameters). If the method isn't defined, and an agent struct field with the same name is present, it is used to back the parameter.

Setters should return the value that is set, so that it can be sent back to the requesting agent. If a setter returns nothing, the actual value is fetched using the getter and then sent to the requesting agent.

An agent may choose to avoid advertising specific parameters by defining isunlisted(Val(symbol)) method for the parameter to return true. Similarly, an agent may choose to mark a parameter as read-only by defining the isreadonly(Val(symbol)) method for the parameter to return true.

Parameter change events may be captured by defining a onparamchange(a::Agent, b::Behavior, param, ndx, value) method for the parameter.

The default init() for an agent automatically adds a ParameterMessageBehavior to dispatch handle parameters for an agent, and so an agent can benefit from this behavior without explicitly adding it. If an agent provides its own init() method and wishes to support parameters, it should add this behavior during init().

Examples:

using Fjage
 
 @agent struct MyAgent
   param1::Int = 1
@@ -113,20 +113,20 @@
 
 Fjage.get(a::MyAgent, ::Val{:X}) = a.x
 Fjage.set(a::MyAgent, ::Val{:X}, value) = (a.x = clamp(value, 0, 10))
-Fjage.get(a::MyAgent, ::Val{:Y}) = a.x + 27
source
Fjage.actionFunction
action(b::Behavior)

The action function for a behavior is repeatedly called when a behavior runs. Typically, each type of Behavior provides an action method that implements its intended behavior.

source
Fjage.addMethod
add(a::Agent, b::Behavior)

Add a behavior to an agent.

source
Fjage.addMethod
add(container::Container, agent)
-add(container::Container, name, agent)

Run an agent in a container. If the name is not specified, a unique name is randomly generated.

source
Fjage.addMethod
add(platform::Platform, container::Container)

Run a container on a platform.

source
Fjage.addlistenerMethod
addlistener(container::Container, listener)

Add message listener to container. Unimplemented.

source
Fjage.agentMethod
agent(a::Agent, name::String)

Generate an owned AgentID for an agent with the given name.

source
Fjage.agentMethod
agent(container::Container, aid::AgentID)
-agent(container::Container, name::String)

Get the agent ID of an agent specified by name or its agent ID.

source
Fjage.agentforserviceMethod
agentforservice(a::Agent, svc::String)

Find an agent providing a specified service. Returns an owned AgentID for the service provider, if one is found, nothing otherwise.

source
Fjage.agentforserviceMethod
agentforservice(c::Container, svc::String, owner::Agent)

Lookup any agent providing the service svc, and return an AgentID owned by owner. Returns nothing if no agent providing specified service found.

source
Fjage.agentsMethod
agents(container::Container)

Get list of agents running in the container.

source
Fjage.agentsforserviceMethod
agentsforservice(a::Agent, svc::String)

Get a list of agents providing a specified service. Returns a list of owned AgentID for the service providers. The list may be empty if no service providers are found.

source
Fjage.agentsforserviceMethod
agentsforservice(c::Container, svc::String, owner::Agent)

Lookup all agents providing the service svc, and return list of AgentID owned by owner. Returns an empty list if no agent providing specified service found.

source
Fjage.autoclone!Method
autoclone!(container::Container, b)

Configure container to automatically clone (or not clone) messages on send. Currently auto-cloning is unimplemented, and so b can only be false.

source
Fjage.autocloneMethod
autoclone(container::Container)

Check if the container is configured to automatically clone messages on send.

source
Fjage.backoffMethod
backoff(b::WakerBehavior, millis)

Schedule the behavior to re-run in millis milliseconds.

source
Fjage.blockMethod
block(b::Behavior)
-block(b::Behavior, millis)

Marks a behavior as blocked, and prevents it from running until it is restarted using restart(b). If millis is specified, the behavior is automatically restarted after millis milliseconds.

source
Fjage.canlocateagentMethod
canlocateagent(container::Container, aid::AgentID)
-canlocateagent(container::Container, name::String)

Check if an agent is running in the container, or in any of the remote containers.

source
Fjage.containersMethod
containers(platform::Platform)

Get list of containers running on the platform.

source
Fjage.containsagentMethod
containsagent(container::Container, aid::AgentID)
-containsagent(container::Container, name::String)

Check if an agent is running in the container.

source
Fjage.delayMethod
delay(a::Agent, millis)

Delay the execution of the agent by millis milliseconds.

source
Fjage.delayMethod
delay(platform::Platform, millis)

Sleep for millis ms on the platform.

source
Fjage.deregisterMethod
deregister(a::Agent, svc::String)

Deregister agent from providing a specied service.

source
Fjage.deregisterMethod
deregister(c::Container, aid::AgentID, svc::String)

Deregister agent aid from providing service svc.

source
Fjage.deregisterMethod
deregister(c::Container, aid::AgentID)

Deregister agent aid from providing any services.

source
Fjage.initMethod
init(a::Agent)

Initialization function for an agent. The default implementation calls setup(a), and adds a ParameterMessageBehavior to support agent parameters, a MessageBehavior that calls processrequest(a, msg) for REQUEST messages or processmessage(a, msg) for all other messages, and a OneShotBehavior that calls startup(a) once the agent is running. An agent may provide a method if these default behaviors are desired.

Examples:

using Fjage
+Fjage.get(a::MyAgent, ::Val{:Y}) = a.x + 27
source
Fjage.actionFunction
action(b::Behavior)

The action function for a behavior is repeatedly called when a behavior runs. Typically, each type of Behavior provides an action method that implements its intended behavior.

source
Fjage.addMethod
add(a::Agent, b::Behavior)

Add a behavior to an agent.

source
Fjage.addMethod
add(container::Container, agent)
+add(container::Container, name, agent)

Run an agent in a container. If the name is not specified, a unique name is randomly generated.

source
Fjage.addMethod
add(platform::Platform, container::Container)

Run a container on a platform.

source
Fjage.addlistenerMethod
addlistener(container::Container, listener)

Add message listener to container. Unimplemented.

source
Fjage.agentMethod
agent(a::Agent, name::String)

Generate an owned AgentID for an agent with the given name.

source
Fjage.agentMethod
agent(container::Container, aid::AgentID)
+agent(container::Container, name::String)

Get the agent ID of an agent specified by name or its agent ID.

source
Fjage.agentforserviceMethod
agentforservice(a::Agent, svc::String)

Find an agent providing a specified service. Returns an owned AgentID for the service provider, if one is found, nothing otherwise.

source
Fjage.agentforserviceMethod
agentforservice(c::Container, svc::String, owner::Agent)

Lookup any agent providing the service svc, and return an AgentID owned by owner. Returns nothing if no agent providing specified service found.

source
Fjage.agentsMethod
agents(container::Container)

Get list of agents running in the container.

source
Fjage.agentsforserviceMethod
agentsforservice(a::Agent, svc::String)

Get a list of agents providing a specified service. Returns a list of owned AgentID for the service providers. The list may be empty if no service providers are found.

source
Fjage.agentsforserviceMethod
agentsforservice(c::Container, svc::String, owner::Agent)

Lookup all agents providing the service svc, and return list of AgentID owned by owner. Returns an empty list if no agent providing specified service found.

source
Fjage.autoclone!Method
autoclone!(container::Container, b)

Configure container to automatically clone (or not clone) messages on send. Currently auto-cloning is unimplemented, and so b can only be false.

source
Fjage.autocloneMethod
autoclone(container::Container)

Check if the container is configured to automatically clone messages on send.

source
Fjage.backoffMethod
backoff(b::WakerBehavior, millis)

Schedule the behavior to re-run in millis milliseconds.

source
Fjage.blockMethod
block(b::Behavior)
+block(b::Behavior, millis)

Marks a behavior as blocked, and prevents it from running until it is restarted using restart(b). If millis is specified, the behavior is automatically restarted after millis milliseconds.

source
Fjage.canlocateagentMethod
canlocateagent(container::Container, aid::AgentID)
+canlocateagent(container::Container, name::String)

Check if an agent is running in the container, or in any of the remote containers.

source
Fjage.containersMethod
containers(platform::Platform)

Get list of containers running on the platform.

source
Fjage.containsagentMethod
containsagent(container::Container, aid::AgentID)
+containsagent(container::Container, name::String)

Check if an agent is running in the container.

source
Fjage.delayMethod
delay(a::Agent, millis)

Delay the execution of the agent by millis milliseconds.

source
Fjage.delayMethod
delay(platform::Platform, millis)

Sleep for millis ms on the platform.

source
Fjage.deregisterMethod
deregister(a::Agent, svc::String)

Deregister agent from providing a specied service.

source
Fjage.deregisterMethod
deregister(c::Container, aid::AgentID, svc::String)

Deregister agent aid from providing service svc.

source
Fjage.deregisterMethod
deregister(c::Container, aid::AgentID)

Deregister agent aid from providing any services.

source
Fjage.initMethod
init(a::Agent)

Initialization function for an agent. The default implementation calls setup(a), and adds a ParameterMessageBehavior to support agent parameters, a MessageBehavior that calls processrequest(a, msg) for REQUEST messages or processmessage(a, msg) for all other messages, and a OneShotBehavior that calls startup(a) once the agent is running. An agent may provide a method if these default behaviors are desired.

Examples:

using Fjage
 
 @agent struct MyBareAgent end
 
 function Fjage.init(a::MyBareAgent)
   @info "MyBareAgent init"
-end
source
Fjage.isidleMethod
isidle(container::Container)

Check if container is idle. Unimplemented. Currently always returns true.

source
Fjage.isidleMethod
isidle(platform::Platform)

Check if platform is idle. Unimplemented. Currently always returns true.

source
Fjage.logerrorFunction
logerror(f::Function)
-logerror(f::Function, src)

Run function f() and log any errors that occur.

source
Fjage.loglevel!Method
loglevel!(level)

Set log level. Supported levels include :debug, :info, :warn, :error, :none. The equivalent Julia Logging.Debug, Logging.Info, etc levels may also be used.

source
Fjage.nanotimeMethod
nanotime(platform::Platform)

Get current time in nanoseconds for the platform.

source
Fjage.platformMethod
platform(a::Agent)

Get platform on which the agent's container is running.

source
Fjage.platformMethod
platform(container::Container)

Get platform on which the container is running.

source
Fjage.platformsendMethod
platformsend(a::Agent, msg::Message)

Send a message to agents running on all containers on a platform. Currently unimplemented.

source
Fjage.processmessageMethod
processmessage(a::Agent, msg)

Unless an agent overrides its init(a) function, the default behavior for an agent is to add a MessageBehavior that calls processmessage(a, msg) when it receives any message (with the exception of messages with performative REQUEST, for which processrequest(a, msg) is called instead). An agent may provide methods to handle specific messages.

Examples:

using Fjage
+end
source
Fjage.isidleMethod
isidle(container::Container)

Check if container is idle. Unimplemented. Currently always returns true.

source
Fjage.isidleMethod
isidle(platform::Platform)

Check if platform is idle. Unimplemented. Currently always returns true.

source
Fjage.logerrorFunction
logerror(f::Function)
+logerror(f::Function, src)

Run function f() and log any errors that occur.

source
Fjage.loglevel!Method
loglevel!(level)

Set log level. Supported levels include :debug, :info, :warn, :error, :none. The equivalent Julia Logging.Debug, Logging.Info, etc levels may also be used.

source
Fjage.nanotimeMethod
nanotime(platform::Platform)

Get current time in nanoseconds for the platform.

source
Fjage.platformMethod
platform(a::Agent)

Get platform on which the agent's container is running.

source
Fjage.platformMethod
platform(container::Container)

Get platform on which the container is running.

source
Fjage.platformsendMethod
platformsend(a::Agent, msg::Message)

Send a message to agents running on all containers on a platform. Currently unimplemented.

source
Fjage.processmessageMethod
processmessage(a::Agent, msg)

Unless an agent overrides its init(a) function, the default behavior for an agent is to add a MessageBehavior that calls processmessage(a, msg) when it receives any message (with the exception of messages with performative REQUEST, for which processrequest(a, msg) is called instead). An agent may provide methods to handle specific messages.

Examples:

using Fjage
 
 const MySpecialNtf = MessageClass(@__MODULE__, "MySpecialNtf")
 
@@ -134,7 +134,7 @@
 
 function Fjage.processmessage(a::MyAgent, msg::MySpecialNtf)
   # do something useful with the message here...
-end
source
Fjage.processrequestMethod
processrequest(a::Agent, req)

Unless an agent overrides its init(a) function, the default behavior for an agent is to add a MessageBehavior that calls processrequest(a, req) when it receives any message with a performative REQUEST. The return value of the function must be either nothing or a response message. If a response message is returned, it is sent. If nothing is returned, a default response with performative NOT_UNDERSTOOD is sent back. An agent may provide methods to handle specific messages. For unhandled requests, the default implementation just returns a nothing.

Examples:

using Fjage
+end
source
Fjage.processrequestMethod
processrequest(a::Agent, req)

Unless an agent overrides its init(a) function, the default behavior for an agent is to add a MessageBehavior that calls processrequest(a, req) when it receives any message with a performative REQUEST. The return value of the function must be either nothing or a response message. If a response message is returned, it is sent. If nothing is returned, a default response with performative NOT_UNDERSTOOD is sent back. An agent may provide methods to handle specific messages. For unhandled requests, the default implementation just returns a nothing.

Examples:

using Fjage
 
 const MySpecialReq = MessageClass(@__MODULE__, "MySpecialReq", nothing, Performative.REQUEST)
 
@@ -144,9 +144,9 @@
   # do something useful with the request here...
   # and return an AGREE response
   Message(req, Performative.AGREE)
-end
source
Fjage.psMethod
ps(c::Container)

Get a list of agents running in a container. The list contains tuples of agent name and agent type. The agent type may be an empty string for agents running in remote containers, if the containers do not support type query.

source
Fjage.queuesize!Method
queuesize!(a::Agent, n)

Set the incoming message queue size for an agent. Currently unimplemented.

source
Fjage.receiveFunction
receive(a::Agent, timeout::Int=0; priority)
-receive(a::Agent, filt, timeout::Int=0; priority)

Receive a message, optionally matching the specified filter. The call blocks for at most timeout milliseconds, if a message is not available. If multiple receive() calls are concurrently active, the priority determines which call gets the message. Only one of the active receive() calls will receive the message. Returns a message or nothing.

If a filter filt is specified, only messages matching the filter trigger this behavior. A filter may be a message class or a function that takes the message as an argument and returns true to accept, false to reject.

Lower priority numbers indicate a higher priority.

source
Fjage.registerMethod
register(a::Agent, svc::String)

Register agent as providing a specied service.

source
Fjage.registerMethod
register(c::Container, aid::AgentID, svc::String)

Register agent aid as providing service svc.

source
Fjage.requestFunction
request(a::Agent, msg::Message)
-request(a::Agent, msg::Message, timeout::Int)

Send a request and wait for a response. If a timeout is specified, the call blocks for at most timeout milliseconds. If no timeout is specified, a system default is used. Returns the response message or nothing if no response received.

source
Fjage.resetMethod
reset(b::Behavior)

Resets a behavior, removing it from an agent running it. Once a behavior is reset, it may be reused later by adding it to an agent.

source
Fjage.restartMethod
restart(b::Behavior)

Restart a blocked behavior, previous blocked by block(b).

source
Fjage.sendMethod
send(a::Agent, msg::Message)

Send a message from agent a.

source
Fjage.sendMethod
send(c::Container, msg)

Send message msg to recipient specified in the message. Return true if the message is accepted for delivery, false otherwise.

source
Fjage.servicesMethod
services(container::Container)

Get list of services running in the container.

source
Fjage.setupFunction
setup(a::Agent)

Unless an agent overrides its init(a) function, the default behavior for an agent is to call setup(a) during initialization, and startup(a) once the agent is running. Typically, the setup(a) function is used to register services, and the startup(a) function is used to lookup services from other agents. Behaviors may be added in either of the functions.

Examples:

using Fjage
+end
source
Fjage.psMethod
ps(c::Container)

Get a list of agents running in a container. The list contains tuples of agent name and agent type. The agent type may be an empty string for agents running in remote containers, if the containers do not support type query.

source
Fjage.queuesize!Method
queuesize!(a::Agent, n)

Set the incoming message queue size for an agent. Currently unimplemented.

source
Fjage.receiveFunction
receive(a::Agent, timeout::Int=0; priority)
+receive(a::Agent, filt, timeout::Int=0; priority)

Receive a message, optionally matching the specified filter. The call blocks for at most timeout milliseconds, if a message is not available. If multiple receive() calls are concurrently active, the priority determines which call gets the message. Only one of the active receive() calls will receive the message. Returns a message or nothing.

If a filter filt is specified, only messages matching the filter trigger this behavior. A filter may be a message class or a function that takes the message as an argument and returns true to accept, false to reject.

Lower priority numbers indicate a higher priority.

source
Fjage.registerMethod
register(a::Agent, svc::String)

Register agent as providing a specied service.

source
Fjage.registerMethod
register(c::Container, aid::AgentID, svc::String)

Register agent aid as providing service svc.

source
Fjage.requestFunction
request(a::Agent, msg::Message)
+request(a::Agent, msg::Message, timeout::Int)

Send a request and wait for a response. If a timeout is specified, the call blocks for at most timeout milliseconds. If no timeout is specified, a system default is used. Returns the response message or nothing if no response received.

source
Fjage.resetMethod
reset(b::Behavior)

Resets a behavior, removing it from an agent running it. Once a behavior is reset, it may be reused later by adding it to an agent.

source
Fjage.restartMethod
restart(b::Behavior)

Restart a blocked behavior, previous blocked by block(b).

source
Fjage.sendMethod
send(a::Agent, msg::Message)

Send a message from agent a.

source
Fjage.sendMethod
send(c::Container, msg)

Send message msg to recipient specified in the message. Return true if the message is accepted for delivery, false otherwise.

source
Fjage.servicesMethod
services(container::Container)

Get list of services running in the container.

source
Fjage.setupFunction
setup(a::Agent)

Unless an agent overrides its init(a) function, the default behavior for an agent is to call setup(a) during initialization, and startup(a) once the agent is running. Typically, the setup(a) function is used to register services, and the startup(a) function is used to lookup services from other agents. Behaviors may be added in either of the functions.

Examples:

using Fjage
 
 @agent struct MyAgent end
 
@@ -156,13 +156,13 @@
 
 function Fjage.startup(a::MyAgent)
   @info "MyAgent started"
-end
source
Fjage.shutdownMethod
shutdown(a::Agent)

This function is called when an agent terminates. An agent may provide a method to handle termination, if desired.

Examples:

using Fjage
+end
source
Fjage.shutdownMethod
shutdown(a::Agent)

This function is called when an agent terminates. An agent may provide a method to handle termination, if desired.

Examples:

using Fjage
 
 @agent struct MyAgent end
 
 function Fjage.shutdown(a::MyAgent)
   @info "MyAgent shutting down"
-end
source
Fjage.shutdownMethod
shutdown(platform::Platform)

Stop the platform and all containers running on the platform.

source
Fjage.shutdownMethod
shutdown(container::Container)

Stop a container and all agents running in it.

source
Fjage.startMethod
start(platform::Platform)

Start the platform and all containers running on the platform.

source
Fjage.startupFunction
setup(a::Agent)

Unless an agent overrides its init(a) function, the default behavior for an agent is to call setup(a) during initialization, and startup(a) once the agent is running. Typically, the setup(a) function is used to register services, and the startup(a) function is used to lookup services from other agents. Behaviors may be added in either of the functions.

Examples:

using Fjage
+end
source
Fjage.shutdownMethod
shutdown(platform::Platform)

Stop the platform and all containers running on the platform.

source
Fjage.shutdownMethod
shutdown(container::Container)

Stop a container and all agents running in it.

source
Fjage.startMethod
start(platform::Platform)

Start the platform and all containers running on the platform.

source
Fjage.startupFunction
setup(a::Agent)

Unless an agent overrides its init(a) function, the default behavior for an agent is to call setup(a) during initialization, and startup(a) once the agent is running. Typically, the setup(a) function is used to register services, and the startup(a) function is used to lookup services from other agents. Behaviors may be added in either of the functions.

Examples:

using Fjage
 
 @agent struct MyAgent end
 
@@ -172,7 +172,7 @@
 
 function Fjage.startup(a::MyAgent)
   @info "MyAgent started"
-end
source
Fjage.stateMethod
state(container::Container)

Get a human-readable state of the container.

source
Fjage.stateMethod
state(container::Container)

Get a human-readable state of the container.

source
Fjage.stopMethod
stop(a::Agent)
 stop(a::Agent, msg)

Terminates an agent, optionally with an error message to be logged, explaining the reason for termination.

Examples:

using Fjage
 
 @agent struct MyAgent
@@ -183,7 +183,7 @@
   a.criticalagent = agentforservice("CriticalService")
   a.criticalagent === nothing && return stop(a, "Could not find an agent providing CriticalService")
   @info "MyAgent up and running"
-end
source
Fjage.storeMethod
store(a::Agent)

Return the persistent data store for agent. Currently unimplemented.

source
Fjage.subscribeMethod
subscribe(c::Container, topic::AgentID, agent::Agent)

Subscribe agent running in container c to topic.

source
Fjage.tickcountMethod
tickcount(b::PoissonBehavior)

Get the number of times a PoissonBehavior has ticked (its action() has been called).

source
Fjage.tickcountMethod
tickcount(b::TickerBehavior)

Get the number of times a TickerBehavior has ticked (its action() has been called).

source
Fjage.unsubscribeMethod
unsubscribe(c::Container, agent::Agent)

Unsubscribe agent running in container c from all topics.

source
Fjage.unsubscribeMethod
unsubscribe(c::Container, topic::AgentID, agent::Agent)

Unsubscribe agent running in container c from topic.

source
Fjage.@agentMacro

The @agent macro is used to define a Fjage agent. The macro takes in a struct definition and converts it into an agent definition. The fields in the struct are treated as agent attributes. Fjage agent types are subtypes of Fjage.Agent and are mutable.

The struct definition may include initialization, as supported by the Base.@kwdef macro.

Examples:

using Fjage
+end
source
Fjage.storeMethod
store(a::Agent)

Return the persistent data store for agent. Currently unimplemented.

source
Fjage.subscribeMethod
subscribe(c::Container, topic::AgentID, agent::Agent)

Subscribe agent running in container c to topic.

source
Fjage.tickcountMethod
tickcount(b::PoissonBehavior)

Get the number of times a PoissonBehavior has ticked (its action() has been called).

source
Fjage.tickcountMethod
tickcount(b::TickerBehavior)

Get the number of times a TickerBehavior has ticked (its action() has been called).

source
Fjage.unsubscribeMethod
unsubscribe(c::Container, agent::Agent)

Unsubscribe agent running in container c from all topics.

source
Fjage.unsubscribeMethod
unsubscribe(c::Container, topic::AgentID, agent::Agent)

Unsubscribe agent running in container c from topic.

source
Fjage.@agentMacro

The @agent macro is used to define a Fjage agent. The macro takes in a struct definition and converts it into an agent definition. The fields in the struct are treated as agent attributes. Fjage agent types are subtypes of Fjage.Agent and are mutable.

The struct definition may include initialization, as supported by the Base.@kwdef macro.

Examples:

using Fjage
 
 @agent struct MyAgent
   field1::Int = 1
@@ -195,4 +195,4 @@
 @agent struct MySpecialAgent <: SpecialAgent
   agentnumber::Int = 007
   licensedtokill::Bool = true
-end
source
+endsource diff --git a/dev/gw.html b/dev/gw.html index 971ca9d..fba82ff 100644 --- a/dev/gw.html +++ b/dev/gw.html @@ -11,4 +11,4 @@ AGREE julia> shell << ShellExecReq(cmd="ps") AGREE -julia> close(gw)

For more information, see fjåge gateway API specifications.

Gateway API documentation

Fjage.GatewayType
gw = Gateway([name,] host, port)

Open a new TCP/IP gateway to communicate with fjåge agents from Julia.

source
Base.closeMethod

Close a gateway connection to the master container.

source
Base.flushMethod

Flush the incoming message queue.

source
Fjage.agentforserviceMethod

Find an agent that provides a named service.

source
Fjage.agentsforserviceMethod

Find all agents that provides a named service.

source
Fjage.nameMethod
name(gw)

Get the name of the gateway.

source
Fjage.receiveFunction
msg = receive(gw[, filter][, timeout])

Receive an incoming message from other agents or topics. Timeout is specified in milliseconds. If no timeout is specified, the call is non-blocking. If a negative timeout is specified, the call is blocking until a message is available.

If a filter is specified, only messages matching the filter are retrieved. A filter may be a message type, a message or a function. If it is a message type, only messages of that type or a subtype are retrieved. If it is a message, any message whose inReplyTo field is set to the msgID of the specified message is retrieved. If it is a function, it must take in a message and return true or false. A message for which it returns true is retrieved.

source
Fjage.requestFunction
rsp = request(gw, msg[, timeout])

Send a request via the gateway to the specified agent, and wait for a response. The response is returned. The recipient field of the request message (msg) must be populated with an agentID. The timeout is specified in milliseconds, and defaults to 1 second if unspecified.

source
Fjage.sendMethod
send(gw, msg)

Send a message via the gateway to the specified agent. The recipient field of the message must be populated with an agentID.

source
Fjage.subscribeMethod

Subscribe to receive all messages sent to the given topic.

source
Fjage.unsubscribeMethod

Unsubscribe from receiving messages sent to the given topic.

source
+julia> close(gw)

For more information, see fjåge gateway API specifications.

Gateway API documentation

Fjage.GatewayType
gw = Gateway([name,] host, port)

Open a new TCP/IP gateway to communicate with fjåge agents from Julia.

source
Base.closeMethod

Close a gateway connection to the master container.

source
Base.flushMethod

Flush the incoming message queue.

source
Fjage.agentforserviceMethod

Find an agent that provides a named service.

source
Fjage.agentsforserviceMethod

Find all agents that provides a named service.

source
Fjage.nameMethod
name(gw)

Get the name of the gateway.

source
Fjage.receiveFunction
msg = receive(gw[, filter][, timeout])

Receive an incoming message from other agents or topics. Timeout is specified in milliseconds. If no timeout is specified, the call is non-blocking. If a negative timeout is specified, the call is blocking until a message is available.

If a filter is specified, only messages matching the filter are retrieved. A filter may be a message type, a message or a function. If it is a message type, only messages of that type or a subtype are retrieved. If it is a message, any message whose inReplyTo field is set to the msgID of the specified message is retrieved. If it is a function, it must take in a message and return true or false. A message for which it returns true is retrieved.

source
Fjage.requestFunction
rsp = request(gw, msg[, timeout])

Send a request via the gateway to the specified agent, and wait for a response. The response is returned. The recipient field of the request message (msg) must be populated with an agentID. The timeout is specified in milliseconds, and defaults to 1 second if unspecified.

source
Fjage.sendMethod
send(gw, msg)

Send a message via the gateway to the specified agent. The recipient field of the message must be populated with an agentID.

source
Fjage.subscribeMethod

Subscribe to receive all messages sent to the given topic.

source
Fjage.unsubscribeMethod

Unsubscribe from receiving messages sent to the given topic.

source
diff --git a/dev/index.html b/dev/index.html index 850b0db..d2f47a4 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,3 +1,3 @@ Home · Fjage.jl

Fjage.jl

Framework for Julia, Java and Groovy agents

Introduction

fjåge provides a lightweight and easy-to-learn framework for agent-oriented software development in Java and Groovy. Fjage.jl is a Julia port of fjåge, which can be independently used, or used in conjunction with a Java/Groovy container in a multi-language application.

Key features

  • Lightweight and fast
  • Easy to learn, and rapid agent development cycle
  • Agent development in Julia, Java or Groovy
  • APIs for access from Java, Groovy, Python, C, Julia, and Javascript
  • JSON-based protocol to interface with external applications

Installation

In Julia REPL:

julia> # press "]" to enter package manager
-pkg> add Fjage

Useful reading

+pkg> add Fjage

Useful reading

diff --git a/dev/msg.html b/dev/msg.html index 497105e..08f2b95 100644 --- a/dev/msg.html +++ b/dev/msg.html @@ -55,22 +55,22 @@ "org.arl.fjage.demo.DynamicMessage" julia> msg isa GenericMessage -true

API

Fjage.GenericMessageType

Generic message type that can carry arbitrary name-value pairs as data.

source
Fjage.MessageType

Base class for messages transmitted by one agent to another.

source
Fjage.MessageType
msg = Message([perf])
-msg = Message(inreplyto[, perf])

Create a message with just a performative (perf) and no data. If the performative is not specified, it defaults to INFORM. If the inreplyto is specified, the message inReplyTo and recipient fields are set accordingly.

source
Fjage.ParameterReqType

Parameter request message.

source
Fjage.ParameterRspType

Parameter response message.

source
Base.get!Method
get!(p::ParameterReq, param)

Request parameter param to be fetched.

Examples

julia> p = ParameterReq(index=1)
+true

API

Fjage.MessageType
msg = Message([perf])
+msg = Message(inreplyto[, perf])

Create a message with just a performative (perf) and no data. If the performative is not specified, it defaults to INFORM. If the inreplyto is specified, the message inReplyTo and recipient fields are set accordingly.

source
Base.get!Method
get!(p::ParameterReq, param)

Request parameter param to be fetched.

Examples

julia> p = ParameterReq(index=1)
 ParameterReq[index=1]
 julia> get!(p, "modulation")
 ParameterReq[index=1 modulation=?]
 julia> get!(p, "fec")
-ParameterReq[index=1 modulation=? ...]
source
Base.getMethod
get(p::ParameterRsp, param)

Extract parameter param from a parameter response message.

source
Fjage.classnameFunction
classname(msg::Message)

Return the fully qualified class name of a message.

source
Fjage.registermessagesFunction
registermessages()
-registermessages(messageclasses)

Register message classes with Fjage. Usually message classes are automatically registered on creation with @message. However, when developing packages, if @message is used at the module level, the types may be precompiled and the code to register the classes may not get executed at runtime. In such cases, you may need to explicitly call registermessages() in the __init()__ function for the module.

source
Fjage.set!Method
set!(p::ParameterReq, param, value)

Request parameter param to be set to value.

Examples

julia> p = ParameterReq(index=1)
+ParameterReq[index=1 modulation=? ...]
source
Base.getMethod
get(p::ParameterRsp, param)

Extract parameter param from a parameter response message.

source
Fjage.classnameFunction
classname(msg::Message)

Return the fully qualified class name of a message.

source
Fjage.registermessagesFunction
registermessages()
+registermessages(messageclasses)

Register message classes with Fjage. Usually message classes are automatically registered on creation with @message. However, when developing packages, if @message is used at the module level, the types may be precompiled and the code to register the classes may not get executed at runtime. In such cases, you may need to explicitly call registermessages() in the __init()__ function for the module.

source
Fjage.set!Method
set!(p::ParameterReq, param, value)

Request parameter param to be set to value.

Examples

julia> p = ParameterReq(index=1)
 ParameterReq[index=1]
 julia> set!(p, "modulation", "ofdm")
 ParameterReq[index=1 modulation=ofdm]
 julia> set!(p, "fec", 1)
-ParameterReq[index=1 modulation=ofdm ...]
source
Fjage.@messageMacro
@message classname [performative] struct mtype [<: supertype]
+ParameterReq[index=1 modulation=ofdm ...]
source
Fjage.@messageMacro
@message classname [performative] struct mtype [<: supertype]
   fields...
 end

Create a message class from a fully qualified class name. If a performative is not specified, it is guessed based on the class name. For class names ending with "Req", the performative is assumed to be REQUEST, and for all other messages, INFORM.

Examples

julia> @message "org.arl.fjage.shell.MyShellExecReq" struct MyShellExecReq
          cmd::String
        end
 julia> req = MyShellExecReq(cmd="ps")
-MyShellExecReq:REQUEST[cmd:"ps"]
source
+MyShellExecReq:REQUEST[cmd:"ps"]source diff --git a/dev/search.html b/dev/search.html index c25b5ce..11f8945 100644 --- a/dev/search.html +++ b/dev/search.html @@ -1,2 +1,2 @@ -Search · Fjage.jl

Loading search...

    +Search · Fjage.jl

    Loading search...