Exemplo n.º 1
0
        /// <summary>回路網テスト1</summary>
        /// <remarks>2節点の流量計算</remarks>
        private static void circuitTest1()
        {
            //節点作成
            Node node1 = new Node("SampleNode1", 0, 10);
            Node node2 = new Node("SampleNode2", 0, 0);

            //流路作成・接続
            Channel channel = new Channel("SampleChannel", 2, 1.2);
            channel.Connect(node1, node2);

            //流量計算
            double flow = channel.GetFlow();

            Console.WriteLine("流量 : " + flow);
            Console.Read();
        }
Exemplo n.º 2
0
        /// <summary>節点を追加する</summary>
        /// <param name="node">追加する節点</param>
        /// <returns>追加した節点(Clone処理を行うため<paramref name="node"/>とは異なる)</returns>
        public ImmutableNode AddNode(Node node)
        {
            //複製してIDを付与
            Node newNode = (Node)node.Clone();
            newNode.ID = nodes.Count;

            //追加
            this.nodes.Add(newNode);

            //イベント通知
            if (NodeAddEvent != null) NodeAddEvent(this, new NodeEventArgs(newNode));

            return newNode;
        }
Exemplo n.º 3
0
        /// <summary>切断する</summary>
        public void Disconnect()
        {
            node1.PotentialChangeEvent -= nodeFnc;
            node2.PotentialChangeEvent -= nodeFnc;

            node1.RemoveChannel(this);
            node2.RemoveChannel(this);

            node1 = null;
            node2 = null;
        }
Exemplo n.º 4
0
        /// <summary>接点を接続する</summary>
        /// <param name="node1">接点1</param>
        /// <param name="node2">接点2</param>
        public void Connect(Node node1, Node node2)
        {
            //接続を解除
            if (this.node1 != null) Disconnect();

            this.node1 = node1;
            this.node2 = node2;

            //接点エネルギー変更イベントを登録
            node1.PotentialChangeEvent += nodeFnc;
            node2.PotentialChangeEvent += nodeFnc;

            node1.AddChannel(this);
            node2.AddChannel(this);
        }
Exemplo n.º 5
0
        /// <summary>デシリアライズ用Constructor</summary>
        /// <param name="sInfo"></param>
        /// <param name="context"></param>
        protected Channel(SerializationInfo sInfo, StreamingContext context)
        {
            //バージョン情報
            double version = sInfo.GetDouble("S_Version");

            //ID
            ID = sInfo.GetInt32("id");
            //名称
            Name = sInfo.GetString("name");
            //接点1
            node1 = (Node)sInfo.GetValue("node1", typeof(Node));
            //接点2
            node2 = (Node)sInfo.GetValue("node2", typeof(Node));
            //抵抗値
            resistance = sInfo.GetDouble("resistance");
            //抵抗指数
            eta = sInfo.GetDouble("eta");
        }
Exemplo n.º 6
0
        /// <summary>Circuit test 1</summary>
        /// <remarks>Calculating energy flow between two nodes</remarks>
        private static void circuitTest1()
        {
            //Create new instance of Node class.
            Node node1 = new Node("SampleNode1", 0, 10);
            Node node2 = new Node("SampleNode2", 0, 0);

            //Create new instance of Channel class and connect nodes.
            Channel channel = new Channel("SampleChannel", 2, 1.2);
            channel.Connect(node1, node2);

            //Calculate energy flow.
            double flow = channel.GetFlow();

            Console.WriteLine("Energy flow is : " + flow.ToString("F2"));
            Console.Read();
        }