Commit 51f40559 authored by Thibaut Démare's avatar Thibaut Démare

Add new tests of data transmitted from Graphstream to Gama

parent 1a7e1c74
...@@ -11,6 +11,8 @@ global { ...@@ -11,6 +11,8 @@ global {
init { init {
// Send data
// Clear all previous senders // Clear all previous senders
gs_clear_senders; gs_clear_senders;
...@@ -98,21 +100,63 @@ global { ...@@ -98,21 +100,63 @@ global {
// If the previous command has worked, the next one should work too // If the previous command has worked, the next one should work too
//gs_add_sender gs_host:"localhost" gs_port:2001 gs_sender_id:"test1"; //gs_add_sender gs_host:"localhost" gs_port:2001 gs_sender_id:"test1";
// Receive Data
// Clear all receivers
gs_clear_receivers;
// Add a new receiver
gs_add_receiver gs_receiver_id:"test2" gs_host:"localhost" gs_port:3001;
// Wait step
write "Receiver created. Wait for a signal of new step.";
float syncStep <- 0.0;
gs_wait_step gs_receiver_id:"test2" gs_return:syncStep;
// Get graph attribute(s)
list val <- nil;
gs_get_graph_attribute gs_receiver_id:"test2" gs_attribute_name:"a" returns:val;
int i<- 0;
loop while: i < length(val) {
write val[i];
i <- i + 1;
}
// Wait step
syncStep <- 0.0;
gs_wait_step gs_receiver_id:"test2" gs_return:syncStep;
// Get node attribute(s)
gs_get_node_attribute gs_receiver_id:"test2" gs_node_id:"0" gs_attribute_name:"na" returns:val;
int i<- 0;
loop while: i < length(val) {
write val[i];
i <- i + 1;
}
// Wait step
syncStep <- 0.0;
gs_wait_step gs_receiver_id:"test2" gs_return:syncStep;
// Get edge attribute(s)
gs_get_edge_attribute gs_receiver_id:"test2" gs_edge_id:"0_1" gs_attribute_name:"ea" returns:val;
int i<- 0;
loop while: i < length(val) {
write val[i];
i <- i + 1;
}
// Flush the given receiver
gs_flush gs_receiver_id:"test2";
} }
} }
species Provider { experiment test_gs_extension type: gui {
aspect base {
draw square(1.5°km) color: rgb([100, 0, 100]) ;
}
} }
experiment test_gs_extension type: gui {
output {
display display_FinalDestinationManager {
species Provider aspect: base;
}
}
}
\ No newline at end of file
...@@ -4,13 +4,42 @@ import java.io.IOException; ...@@ -4,13 +4,42 @@ import java.io.IOException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import org.graphstream.stream.netstream.NetStreamReceiver; import org.graphstream.stream.netstream.NetStreamReceiver;
import org.graphstream.stream.netstream.NetStreamSender;
public class Tests { public class Tests {
public static void main(String[] args) throws InterruptedException, UnknownHostException, IOException { public static void main(String[] args) throws InterruptedException, UnknownHostException, IOException {
// Receive event
NetStreamReceiver receiver = new NetStreamReceiver(2001); NetStreamReceiver receiver = new NetStreamReceiver(2001);
new SimpleNetStreamViewer(receiver, true); new SimpleNetStreamViewer(receiver, true);
new SimpleSinkAdapter(receiver); new SimpleSinkAdapter(receiver);
// Send event
System.out.println("Press enter and then it will start to send value");
System.in.read();
NetStreamSender sender = new NetStreamSender(3001);
long timeId = 0;
System.out.println("Start sending data.");
sender.stepBegins("foo", timeId++, 1);
sender.graphAttributeAdded("foo", timeId++, "a", 1);
sender.graphAttributeAdded("foo", timeId++, "a", true);
sender.graphAttributeAdded("foo", timeId++, "a", "bar");
Integer[] array = new Integer[3];
array[0] = 0; array[1] = 1; array[2] = 2;
sender.graphAttributeAdded("foo", timeId++, "a", array);
sender.graphAttributeAdded("foo", 0, "a", "old");
sender.stepBegins("foo", timeId++, 1);
sender.nodeAttributeAdded("foo", timeId++, "0", "na", "bar");
sender.nodeAttributeChanged("foo", timeId++, "0", "na", "bar", "newbar");
sender.stepBegins("foo", timeId++, 2);
sender.edgeAttributeAdded("foo", timeId++, "0_1", "ea", array);
sender.close();
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment