GlowMatrixBase MatrixToGlow(Model.Matrix matrix, ElementToGlowOptions options) { var dirFieldMask = options.DirFieldMask; var glow = new GlowQualifiedMatrix(matrix.Path) { Identifier = matrix.Identifier, TargetCount = matrix.TargetCount, SourceCount = matrix.SourceCount, }; if (dirFieldMask.HasBits(GlowFieldFlags.Description) && String.IsNullOrEmpty(matrix.Description) == false) { glow.Description = matrix.Description; } if (matrix.LabelsNode != null && dirFieldMask == GlowFieldFlags.All) { var labels = new EmberSequence(GlowTags.MatrixContents.Labels); labels.Insert(new GlowLabel { BasePath = matrix.LabelsNode.Path, Description = "Primary" }); glow.Labels = labels; } if (dirFieldMask.HasBits(GlowFieldFlags.Connections) && options.IsCompleteMatrixEnquired) { var glowConnections = glow.EnsureConnections(); foreach (var signal in matrix.Targets) { var glowConnection = new GlowConnection(signal.Number); if (signal.ConnectedSources.Any()) { glowConnection.Sources = signal.ConnectedSources.Select(source => source.Number).ToArray(); } glowConnections.Insert(glowConnection); } } if ((dirFieldMask == GlowFieldFlags.All) && String.IsNullOrEmpty(matrix.SchemaIdentifier) == false) { glow.SchemaIdentifiers = matrix.SchemaIdentifier; } return(glow); }
public void SubscribeToMatrix(Model.Matrix matrix, bool subscribe) { lock (_sync) { if (subscribe) { if (_subscribedMatrices.Contains(matrix) == false) { _subscribedMatrices.AddLast(matrix); } } else { _subscribedMatrices.Remove(matrix); } } }
public void NotifyMatrixConnection(Model.Matrix matrix, Model.Signal target, object state) { var glow = GlowRootElementCollection.CreateRoot(); var glowMatrix = new GlowQualifiedMatrix(matrix.Path); var glowConnection = new GlowConnection(target.Number) { Sources = target.ConnectedSources.Select(signal => signal.Number).ToArray(), Disposition = GlowConnectionDisposition.Modified, }; glowMatrix.EnsureConnections().Insert(glowConnection); glow.Insert(glowMatrix); OnGlowRootReady(new GlowRootReadyArgs(glow, null) { Matrix = matrix }); }
public bool HasSubscribedToMatrix(Model.Matrix matrix) { lock (_sync) return(_subscribedMatrices.Contains(matrix)); }