changeset 47:61ec3dd0995c

bug fixing
author riono <e165729@ie.u-ryukyu.ac.jp>
date Mon, 10 Jan 2022 00:45:32 +0900
parents 41aae40a611c
children 6e5c0977d756
files Test/Example/FizzBuzz/Counter.cs Test/Example/FizzBuzz/FizzBuzz.cs Test/Example/FizzBuzz/StartFizzBuzz.cs Test/Example/Roop/PrintNumber.cs Test/Example/Roop/StartRoop.cs daemon/Connection.cs daemon/IncomingTcpConnection.cs daemon/ThreadPoolExecutors.cs datagear/LocalDataGearManager.cs datagear/RemoteDataGearManager.cs
diffstat 10 files changed, 63 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/Test/Example/FizzBuzz/Counter.cs	Fri Jan 07 19:38:49 2022 +0900
+++ b/Test/Example/FizzBuzz/Counter.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -5,13 +5,14 @@
 
 namespace Christie_net.Test.Example.FizzBuzz {
 public class Counter: CodeGear {
-    [Take] private int cunt;
+    [Take] private int count;
     
     public override void Run(CodeGearManager cgm) {
-        if (cunt <= 100) {
-            Console.WriteLine("cunt;" + cunt);
-            GetDgm("FizzBuzz").Put("num", cunt);
-            cgm.GetLocalDGM().Put("cunt", cunt+1);
+        if (count <= 100) {
+            GetDgm("FizzBuzz").Put("num", count);
+            //cgm.GetLocalDGM().Put("cunt", count+1);
+            Console.WriteLine("cunt:" + count);
+
             cgm.Setup(new Counter());
         } else {
             GetDgm("FizzBuzz").Put("num", -1);
--- a/Test/Example/FizzBuzz/FizzBuzz.cs	Fri Jan 07 19:38:49 2022 +0900
+++ b/Test/Example/FizzBuzz/FizzBuzz.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -18,6 +18,7 @@
         } else {
             Console.WriteLine(num);
         }
+        GetDgm("Counter").Put("count", num+1);
         cgm.Setup(new FizzBuzz());
     }
 }
--- a/Test/Example/FizzBuzz/StartFizzBuzz.cs	Fri Jan 07 19:38:49 2022 +0900
+++ b/Test/Example/FizzBuzz/StartFizzBuzz.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -14,7 +14,8 @@
         counter.Setup(new Counter());
         fizzbuzz.Setup(new FizzBuzz());
         counter.CreateRemoteDGM("FizzBuzz", "localhost", 10002);
-        counter.GetLocalDGM().Put("cunt", 3);
+        fizzbuzz.CreateRemoteDGM("Counter", "localhost", 10001);
+        counter.GetLocalDGM().Put("count", 1);
     }
 }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/Example/Roop/PrintNumber.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -0,0 +1,19 @@
+using System;
+using Christie_net.annotation;
+using Christie_net.codegear;
+
+namespace Christie_net.Test.Example.Loop {
+public class PrintNumber: CodeGear {
+    [Take] public int count;
+    
+    public override void Run(CodeGearManager cgm) {
+       Console.WriteLine(count);
+       if (count <= 10) {
+           cgm.Setup(new PrintNumber());
+           Put("count", count + 1);
+       } else {
+           cgm.GetLocalDGM().Finish();
+       }
+    }
+}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/Example/Roop/StartRoop.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -0,0 +1,16 @@
+using Christie_net.codegear;
+
+namespace Christie_net.Test.Example.Loop {
+public class StartRoop: StartCodeGear {
+    public StartRoop(CodeGearManager cgm) : base(cgm) { }
+
+    public static void Main() {
+        StartRoop roop = new StartRoop(CreateCgm(10000));
+    }
+
+    public override void Run(CodeGearManager cgm) {
+       cgm.Setup(new PrintNumber());
+       Put("count", 1);
+    }
+}
+}
\ No newline at end of file
--- a/daemon/Connection.cs	Fri Jan 07 19:38:49 2022 +0900
+++ b/daemon/Connection.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -55,16 +55,14 @@
     public void Write(Command cmd) {
         // Debug
         //RTCommand rtcmd = (RTCommand)cmd.dg.GetData();
-        //Console.WriteLine("length:" + rtcmd.line);
+        //Console.WriteLine("length:" + cmd.dg);
         
         byte[] buffer = cmd.Convert();
 
         try {
-            while (buffer.Length > 0) {
-                stream.Write(buffer);
-            }
+            stream.Write(buffer);
         } catch (Exception e) {
-            Console.WriteLine(e.StackTrace); 
+            Console.WriteLine(e.StackTrace);
         }
     }
 }
