Messages

Messages are dictionary-like containers that carry information between agents. Keys can be accessed on messages using the property notation (msg.key), and keys that are absent yield nothing. When interacting with Java/Groovy agents, messages are mapped to Java/Groovy message classes with fields with the same name as the keys in the message.

Message types are defined using the MessageClass function. For example:

const ShellExecReq = MessageClass(@__MODULE__, "org.arl.fjage.shell.ShellExecReq")

defines a ShellExecReq message type that maps to a Java class with the package org.arl.fjage.shell.ShellExecReq.

API

Fjage.GenericMessageType

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

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.

Fjage.MessageType

Base class for messages transmitted by one agent to another.

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=? ...]
Base.getMethod
get(p::ParameterRsp, param)

Extract parameter param from a parameter response message.

Fjage.MessageClassFunction
mtype = MessageClass(context, clazz[, superclass[, performative]])

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> MyShellExecReq = MessageClass(@__MODULE__, "org.arl.fjage.shell.ShellExecReq");
julia> req = MyShellExecReq(cmd="ps")
ShellExecReq: REQUEST [cmd:"ps"]
Fjage.registermessagesFunction
registermessages()
registermessages(messageclasses)

Register message classes with Fjage. Usually message classes are automatically registered on creation with MessageClass(). However, when developing packages, if MessageClass() 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()__ funciton for the module.

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 ...]