public void TestActiveConfiguration() { var handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerInputSetCommand, FairlightMixerInputGetCommand>("ActiveConfiguration"); bool tested = false; AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightMain, helper => { IEnumerable <long> useIds = Randomiser.SelectionOfGroup(helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList()); foreach (long id in useIds) { IBMDSwitcherFairlightAudioInput input = GetInput(helper, id); AtemState stateBefore = helper.Helper.BuildLibState(); FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id]; var testConfigs = AtemSDKConverter.GetFlagsValues(input.GetSupportedConfigurations, AtemEnumMaps.FairlightInputConfigurationMap); // Need more than 1 config to allow for switching around if (1 == testConfigs.Count) { continue; } tested = true; for (int i = 0; i < 5; i++) { var target = testConfigs[i % testConfigs.Count]; inputState.ActiveConfiguration = target.Item2; helper.SendAndWaitForChange(stateBefore, () => { input.SetConfiguration(target.Item1); }); } } }); Assert.True(tested); }
public void TestInputTalkbackGain() { var handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerMonitorSetCommand, FairlightMixerMonitorGetCommand>("InputTalkbackGain"); bool tested = false; AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightMain, helper => { var monitor = GetMonitor(helper); if (monitor == null) { return; } tested = true; AtemState stateBefore = helper.Helper.BuildLibState(); FairlightAudioState.MonitorOutputState monState = stateBefore.Fairlight.Monitors.Single(); for (int i = 0; i < 5; i++) { var target = Randomiser.Range(-60, 0); monState.InputTalkbackGain = target; helper.SendAndWaitForChange(stateBefore, () => { monitor.SetInputTalkbackGain(target); }); } }); Assert.True(tested); }
public void TestPeriodicFlushInterval() { var handler = CommandGenerator.CreateAutoCommandHandler <CameraControlSettingsSetCommand, CameraControlSettingsGetCommand>("Interval", true); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.CameraControl, helper => { helper.Helper.StateSettings.IgnoreUnknownCameraControlProperties = true; IBMDSwitcherCameraControl camera = helper.SdkClient.SdkSwitcher as IBMDSwitcherCameraControl; Assert.NotNull(camera); for (int i = 0; i < 5; i++) { AtemState stateBefore = helper.Helper.BuildLibState(); uint interval = Randomiser.RangeInt(int.MaxValue); stateBefore.CameraControl.PeriodicFlushInterval = interval; helper.SendAndWaitForChange(stateBefore, () => { camera.SetPeriodicFlushInterval(interval); }); } }); }
public void TestStoreAsKeyFrame() { bool tested = false; var expectedCmd = new MixEffectKeyFlyKeyframeStoreCommand(); var handler = CommandGenerator.MatchCommand(expectedCmd, true); AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper => { SelectionOfKeyers <IBMDSwitcherKeyFlyParameters>(helper, (stateBefore, keyerBefore, sdkKeyer, meId, keyId, i) => { sdkKeyer.GetCanRotate(out int canRotate); if (canRotate != 0) { tested = true; expectedCmd.MixEffectIndex = meId; expectedCmd.KeyerIndex = keyId; expectedCmd.KeyFrame = Randomiser.EnumValue <FlyKeyKeyFrameId>(); var kfId = expectedCmd.KeyFrame == FlyKeyKeyFrameId.One ? _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameA : _BMDSwitcherFlyKeyFrame.bmdSwitcherFlyKeyFrameB; helper.SendAndWaitForChange(stateBefore, () => { sdkKeyer.StoreAsKeyFrame(kfId); }); } }); }); Assert.True(tested); }
public GameController GetGameController(IOutputter outputter) { var randomiser = new Randomiser(new System.Random()); var scheduleController = new ScheduleController(); var renderController = new RenderController(outputter); var inputController = new InputController(); var saveController = new SaveController(); var levelController = new LevelController(); var levelFactory = new LevelFactory(randomiser); var itemFactory = new ItemFactory(); var stringFormatter = new StringFormatterSmartFormat(); var assetBank = new AssetBank(stringFormatter); var eventBus = new EventBus(); var eventKeeper = new EventKeeper(eventBus, assetBank); var screenFactory = new ScreenFactory(eventKeeper); var playerFactory = new PlayerFactory(levelController, eventBus, randomiser, scheduleController); var enemyFactory = new EnemyFactory(eventBus, randomiser, scheduleController); return(new GameController( renderController, inputController, saveController, levelController, levelFactory, itemFactory, screenFactory, playerFactory, enemyFactory, eventBus, scheduleController )); }
public void TestHasUnsupportedOps() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.MacroTransfer, helper => { var pool = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroPool; Assert.NotNull(pool); ImmutableList <ICommand> previousCommands = helper.Server.GetParsedDataDump(); for (int i = 0; i < 10; i++) { AtemState stateBefore = helper.Helper.BuildLibState(); uint index = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count); MacroPropertiesGetCommand cmd = previousCommands.OfType <MacroPropertiesGetCommand>().Single(c => c.Index == index); cmd.HasUnsupportedOps = i % 2 == 0; stateBefore.Macros.Pool[(int)index].HasUnsupportedOps = cmd.HasUnsupportedOps; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(cmd); }); } }); }
public void TestTally() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.FairlightMain, helper => { IBMDSwitcherFairlightAudioMixer mixer = GetFairlightMixer(helper); AtemState stateBefore = helper.Helper.BuildLibState(); for (int i = 0; i < 5; i++) { var cmd = new FairlightMixerTallyCommand { Tally = new Dictionary <Tuple <AudioSource, long>, bool>() }; Assert.NotEmpty(stateBefore.Fairlight.Tally); // the sdk is a bit picky about ids, so best to go with what it expects foreach (KeyValuePair <Tuple <AudioSource, long>, bool> k in stateBefore.Fairlight.Tally) { bool isMixedIn = Randomiser.Range(0, 1) > 0.7; cmd.Tally[k.Key] = isMixedIn; } stateBefore.Fairlight.Tally = cmd.Tally; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(cmd); }); } }); }
public void TestClipSetValid() { AtemMockServerWrapper.Each(_output, _pool, SetValidCommandHandler, DeviceTestCases.MediaPlayerClips, helper => { for (int i = 0; i < 3; i++) { AtemState stateBefore = helper.Helper.BuildLibState(); uint index = Randomiser.RangeInt((uint)stateBefore.MediaPool.Clips.Count); IBMDSwitcherClip clip = GetClip(helper, index); string name = Guid.NewGuid().ToString(); uint frameCount = Randomiser.RangeInt(5) + 3; var cb = new LockCallback(); helper.SendAndWaitForChange(stateBefore, () => { clip.Lock(cb); }); Assert.True(cb.Wait.WaitOne(2000)); var clipState = stateBefore.MediaPool.Clips[(int)index]; clipState.IsUsed = true; clipState.Name = name; clipState.FrameCount = frameCount; helper.SendAndWaitForChange(stateBefore, () => { clip.SetValid(name, frameCount); }); helper.SendAndWaitForChange(stateBefore, () => { clip.Unlock(cb); }); } }); }
public LuckRoll MakeLuckRoll() { var luckRoll = (LuckRoll)Randomiser.RandomInt(0, 2); NotificiationService.Notify(string.Format("LuckRoll value : {0}", luckRoll)); return(luckRoll); }
public LogialXORBenchmarks() { _trainingData = new List <TrainingElement> { new TrainingElement { Inputs = new double[] { 0D, 0D }, ExpectedOutputs = new double[] { 0D } }, new TrainingElement { Inputs = new double[] { 1D, 0D }, ExpectedOutputs = new double[] { 1D } }, new TrainingElement { Inputs = new double[] { 0D, 1D }, ExpectedOutputs = new double[] { 1D } }, new TrainingElement { Inputs = new double[] { 1D, 1d }, ExpectedOutputs = new double[] { 0D } } }; var layer = new ILayer[] { new FullyConnectedLayer(new Sigmoid(), 3, 2), new FullyConnectedLayer(new Sigmoid(), 1, 3) }; Randomiser.Randomise(layer, new Random(1)); _trainer = new StochasticGradientDescent(new CrossEntropy(), layer, 1000, 4, 5D, 0D); }
public void TestGetStyle() { bool tested = false; AtemMockServerWrapper.Each(Output, Pool, null, DeviceTestCases.All, helper => { EachMixEffect <IBMDSwitcherTransitionParameters>(helper, (stateBefore, meBefore, sdk, meId, i) => { tested = true; TransitionStyle target = Randomiser.EnumValue <TransitionStyle>(); meBefore.Transition.Properties.Style = target; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(new TransitionPropertiesGetCommand { Index = meId, NextStyle = meBefore.Transition.Properties.NextStyle, Style = target, NextSelection = meBefore.Transition.Properties.NextSelection, Selection = meBefore.Transition.Properties.Selection, }); }); }); }); Assert.True(tested); }
public void TestMode() { var handler = CommandGenerator.CreateAutoCommandHandler <MixMinusOutputSetCommand, MixMinusOutputGetCommand>("Mode"); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MixMinusOutputs, helper => { bool tested = false; List <IBMDSwitcherMixMinusOutput> outputs = GetMixMinusOutputs(helper); for (int id = 0; id < outputs.Count; id++) { IBMDSwitcherMixMinusOutput mixMinus = outputs[id]; tested = true; AtemState stateBefore = helper.Helper.BuildLibState(); SettingsState.MixMinusOutputState mixMinusState = stateBefore.Settings.MixMinusOutputs[id]; for (int i = 0; i < 5; i++) { MixMinusMode newValue = Randomiser.EnumValue <MixMinusMode>(); mixMinusState.Mode = newValue; helper.SendAndWaitForChange(stateBefore, () => { mixMinus.SetAudioMode(AtemEnumMaps.MixMinusModeMap[newValue]); }); } } Assert.True(tested); }); }
public void TestPreviewInput() { var ignorePortTypes = new HashSet <InternalPortType> { InternalPortType.Mask, InternalPortType.Auxiliary, InternalPortType.MEOutput }; bool tested = false; var handler = CommandGenerator.CreateAutoCommandHandler <PreviewInputSetCommand, PreviewInputGetCommand>("Source", true); AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper => { // TODO - this could be better and use the availabilitymask List <VideoSource> validSources = helper.Helper.BuildLibState().Settings.Inputs .Where(s => !ignorePortTypes.Contains(s.Value.Properties.InternalPortType)).Select(s => s.Key) .ToList(); VideoSource[] sampleSources = Randomiser.SelectionOfGroup(validSources).ToArray(); EachMixEffect <IBMDSwitcherMixEffectBlock>(helper, (stateBefore, meBefore, sdk, meId, i) => { tested = true; VideoSource target = sampleSources[i]; meBefore.Sources.Preview = target; helper.SendAndWaitForChange(stateBefore, () => { sdk.SetPreviewInput((long)target); }); }, sampleSources.Length); }); Assert.True(tested); }
public void TestGetSelection() { bool tested = false; AtemMockServerWrapper.Each(Output, Pool, null, DeviceTestCases.All, helper => { EachMixEffect <IBMDSwitcherTransitionParameters>(helper, (stateBefore, meBefore, sdk, meId, i) => { tested = true; uint maxSelectionValue = (uint)1 << meBefore.Keyers.Count; uint maxSelection = (maxSelectionValue << 1) - 1; uint target = 1 + Randomiser.RangeInt(maxSelection - 1); meBefore.Transition.Properties.Selection = (TransitionLayer)target; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(new TransitionPropertiesGetCommand { Index = meId, NextStyle = meBefore.Transition.Properties.NextStyle, Style = meBefore.Transition.Properties.Style, NextSelection = meBefore.Transition.Properties.NextSelection, Selection = (TransitionLayer)target, }); }); }); }); Assert.True(tested); }
public void TestStyle() { bool tested = false; var handler = CommandGenerator.CreateAutoCommandHandler <TransitionDVESetCommand, TransitionDVEGetCommand>("Style"); AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper => { EachMixEffect <IBMDSwitcherTransitionDVEParameters>(helper, (stateBefore, meBefore, sdk, meId, i) => { if (stateBefore.Info.DVE != null && stateBefore.Info.DVE.SupportedTransitions.Count > 0) { var selection = Randomiser .SelectionOfGroup(stateBefore.Info.DVE.SupportedTransitions.ToList(), 3).ToList(); tested = true; Assert.NotNull(meBefore.Transition.DVE); foreach (DVEEffect style in selection) { meBefore.Transition.DVE.Style = style; helper.SendAndWaitForChange(stateBefore, () => { sdk.SetStyle(AtemEnumMaps.DVEStyleMap[style]); }); } } }); }); Assert.True(tested); }
public void TestIsRunning() { bool tested = false; AtemMockServerWrapper.Each(Output, Pool, null, DeviceTestCases.All, helper => { SelectionOfKeyers <IBMDSwitcherKeyFlyParameters>(helper, (stateBefore, keyerBefore, sdkKeyer, meId, keyId, i) => { tested = true; var cmd = helper.Server.GetParsedDataDump().OfType <MixEffectKeyFlyPropertiesGetCommand>() .Single(c => c.MixEffectIndex == meId && c.KeyerIndex == keyId); for (int o = 0; o < 5; o++) { var targetFrame = Randomiser.RangeInt(10) > 7 ? FlyKeyKeyFrameType.RunToInfinite : Randomiser.EnumValue <FlyKeyKeyFrameType>(); var targetInfinite = Randomiser.EnumValue <FlyKeyLocation>(); keyerBefore.FlyProperties.RunningToKeyFrame = cmd.RunningToKeyFrame = targetFrame; keyerBefore.FlyProperties.RunningToInfinite = cmd.RunningToInfinite = targetFrame == FlyKeyKeyFrameType.RunToInfinite ? targetInfinite : 0; helper.SendFromServerAndWaitForChange(stateBefore, cmd); } }); }); Assert.True(tested); }
public void TestRecordingState() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.Recording, helper => { var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherRecordAV; Assert.NotNull(switcher); AtemState stateBefore = helper.Helper.BuildLibState(); InitDisk(helper, stateBefore); InitRecording(helper, stateBefore); stateBefore.Recording.Status.TotalRecordingTimeAvailable = 0; for (int i = 0; i < 10; i++) { stateBefore.Recording.Status.State = Randomiser.EnumValue <RecordingStatus>(); stateBefore.Recording.Status.Error = Randomiser.EnumValue <RecordingError>(); var cmd = new RecordingStatusGetCommand() { Status = stateBefore.Recording.Status.State, Error = stateBefore.Recording.Status.Error, }; helper.SendFromServerAndWaitForChange(stateBefore, cmd); } }); }
public void TestDiskRemoval() { var handler = CommandGenerator.CreateAutoCommandHandler <RecordingStatusSetCommand, RecordingStatusGetCommand>("IsRecording", true); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper => { var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherStreamRTMP; Assert.NotNull(switcher); AtemState stateBefore = helper.Helper.BuildLibState(); // Init a disk that will persit InitDisk(helper, stateBefore, 99); for (int i = 0; i < 10; i++) { var id = Randomiser.RangeInt(20); var cmd = InitDisk(helper, stateBefore, id); // Simulate removal cmd.IsDelete = true; stateBefore.Recording.Disks.Remove(id); helper.SendFromServerAndWaitForChange(stateBefore, cmd); } }); }
public void Run() { Console.WriteLine("Building random neural network"); var layers = new ILayer[] { new FullyConnectedLayer(new Sigmoid(), 30, 784), new FullyConnectedLayer(new Sigmoid(), 10, 30) }; Randomiser.Randomise(layers); Console.WriteLine("Evaluating untrained neural network"); var untrainedAccuracy = Statistics.GetAccuracyByMax(_validationData, new NeuralNetwork(layers, 784)); Console.WriteLine($"Untrained network accuracy: {untrainedAccuracy.ToString("N2")}%"); var stochasticGradientDescent = new StochasticGradientDescent(new CrossEntropy(), layers, 1, 20, 1D, 0D); var maxAccuracy = 0D; for (int i = 0; i < _epochs; i++) { Console.WriteLine($"Epoch {i + 1} started"); var trainingLength = Statistics.GetTrainingLength(stochasticGradientDescent, _trainingData); var trainingAccuracy = Statistics.GetAccuracyByMax(_validationData, new NeuralNetwork(layers, 784)); Console.WriteLine($"Results after epoch {i + 1}:"); Console.WriteLine($"Training length in miliseconds: {trainingLength}, Accuracy: {trainingAccuracy.ToString("N2")}%"); if (maxAccuracy < trainingAccuracy) { maxAccuracy = trainingAccuracy; } } Console.WriteLine($"End of training. Best accuracy {maxAccuracy.ToString("N2")}%"); }
protected static void EachSuperSourceBox(AtemMockServerWrapper helper, Action <AtemState, SuperSourceState.BoxState, IBMDSwitcherSuperSourceBox, SuperSourceId, SuperSourceBoxId, int> fcn, int iterations = 5) { var allBoxes = new List <Tuple <SuperSourceId, SuperSourceBoxId, IBMDSwitcherSuperSourceBox> >(); foreach (KeyValuePair <VideoSource, IBMDSwitcherInputSuperSource> ssrc in helper.GetSdkInputsOfType <IBMDSwitcherInputSuperSource>()) { SuperSourceId id = (SuperSourceId)(ssrc.Key - VideoSource.SuperSource); var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherSuperSourceBoxIterator>(ssrc.Value.CreateIterator); AtemSDKConverter.Iterate <IBMDSwitcherSuperSourceBox>(iterator.Next, (box, i) => { allBoxes.Add(Tuple.Create(id, (SuperSourceBoxId)i, box)); }); } var boxes = Randomiser.SelectionOfGroup(allBoxes); foreach (Tuple <SuperSourceId, SuperSourceBoxId, IBMDSwitcherSuperSourceBox> box in boxes) { AtemState stateBefore = helper.Helper.BuildLibState(); SuperSourceState.BoxState boxBefore = stateBefore.SuperSources[(int)box.Item1].Boxes[(int)box.Item2]; Assert.NotNull(boxBefore); for (int i = 0; i < iterations; i++) { fcn(stateBefore, boxBefore, box.Item3, box.Item1, box.Item2, i); } } }
public void TestAudioInputId() { var handler = CommandGenerator.CreateAutoCommandHandler <MixMinusOutputSetCommand, MixMinusOutputGetCommand>("Mode"); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MixMinusOutputs, helper => { var previousCommands = helper.Server.GetParsedDataDump().OfType <MixMinusOutputGetCommand>().ToList(); for (int i = 0; i < 10; i++) { AtemState stateBefore = helper.Helper.BuildLibState(); uint id = Randomiser.RangeInt((uint)stateBefore.Settings.MixMinusOutputs.Count - 1); SettingsState.MixMinusOutputState mixMinusState = stateBefore.Settings.MixMinusOutputs[(int)id]; MixMinusOutputGetCommand cmd = previousCommands.Single(c => c.Id == id); uint newValue = Randomiser.RangeInt(9) + 1; cmd.HasAudioInputId = i % 2 == 0; cmd.AudioInputId = cmd.HasAudioInputId ? (AudioSource)newValue : 0; mixMinusState.HasAudioInputId = cmd.HasAudioInputId; mixMinusState.AudioInputId = cmd.AudioInputId; helper.SendFromServerAndWaitForChange(stateBefore, cmd); } }); }
public static List <CodeReviewPairing> GetCodeReviewPairs(IEnumerable <string> participantCollection) { var participants = participantCollection.ToList(); List <CodeReviewPairing> pairs = new List <CodeReviewPairing>(); if (participants == null || participants.Count < 2) { return(new List <CodeReviewPairing>()); } while (participants.Count > 1) { var reviewerIndex = Randomiser.GetRandomInt(0, participants.Count); var reviewer = participants[reviewerIndex]; participants.RemoveAt(reviewerIndex); var revieweeIndex = Randomiser.GetRandomInt(0, participants.Count); var reviewee = participants[revieweeIndex]; participants.RemoveAt(revieweeIndex); pairs.Add(new CodeReviewPairing(reviewer, reviewee)); } //Odd number so pick a reviewee to be a reviewer if (participants.Any()) { var reviewerIndex = Randomiser.GetRandomInt(0, pairs.Count); pairs.Add(new CodeReviewPairing(pairs[reviewerIndex].Reviewee, participants[0])); } return(pairs); }
public void TestRecordPause() { var expectedCommand = new MacroAddTimedPauseCommand(); var handler = CommandGenerator.MatchCommand(expectedCommand); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper => { var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl; Assert.NotNull(control); AtemState stateBefore = helper.Helper.BuildLibState(); for (int i = 0; i < 5; i++) { uint frames = Randomiser.RangeInt(2500); expectedCommand.Frames = frames; uint timeBefore = helper.Server.CurrentTime; helper.SendAndWaitForChange(stateBefore, () => { control.RecordPause(frames); }); // It should have sent a response, but we dont expect any comparable data Assert.NotEqual(timeBefore, helper.Server.CurrentTime); } }); }
public void TestTransitionFramesRemaining() { bool tested = false; AtemMockServerWrapper.Each(Output, Pool, null, DeviceTestCases.All, helper => { EachMixEffect <IBMDSwitcherMixEffectBlock>(helper, (stateBefore, meBefore, sdk, meId, i) => { tested = true; uint target = Randomiser.RangeInt(250); meBefore.Transition.Position.RemainingFrames = target; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(new TransitionPositionGetCommand { Index = meId, RemainingFrames = target, InTransition = meBefore.Transition.Position.InTransition, HandlePosition = meBefore.Transition.Position.HandlePosition }); }); }); }); Assert.True(tested); }
public void TestRun() { var expectedCommand = RunThroughSerialize(new MacroActionCommand { Action = MacroActionCommand.MacroAction.Run }); var handler = CommandGenerator.MatchCommand(expectedCommand); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper => { var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl; Assert.NotNull(control); AtemState stateBefore = helper.Helper.BuildLibState(); for (int i = 0; i < 5; i++) { uint index = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count); expectedCommand.Index = index; uint timeBefore = helper.Server.CurrentTime; helper.SendAndWaitForChange(stateBefore, () => { control.Run(index); }); // It should have sent a response, but we dont expect any comparable data Assert.NotEqual(timeBefore, helper.Server.CurrentTime); } }); }
public void Initialize() { _layers = new ILayer[] { new FullyConnectedLayer(new Sigmoid(), 3, 2), new FullyConnectedLayer(new Sigmoid(), 1, 3) }; Randomiser.Randomise(_layers, new Random(5)); _trainingData = new List <TrainingElement> { new TrainingElement { Inputs = new double[] { 0D, 0D }, ExpectedOutputs = new double[] { 0D } }, new TrainingElement { Inputs = new double[] { 1D, 0D }, ExpectedOutputs = new double[] { 1D } }, new TrainingElement { Inputs = new double[] { 0D, 1D }, ExpectedOutputs = new double[] { 1D } }, new TrainingElement { Inputs = new double[] { 1D, 1d }, ExpectedOutputs = new double[] { 0D } } }; }
public void TestRunStatus() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper => { var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl; Assert.NotNull(control); AtemState stateBefore = helper.Helper.BuildLibState(); for (int i = 0; i < 5; i++) { uint index = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count); var status = Randomiser.EnumValue <MacroState.MacroRunStatus>(); stateBefore.Macros.RunStatus.RunIndex = index; stateBefore.Macros.RunStatus.RunStatus = status; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(new MacroRunStatusGetCommand { Index = index, IsWaiting = status == MacroState.MacroRunStatus.UserWait, IsRunning = status == MacroState.MacroRunStatus.Running, Loop = stateBefore.Macros.RunStatus.Loop, }); }); } }); }
public void TestNextStyle() { bool tested = false; var handler = CommandGenerator.CreateAutoCommandHandler <TransitionPropertiesSetCommand, TransitionPropertiesGetCommand>("NextStyle"); AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper => { EachMixEffect <IBMDSwitcherTransitionParameters>(helper, (stateBefore, meBefore, sdk, meId, i) => { tested = true; var omitStyles = new List <TransitionStyle>(); if (stateBefore.Info.DVE == null) { omitStyles.Add(TransitionStyle.DVE); } if (stateBefore.MediaPool.Clips.Count == 0) { omitStyles.Add(TransitionStyle.Stinger); } TransitionStyle target = Randomiser.EnumValue(omitStyles.ToArray()); _BMDSwitcherTransitionStyle target2 = AtemEnumMaps.TransitionStyleMap[target]; meBefore.Transition.Properties.NextStyle = target; helper.SendAndWaitForChange(stateBefore, () => { sdk.SetNextTransitionStyle(target2); }); }); }); Assert.True(tested); }
public void TestRecordStatus() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper => { var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl; Assert.NotNull(control); AtemState stateBefore = helper.Helper.BuildLibState(); for (int i = 0; i < 5; i++) { uint index = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count); bool recording = Randomiser.RangeInt(1) == 1; stateBefore.Macros.RecordStatus.RecordIndex = index; stateBefore.Macros.RecordStatus.IsRecording = recording; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(new MacroRecordingStatusGetCommand() { Index = index, IsRecording = recording, }); }); } }); }
public void TestTally() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.ClassicAudioMain, helper => { AtemState stateBefore = helper.Helper.BuildLibState(); for (int i = 0; i < 5; i++) { var cmd = new AudioMixerTallyCommand { Inputs = new Dictionary <AudioSource, bool>() }; Assert.NotEmpty(stateBefore.Audio.Tally); // the sdk is a bit picky about ids, so best to go with what it expects foreach (KeyValuePair <AudioSource, bool> k in stateBefore.Audio.Tally) { bool isMixedIn = Randomiser.Range(0, 1) > 0.7; cmd.Inputs[k.Key] = isMixedIn; } stateBefore.Audio.Tally = cmd.Inputs; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(cmd); }); } }); }
public void LoginRandomiser(ref Randomiser.Randomiser obj_Randomiser) { try { if (!IsLoggedIn) { Login(); } if (IsLoggedIn) { if (IsNotSuspended) { //Randomiser.Randomiser obj_Randomiser = new Randomiser.Randomiser(Username, userID, Password, Screen_name, proxyAddress, proxyPort, proxyUsername, proxyPassword); obj_Randomiser.StartRandomiser(ref globusHttpHelper, ref userID, ref Username, ref Screen_name, ref postAuthenticityToken); } } } catch { } }