First program and starting
Let’s build our first program. The goal is to have one node saying Hello World on startup. Therefor you need to create a node type we’ll call myNode and a method. The method init() is called by the framework when a node starts. Think of this method as a constructor. Open an editor and save the following code in a file named helloWorld:
myNode{
init(){
print("Hello World");
}
}
On Linux you open a terminal in the folder you saved the file in and start the program with netsimlan helloWorld
.
On Windows you double click Launcher.jar, enter your file as source code file and press Run Simulation.
Alternatively you can open a command line and enter java.exe -jar Launcher.jar helloWorld
to fill the field already.
You may ignore the other fields for now.
Every time you change your code, you need to close the simulation and restart it.
If you have any syntax issues in your code, the launcher will tell you. Otherwise the simulation framework will start with a window opens looking like the following picture. It’s called the main window. You see three areas. The upper left one is for administrating the simulation. It starts with an area for generating nodes. You see your type from the code file. Select that type, set the number of nodes to 1, make sure autostart is checked and press Create.
Now different things happen. First another window, the so called visualization window, opens showing the graph of connections between the nodes in the simulation. You only have one node without any connection currently, so you just see one point here. In the upper right area you now see the controll for a single node. We’ll come back to that later. In the lower area you see output from the nodes and the simulation framework. Here you see the new node saying “Hello World”. Great, you just created your first simulation.
Previous: Installation Next: Connected Nodes