changeset 103:37f3483a869b working

remove bug from "CheckParentIndex" and "CheckLocalIndex"
author sugi
date Mon, 02 Jul 2012 11:16:01 +0900
parents 5d9d0bd2fee4
children e9005fc9b913
files src/alice/test/codesegment/local/TestCodeSegment.java src/alice/test/topology/share/CheckLocalIndex.java src/alice/test/topology/share/CheckMyName.java src/alice/test/topology/share/CheckNeedLocalUpdate.java src/alice/test/topology/share/CheckNeedParentUpdate.java src/alice/test/topology/share/CheckParentIndex.java src/alice/test/topology/share/RelayPoint.java
diffstat 7 files changed, 56 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/test/codesegment/local/TestCodeSegment.java	Thu Jun 28 03:43:56 2012 +0900
+++ b/src/alice/test/codesegment/local/TestCodeSegment.java	Mon Jul 02 11:16:01 2012 +0900
@@ -20,11 +20,13 @@
 	public void run() {
 		System.out.println("index = " + arg1.index);
 		System.out.println("data = " + arg1.val);
+		System.out.println("data = " + arg1.asClass(FishPoint.class));
 		System.out.println(arg1.val.getType());
+		/*
 		FishPoint PD = this.arg1.asClass(FishPoint.class);
 		
 		PD.setXY(PD.getX()+1,PD.getY()+1);
-		
+		*/
 		if (arg1.index == 10) {
 			System.exit(0);
 			return;
@@ -35,7 +37,7 @@
 		*/
 		new TestCodeSegment(arg1.index);
 		// DataSegment.get("local").update
-		ods.update("local", "key1", PD);
+		ods.update("local", "key1", this.arg1.asClass(FishPoint.class));
 	}
 
 }
