private void UpdateComposite(amBXScene scene) { foreach (var component in scene.FrameStatistics.EnabledDirectionalComponents) { componentsList.MergeComposite(new CompositeComponentWrapper(scene, component, new AtypicalFirstRunInfiniteTicker(scene))); } }
private amBXScene GetPreviousScene(amBXScene newScene) { // To handle startup if (previousScene == null) { return newScene; } if (currentScene.SceneType == eSceneType.Composite || (currentScene.SceneType == eSceneType.Singular && currentScene.HasRepeatableFrames)) { return currentScene; } // From this point, the currentScenes // SceneType is Singular and there are no Repeatable Frames if (newScene.HasRepeatableFrames) { // Don't interrupt the currently playing scene - it'll finish and rollback. // Instead quietly update the previous scene so that we fall back to this // new one return newScene; } // In this case, both don't have repeated frames. // Dont update the previous scene, to ensure that we don't get // stuck in an infinite loop. return previousScene; }
public void Process(amBXScene scene) { var frame = scene.Frames.Single(); ProcessSection(frame.LightSection); ProcessSection(frame.FanSection); ProcessSection(frame.RumbleSection); }
public NewSceneProcessor(ComponentWrapperListBuilder componentWrapperListBuilder, TaskManager taskManager, ComponentWrapperList wrappedComponents) { this.componentWrapperListBuilder = componentWrapperListBuilder; this.taskManager = taskManager; this.wrappedComponents = wrappedComponents; currentScene = new amBXScene { SceneType = eSceneType.Composite }; }
private static void SaveNewScene(amBXScene newScene, string path, string filename) { var fullpath = Path.Combine(path, "new_" + filename); using (var stream = new FileStream(fullpath, FileMode.Create)) { var deserialiser = new XmlSerializer(typeof(amBXScene)); deserialiser.Serialize(stream, newScene); } }
public amBXScene Migrate(amBXSceneV1 oldScene) { var newScene = new amBXScene(); newScene.IsExclusive = oldScene.IsExclusive; newScene.SceneType = oldScene.SceneType; newScene.Frames = MigrateFrames(oldScene.Frames).ToList(); return newScene; }
public void PushingACustomScene_SendsTheExpectedScene() { var scene = new amBXScene(); client.PushScene(scene); Assert.AreEqual(1, host.Scenes.Count); Assert.AreEqual(false, host.Scenes[0].Item1); //TODO: More comprehensive equality tests }
public void Process(amBXScene newScene) { previousScene = GetPreviousScene(newScene); currentScene = newScene; PushChanges(); if (!newScene.HasRepeatableFrames) { SetupRollback(); } }
public ComponentWrapperList Build(amBXScene scene) { switch (scene.SceneType) { case eSceneType.Composite: UpdateComposite(scene); break; case eSceneType.Singular: UpdateSingular(scene); break; default: throw new ArgumentException("qq"); } return componentsList; }
public void RunScene(amBXScene scene) { action(scene); }
private void PushScene(ChannelFactory<INotificationService> hostService, amBXScene scene) { hostService.CreateChannel().RunScene(scene); }
public SingularComponentWrapper(amBXScene scene, AtypicalFirstRunInfiniteTicker ticker) : base(scene, ticker) { }
public override void PushScene(amBXScene scene) { CustomScenesPushed.Add(scene); }
public static void Update(amBXScene scene) { newSceneProcessor.Process(scene); }
public static void UpdateExclusive(Frame frame) { var scene = new amBXScene {Frames = new List<Frame> {frame}}; exclusiveProcessor.Process(scene); }
public void SetupTests() { host = new TestNotificationService(); client = new NotificationClient(host.Hostname); arbitraryScene = new DefaultScenes().Rainbow; }
protected ComponentWrapperBase(amBXScene scene, AtypicalFirstRunInfiniteTicker ticker) { Scene = scene; Ticker = ticker; }
public void SetScene(amBXScene scene) { ThrowIfAlreadyAssignedOnce(); Scene = scene; Assigned = true; }
private void UpdateSingular(amBXScene scene) { componentsList.ReplaceAllWith(new SingularComponentWrapper(scene, new AtypicalFirstRunInfiniteTicker(scene))); }
private void ThrowExceptionIfSpecified(amBXScene scene) { if (scene.PropertyOneString == "ThrowException") { throw new InvalidOperationException("Test exception"); } }
private void PushScene(amBXScene scene) { notificationService.PushScene(scene); }
public AtypicalFirstRunInfiniteTicker(amBXScene scene) : this(scene.Frames.Count, scene.RepeatableFrames.Count) { }
public virtual void PushScene(amBXScene scene) { UpdateClientsIfHostnameChanged(); if (!SupportsScenes) { ThrowUnsupportedException("custom-built"); } Parallel.ForEach(hosts, host => PushScene(host.HostService, scene)); }
public CompositeComponentWrapper(amBXScene scene, DirectionalComponent directionalComponent, AtypicalFirstRunInfiniteTicker ticker) : base(scene, ticker) { DirectionalComponent = directionalComponent; }
private void RollbackScene() { currentScene = previousScene; PushChanges(); }
public void RunScene(amBXScene scene) { ThrowExceptionIfSpecified(scene); Scenes.Add(new Tuple<bool, object>(false, scene)); }