### start Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/connectors/WebServer.html Starts the WebServer. ```APIDOC ## start ### Description Starts the web server. ### Method `public void start()` ``` -------------------------------- ### Remove Quickstart Script Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/quickstart.md After setup, you can optionally remove the fjage_quickstart.sh script. ```sh rm fjage_quickstart.sh ``` -------------------------------- ### start Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Platform.html Starts all containers on the platform. ```APIDOC ## start ### Description Starts all containers on the platform. ### Method public void ``` -------------------------------- ### Initialize and Start RealTimePlatform Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/RealTimePlatform.html Demonstrates the typical usage of initializing a RealTimePlatform, creating a container, adding agents, and starting the platform. ```Java Platform platform = new RealTimePlatform(); Container container = new Container(platform); container.add("myAgent", new myAgent()); // add appropriate agents platform.start(); ``` -------------------------------- ### install Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/LogHandlerProxy.html Installs this handler for all handlers in the root logger. ```APIDOC ## install ### Description Installs this handler for all handlers in the root logger. ### Method static void ### Endpoint install([TimestampProvider](../../../org/arl/fjage/TimestampProvider.html "interface in org.arl.fjage") timesrc, java.util.logging.Logger log) ``` -------------------------------- ### install Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/LogFormatter.html Installs this formatter for all handlers in the specified logger. ```APIDOC ## install(Logger log) ### Description Installs this formatter for all handlers in the root logger. ### Method `static void install(Logger log)` ### Parameters #### Path Parameters * **log** (Logger) - logger to install on, null for root logger. ### Response #### Success Response (200) void ``` -------------------------------- ### start Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Container.html Starts the container and all agents within it. ```APIDOC ## start ### Description Starts the container and all agents in it. ### Method POST (assumed, as it initiates an action) ### Endpoint /container/start ``` -------------------------------- ### start Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/DiscreteEventSimulator.html Starts all containers on the platform. This method overrides the start method in the Platform class. ```APIDOC ## start ### Description Starts all containers on the platform. ### Method `public void start()` ### Method Signature `start()` ``` -------------------------------- ### Typical Usage of TestBehavior Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/TestBehavior.html Demonstrates the typical setup, execution, and tear down for using TestBehavior within an agent. This includes platform and container setup, agent addition, starting the platform, running the test behavior, and shutting down the platform. ```java // setup Platform platform = new RealtimePlatform(); Container container = new Container(platform); Agent agent = new Agent(); container.add(agent); platform.start(); // test TestBehavior test = new TestBehavior() { public void test() { : : } }; test.runOn(agent); // tear down platform.shutdown(); ``` -------------------------------- ### Fjage Interactive Shell Example Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/quickstart.md Start the Fjage interactive shell, list running agents, and shut down Fjage. ```console bash$ ./fjage.sh > ps shell > shutdown bash$ ``` -------------------------------- ### start Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/DiscreteEventSimulator.html Starts all containers on the platform. This method initiates the operation of the fjage platform. ```APIDOC ## start ### Description Starts all containers on the platform. ### Method `start()` ### Response #### Success Response `void` ``` -------------------------------- ### Install and Build Documentation Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/fjagepy.md Commands to install documentation dependencies and build the project's documentation locally using Sphinx. Includes instructions to view the built documentation in a browser. ```bash # Install documentation dependencies pip install -e ".[docs]" # Build docs sphinx-build -b html docs/ ../../docs/pydocs/ # View in browser open ../../docs/pydocs/index.html ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/org-arl/fjage/blob/master/gateways/python/README.md Installs the necessary dependencies for building the documentation for the fjagepy library. ```bash pip install -e ".[docs"] ``` -------------------------------- ### Generate Developer's Guide with Gradle Source: https://github.com/org-arl/fjage/blob/master/BUILD.md This command generates the developer's guide and related documentation in HTML format. The output will be located at `htdocs/doc/html/index.html`. ```bash gradle doc ``` -------------------------------- ### Simple Example Agent in Java Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Agent.html An example of a basic agent extending the Agent class. It overrides the init() method to log a startup message and add a MessageBehavior to handle incoming messages. ```Java import org.arl.fjage.*; public class MyAgent extends Agent { @Override public void init() { log.info("MyAgent is starting"); add(new MessageBehavior() { @Override public void onReceive(Message msg) { log.info("Got a message!"); // do things with the message } }); // add other behaviors } } ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/org-arl/fjage/blob/master/docs/pydocs/fjagepy.html Installs the necessary Python packages to build the documentation locally. This includes the documentation build tools. ```bash pip install -e ".[docs]" ``` -------------------------------- ### Install Twine for PyPI Publishing Source: https://github.com/org-arl/fjage/blob/master/BUILD.md Install the 'twine' package, a command-line utility for uploading Python packages to PyPI. ```bash pip install twine ``` -------------------------------- ### install Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/LogHandlerProxy.html Installs this LogHandlerProxy for all handlers in a specified logger, or the root logger if none is specified. This allows the handler to intercept and process log records. ```APIDOC ## install ### Description Installs this handler for all handlers in the root logger. ### Method `public static void install(TimestampProvider timesrc, java.util.logging.Logger log)` ### Parameters #### Path Parameters - `timesrc` (TimestampProvider) - TimestampProvider to use for timestamps. - `log` (java.util.logging.Logger) - logger to install on, null for root logger. ``` -------------------------------- ### Install fjagepy from PyPI Source: https://github.com/org-arl/fjage/blob/master/gateways/python/README.md Install the fjagepy library using pip. This is the recommended method for most users. ```bash pip install fjagepy ``` -------------------------------- ### Start Master Container Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/remote.md Initializes and starts a master fjåge container. Specify the port if needed; otherwise, a port is automatically chosen. ```groovy import org.arl.fjage.* import org.arl.fjage.remote.* platform = new RealTimePlatform() container = new MasterContainer(platform, name) println "Master container started on port ${container.port}" // add agents to the container here platform.start() ``` -------------------------------- ### Install Wheel for PyPI Publishing Source: https://github.com/org-arl/fjage/blob/master/BUILD.md Install the 'wheel' package, which is used for building Python wheel distributions. ```bash pip install wheel ``` -------------------------------- ### Install fjagepy for Development Source: https://github.com/org-arl/fjage/blob/master/gateways/python/README.md Install fjagepy with development and testing dependencies included. This is for contributors and developers working on the library itself. ```bash pip install -e ".[dev]" ``` -------------------------------- ### Install fjagepy from Source Source: https://github.com/org-arl/fjage/blob/master/gateways/python/README.md Install fjagepy from its source code repository. This is useful for development or when needing the latest unreleased features. ```bash git clone https://github.com/org-arl/fjage.git cd fjage/gateways/python pip install -e . ``` -------------------------------- ### Install Test Dependencies Source: https://github.com/org-arl/fjage/blob/master/gateways/python/README.md Installs the necessary dependencies for running the test suite of the fjagepy library. ```bash pip install -e ".[dev"] ``` -------------------------------- ### Simple Example: Execute Remote Shell Command Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/cgw.md A complete C program demonstrating how to connect to a fjage server, find the SHELL service agent, send a command (e.g., 'ps'), and process the response. This example requires linking with libfjage.a. ```c #include #include "fjage.h" int main() { fjage_gw_t gw = fjage_tcp_open("localhost", 5081); if (gw == NULL) { printf("Connection failed\n"); return 1; } fjage_aid_t aid = fjage_agent_for_service(gw, "org.arl.fjage.shell.Services.SHELL"); if (aid == NULL) { printf("Could not find SHELL agent\n"); fjage_close(gw); return 1; } fjage_msg_t msg = fjage_msg_create("org.arl.fjage.shell.ShellExecReq", FJAGE_REQUEST); fjage_msg_set_recipient(msg, aid); fjage_msg_add_string(msg, "cmd", "ps"); fjage_msg_t rsp = fjage_request(gw, msg, 1000); if (rsp != NULL && fjage_msg_get_performative(rsp) == FJAGE_AGREE) printf("SUCCESS\n"); else printf("FAILURE\n"); if (rsp != NULL) fjage_msg_destroy(rsp); fjage_aid_destroy(aid); fjage_close(gw); return 0; } ``` -------------------------------- ### init Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/remote/Tunnel.html Called by the container when the agent is started. ```APIDOC ## init ### Description Called by the container when the agent is started. ### Method `void init()` ``` -------------------------------- ### Start fjåge Container for Python Tests Source: https://github.com/org-arl/fjage/blob/master/gateways/python/README.md Starts a fjåge container specifically for running Python tests, using Gradle. This command is executed from the main fjåge directory. ```bash ./gradlew --info -PmanualPyTest=true test --tests="org.arl.fjage.test.fjagepyTest" ``` -------------------------------- ### Javascript Gateway API Usage Example Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/jsgw.md Demonstrates how to use the Javascript Gateway to connect to fjåge agents, subscribe to messages, and execute commands. This example finds the SHELL service, sends a 'ps' command, and logs the response. ```javascript import { Gateway, MessageClass, Performative } from '/fjage/fjage.js'; var gw = new Gateway(); MessageClass('org.arl.fjage.shell.ShellExecReq'); gw.agentForService('org.arl.fjage.shell.Services.SHELL').then((aid) => { shell = aid; gw.subscribe(gw.topic(shell)); makeRq(shell); }).catch((ex) => { console.log('Could not find SHELL: '+ex); }); gw.addMessageListener((msg) => { console.log(msg); return false; }); function makeRq(shell) { let req = new ShellExecReq(); req.recipient = shell; req.cmd = 'ps'; gw.request(req).then((msg) => { console.log(msg); }).catch((ex) => { console.log('Could not execute command: '+ex); }); } ``` -------------------------------- ### Start fjåge Container for Testing Source: https://github.com/org-arl/fjage/blob/master/docs/pydocs/fjagepy.html Starts a fjåge container on localhost:5081 for running Python tests. Ensure you are in the main fjåge directory before executing. ```bash # In the main fjage directory ./gradlew --info -PmanualPyTest=true test --tests="org.arl.fjage.test.fjagepyTest" ``` -------------------------------- ### Groovy Shell Extension Example Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/shell.md An example of a Groovy class implementing ShellExtension. It defines documentation, imports classes, and adds a 'hello' command to the shell. ```groovy class DemoShellExt implements org.arl.fjage.shell.ShellExtension { static final public String __doc__ = '''\ # demo - demo shell extension This shell extension imports all classes from the package "my.special.package" into the shell. In addition, it adds a command "hello", which is described below: ## hello - say hello to the world Usage: hello // say hello hello() // say hello Example: > hello Hello world!!! ''' static void __init__(ScriptEngine engine) { engine.importClasses('my.special.package.*') } static String hello() { return 'Hello world!!!' } } ``` -------------------------------- ### Install and Run Python Test Suite Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/fjagepy.md Commands to install development dependencies and execute the test suite for fjagepy using pytest. Includes options for running specific files or with code coverage. ```bash # Install test dependencies pip install -e ".[dev]" # Run tests pytest # Run specific test file pytest test/test_gateway.py # Run with coverage pytest --cov=fjagepy ``` -------------------------------- ### GetFileRsp.getOffset() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Get the start location in file. ```APIDOC ## GetFileRsp.getOffset() ### Description Get the start location in file. ### Method N/A (Java Method) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Run Fjage Quickstart Script Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/quickstart.md Execute the downloaded script to set up your Fjage project with necessary libraries and startup scripts. ```sh sh fjage_quickstart.sh ``` -------------------------------- ### PutFileReq.getOffset() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Get the start location in file to write to. ```APIDOC ## PutFileReq.getOffset() ### Description Get the start location in file to write to. ### Method N/A (Java Method) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### GetFileReq.getOffset() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Get the start location in file to read from. ```APIDOC ## GetFileReq.getOffset() ### Description Get the start location in file to read from. ### Method N/A (Java Method) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Pure Java Application Bootup Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/quickstart.md Demonstrates how to set up the fjage platform and container directly from a Java main() program for pure-Java applications. ```java import org.arl.fjage.*; public class MyProject { public static void main(String[] args) throws Exception { Platform platform = new RealTimePlatform(); Container container = new Container(platform); // add your agents to the container here // e.g. container.add("hello", new HelloWorldAgent()); platform.start(); } } ``` -------------------------------- ### Get Offset Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/shell/GetFileReq.html Retrieves the starting location in the file to read from. ```APIDOC ## getOffset ### Description Get the start location in file to read from. ### Method public long getOffset() ### Returns start locaion in file (negative for offset relative to end of file). ``` -------------------------------- ### Download Fjage Quickstart Script Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/quickstart.md Use curl to download the fjage_quickstart.sh script into your project directory. ```sh curl -O https://raw.githubusercontent.com/org-arl/fjage/master/src/sphinx/fjage_quickstart.sh ``` -------------------------------- ### input() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/shell/EchoScriptEngine.html Gets an input offered by ScriptEngine.offer(String). ```APIDOC ## input() ### Description Gets an input offered by [`ScriptEngine.offer(String)`](../../../../org/arl/fjage/shell/ScriptEngine.html#offer-java.lang.String-). ### Method `input` ### Returns `java.lang.Object` ``` -------------------------------- ### Create and Start DiscreteEventSimulator Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/DiscreteEventSimulator.html Demonstrates the typical usage of DiscreteEventSimulator, including platform creation, container addition, agent registration, and platform startup. ```Java import org.arl.fjage.*; Platform platform = new DiscreteEventSimulator(); Container container = new Container(platform); container.add("myAgent", new myAgent()); // add appropriate agents platform.start(); ``` -------------------------------- ### getPrompt(boolean cont) Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/shell/EchoScriptEngine.html Get the command prompt. ```APIDOC ## getPrompt(boolean cont) ### Description Get the command prompt. This method is inherited from the ScriptEngine interface. ### Method `getPrompt` ### Parameters #### Path Parameters - **cont** (boolean) - Description: true if continuation line, false if first line. ### Returns `java.lang.String` - prompt string or null to let shell choose prompt. ``` -------------------------------- ### getInstances Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/connectors/WebServer.html Gets all web server instances that are currently running. ```APIDOC ## getInstances ### Description Gets all web server instances running. ### Method Not specified (likely internal Java method call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response Returns an array of WebServer instances. #### Response Example None ``` -------------------------------- ### currentTimeMillis Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/RealTimePlatform.html Gets the current platform time in milliseconds. This method returns the elapsed time since the platform was started, in milliseconds. ```APIDOC ## currentTimeMillis() ### Description Gets the current platform time in milliseconds. ### Method `long currentTimeMillis()` ``` -------------------------------- ### Get Parameter Value using ParameterReq Source: https://github.com/org-arl/fjage/blob/master/docs/jsdoc/index.html Example of creating a ParameterReq message to request the current value of a specific parameter ('x') from an agent. ```javascript let req = new ParameterReq({ recipient: myAgentId, param: 'x' }); ``` -------------------------------- ### Enable WebSocket Connector for Javascript Gateway Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/jsgw.md Configure the fjåge platform to enable the WebSocket connector, allowing web applications to connect. This setup involves starting a RealTimePlatform, a Container, and a WebServer, then adding the WebSocket connector. ```groovy import org.arl.fjage.* import org.arl.fjage.shell.* import org.arl.fjage.connectors.* platform = new RealTimePlatform() container = new Container(platform) def websvr = org.arl.fjage.connectors.WebServer.getInstance(8080) websvr.add('/fjage', '/org/arl/fjage/web') // add any other contexts needed to serve your application here container.addConnector(new WebSocketConnector(8080, "/ws", true)) container.add 'shell', shell // add other agents to the container here platform.start() ``` -------------------------------- ### Example Usage of SimpleFirewallSupplier Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/auth/SimpleFirewallSupplier.html Demonstrates how to create and configure a SimpleFirewallSupplier by adding policies and users. Use this to set up access control rules for your application. ```java final SimpleFirewallSupplier simpleFirewallSupplier = new SimpleFirewallSupplier() .addPolicy("policy1", policy -> policy .allowedServiceNames("server") .allowedAgentNames("server1") .allowedTopicNames("server1__ntf") ) .addUser("user", "somecreds", "policy1") .addUser("app", "someappcreds", SimpleFirewallSupplier.POLICY_ID_ALLOW_ALL); ``` -------------------------------- ### Run and Verify Hello World Agent Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/quickstart.md Start Fjage, run the 'hello' agent, check if it's running, shut down Fjage, and verify the output in the log file. ```console bash$ ./fjage.sh > ps hello shell > shutdown bash$ cat logs/log-0.txt | grep HelloWorldAgent@ 1377443280802|INFO|HelloWorldAgent@18:println|Hello world!!! ``` -------------------------------- ### Install fjage.js via npm Source: https://github.com/org-arl/fjage/blob/master/gateways/js/README.md Install the fjage.js package using npm. This command downloads and installs the library and its dependencies. ```sh $ npm install fjage ``` -------------------------------- ### WebSocket Connection Setup Source: https://github.com/org-arl/fjage/blob/master/docs/jsdoc/fjage.js.html Initializes a new WebSocket connection to the specified URL. Includes basic error handling and sets up event listeners for 'onerror' and 'onopen' events. ```javascript _websockSetup(url){ try { this.sock = new WebSocket(url); this.sock.onerror = this._websockReconnect.bind(this); this.sock.onopen = this._onWebsockOpen.bind(this); } catch (error) { if(this.debug) console.log('Connection failed to ', this.sock.url); return; } } ``` -------------------------------- ### View Built Documentation Source: https://github.com/org-arl/fjage/blob/master/docs/pydocs/fjagepy.html Opens the locally built HTML documentation in the default web browser. ```bash open ../../docs/pydocs/index.html ``` -------------------------------- ### Example initrc.groovy Script Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/quickstart.md A sample Groovy script for initializing the fjage platform, container, and shell agent. This script is typically executed during bootup. ```groovy import org.arl.fjage.* import org.arl.fjage.shell.* platform = new RealTimePlatform() container = new Container(platform) shell = new ShellAgent(new ConsoleShell(), new GroovyScriptEngine()) container.add 'shell', shell // add other agents to the container here platform.start() ``` -------------------------------- ### GroovyBoot Main Method Example Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/quickstart.md A simplified Java code extract from the org.arl.fjage.shell.GroovyBoot.main() method, illustrating how initialization scripts are executed. ```java public static void main(String[] args) throws Exception { GroovyExtensions.enable(); engine = new GroovyScriptEngine(); for (String a: args) { engine.exec(new File(a), null); engine.waitUntilCompletion(); } engine.shutdown(); } ``` -------------------------------- ### get(Parameter param) Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/param/ParameterReq.html Requests a single parameter. This method allows for chaining multiple 'get' calls. ```APIDOC ## get(Parameter param) ### Description Requests a parameter. ### Method public ParameterReq get(Parameter param) ### Parameters #### Path Parameters - **param** (Parameter) - Description: parameter to be requested ### Returns - **ParameterReq** - this object, to allow multiple gets to be concatenated ``` -------------------------------- ### FSMBehavior Example Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/FSMBehavior.html Demonstrates how to create and configure an FSM behavior by adding states with actions and transitions. This FSM transitions from 'state1' to 'state2' and then terminates. ```java FSMBehavior fsm = new FSMBehavior(); fsm.add(new FSMBehavior.State("state1") { public void action() { log.info("In State #1"); setNextState("state2"); } }); fsm.add(new FSMBehavior.State("state2") { public void action() { log.info("In State #2"); terminate(); } }); agent.add(fsm); ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/org-arl/fjage/blob/master/docs/pydocs/fjagepy.html Builds the documentation in HTML format using Sphinx. The output will be placed in the specified directory. ```bash sphinx-build -b html docs/ ../../docs/pydocs/ ``` -------------------------------- ### add Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Agent.html Adds a behavior to the agent. The Behavior.onStart() method of the behavior is immediately called once its added to the agent. ```APIDOC ## add(Behavior b) ### Description Adds a behavior to the agent. The [`Behavior.onStart()`](../../../org/arl/fjage/Behavior.html#onStart--) method of the behavior is immediately called once its added to the agent. ### Method `public Behavior add(Behavior b)` ### Parameters #### Path Parameters - **b** (Behavior) - Required - Behavior to be added. ### Returns - Behavior - the behavior (same as input b). ``` -------------------------------- ### Skeleton Agent Example Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/behaviors.md A basic skeleton for a FJage agent, demonstrating the init() and shutdown() methods. ```groovy class MyAgent extends Agent { void init() { // agent is in INIT state log.info 'Agent init' add new OneShotBehavior({ // behavior will be executed after all agents are initialized // agent is in RUNNING state log.info 'Agent ready' }) } void shutdown() { log.info 'Agent shutdown' } } ``` -------------------------------- ### WebServer Constructors Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/connectors/WebServer.html Constructors for creating a WebServer instance. ```APIDOC ## WebServer(int port) ### Description Protected constructor to create a new web server instance. ### Constructor `protected WebServer(int port)` ## WebServer(int port, String ip) ### Description Creates a new web server instance. ### Constructor `protected WebServer(int port, String ip)` ``` -------------------------------- ### Cyclic Behavior Example Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/behaviors.md An example of a CyclicBehavior that increments a counter and blocks itself after reaching a certain count. Note that Behavior.block() is not a blocking call; it marks the behavior as blocked. ```groovy class MyAgent extends Agent { int n = 0 void init() { // a cyclic behavior that runs 5 times and then marks itself as blocked add new CyclicBehavior({ agent.n++ println "n = ${agent.n}" if (agent.n >= 5) block() }) } } ``` -------------------------------- ### Initialize Gateway with CommonJS Source: https://github.com/org-arl/fjage/blob/master/gateways/js/README.md Import necessary components and initialize the Gateway for CommonJS environments. Ensure the hostname and port are correctly configured for your fjage master container. ```js const { Performative, AgentID, Message, Gateway, MessageClass } = require('fjage'); const shell = new AgentID('shell'); const gw = new Gateway({ hostname: 'localhost', port : '5081', }); ``` -------------------------------- ### getSender() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the sender of the message. ```APIDOC ## getSender() ### Description Gets the sender of this message. ### Method (Not specified, likely a getter method) ### Endpoint (Not applicable, this is an SDK method) ### Parameters (None) ### Request Example (None) ### Response #### Success Response (Type not specified, likely an AgentID or similar identifier) #### Response Example (None) ``` -------------------------------- ### Initialize Terminal and Load Addons in JavaScript Source: https://github.com/org-arl/fjage/blob/master/src/main/resources/org/arl/fjage/web/shell/index.html Initializes a new Terminal instance, loads necessary addons (FitAddon, WebLinksAddon), opens the terminal in a specified DOM element, and fits it to the container. ```javascript window.addEventListener('load', () => { // Initialize terminal let term = new Terminal({ cols: COLS, rows: ROWS }); let fitAddon = new FitAddon.FitAddon(); term.loadAddon(fitAddon); term.loadAddon(new WebLinksAddon.WebLinksAddon()); term.open(document.getElementById('terminal')); fitAddon.fit(); // Initialize color schemes let initialScheme = initializeSchemes(term); setScheme(term, initialScheme); let attachAddon = null; const urlParams = new URLSearchParams(window.location.search); const url = urlParams.get('url') || (window.location.hostname + ':' + window.location.port + wind ``` -------------------------------- ### Console Interaction for Standard Parameters Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/params.md Demonstrates how to add an agent to the container and then query its standard parameters (title and description) and other defined parameters (x, y) from the fjåge console. ```bash bash$ ./fjage.sh > container.add 'a', new MyAgentWithParams() a > a « My agent with parameters » This is a sample agent to demonstrate the use of parameters [MyParams] x = 42 y = 7 ``` -------------------------------- ### getRecipient() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the recipient of the message. ```APIDOC ## getRecipient() ### Description Gets the recipient of this message. ### Method (Not specified, likely a getter method) ### Endpoint (Not applicable, this is an SDK method) ### Parameters (None) ### Request Example (None) ### Response #### Success Response (Type not specified, likely an AgentID or similar identifier) #### Response Example (None) ``` -------------------------------- ### getPolicyId() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the policy ID. ```APIDOC ## getPolicyId() ### Description Gets the policy ID. ### Method (Not specified, likely Java method call) ### Endpoint (Not applicable) ### Parameters (None specified) ### Response (Not specified, likely the policy ID) ``` -------------------------------- ### Run fjåge Server for Testing Source: https://github.com/org-arl/fjage/blob/master/gateways/c/README.md Starts the fjåge server from the project root directory, required before running the test suite. ```bash # cd to the project root > cd ../.. > ./fjage.sh ``` -------------------------------- ### getPerformative() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the performative for this message. ```APIDOC ## getPerformative() ### Description Gets the performative for this message. ### Method (Not specified, likely Java method call) ### Endpoint (Not applicable) ### Parameters (None specified) ### Response (Not specified, likely the performative string) ``` -------------------------------- ### RealTimePlatform Constructor Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/RealTimePlatform.html Constructs a new RealTimePlatform instance. ```APIDOC ## RealTimePlatform() ### Description Constructs a new RealTimePlatform instance. ### Constructor `public RealTimePlatform()` ``` -------------------------------- ### Container.getName() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the name of the container. ```APIDOC ## Container.getName() ### Description Gets the name of the container. ### Method N/A (Java Method) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Agent.getName() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the name of the agent. ```APIDOC ## Agent.getName() ### Description Gets the name of the agent. ### Method N/A (Java Method) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Configure Discrete Event Simulator Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/simulation.md Replace the RealTimePlatform with DiscreteEventSimulator to enable discrete event simulation mode. Add agents to the container after initialization. ```groovy import org.arl.fjage.* platform = new DiscreteEventSimulator() container = new Container(platform) // add agents to the container here platform.start() ``` -------------------------------- ### agent_id Source: https://github.com/org-arl/fjage/blob/master/docs/pydocs/_modules/fjagepy/Gateway.html Gets the AgentID of this gateway. ```APIDOC ## agent_id ### Description Gets the AgentID of this gateway. ### Method `agent_id() -> AgentID` ### Returns - **AgentID** - The AgentID of this gateway. ``` -------------------------------- ### getState Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Agent.html Gets the state of the agent. ```APIDOC ## getState() ### Description Gets the state of the agent. ### Method `public AgentState getState()` ### Returns - AgentState - the state of the agent. ``` -------------------------------- ### WebServer.WebServerOptions Class Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/connectors/package-summary.html Builder style class for configuring web server options. ```APIDOC ## Class: WebServer.WebServerOptions ### Description Builder style class for configuring web server options. ### Methods (No methods explicitly documented in the summary) ``` -------------------------------- ### getAgentID Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Agent.html Gets the agent id. ```APIDOC ## getAgentID() ### Description Gets the agent id. ### Method public AgentID ### Returns the agent id for this agent. ``` -------------------------------- ### getContainers Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Platform.html Gets all the containers on the platform. ```APIDOC ## getContainers ### Description Gets all the containers on the platform. ### Method public Container[] ### Returns an array of containers. ``` -------------------------------- ### nanoTime Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Agent.html Gets the current platform time in nanoseconds. This method should be used by the agent to get the current time in preference to System.nanoTime() as this method returns the real time or the simulated discrete time depending on the platform that the agent is running on. ```APIDOC ## nanoTime() ### Description Gets the current platform time in nanoseconds. This method should be used by the agent to get the current time in preference to `System.nanoTime()` as this method returns the real time or the simulated discrete time depending on the platform that the agent is running on. Specified by: `[nanoTime](../../../org/arl/fjage/TimestampProvider.html#nanoTime--)` in interface `[TimestampProvider](../../../org/arl/fjage/TimestampProvider.html "interface in org.arl.fjage")` ### Method `public long nanoTime()` ### Returns - long - current platform time in nanoseconds. ``` -------------------------------- ### Browser UMD Bundle Example Source: https://github.com/org-arl/fjage/blob/master/gateways/js/examples/readme.md An HTML page using a UMD bundle of fjage.js. Requires `bundle.js` to be generated. Access at `http://localhost:8000/example-bundle.html`. ```html fjage.js UMD Bundle Example

