public async void RunMacro(int index) { if (Switcher != null) { while (true) { if (nextMacroRun <= DateTime.Now) { nextMacroRun = DateTime.Now.Add(macroWaitTime); IBMDSwitcherMacroControl macroControl = (IBMDSwitcherMacroControl)Switcher; macroControl.Run(Convert.ToUInt32(index)); return; } else { await Task.Delay(TimeSpan.FromMilliseconds(1)); } } } }
public StopMacroRecord(IBMDSwitcherMacroControl ctrl) { _ctrl = ctrl; }
public void AutoTestMacroOps() { using (var helper = new AtemComparisonHelper(Client, Output)) { IBMDSwitcherMacroControl ctrl = GetMacroControl(); var failures = new List <string>(); Assembly assembly = typeof(ICommand).GetTypeInfo().Assembly; IEnumerable <Type> types = assembly.GetTypes().Where(t => typeof(SerializableCommandBase).GetTypeInfo().IsAssignableFrom(t)); foreach (Type type in types) { if (type == typeof(SerializableCommandBase)) { continue; } /* * if (type != typeof(AuxSourceSetCommand)) * continue;*/ try { Output.WriteLine("Testing: {0}", type.Name); for (int i = 0; i < 10; i++) { SerializableCommandBase raw = (SerializableCommandBase)RandomPropertyGenerator.Create(type, (o) => AvailabilityChecker.IsAvailable(helper.Profile, o)); // TODO - wants to be ICommand IEnumerable <MacroOpBase> expectedOps = raw.ToMacroOps(ProtocolVersion.Latest); if (expectedOps == null) { Output.WriteLine("Skipping"); break; } using (new StopMacroRecord(ctrl)) // Hopefully this will stop recording if it exceptions { ctrl.Record(0, string.Format("record-{0}-{1}", type.Name, i), ""); helper.SendCommand(raw); helper.Sleep(20); } helper.Sleep(40); byte[] r = DownloadMacro(0); if (r.Length == 0) { throw new Exception("Macro has no operations"); } MacroOpBase decoded = MacroOpManager.CreateFromData(r, false); // This is assuming that there is a single macro op RandomPropertyGenerator.AssertAreTheSame(expectedOps.Single(), decoded); } } catch (Exception e) { var msg = string.Format("{0}: {1}", type.Name, e.Message); Output.WriteLine(msg); failures.Add(msg); } } Assert.Empty(failures); } }