changeset 387:1cbac5818dca multicast

add scope dataSegment
author sugi
date Mon, 16 Jun 2014 16:59:39 +0900
parents aae8e515b0d9
children cef1e0a46bb9
files src/main/java/alice/test/topology/aquarium/fx/Aquarium.java src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java src/main/java/alice/test/topology/aquarium/fx/RegisterList.java src/main/java/alice/test/topology/aquarium/fx/SetTranslate.java
diffstat 4 files changed, 28 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java	Mon Jun 16 16:57:31 2014 +0900
+++ b/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java	Mon Jun 16 16:59:39 2014 +0900
@@ -24,8 +24,8 @@
 	
 	@Override
 	public void start(Stage primaryStage) throws IOException {
-		String myName = getParameters().getRaw().get(0);
-		primaryStage.setTitle("Aquarium "+ myName); // name
+		String myName = getParameters().getRaw().get(0); // name
+		primaryStage.setTitle("Aquarium "+ myName); 
 		primaryStage.setResizable(false);
 		primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>(){
 			@Override
@@ -40,16 +40,25 @@
 		    public void handle(KeyEvent t) {
 		    	switch (t.getCode()) {
 		    	case RIGHT:
-		    		ods.update(myName+"FishPosition", new FishInfo(0.1,0,0));
+		    		ods.update(myName+"FishdiffP", new FishInfo(0.1,0,0));
 		    		break;
 		    	case LEFT:
-		    		ods.update(myName+"FishPosition", new FishInfo(-0.1,0,0));
+		    		ods.update(myName+"FishdiffP", new FishInfo(-0.1,0,0));
 		    		break;
 		    	case UP:
-		    		ods.update(myName+"FishPosition", new FishInfo(0,-0.1,0));
+		    		ods.update(myName+"FishdiffP", new FishInfo(0,-0.1,0));
 		    		break;
 		    	case DOWN:
-		    		ods.update(myName+"FishPosition", new FishInfo(0,0.1,0));
+		    		ods.update(myName+"FishdiffP", new FishInfo(0,0.1,0));
+		    		break;
+		    	case N:
+		    		ods.update(myName+"FishdiffP", new FishInfo(0,0,0.1));
+		    		break;
+		    	case M:
+		    		ods.update(myName+"FishdiffP", new FishInfo(0,0,-0.1));
+		    		break;
+		    	case R: // reset. need absolute position
+		    		ods.update(myName+"FishdiffP", new FishInfo(0,0,0));
 		    		break;
 				default: // do nothing
 					break;
@@ -79,7 +88,7 @@
 		subScene.setFill(Color.TRANSPARENT);
 		subScene.setCamera(camera);
 		Group parent = new Group(subScene);
-		
+
 		return parent;
 	}
 
--- a/src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java	Mon Jun 16 16:57:31 2014 +0900
+++ b/src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java	Mon Jun 16 16:59:39 2014 +0900
@@ -11,7 +11,8 @@
 public class CheckMyName extends CodeSegment {
 	private Receiver host = ids.create(CommandType.PEEK);
 	private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$");
-
+	private int INNER_WIDTH = 10;
+	
 	public CheckMyName(){
 		host.setKey("host");
 	}
@@ -23,8 +24,10 @@
 		matcher.find();
 
 		// use view scope
-		//String type = matcher.group(1);
 		int num = new Integer(matcher.group(2));
+		// scope: A_n = 5 + 10(n - 1);
+		int scope = 5 + INNER_WIDTH * (num - 1);
+		ods.put("startX", scope);
 		
 		if (num == 0){ // root node
 			new RegisterList();
--- a/src/main/java/alice/test/topology/aquarium/fx/RegisterList.java	Mon Jun 16 16:57:31 2014 +0900
+++ b/src/main/java/alice/test/topology/aquarium/fx/RegisterList.java	Mon Jun 16 16:59:39 2014 +0900
@@ -18,7 +18,6 @@
 	
 	@Override
 	public void run() {
-		System.out.println("registeredList");
 		FishInfo fishInfo = info.asClass(FishInfo.class);
 	
 		@SuppressWarnings("unchecked")
--- a/src/main/java/alice/test/topology/aquarium/fx/SetTranslate.java	Mon Jun 16 16:57:31 2014 +0900
+++ b/src/main/java/alice/test/topology/aquarium/fx/SetTranslate.java	Mon Jun 16 16:59:39 2014 +0900
@@ -9,11 +9,14 @@
 public class SetTranslate extends CodeSegment {
 	
 	private Receiver info  = ids.create(CommandType.TAKE); // object instance
-	private Receiver info1 = ids.create(CommandType.TAKE); // fish position information
+	private Receiver info1 = ids.create(CommandType.TAKE); // differential value
+	//private Receiver info2 = ids.create(CommandType.TAKE); // absolute fish position value
+	private Receiver info3 = ids.create(CommandType.PEEK); // start x
 	private boolean executed = false;
 	public SetTranslate(String key) {
 		info.setKey(key);
-		info1.setKey(key+"Position");
+		info1.setKey(key+"diffP");
+		info3.setKey("startX");
 	}
 
 	@Override
@@ -24,8 +27,9 @@
 			// javafx's Scene can be accessed only FX application thread.
 			Platform.runLater(this);
 		} else {
-			Group fish   = info.asClass(Group.class);
+			Group fish = info.asClass(Group.class);
 			FishInfo fp = info1.asClass(FishInfo.class);
+			//int scope = info3.asInteger();
         	
         	fish.setTranslateX(fish.getTranslateX()+fp.getX());
         	fish.setTranslateY(fish.getTranslateY()+fp.getY());