// ANCHOR_END: association_config private static async Task RunChannel(MasterChannel channel) { // ANCHOR: association_create var association = channel.AddAssociation( 1024, GetAssociationConfig(), new TestReadHandler(), new TestAssocationHandler() ); // ANCHOR_END: association_create // ANCHOR: add_poll var poll = channel.AddPoll(association, Request.ClassRequest(false, true, true, true), TimeSpan.FromSeconds(5)); // ANCHOR_END: add_poll // start communications channel.Enable(); while (true) { switch (await GetInputAsync()) { case "x": return; case "enable": { channel.Enable(); break; } case "disable": { channel.Disable(); break; } case "dln": { channel.SetDecodeLevel(new DecodeLevel()); break; } case "dlv": { channel.SetDecodeLevel(new DecodeLevel() { Application = AppDecodeLevel.ObjectValues }); break; } case "rao": { var request = new Request(); request.AddAllObjectsHeader(Variation.Group40Var0); var result = await channel.Read(association, request); Console.WriteLine($"Result: {result}"); break; } case "rmo": { var request = new Request(); request.AddAllObjectsHeader(Variation.Group10Var0); request.AddAllObjectsHeader(Variation.Group40Var0); var result = await channel.Read(association, request); Console.WriteLine($"Result: {result}"); break; } case "cmd": { // ANCHOR: assoc_control var commands = new Commands(); commands.AddG12v1u8(3, new G12v1(new ControlCode(TripCloseCode.Nul, false, OpType.LatchOn), 1, 1000, 1000)); var result = await channel.Operate(association, CommandMode.SelectBeforeOperate, commands); Console.WriteLine($"Result: {result}"); // ANCHOR_END: assoc_control break; } case "evt": { channel.DemandPoll(poll); break; } case "lts": { var result = await channel.SynchronizeTime(association, TimeSyncMode.Lan); Console.WriteLine($"Result: {result}"); break; } case "nts": { var result = await channel.SynchronizeTime(association, TimeSyncMode.NonLan); Console.WriteLine($"Result: {result}"); break; } case "crt": { var result = await channel.ColdRestart(association); Console.WriteLine($"Result: {result}"); break; } case "wrt": { var result = await channel.WarmRestart(association); Console.WriteLine($"Result: {result}"); break; } case "lsr": { var result = await channel.CheckLinkStatus(association); Console.WriteLine($"Result: {result}"); break; } default: Console.WriteLine("Unknown command"); break; } } }