fjage.js UMD Bundle Example

``` -------------------------------- ### getInstance (multiple overloads) Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/connectors/WebServer.html Gets an instance of a web server running on the specified port. Allows retrieval of a WebServer instance, optionally specifying the IP address. ```APIDOC ## getInstance ### Description Gets an instance of a web server running on the specified port. ### Method Not specified (likely internal Java method call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response Returns a WebServer instance. #### Response Example None ``` ```APIDOC ## getInstance ### Description Gets an instance of a web server running on the specified port and IP address. ### Method Not specified (likely internal Java method call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response Returns a WebServer instance. #### Response Example None ``` -------------------------------- ### WebServer.getInstance(int, String) Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Obtains a singleton instance of a web server operating on a specified port and with a given context path. This provides more specific control over web server instances. ```APIDOC ## WebServer.getInstance(int, String) ### Description Gets an instance of a web server running on the specified port. ### Method N/A (Java static method) ### Endpoint N/A (Java static method) ### Parameters - **port** (int) - The port number the web server is running on. - **contextPath** (String) - The context path for the web server. ### Response - **webServer** (WebServer) - An instance of the WebServer. ``` -------------------------------- ### getScriptFile() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Get the script file to execute. ```APIDOC ## getScriptFile() ### Description Get the script to execute. ### Method (Not specified, likely a getter method) ### Endpoint (Not applicable, this is an SDK method) ### Parameters (None) ### Request Example (None) ### Response #### Success Response (Type not specified, likely a File or String representing the script) #### Response Example (None) ``` -------------------------------- ### initComplete Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/remote/SlaveContainer.html Called when the container is initialized. ```APIDOC ## initComplete ### Description Called when the container is initialized. ### Method initComplete ``` -------------------------------- ### getPlatform() - Gateway Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the platform for the gateway. ```APIDOC ## getPlatform() - Gateway ### Description Gets the platform for the gateway. ### Method (Not specified, likely Java method call) ### Endpoint (Not applicable) ### Parameters (None specified) ### Response (Not specified, likely the platform identifier) ``` -------------------------------- ### getParameters() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets all requested parameters as a map. ```APIDOC ## getParameters() ### Description Gets all requested parameters as a map. ### Method (Not specified, likely Java method call) ### Endpoint (Not applicable) ### Parameters (None specified) ### Response (Not specified, likely a map of parameters) ``` -------------------------------- ### Poisson Behavior Example Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/behaviors.md Simulates a Poisson arrival process by invoking actions at intervals that are exponentially distributed random variables. The average rate of invocation is specified. ```groovy add new PoissonBehavior(5000, { // called at an average rate of once every 5 seconds println 'arrival!' }) ``` -------------------------------- ### AgentID.getOwner() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the owner of the agent id. ```APIDOC ## AgentID.getOwner() ### Description Gets the owner of the agent id. ### Method N/A (Java Method) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### addInitrc Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/shell/ShellAgent.html Adds initialization scripts to set up the console environment. ```APIDOC ## addInitrc ### Description Adds initialization scripts to set up the console environment. ### Methods - `void addInitrc(File script)`: Adds a initialization script file. - `void addInitrc(String script)`: Adds a name of the initialization script. - `void addInitrc(String name, Reader reader)`: Adds a initialization script from a reader. ``` -------------------------------- ### Initialize Gateway with ECMAScript Modules Source: https://github.com/org-arl/fjage/blob/master/gateways/js/README.md Import necessary components and initialize the Gateway for ECMAScript module environments. This syntax is common in modern JavaScript development. ```js import { Performative, AgentID, Message, Gateway, MessageClass } from 'fjage.js' const shell = new AgentID('shell'); const gw = new Gateway({ hostname: 'localhost', port : '5081', }); ``` -------------------------------- ### FSMBehavior.State.getName() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Gets the name of the FSM state. ```APIDOC ## FSMBehavior.State.getName() ### Description Gets the name of the FSM state. ### Method N/A (Java Method) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Connector.getName() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/index-all.html Get a string representation of the connection. ```APIDOC ## Connector.getName() ### Description Get a string representation of the connection. ### Method N/A (Java Method) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Build fjåge Developer Documentation Source: https://github.com/org-arl/fjage/blob/master/README.md Generate the developer's documentation in HTML format using the make html command. This process is automated through ReadTheDocs. ```bash make html ``` -------------------------------- ### getTitle Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/shell/ShellAgent.html Gets the title of the shell agent. ```APIDOC ## getTitle ### Description Gets the title of the shell agent. ### Method - `String getTitle()()` ``` -------------------------------- ### getLanguage Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/shell/ShellAgent.html Gets the supported script language. ```APIDOC ## getLanguage ### Description Gets the supported script language. ### Method - `String getLanguage()()` ``` -------------------------------- ### getDescription Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/shell/ShellAgent.html Gets the description of the shell agent. ```APIDOC ## getDescription ### Description Gets the description of the shell agent. ### Method - `String getDescription()()` ``` -------------------------------- ### Initialize Gateway with UMD Source: https://github.com/org-arl/fjage/blob/master/gateways/js/README.md Include the fjage.js UMD bundle via a script tag and initialize the Gateway. This method is suitable for environments that do not support traditional module systems. ```js ``` -------------------------------- ### toString() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Agent.html Gets a string representation of the agent. ```APIDOC ## toString() ### Description Gets a string representation of the agent. ### Returns - String - String representation of the agent. ``` -------------------------------- ### WebServer Class Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/connectors/package-summary.html Web server instance manager. ```APIDOC ## Class: WebServer ### Description Web server instance manager. ### Methods (No methods explicitly documented in the summary) ``` -------------------------------- ### getStore() Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/Agent.html Gets a persistent store for the agent. ```APIDOC ## getStore() ### Description Gets a persistent store for the agent. ### Returns - Store - A persistent store for the agent. ``` -------------------------------- ### Start Slave Container Source: https://github.com/org-arl/fjage/blob/master/gateways/python/docs/remote.md Connects a slave fjåge container to a specified master container. Requires master's hostname and port. ```groovy import org.arl.fjage.* import org.arl.fjage.remote.* platform = new RealTimePlatform() container = new SlaveContainer(platform, hostname, port) // add agents to the container here platform.start() ``` -------------------------------- ### getName Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/connectors/SerialPortConnector.html Gets a string representation of the connection. ```APIDOC ## getName() ### Description Get a string representation of the connection. ### Returns * String ``` -------------------------------- ### Initialize FJAGE Gateway Connection Source: https://github.com/org-arl/fjage/blob/master/docs/pydocs/_modules/fjagepy/Gateway.html Establishes a connection to the FJAGE gateway. Ensure the gateway is running before executing this code. ```python from fjagepy import Gateway gateway = Gateway() gateway.start() print("Connected to FJAGE gateway.") ``` -------------------------------- ### getSerialPort Source: https://github.com/org-arl/fjage/blob/master/docs/javadoc/org/arl/fjage/connectors/SerialPortConnector.html Gets the underlying SerialPort object. ```APIDOC ## getSerialPort() ### Description Get the underlying serial port. ### Method `public com.fazecast.jSerialComm.SerialPort getSerialPort()` ``` -------------------------------- ### Browser UMD Example Source: https://github.com/org-arl/fjage/blob/master/gateways/js/examples/readme.md An HTML page demonstrating the UMD version of fjage.js. Requires a local web server. Access at `http://localhost:8000/example-umd.html`. ```html fjage.js UMD Example

fjage.js UMD Example

```