changeset 30:250ae646db7f

minor change
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Sat, 03 Feb 2018 19:23:24 +0900
parents be58bfe90766
children e29900328fff
files src/main/java/christie/datagear/LocalDataGearManager.java
diffstat 1 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/christie/datagear/LocalDataGearManager.java	Thu Feb 01 20:12:02 2018 +0900
+++ b/src/main/java/christie/datagear/LocalDataGearManager.java	Sat Feb 03 19:23:24 2018 +0900
@@ -42,23 +42,23 @@
 
                 break;
             case TAKE:
-                cm.dg.setData(dataGears.take(cm.key));
-                cm.cg.getIdg().setInputs(cm.key, cm.dg);
+                takeAndSetData(cm);
+                setInputToCG(cm);
 
                 break;
             case REMOTETAKE:
-                cm.dg.setData(dataGears.take(cm.key));
+                takeAndSetData(cm);
                 runCommand(new ReplyCommand(cm.fromDgmName, cm.key, cm.dg, cm.connection));
 
                 break;
             case PEEK:
-                cm.dg.setData(dataGears.peek(cm.key));
-                cm.cg.getIdg().setInputs(cm.key, cm.dg);
+                peekAndSetData(cm);
+                setInputToCG(cm);
 
                 break;
             case REMOTEPEEK://ToDo:implement
-                //cm.dg.setData(dataGears.get(cm.key).peek().getData());
-                //runCommand(new ReplyCommand(cm.cgmID, cm.fromDgmName, cm.key, cm.dg, cm.connection));
+                //peekAndSetData(cm);
+                //runCommand(new RemotePeekCommand(cm.cgmID, cm.fromDgmName, cm.key, cm.dg, cm.connection));
                 break;
             case REPLY:
                 cm.connection.write(cm);
@@ -66,4 +66,16 @@
         }
     }
 
+    private void takeAndSetData(Command cm){
+        cm.dg.setData(dataGears.take(cm.key));
+    }
+
+    private void peekAndSetData(Command cm){
+        cm.dg.setData(dataGears.peek(cm.key));
+    }
+
+    private void setInputToCG(Command cm){
+        cm.cg.getIdg().setInputs(cm.key, cm.dg);
+    }
+
 }