In this assignment you will learn how to use the MundoCore communication middleware and how to write and simulate a small context-aware application.
/fs-0/5/aitenbic/pub/mundocore-java-0.9.9-1.zipconfig/build.properties and set the variable mcroot to the directory where you have unpacked MundoCore. Also set the variable mcc such that it points to the Linux-Version of the precompiler, i.e. mcc-linux.samples/chat/simple.ant to compile it../run.sh.Start two instances of the chat program and check that they communicate with each other. The program can be exited by entering only . on a line.
/fs-0/5/aitenbic/pub/worldview-0.9.7.zipworldview and unpack the ZIP-File into it.java -jar worldview.jar.Now create a map with three rooms, add a Ubisense controller, and three tags:
room1...room3.channelName-Property to ubisense.name and tagName properties.Now you can simulate the Ubisense system with one instance of WorldView and monitor it with another one.
In this exercise you will learn how to receive messages using the publish/subscribe system. Write a small console program that receives and prints Ubisense messages, sent by WorldView. To create a new project in Eclipse, perform the following steps:
lib/mundocore.jar. Then expand the new entry, select Source Attachment, click Edit, and select sources.zip from the MundoCore distribution.node.conf.xml from the WorldView directory to the project directory.Complete the following program, compile, and run it:
public class UbisenseTest extends DefaultApplication implements IReceiver
{
@Override
public void init()
{
super.init();
session.subscribe("lan", "ubisense", this);
}
public void received(Message msg, MessageContext ctx) // IReceiver
{
TypedMap m = msg.getMap("main", "passive").getMap("object");
System.out.println(m);
}
public static void main(String args[])
{
start(new UbisenseTest());
}
}
When you now simulate the Ubisense system with WorldView, your program should print coordinates to the console.
Next, extend this program with formatted output. Use the method getString of TypedMap to obtain the tag name. Use getMap to obtain the nested map p and then read the coordinates x and y from it with getDouble.
In this exercise you will learn how to make Remote Method Calls (RMCs) to services using MundoCore. Write a small console program that reads input from the console and controls a lamp, simulated by WorldView. When you type 0 on the console, the lamp should be turned off, and when you type 1 on the console, then the lamp should be turned on.
Create a new project:
prep.lib/mundocore.jar. Then expand the new entry, select Source Attachment, click Edit, and select sources.zip from the MundoCore distribution.node.conf.xml from the WorldView directory to the project directory./fs-0/5/aitenbic/pub/build.xml to the project directory.Add the following import statement to your program. The @mcImport tag will instruct the precompiler (mcc) to generate the lamp interface and client stub from the WSDL interface description of the Lamp-Service:
//@mcImport import org.mundo.bas.ILamp; import org.mundo.bas.DoILamp;
Now run the ant buildfile by selecting Run As > Ant Build. ILamp and DoILamp should appear in the subdirectory prep.
In the init method, create a distributed object and connect it:
doLamp = new DoILamp();
Signal.connect(doLamp, session.publish("lan", channelName));
You can now use the setState method to switch the lamp on or off. Hint: You can look at the source code of the chat example program to see how to read input from the console.
Next, model a lamp in WorldView and test your application:
lamp1.In WorldView, put a lamp into each of your three rooms. Write a program that controls these lamps. If at least one tag is located inside a room, then automatically turn the corresponding light on. If a room is empty, then turn the light off.
Note: In this step you can hardcode the coordinates of the rooms in your program.
Extend your program to use the World Model Store Service to obtain the coordinates of rooms.
org.mundo.service.wmstore.WMStoreServicewmstore to access the World Model Store Service.Starting the WMStore service:
/fs-0/5/aitenbic/pub/wmstore.tar.gz to your home directory.java -jar wmstore-app.jarCall select("MapRect") on WMStoreService to obtain all rectangles in the map.