private static void HandleTopologyCommand(AtemState state, UpdateResultImpl result, TopologyV811Command cmd) { state.Auxiliaries = UpdaterUtil.CreateList(cmd.Auxiliaries, (i) => new AuxState()); state.ColorGenerators = UpdaterUtil.CreateList(2, (i) => new ColorState()); state.DownstreamKeyers = UpdaterUtil.CreateList(cmd.DownstreamKeyers, (i) => new DownstreamKeyerState()); state.MediaPlayers = UpdaterUtil.CreateList(cmd.MediaPlayers, (i) => new MediaPlayerState()); state.SuperSources = UpdaterUtil.CreateList(cmd.SuperSource, (i) => new SuperSourceState()); state.Hyperdecks = UpdaterUtil.CreateList(cmd.HyperDecks, i => new HyperdeckState()); state.Settings.Talkback = UpdaterUtil.CreateList(cmd.TalkbackChannels, (i) => new SettingsState.TalkbackState()); state.MixEffects = UpdaterUtil.CreateList(cmd.MixEffectBlocks, (i) => { var me = new MixEffectState(); if (cmd.Stingers > 0) { me.Transition.Stinger = new MixEffectState.TransitionStingerState(); } if (cmd.DVE > 0) { me.Transition.DVE = new MixEffectState.TransitionDVEState(); } return(me); }); state.Settings.MultiViewers = UpdaterUtil.UpdateList(state.Settings.MultiViewers, cmd.Multiviewers, i => new MultiViewerState { Windows = new List <MultiViewerState.WindowState>(), // Size gets done in a second }); state.Settings.MixMinusOutputs = UpdaterUtil.CreateList(cmd.MixMinusOutputs, i => new SettingsState.MixMinusOutputState()); state.Info.AdvancedChromaKeyers = cmd.AdvancedChromaKeyers; state.Info.OnlyConfigurableOutputs = cmd.OnlyConfigurableOutputs; state.Info.HasCameraControl = cmd.CameraControl; // Everything has changed result.SetSuccess(""); }
private static void UpdateMultiViewers(AtemState state, UpdateResultImpl result, ICommand command) { if (command is MultiviewerConfigV811Command multiviewer811Cmd) { state.Info.MultiViewers = new InfoState.MultiViewInfoState { CanRouteInputs = multiviewer811Cmd.CanRouteInputs, SupportsVuMeters = multiviewer811Cmd.SupportsVuMeters, SupportsProgramPreviewSwapped = multiviewer811Cmd.CanSwapPreviewProgram, SupportsQuadrantLayout = multiviewer811Cmd.SupportsQuadrants, SupportsToggleSafeArea = multiviewer811Cmd.CanToggleSafeArea, CanChangeLayout = multiviewer811Cmd.CanChangeLayout, //CanChangeVuMeterOpacity = multiviewer811Cmd.CanChangeVuMeterOpacity, }; state.Settings.MultiViewers.ForEach(mv => mv.Windows = UpdaterUtil.UpdateList(mv.Windows, multiviewer811Cmd.WindowCount, w => new MultiViewerState.WindowState())); result.SetSuccess(new[] { $"Info.MultiViewers", $"Settings.MultiViewers" }); } else if (command is MultiviewerConfigV8Command multiview8Cmd) { state.Info.MultiViewers = new InfoState.MultiViewInfoState { CanRouteInputs = multiview8Cmd.CanRouteInputs, SupportsVuMeters = multiview8Cmd.SupportsVuMeters, SupportsProgramPreviewSwapped = multiview8Cmd.CanSwapPreviewProgram, SupportsQuadrantLayout = multiview8Cmd.SupportsQuadrants, SupportsToggleSafeArea = multiview8Cmd.CanToggleSafeArea, }; state.Settings.MultiViewers = UpdaterUtil.UpdateList(state.Settings.MultiViewers, multiview8Cmd.Count, i => new MultiViewerState { Windows = new List <MultiViewerState.WindowState>(), // Size gets done in a second }); state.Settings.MultiViewers.ForEach(mv => mv.Windows = UpdaterUtil.UpdateList(mv.Windows, multiview8Cmd.WindowCount, w => new MultiViewerState.WindowState())); result.SetSuccess(new[] { $"Info.MultiViewers", $"Settings.MultiViewers" }); } else if (command is MultiviewerConfigCommand multiviewCmd) { state.Info.MultiViewers = new InfoState.MultiViewInfoState { CanRouteInputs = multiviewCmd.CanRouteInputs, SupportsProgramPreviewSwapped = multiviewCmd.CanSwapPreviewProgram }; state.Settings.MultiViewers = UpdaterUtil.UpdateList(state.Settings.MultiViewers, multiviewCmd.Count, i => new MultiViewerState { Windows = new List <MultiViewerState.WindowState>(), // Size gets done in a second }); state.Settings.MultiViewers.ForEach(mv => mv.Windows = UpdaterUtil.UpdateList(mv.Windows, multiviewCmd.WindowCount, w => new MultiViewerState.WindowState())); result.SetSuccess(new[] { $"Info.MultiViewers", $"Settings.MultiViewers" }); } else if (command is MultiviewVuOpacityCommand vuOpacityCmd) { // HACK - dont see a real property anywhere state.Info.MultiViewers.CanChangeVuMeterOpacity = state.Info.Model != ModelId.MiniPro && state.Info.Model != ModelId.MiniProISO; UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)vuOpacityCmd.MultiviewIndex, mv => { mv.VuMeterOpacity = vuOpacityCmd.Opacity; result.SetSuccess($"Settings.MultiViewers.{vuOpacityCmd.MultiviewIndex:D}.VuMeterOpacity"); }); } else if (command is MultiviewPropertiesGetV8Command props8Cmd) { UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)props8Cmd.MultiviewIndex, mv => { mv.Properties.Layout = props8Cmd.Layout; mv.Properties.ProgramPreviewSwapped = props8Cmd.ProgramPreviewSwapped; result.SetSuccess($"Settings.MultiViewers.{props8Cmd.MultiviewIndex:D}.Properties"); }); } else if (command is MultiviewPropertiesGetCommand propsCmd) { UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)propsCmd.MultiviewIndex, mv => { if (!Enum.TryParse(propsCmd.Layout.ToString(), true, out MultiViewLayoutV8 layout)) { layout = 0; } mv.Properties.Layout = layout; mv.Properties.ProgramPreviewSwapped = propsCmd.ProgramPreviewSwapped; result.SetSuccess($"Settings.MultiViewers.{propsCmd.MultiviewIndex:D}.Properties"); }); } else if (command is MultiviewWindowInputGetCommand winCmd) { UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)winCmd.MultiviewIndex, mv => { UpdaterUtil.TryForIndex(result, mv.Windows, (int)winCmd.WindowIndex, win => { win.Source = winCmd.Source; win.SupportsVuMeter = winCmd.SupportVuMeter; win.SupportsSafeArea = winCmd.SupportsSafeArea; result.SetSuccess($"Settings.MultiViewers.{winCmd.MultiviewIndex:D}.Windows.{winCmd.WindowIndex:D}"); }); }); } else if (command is MultiviewWindowVuMeterGetCommand vuMeterCmd) { UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)vuMeterCmd.MultiviewIndex, mv => { UpdaterUtil.TryForIndex(result, mv.Windows, (int)vuMeterCmd.WindowIndex, win => { win.VuMeterEnabled = vuMeterCmd.VuEnabled; result.SetSuccess($"Settings.MultiViewers.{vuMeterCmd.MultiviewIndex:D}.Windows.{vuMeterCmd.WindowIndex:D}"); }); }); } else if (command is MultiviewWindowSafeAreaCommand safeAreaCmd) { UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)safeAreaCmd.MultiviewIndex, mv => { UpdaterUtil.TryForIndex(result, mv.Windows, (int)safeAreaCmd.WindowIndex, win => { win.SafeAreaEnabled = safeAreaCmd.SafeAreaEnabled; result.SetSuccess($"Settings.MultiViewers.{safeAreaCmd.MultiviewIndex:D}.SafeAreaEnabled"); }); }); } }
public static void Update(AtemState state, UpdateResultImpl result, ICommand command) { if (command is MediaPoolConfigCommand confCmd) { state.MediaPool.Clips = UpdaterUtil.CreateList(confCmd.ClipCount, i => new MediaPoolState.ClipState()); state.MediaPool.Stills = UpdaterUtil.CreateList(confCmd.StillCount, i => new MediaPoolState.StillState()); result.SetSuccess($"MediaPool"); } else if (command is MediaPoolFrameDescriptionCommand frameCmd) { switch (frameCmd.Bank) { case MediaPoolFileType.Still: UpdaterUtil.TryForIndex(result, state.MediaPool.Stills, (int)frameCmd.Index, still => { UpdaterUtil.CopyAllProperties(frameCmd, still, new[] { "Index", "Bank" }); result.SetSuccess($"MediaPool.Stills.{frameCmd.Index:D}"); }); break; case MediaPoolFileType.Clip1: case MediaPoolFileType.Clip2: case MediaPoolFileType.Clip3: case MediaPoolFileType.Clip4: int bankId = (int)frameCmd.Bank - 1; UpdaterUtil.TryForIndex(result, state.MediaPool.Clips, bankId, clip => { UpdaterUtil.TryForIndex(result, clip.Frames, (int)frameCmd.Index, frame => { UpdaterUtil.CopyAllProperties(frameCmd, frame, new[] { "Index", "Bank", "Filename" }); result.SetSuccess($"MediaPool.Clips.{bankId:D}.Frames.{frameCmd.Index:D}"); }); }); break; } } else if (command is MediaPoolAudioDescriptionCommand audioCmd) { uint index = audioCmd.Index - 1; UpdaterUtil.TryForIndex(result, state.MediaPool.Clips, (int)index, clip => { UpdaterUtil.CopyAllProperties(audioCmd, clip.Audio, new[] { "Index" }); result.SetSuccess($"MediaPool.Clips.{index:D}.Audio"); }); } else if (command is MediaPoolClipDescriptionCommand clipCmd) { UpdaterUtil.TryForIndex(result, state.MediaPool.Clips, (int)clipCmd.Index, clip => { clip.IsUsed = clipCmd.IsUsed; clip.Name = clipCmd.Name; clip.FrameCount = clipCmd.FrameCount; result.SetSuccess($"MediaPool.Clips.{clipCmd.Index:D}"); }); } else if (command is MediaPoolSettingsGetCommand settingsCmd) { state.MediaPool.Clips.ForEach((i, clip) => { clip.MaxFrames = settingsCmd.MaxFrames[i]; clip.Frames = UpdaterUtil.UpdateList(clip.Frames, settingsCmd.MaxFrames[i], o => new MediaPoolState.FrameState()); }); state.MediaPool.UnassignedFrames = settingsCmd.UnassignedFrames; result.SetSuccess(new[] { $"MediaPool.Clips", $"MediaPool.UnassignedFrames" }); } }