--- a/daemon/IncomingTcpConnection.cs	Fri Jan 07 19:38:49 2022 +0900
+++ b/daemon/IncomingTcpConnection.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -31,16 +31,11 @@
     public void Run() {
         //TODO: Data長がわからないので1024で仮置き → ぴったしで読み込む必要がある
         byte[] streamData = new byte[1024];
-        
         try {
             connection.stream.Read(streamData);
         } catch (Exception e) {
             Console.WriteLine(e);
         }
-
-        // if (memoryData == null) {
-        //     return;
-        // }
         
         while (true) {
             try {
@@ -49,14 +44,14 @@
 
                 // Debug
                 //Console.WriteLine("length: " + dataLength);
-                
+
                 RemoteMessage msg = MessagePackSerializer.Deserialize<RemoteMessage>(streamData);
                 CommandType type = CommandTypeExt.GetCommandTypeFormId(msg.type);
-                
+
                 // Debug
                 //Console.WriteLine("incoming:" + msg.type);
                 byte[] data;
-               
+
                 switch (type) {
                     case CommandType.PUT:
                         //data = new byte[MessagePackSerializer.Deserialize<int>(deserializeCommand)];
@@ -66,7 +61,7 @@
                         try {
                             MessagePackDataGear<object> dg =
                                 new MessagePackDataGear<object>(data, Type.GetType(msg.clazz));
-                           
+
                             // Debug
                             // var ty = Type.GetType(msg.clazz);
                             // var obj = MessagePackSerializer.Deserialize<dynamic>(msg.data);
@@ -76,11 +71,11 @@
                             // foreach (var VARIABLE in test) {
                             //     Console.WriteLine("key:" + VARIABLE.Key + " val:" + VARIABLE.Value);
                             // }
-                            
+
                             //RTCommand cmd = (RTCommand) obj;
                             //Console.WriteLine("***type:" + msg.type +  " key:" + msg.key + " fromDgm:" + msg.fromDmgName + " class:" + msg.clazz);
-                           //Console.WriteLine("data :" + cmd.line);
-                            
+                            //Console.WriteLine("data :" + cmd.line);
+
                             cgm.GetLocalDGM().Put(msg.key, dg);
                         } catch (TypeLoadException e) {
                             Console.WriteLine(e.StackTrace);
@@ -102,7 +97,7 @@
                         break;
                     case CommandType.REPLY: // 待っていたwaitlistに渡してcsにセット
                         data = msg.data;
-                        
+
                         // data = new byte[MessagePackSerializer.Deserialize<int>(streamData)];
                         // connection.socket.Receive(data);
 
--- a/daemon/ThreadPoolExecutors.cs	Fri Jan 07 19:38:49 2022 +0900
+++ b/daemon/ThreadPoolExecutors.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -19,6 +19,11 @@
     
     public void Execute(CodeGearExecutor command) {
         Task.Factory.StartNew(() => command.Run());
+        // Thread thread = new Thread(() => {
+        //     command.Run();
+        // });
+        //
+        // thread.Start();
     }
 }
 }
\ No newline at end of file
--- a/datagear/LocalDataGearManager.cs	Fri Jan 07 19:38:49 2022 +0900
+++ b/datagear/LocalDataGearManager.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -26,7 +26,8 @@
     public override void RunCommand(Command cm) {
         switch (cm.type) {
             case CommandType.PUT:
-                Console.WriteLine("data:" + cm.key + "  dg:"  + cm.dg.GetData().ToString());
+                // Debug
+                //Console.WriteLine("data:" + cm.key + "  dg:"  + cm.dg.GetData().ToString());
                 dataGears.SetData(cm);
                 if (waitList.ContainsKey(cm.key)) {
                     RunCommand(waitList.GetAndRemoveCommand(cm.key));
--- a/datagear/RemoteDataGearManager.cs	Fri Jan 07 19:38:49 2022 +0900
+++ b/datagear/RemoteDataGearManager.cs	Mon Jan 10 00:45:32 2022 +0900
@@ -73,7 +73,7 @@
         }
        
         // Debug
-        Console.WriteLine("connect:" + connection.name);
+        //Console.WriteLine("connect:" + connection.name);
         //Console.WriteLine("data:" + cmd.command);
         
         connection.Write(cm);