--- a/src/alice/test/topology/share/CheckLocalIndex.java	Thu Jun 28 03:43:56 2012 +0900
+++ b/src/alice/test/topology/share/CheckLocalIndex.java	Mon Jul 02 11:16:01 2012 +0900
@@ -6,24 +6,19 @@
 
 public class CheckLocalIndex extends CodeSegment {
 
-	private Receiver localX = ids.create(CommandType.PEEK);
-	private Receiver parentX = ids.create(CommandType.PEEK);
+	private Receiver local = ids.create(CommandType.PEEK);
 	String key;
 	
-	public CheckLocalIndex(String key){
+	public CheckLocalIndex(String key, int index){
 		this.key = key;
-		this.localX.setKey("local", this.key, this.localX.index);
-		this.parentX.setKey("parent",this.key);
+		this.local.setKey("local", this.key, index);
 	}
 	
 	@Override
 	public void run() {
-		System.out.println("index: "+this.localX.index + " value: "+this.localX.asInteger());
-		if (this.localX.index > this.parentX.index)
-			ods.update("parent", this.key, this.localX.asInteger());
-		new CheckLocalIndex(this.key);
-		
-		
+		System.out.println("index: "+this.local.index + " value: "+this.local.val);
+		new CheckNeedParentUpdate(this.key, local);
+						
 	}
 
 }
--- a/src/alice/test/topology/share/CheckMyName.java	Thu Jun 28 03:43:56 2012 +0900
+++ b/src/alice/test/topology/share/CheckMyName.java	Mon Jul 02 11:16:01 2012 +0900
@@ -6,11 +6,14 @@
 import alice.codesegment.CodeSegment;
 import alice.datasegment.CommandType;
 import alice.datasegment.Receiver;
+import alice.test.topology.movement.FishPoint;
 
 public class CheckMyName extends CodeSegment {
 	Receiver host = ids.create(CommandType.PEEK);
 	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
 	
+	String key = "fish";
+	
 	public CheckMyName(){
 		host.setKey("local","host");
 	}
@@ -28,8 +31,9 @@
 		
 		if (type.equals("cli")){
 			System.out.println("cli"+cliNum);
-			ods.update("local", "fish", 0);
-			new RelayPoint("fish");
+			ods.update("local", this.key, new FishPoint(0.0f,0.0f));
+			new CheckLocalIndex(this.key,0);
+			new CheckParentIndex(this.key,0);
 			
 			
 									
@@ -37,19 +41,20 @@
 			
 			System.out.println("node"+cliNum);
 			if (cliNum == 0){
-				for (int i = 0; i < 20; i++) {
-					System.out.println("i = " + i);
-					ods.update("local", "fish", i);
-					try {
+				try {
+					for (float i = 0.0f; i < 2.0f; i +=0.1f) {
+						System.out.println("i = " + i);
+						ods.update("local", "fish", new FishPoint(i,i));
 						wait(500);
-					} catch (InterruptedException e) {
-						
-						e.printStackTrace();
-					}
+					} 
+				}catch (InterruptedException e) {
+					
+					e.printStackTrace();
 				}
 			}else{
-				ods.update("local", "fish", 0);
-				new RelayPoint("fish");
+				ods.update("local", this.key, new FishPoint(0.0f,0.0f));
+				new CheckLocalIndex(this.key,0);
+				new CheckParentIndex(this.key,0);
 				
 			}
 						
--- a/src/alice/test/topology/share/CheckNeedLocalUpdate.java	Thu Jun 28 03:43:56 2012 +0900
+++ b/src/alice/test/topology/share/CheckNeedLocalUpdate.java	Mon Jul 02 11:16:01 2012 +0900
@@ -3,27 +3,27 @@
 import alice.codesegment.CodeSegment;
 import alice.datasegment.CommandType;
 import alice.datasegment.Receiver;
+import alice.test.topology.movement.FishPoint;
 
 public class CheckNeedLocalUpdate extends CodeSegment {
 
-	private Receiver localX = ids.create(CommandType.PEEK);
-	int parentValue;
-	int parentIndex;
+	private Receiver local = ids.create(CommandType.PEEK);
+	private Receiver parent;
 	String key;
 	
-	public CheckNeedLocalUpdate(String key,int index,int value){
+	public CheckNeedLocalUpdate(String key, Receiver parent) {
 		this.key = key;
-		this.parentValue = value;
-		this.parentIndex = index;
-		this.localX.setKey("local", this.key);
+		this.parent = parent;
+		this.local.setKey("local", this.key);
 	}
-	
+
 	@Override
 	public void run() {
-		if (this.parentIndex > this.localX.index){
-			ods.update("local", this.key, this.parentValue);
+		if (this.parent.index > this.local.index){
+			System.out.println("local is updated");
+			ods.update("local", this.key, this.parent.asClass(FishPoint.class));
 		}
-		new CheckParentIndex(this.key);
+		new CheckParentIndex(this.key ,this.parent.index);
 		
 	}
 
--- a/src/alice/test/topology/share/CheckNeedParentUpdate.java	Thu Jun 28 03:43:56 2012 +0900
+++ b/src/alice/test/topology/share/CheckNeedParentUpdate.java	Mon Jul 02 11:16:01 2012 +0900
@@ -3,23 +3,27 @@
 import alice.codesegment.CodeSegment;
 import alice.datasegment.CommandType;
 import alice.datasegment.Receiver;
+import alice.test.topology.movement.FishPoint;
 
 public class CheckNeedParentUpdate extends CodeSegment {
 
-	private Receiver parentX = ids.create(CommandType.PEEK);
-	int localX;
+	private Receiver parent = ids.create(CommandType.PEEK);
+	private Receiver local;
 	String key;
 	
-	public CheckNeedParentUpdate(String key ,int localX){
+	public CheckNeedParentUpdate(String key ,Receiver local){
 		this.key = key;
-		this.parentX.setKey("parent", this.key, this.parentX.index);
+		this.local = local;
+		this.parent.setKey("parent", this.key);
 	}
-	
+
 	@Override
 	public void run() {
-		if (this.localX != this.parentX.asInteger())
-			ods.update("parent", this.key, localX);
-		new CheckLocalIndex(this.key);
+		if (this.local.index > this.parent.index){
+			System.out.println("parent is updated");
+			ods.update("parent", this.key, this.local.asClass(FishPoint.class));
+		}
+		new CheckLocalIndex(this.key,this.local.index);
 		
 	}
 
--- a/src/alice/test/topology/share/CheckParentIndex.java	Thu Jun 28 03:43:56 2012 +0900
+++ b/src/alice/test/topology/share/CheckParentIndex.java	Mon Jul 02 11:16:01 2012 +0900
@@ -6,24 +6,17 @@
 
 public class CheckParentIndex extends CodeSegment {
 
-	public Receiver parentX = ids.create(CommandType.PEEK);
-	public Receiver localX = ids.create(CommandType.PEEK);
+	public Receiver parent = ids.create(CommandType.PEEK);
 	String key;
 		
-	public CheckParentIndex(String key){
+	public CheckParentIndex(String key ,int index){
 		this.key = key;
-		this.parentX.setKey("parent", this.key, this.parentX.index);
-		this.localX.setKey("local",this.key);
+		this.parent.setKey("parent", this.key, index);
 	}
 	
 	@Override
 	public void run() {
-		System.out.println("parents.index: "+this.parentX.index +"parents.value: "+this.parentX.asInteger());
-		System.out.println("local.index: "+this.localX.index + " local.value: "+this.localX.asInteger());
-		if (this.parentX.index > this.localX.index)
-			ods.update("local", this.key, this.parentX.asInteger());
-		//new CheckNeedLocalUpdate(this.key,this.parentX.index,this.parentX.asInteger());
-		new CheckParentIndex(this.key);
+		new CheckNeedLocalUpdate(this.key, parent);
 	}
 
 }
--- a/src/alice/test/topology/share/RelayPoint.java	Thu Jun 28 03:43:56 2012 +0900
+++ b/src/alice/test/topology/share/RelayPoint.java	Mon Jul 02 11:16:01 2012 +0900
@@ -17,8 +17,8 @@
 	@Override
 	public void run() {
 		System.out.println("run RelayPoint");	
-		new CheckLocalIndex(this.key);
-		new CheckParentIndex(this.key);
+		new CheckLocalIndex(this.key,0);
+		new CheckParentIndex(this.key,0);
 	}
 
 }