Mercurial > hg > Applications > AliceVNC
changeset 40:47d6f7a76b86
for measurement
author | sugi |
---|---|
date | Mon, 08 Dec 2014 22:05:56 +0900 |
parents | dcc90f91f804 |
children | 1cb529b46876 |
files | src/main/java/jp/ac/u_ryukyu/alicevnc/AliceVNC.java src/main/java/jp/ac/u_ryukyu/alicevnc/AliceVNCConfig.java src/main/java/jp/ac/u_ryukyu/alicevnc/MeasurementData.java src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveMeasurement.java src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveUpdateRectangle.java src/main/java/jp/ac/u_ryukyu/alicevnc/StartAliceVNC.java |
diffstat | 6 files changed, 109 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/alicevnc/AliceVNC.java Mon Dec 08 16:43:39 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/alicevnc/AliceVNC.java Mon Dec 08 22:05:56 2014 +0900 @@ -12,6 +12,7 @@ public void run() { ods.put("AliceVNCConfig", conf); + new ReceiveMeasurement(); new CheckMyName(); }
--- a/src/main/java/jp/ac/u_ryukyu/alicevnc/AliceVNCConfig.java Mon Dec 08 16:43:39 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/alicevnc/AliceVNCConfig.java Mon Dec 08 22:05:56 2014 +0900 @@ -5,6 +5,7 @@ public class AliceVNCConfig extends TopologyNodeConfig { private boolean change = true; private boolean debug = false; + private String path; public AliceVNCConfig(String[] args) { super(args); @@ -13,6 +14,8 @@ change = false; } else if ("--debug".equals(args[i])) { debug = true; + } else if ("--file".equals(args[i])) { + path = args[++i]; } } } @@ -24,4 +27,8 @@ public boolean debugMode(){ return debug; } + + public String getFilePath() { + return path; + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/alicevnc/MeasurementData.java Mon Dec 08 22:05:56 2014 +0900 @@ -0,0 +1,13 @@ +package jp.ac.u_ryukyu.alicevnc; + +import org.msgpack.annotation.Message; + +@Message +public class MeasurementData { + + public int depth; + public long time; + public long size; + + public MeasurementData(){} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveMeasurement.java Mon Dec 08 22:05:56 2014 +0900 @@ -0,0 +1,64 @@ +package jp.ac.u_ryukyu.alicevnc; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class ReceiveMeasurement extends CodeSegment { + + private Receiver info = ids.create(CommandType.TAKE); + private Receiver info1 = ids.create(CommandType.PEEK); + private Receiver info2 = ids.create(CommandType.PEEK); + + public ReceiveMeasurement() { + info.setKey("measurement"); + info1.setKey("_CLIST"); + info2.setKey("AliceVNCConfig"); + } + + @SuppressWarnings("unchecked") + @Override + public void run() { + ArrayList<String> clist = info1.asClass(ArrayList.class); + boolean route = true; + for (String node : clist){ + if ("parent".equals(node)) { + route = false; + break; + } + } + + try { + if (route) { + AliceVNCConfig conf = info2.asClass(AliceVNCConfig.class); + if (conf.getFilePath()!=null) { + File file = new File(conf.getFilePath()); + if (!file.exists()) { + file.createNewFile(); + } + FileWriter filewriter = new FileWriter(file, true); + BufferedWriter bw = new BufferedWriter(filewriter); + PrintWriter pw = new PrintWriter(bw); + + MeasurementData md = info.asClass(MeasurementData.class); + pw.println(md.depth+" "+md.time+" "+md.size); + pw.close(); + } + } else { + ods.put("parent", info.key, info.getReceiveData()); + } + + } catch (IOException e) { + + } + this.recycle(); + } + +}
--- a/src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveUpdateRectangle.java Mon Dec 08 16:43:39 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveUpdateRectangle.java Mon Dec 08 22:05:56 2014 +0900 @@ -12,6 +12,7 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; +import alice.datasegment.ReceiveData; import alice.datasegment.Receiver; public class ReceiveUpdateRectangle extends CodeSegment{ @@ -30,6 +31,16 @@ @Override public void run() { + // for measurement; + long time = System.currentTimeMillis(); + MeasurementData md = null; + if (info2.getReceiveData().setTime) { + ReceiveData r = info2.getReceiveData(); + md = new MeasurementData(); + md.depth = r.depth; + md.time = time - r.time; + md.size = ((byte[])info2.getObj()).length; + } // send other node @SuppressWarnings("unchecked") ArrayList<String> clist = info3.asClass(ArrayList.class); @@ -39,11 +50,18 @@ // Data Segment from other node is already serialized ods.put(node, "updateRectangle", info1.getReceiveData()); //TODO need timeout counter //ods.setCompressFlag(true); + + // for measurement + ReceiveData r = info2.getReceiveData(); + if (!r.setTime) { + r.setTime = true; + r.time = System.currentTimeMillis(); + } ods.put(node, "pixelData", info2.getReceiveData()); ods.setCompressFlag(false); } + } - } try { RenderAndControllerHolder holder = info.asClass(RenderAndControllerHolder.class); @@ -76,6 +94,10 @@ holder.getRepaintController().repaintCursor(); } + // for measurement + if (md !=null) + ods.put("parent", "measurement", md); + this.recycle(); //TODO } catch (TransportException e) {
--- a/src/main/java/jp/ac/u_ryukyu/alicevnc/StartAliceVNC.java Mon Dec 08 16:43:39 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/alicevnc/StartAliceVNC.java Mon Dec 08 22:05:56 2014 +0900 @@ -17,6 +17,7 @@ if (conf.getManagerHostName() ==null){ conf.setManagerHostName("firefly.cr.ie.u-ryukyu.ac.jp"); + conf.setManagerPort(10000); } new TopologyNode(conf, cs);