# HG changeset patch # User riono # Date 1641743132 -32400 # Node ID 61ec3dd0995c8bd3a78dfd12fdf38518853a9616 # Parent 41aae40a611c9c3278d271b1bc1d6bcbc6e56f6c bug fixing diff -r 41aae40a611c -r 61ec3dd0995c Test/Example/FizzBuzz/Counter.cs --- 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); diff -r 41aae40a611c -r 61ec3dd0995c Test/Example/FizzBuzz/FizzBuzz.cs --- 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()); } } diff -r 41aae40a611c -r 61ec3dd0995c Test/Example/FizzBuzz/StartFizzBuzz.cs --- 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 diff -r 41aae40a611c -r 61ec3dd0995c Test/Example/Roop/PrintNumber.cs --- /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 diff -r 41aae40a611c -r 61ec3dd0995c Test/Example/Roop/StartRoop.cs --- /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 diff -r 41aae40a611c -r 61ec3dd0995c daemon/Connection.cs --- 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); } } } diff -r 41aae40a611c -r 61ec3dd0995c daemon/IncomingTcpConnection.cs --- 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(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(deserializeCommand)]; @@ -66,7 +61,7 @@ try { MessagePackDataGear dg = new MessagePackDataGear(data, Type.GetType(msg.clazz)); - + // Debug // var ty = Type.GetType(msg.clazz); // var obj = MessagePackSerializer.Deserialize(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(streamData)]; // connection.socket.Receive(data); diff -r 41aae40a611c -r 61ec3dd0995c daemon/ThreadPoolExecutors.cs --- 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 diff -r 41aae40a611c -r 61ec3dd0995c datagear/LocalDataGearManager.cs --- 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)); diff -r 41aae40a611c -r 61ec3dd0995c datagear/RemoteDataGearManager.cs --- 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);