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"); }
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"); }
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"); }