static void Main() { // Lokomotive: 18 527 DRG int locToTrigger = 1000; uint objectFuncIdx = 2; // S88 Feedback: FB3 int s88id = 102; uint s88pin = 16; Locomotive locItem = null; S88 s88Item = null; var ws = new WsConnect(); ws.WsData += (sender, dp) => { if (dp.GetObjectBy(s88id) is S88 localS88Item) { s88Item = localS88Item; } if (dp.GetObjectBy(locToTrigger) is Locomotive localLocItem) { locItem = localLocItem; } if (s88Item == null || locItem == null) { return; } var currentState = s88Item?.Pin(s88pin); var currentPinState = currentState.GetValueOrDefault(false); locItem.ToggleFunctions(new Dictionary <uint, bool> { { objectFuncIdx, currentPinState } }); Console.WriteLine($"Name: {locItem.Name}, State: {currentPinState}"); var cmdsToSend = locItem.GetCommands() as List <string>; ws.SendCommands(cmdsToSend); }; var res = ws.ConnectTo("ws://127.0.0.1:10050", new[] { "enableS88", "enableLocomotives" }); if (res) { Console.WriteLine("Wait for data..."); } Console.CancelKeyPress += (sender, eArgs) => { QuitEvent.Set(); eArgs.Cancel = true; }; QuitEvent.WaitOne(); }