public void GetMachineDescription() { var md = MpfApi.GetMachineDescription(machineFolder); availableSwitches = md.GetSwitches().ToArray(); availableCoils = md.GetCoils().ToArray(); availableLamps = md.GetLights().ToArray(); }
private void OnDmdFrame(object sender, SetDmdFrameRequest frame) { Logger.Info($"<-- dmd frame: {frame.Name}"); if (!_displaysAnnounced) { _displaysAnnounced = true; var config = _api.GetMachineDescription(); Logger.Info($"[MPF] Announcing {config.Dmds} display(s)"); foreach (var dmd in config.Dmds) { Logger.Info($"[MPF] Announcing display \"{dmd.Name}\" @ {dmd.Width}x{dmd.Height}"); lock (_dispatchQueue) { _dispatchQueue.Enqueue(() => OnDisplaysAvailable?.Invoke(this, new AvailableDisplays(new DisplayConfig(dmd.Name, dmd.Width, dmd.Height, true)))); } } Logger.Info("[MPF] Displays announced."); } lock (_dispatchQueue) { _dispatchQueue.Enqueue(() => OnDisplayFrame?.Invoke(this, new DisplayFrameData(frame.Name, DisplayFrameFormat.Dmd24, frame.FrameData()))); } }
public static async Task Main(string[] args) { var machineFolder = Path.GetFullPath(@"../../../../VisualPinball.Engine.Mpf/machine"); // Console.WriteLine("Starting..."); // var client = new MpfClient(); // client.Connect(); // client.StartGame(new Dictionary<string, bool> { // { "sw11", true } // }); // Console.WriteLine("Description = " + client.GetMachineDescription()); // Console.WriteLine("Done!"); var s = Stopwatch.StartNew(); var mpfApi = new MpfApi(machineFolder); mpfApi.Launch(new MpfConsoleOptions { //ShowLogInsteadOfConsole = true, //CatchStdOut = true, }); mpfApi.StartGame(new Dictionary <string, bool> { { "1", true }, { "2", true }, { "3", true }, { "4", true }, { "5", true }, { "6", true }, }); mpfApi.Client.OnConfigureHardwareRule += (_, request) => { Console.WriteLine($"[MPF] configure hw/rule: sw{request.SwitchNumber} -> c{request.CoilNumber} @{request.HoldPower} | pulse: {request.PulseMs}ms @{request.PulsePower}"); }; mpfApi.Client.OnRemoveHardwareRule += (_, request) => { Console.WriteLine($"[MPF] remove hw/rule: sw{request.SwitchNumber} -> c{request.CoilNumber}"); }; mpfApi.Client.OnEnableCoil += (_, request) => { Console.WriteLine($"[MPF] enable coil c{request.CoilNumber} @{request.HoldPower} | pulse: {request.PulseMs}ms @{request.PulsePower}"); }; mpfApi.Client.OnDisableCoil += (_, request) => { Console.WriteLine($"[MPF] disable coil c{request.CoilNumber}"); }; mpfApi.Client.OnPulseCoil += (_, request) => { Console.WriteLine($"[MPF] pulse coil c{request.CoilNumber} {request.PulseMs}ms @{request.PulsePower}"); }; mpfApi.Client.OnFadeLight += (_, request) => { Console.WriteLine($"[MPF] light fades ({request.CommonFadeMs}ms):"); }; mpfApi.Client.OnDmdFrame += (_, request) => { Console.WriteLine($"[MPF] new DMD frame!"); }; var descr = mpfApi.GetMachineDescription(); Console.WriteLine($"Description: {descr} in {s.ElapsedMilliseconds}ms"); ConsoleKeyInfo key; do { key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.A: await mpfApi.Switch("0", true); break; case ConsoleKey.S: await mpfApi.Switch("0", false); break; } } while (key.Key != ConsoleKey.Escape); mpfApi.Dispose(); }