annotate datagear/command/CommandType.cs @ 23:46cfeb0609c5

Add TcpConnections
author riono <e165729@ie.u-ryukyu.ac.jp>
date Tue, 15 Dec 2020 22:11:40 +0900
parents 8fe565f8acb8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
5c334a1fbc5e fix blanks
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
1 using System;
5
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
2 using System.Collections.Generic;
23
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
3 using Christie_net.daemon;
5
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
4
4
a6f7466473f5 add command
riono <e165729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 namespace Christie_net.datagear.command {
18
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
6 public enum CommandType {
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
7 PUT = 1,
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
8 TAKE,
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
9 PEEK,
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
10 REMOTETAKE,
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
11 REMOTEPEEK,
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
12 REPLY,
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
13 CLOSE,
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
14 FINISH
8
e6f5b7d14dd1 update DataGears
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
15 }
23
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
16
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
17 public static class CommandTypeExt {
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
18 public static Dictionary<int, CommandType> hash = new Dictionary<int, CommandType>();
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
19
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
20 static CommandTypeExt() {
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
21 foreach (CommandType value in Enum.GetValues(typeof(CommandType))) {
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
22 hash.Add((int)value, value);
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
23 }
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
24 }
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
25
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
26 public static CommandType GetCommandTypeFormId(int id) {
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
27 return hash[id];
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
28 }
46cfeb0609c5 Add TcpConnections
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
29 }
18
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
30 // public class CommandType {
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
31 // private static int lastId = 0; // コマンドの総数
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
32 // public readonly int id = ++lastId; // コマンドのid コンストラクタが呼ばれるたびにlastIdが++される
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
33 // public static readonly Dictionary<int, CommandType> hash = new Dictionary<int, CommandType>();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
34 //
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
35 // private CommandType() {
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
36 // hash.Add(this.id, this);
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
37 // }
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
38 //
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
39 // /// <summary>
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
40 // /// idよりCommandTypeを返す
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
41 // /// </summary>
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
42 // /// <param name="id"></param>
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
43 // /// <returns></returns>
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
44 // public static CommandType GetCommandTypeFromId(int id) {
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
45 // return hash[id];
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
46 // }
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
47 //
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
48 // public static readonly CommandType PUT = new CommandType();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
49 // public static readonly CommandType TAKE = new CommandType();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
50 // public static readonly CommandType PEEK = new CommandType();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
51 // public static readonly CommandType REMOTETAKE = new CommandType();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
52 // public static readonly CommandType REMOTEPEEK = new CommandType();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
53 // public static readonly CommandType REPLY = new CommandType();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
54 // public static readonly CommandType CLOSE = new CommandType();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
55 // public static readonly CommandType FINISH = new CommandType();
8fe565f8acb8 fix CommandType enum
riono <e165729@ie.u-ryukyu.ac.jp>
parents: 17
diff changeset
56 // }
4
a6f7466473f5 add command
riono <e165729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 }