/// <summary> /// EmBER+ tree matrix event changes /// </summary> private void ReceivedMatrixConnectionEvent(string identifierPath, GlowConnection connection, int[] path) { log.Debug($"Received Matrix Connection {identifierPath} , Operation: {(ConnectOperation)connection.Operation}, Target: {connection.Target}, First source: {connection.Sources.FirstOrDefault()}"); // Send out the target state var signal = new ClientMatrixSignalViewModel() { Index = connection.Target, ConnectedSources = connection.Sources }; _websocketHub.Clients.All.ChangesInEmberTreeMatrix(identifierPath, signal); }
/// <summary> /// Returns a representation of the current parameter state of the tree /// </summary> private void EmberTreeInitialState() { // Send out the regular nodes/parameters from the tree Dictionary <string, ClientTreeParameterViewModel> tree = new Dictionary <string, ClientTreeParameterViewModel>(); foreach (ParameterBase parameter in _emberTree.GetChildParameterElements()) { log.Debug(parameter.IdentifierPath, parameter.GetValue().ToString()); tree.Add(parameter.IdentifierPath, new ClientTreeParameterViewModel() { Type = parameter.GetType().ToString(), Value = parameter.GetValue(), NumericPath = string.Join(".", parameter.Path), IsWritable = parameter.IsWritable, Options = new { } }); } _websocketHub.Clients.All.InitialEmberTree(tree); // Send out the matrices in the tree Dictionary <string, ClientMatrixViewModel> matrices = new Dictionary <string, ClientMatrixViewModel>(); foreach (Matrix treeMatrix in _emberTree.GetChildMatrixElements()) { ClientMatrixViewModel matrix = new ClientMatrixViewModel() { Name = treeMatrix.Parent.Parent.Identifier + " " + treeMatrix.Parent.Identifier, NumericPath = string.Join(".", treeMatrix.Path) }; foreach (var target in treeMatrix.Targets) { var item = new ClientMatrixSignalViewModel() { Index = target.Number, Name = target.LabelParameter.Value, LabelPath = target.LabelParameter.IdentifierPath, ConnectedSources = target.ConnectedSources.Select((x) => x.Number).ToArray() }; matrix.Targets.Add(item); } foreach (var source in treeMatrix.Sources) { var item = new ClientMatrixSignalViewModel() { Index = source.Number, Name = source.LabelParameter.Value }; matrix.Sources.Add(item); } matrices.Add(treeMatrix.IdentifierPath, matrix); } _websocketHub.Clients.All.InitialEmberTreeMatrix(matrices); }