changeset 83:909e1c9bc6fc working

set range
author sugi
date Tue, 29 May 2012 17:14:20 +0900
parents 5cf20458b9e0
children 4bd3178f218b
files scripts/movement_run.sh src/alice/test/topology/movement/CheckMyName.java src/alice/test/topology/movement/FishMovement.java src/alice/test/topology/movement/SendLocation.java
diffstat 4 files changed, 43 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/movement_run.sh	Tue May 29 17:14:20 2012 +0900
@@ -0,0 +1,15 @@
+#!/bin/bash
+max=$1
+child_num=$2
+ruby ./topology/treen.rb $1 $2 > ./topology/tree.dot
+#dot -Tpng ./topology/tree.dot > ./topology/tree.png
+#open ./topology/tree.png
+java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/tree.dot -log ./output/manager.log -level debug > ./output/std_manager.log &
+
+cnt=0
+while [ $cnt -lt $max ]
+do
+    java -cp ../Alice.jar alice.test.topology.movement.FishMovementTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/fishmovement${cnt}.log -level debug > ./output/std_fishmovement${cnt}.log &
+    cnt=`expr $cnt + 1`
+done
+wait
--- a/src/alice/test/topology/movement/CheckMyName.java	Thu May 24 16:57:52 2012 +0900
+++ b/src/alice/test/topology/movement/CheckMyName.java	Tue May 29 17:14:20 2012 +0900
@@ -27,12 +27,12 @@
 			
 			SendLocation cs = new SendLocation();
 			cs.nowX.setKey("parent","fishX");
-			cs.nowY.setKey("parent","fishY");
+			cs.host.setKey("local","host");
+			
 					
 		}else if(type.equals("node")){
 			System.out.println("node0");
-			ods.update("local", "fishX", 10);
-			ods.update("local", "fishY", 10);
+			ods.update("local", "fishX", -1000);
 			
 		}
 	}
--- a/src/alice/test/topology/movement/FishMovement.java	Thu May 24 16:57:52 2012 +0900
+++ b/src/alice/test/topology/movement/FishMovement.java	Tue May 29 17:14:20 2012 +0900
@@ -70,7 +70,7 @@
 		transform_group = new TransformGroup();
 		scene.addChild(transform_group);
 		transform_group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
-		Box box = new Box(0.4f,0.4f,0.8f,
+		Box box = new Box(0.1f,0.1f,0.0f,
 				Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance());
 		transform_group.addChild(box);
 		setLocation(0.0f,0.0f);
--- a/src/alice/test/topology/movement/SendLocation.java	Thu May 24 16:57:52 2012 +0900
+++ b/src/alice/test/topology/movement/SendLocation.java	Tue May 29 17:14:20 2012 +0900
@@ -1,5 +1,8 @@
 package alice.test.topology.movement;
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import alice.codesegment.CodeSegment;
 import alice.datasegment.CommandType;
 import alice.datasegment.Receiver;
@@ -7,28 +10,35 @@
 
 public class SendLocation extends CodeSegment{
 	
-	public Receiver nowX = ids.create(CommandType.TAKE);
-	public Receiver nowY = ids.create(CommandType.TAKE);
+	public Receiver nowX = ids.create(CommandType.PEEK);
+	public Receiver host = ids.create(CommandType.PEEK);
 	
 	@Override
 	public void run(){
-		System.out.println("run SendLocation");
+		System.out.println("SendLocation");
+		String name = host.asString();
+		Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
+		Matcher matcher = pattern.matcher(name);
+		
+		matcher.find();
+		int num = new Integer(matcher.group(2));
 		int x = this.nowX.asInteger();
-		int y = this.nowY.asInteger();
-		System.out.println("setX : " +x/100);
+		System.out.println("X : " +(float)x/1000);
 		
-		FishMovement fm = FishMovement.getInstance();
-		fm.setLocation((float)x/1000, (float)y/1000);
-		x++;
-		y++;
-
+		float start = num * 2.0f - 3;
+		float end = num * 2.0f - 0.9f;
 		
+		if (start <= (float)x/1000 && (float)x/1000<= end){
+			FishMovement fm = FishMovement.getInstance();
+			fm.setLocation((float)x/1000, 0.0f);
+			x++;
+			ods.update("parent", "fishX", x);
+		}
 		SendLocation cs = new SendLocation();
-		cs.nowX.setKey("parent","fishX");
-		cs.nowY.setKey("parent","fishY");
+		cs.host.setKey("local","host");
+		cs.nowX.setKey("parent","fishX",this.nowX.index);
+	
 		
-		ods.update("parent", "fishX", x);
-		ods.update("parent", "fishY", y);