private static LinkUpNode CreateNode(LinkUpNode masterNode, string name) { LinkUpNode node = new LinkUpNode(); node.Name = name; BlockingCollection <byte[]> col1 = new BlockingCollection <byte[]>(); BlockingCollection <byte[]> col2 = new BlockingCollection <byte[]>(); LinkUpMemoryConnector slaveToMaster = new LinkUpMemoryConnector(col1, col2); LinkUpMemoryConnector masterToSlave = new LinkUpMemoryConnector(col2, col1); node.MasterConnector = slaveToMaster; masterNode.AddSubNode(masterToSlave); node.AddLabel <LinkUpPropertyLabel <int> >("val1"); node.AddLabel <LinkUpPropertyLabel <int> >("val2"); return(node); }
private static void Main(string[] args) { LinkUpUdpConnector clientToServer = new LinkUpUdpConnector(IPAddress.Parse("127.0.0.1"), IPAddress.Parse("127.0.0.1"), 2000, 1000); clientToServer.ReveivedPacket += ClientToServer_ReveivedPacket; LinkUpNode node = new LinkUpNode(); node.Name = "leaf"; node.MasterConnector = clientToServer; LinkUpPropertyLabel <int> val1 = node.AddLabel <LinkUpPropertyLabel <int> >("val1"); val1.Value = 1213; Console.Read(); }
private static void Main(string[] args) { LinkUpUdpConnector apiConnector = new LinkUpUdpConnector(IPAddress.Parse("127.0.0.1"), IPAddress.Parse("127.0.0.1"), 1000, 2000); apiConnector.ReveivedPacket += ReveivedPacket; apiConnector.SentPacket += SentPacket; masterNode.Name = "master"; masterNode.MasterConnector = apiConnector; masterNode.AddLabel <LinkUpPropertyLabel <int> >("val1"); LinkUpNode slave1 = CreateNode(masterNode, "slave1"); LinkUpNode slave2 = CreateNode(masterNode, "slave2"); LinkUpNode slaveSlave1 = CreateNode(slave1, "slave11"); Timer t = new Timer(500); t.Elapsed += T_Elapsed; t.Start(); Console.Read(); }
private static void StaticTest2() { BlockingCollection <byte[]> col1 = new BlockingCollection <byte[]>(); BlockingCollection <byte[]> col2 = new BlockingCollection <byte[]>(); BlockingCollection <byte[]> col3 = new BlockingCollection <byte[]>(); BlockingCollection <byte[]> col4 = new BlockingCollection <byte[]>(); LinkUpMemoryConnector masterToSlave = new LinkUpMemoryConnector(col1, col2); LinkUpMemoryConnector slaveToMaster = new LinkUpMemoryConnector(col2, col1); LinkUpMemoryConnector masterToSuper = new LinkUpMemoryConnector(col3, col4); LinkUpMemoryConnector superToMaster = new LinkUpMemoryConnector(col4, col3); masterToSlave.ReveivedPacket += MasterToSlave_ReveivedPacket; slaveToMaster.ReveivedPacket += SlaveToMaster_ReveivedPacket; masterToSuper.ReveivedPacket += MasterToSuper_ReveivedPacket; superToMaster.ReveivedPacket += SuperToMaster_ReveivedPacket; LinkUpNode super = new LinkUpNode(); super.AddSubNode(superToMaster); super.Name = "super"; LinkUpNode master = new LinkUpNode(); master.AddSubNode(masterToSlave); master.MasterConnector = masterToSuper; master.Name = "master"; LinkUpNode slave = new LinkUpNode(); slave.MasterConnector = slaveToMaster; slave.Name = "slave"; LinkUpPropertyLabel <int> value2 = master.AddLabel <LinkUpPropertyLabel <int> >("value2"); LinkUpPropertyLabel <int> value1 = slave.AddLabel <LinkUpPropertyLabel <int> >("value1"); value1.Value = 10; value2.Value = 1011; Console.WriteLine("Continue after init!"); Console.ReadLine(); LinkUpPropertyLabel <int> value1Ref = (LinkUpPropertyLabel <int>)master.Labels.FirstOrDefault(c => c.Name == "master/slave/value1"); Console.WriteLine("value1Ref: " + value1Ref.Value); value1Ref.Value = 123; Console.WriteLine("value1: " + value1.Value); value1Ref.Value = 10; Console.WriteLine("value1: " + value1.Value); LinkUpPropertyLabel <int> value1RefSuper = (LinkUpPropertyLabel <int>)super.Labels.FirstOrDefault(c => c.Name == "super/master/slave/value1"); Console.WriteLine("value1RefSuper: " + value1RefSuper.Value); value1RefSuper.Value = 123; Console.WriteLine("value1: " + value1.Value); value1RefSuper.Value = 10; Console.WriteLine("value1: " + value1.Value); LinkUpPropertyLabel <int> value2RefSuper = (LinkUpPropertyLabel <int>)super.Labels.FirstOrDefault(c => c.Name == "super/master/value2"); Console.WriteLine("value2RefSuper: " + value2RefSuper.Value); value2RefSuper.Value = 1245; Console.WriteLine("value2: " + value2.Value); value2RefSuper.Value = 1152; Console.WriteLine("value2: " + value2.Value); Console.WriteLine("done"); Console.ReadLine(); }