Ejemplo n.º 1
0
        protected override void Run(string[] args)
        {
            AutoResetEvent waiter = new AutoResetEvent(false);
            int            data   = 0;
            var            clay1  = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "IN"
                },
                Response = (center, clay, cp) =>
                {
                    center["OUT"] = (center.GetSignal <int>("IN") + 1);
                }
            });

            var clay2 = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "IN"
                },
                Response = (center, clay, cp) =>
                {
                    center["OUT"] = (center.GetSignal <int>("IN") * 2);
                }
            });


            var clay3 = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "A", "B"
                },
                Response = (center, clay, cp) =>
                {
                    data = center.GetSignal <int>("A") + center.GetSignal <int>("B");
                    waiter.Set();
                }
            });

            var start = new Starter();

            var con1 = Conduit.CreateLink(new LinkDef(clay1, "IN"), new LinkDef(clay2, "IN"));
            var con2 = new Conduit();

            con2.Link(new LinkDef(start, "OUT"));

            con1.Link(new LinkDef(con2, "X"));

            Conduit.CreateLink(new LinkDef(clay1, "OUT"), new LinkDef(clay3, "A"));
            Conduit.CreateLink(new LinkDef(clay2, "OUT"), new LinkDef(clay3, "B"));

            start.Test(3);

            waiter.WaitOne();
            Assert(data == 10, "Data supposed to be");
        }
Ejemplo n.º 2
0
        protected override void Run(string[] args)
        {
            var waiter = new AutoResetEvent(false);
            var a1     = new Add2Number();
            var t1     = new Times2Number();
            var t2     = new Times2Number();

            var s1 = new Starter();
            var s2 = new Starter();

            Conduit.CreateLink(t1, "O", a1, "A");
            Conduit.CreateLink(t2, "O", a1, "B");

            float data = 0;

            SClay sclay = new SClay(new SAgreement
            {
                LayoutMap = new Dictionary <object, object[]> {
                    { "X", new object[] { t1, "A" } },
                    { "Y", new object[] { t2, "A" } },
                    { "O", new object[] { a1, "O" } }
                }
            });

            var vclay = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "IN"
                },

                Response = (center, clay, sp) =>
                {
                    data = center.GetSignal <float>("IN");
                    waiter.Set();
                }
            });

            Conduit.CreateLink(sclay, "X", s1, "OUT");
            Conduit.CreateLink(sclay, "Y", s2, "OUT");
            Conduit.CreateLink(sclay, "O", vclay, "IN");

            s1.Test(.4f);
            s2.Test(.5f);
            waiter.WaitOne();
            Assert(data == 1.8f, "Supposed to be 1.8");
        }
Ejemplo n.º 3
0
        protected override void Run(string[] args)
        {
            var waiter = new AutoResetEvent(false);


            int data  = 0;
            var clay1 = new Starter();
            var clay2 = new Starter();
            var clay3 = new Starter();

            var clayx = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "A", "B", "C"
                },
                Response = (center, clay, cp) => {
                    var A = center.GetSignal <int>("A");
                    var B = center.GetSignal <int>("B");
                    var C = center.GetSignal <int>("C");
                    data  = A + B + C;
                    waiter.Set();
                }
            });

            Conduit.CreateLink(new LinkDef[] {
                new LinkDef(clay1, "OUT"),
                new LinkDef(clayx, "A")
            });
            Conduit.CreateLink(new LinkDef[] {
                new LinkDef(clay2, "OUT"),
                new LinkDef(clayx, "B")
            });
            Conduit.CreateLink(new LinkDef[] {
                new LinkDef(clay3, "OUT"),
                new LinkDef(clayx, "C")
            });



            clay1.Test(1);
            clay2.Test(2);
            clay3.Test(3);

            waiter.WaitOne();
            Assert(data == 6, "Supposed to be 6");
        }
Ejemplo n.º 4
0
        protected override void Run(string[] args)
        {
            var waiter = new AutoResetEvent(false);


            int data  = 0;
            var clay1 = new Starter();

            var f1 = new SignalFilter(new FilterAgr
            {
                Weight = 2
            });
            var f2 = new SignalFilter(new FilterAgr
            {
                Weight = 3
            });

            var f3 = new SignalFilter(new FilterAgr {
                Weight = 4
            });



            var clayx = new RClay(new RAgreement
            {
                SensorPoints = new List <object> {
                    "A", "B", "C"
                },
                Response = (center, clay, cp) => {
                    var A = center.GetSignal <int>("A");
                    var B = center.GetSignal <int>("B");
                    var C = center.GetSignal <int>("C");
                    data  = A + B + C;
                    waiter.Set();
                }
            });

            Conduit.CreateLink(
                new LinkDef(clay1, "OUT"),
                new LinkDef(f1, "IN"),
                new LinkDef(f2, "IN"),
                new LinkDef(f3, "IN")
                );

            Conduit.CreateLink(new LinkDef[] {
                new LinkDef(f1, "OUT"),
                new LinkDef(clayx, "A")
            });
            Conduit.CreateLink(new LinkDef[] {
                new LinkDef(f2, "OUT"),
                new LinkDef(clayx, "B")
            });
            Conduit.CreateLink(new LinkDef[] {
                new LinkDef(f3, "OUT"),
                new LinkDef(clayx, "C")
            });



            clay1.Test(5);

            waiter.WaitOne();
            Assert(data == 45, "Supposed to be 45");
        }