protected override bool ConnectOverride(Signal target, IEnumerable <Signal> sources, ConnectOperation operation) { if (operation == ConnectOperation.Disconnect) { target.Disconnect(sources); } else { target.Connect(sources, operation == ConnectOperation.Absolute); } return(true); }
private static void WriteConnect(ref NatsWriter writer, ConnectOperation op) { writer.WriteString($"CONNECT "); writer.WriteJson(op); writer.Write(CRLF); }
public void NotifyMatrixConnection(Matrix matrix, Signal target, object state, ConnectOperation operation) { 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, Operation = (int)operation }; glowMatrix.EnsureConnections().Insert(glowConnection); glow.Insert(glowMatrix); OnGlowRootReady(new GlowRootReadyArgs(glow, null) { Matrix = matrix }); }
protected override bool ConnectOverride(Signal target, IEnumerable <Signal> sources, ConnectOperation operation) { if (operation == ConnectOperation.Disconnect) { target.Disconnect(sources); } else if (operation == ConnectOperation.Connect) { target.Connect(sources.Take(1), true); } else if (target.HasConnectedSources) { if (target.ConnectedSources.Contains(sources.FirstOrDefault())) { target.Disconnect(sources); } else { target.Connect(sources.Take(1), operation == ConnectOperation.Absolute); } } else { target.Connect(sources.Take(1), operation == ConnectOperation.Absolute); } return(true); }
protected override bool ConnectOverride(Signal target, IEnumerable <Signal> sources, ConnectOperation operation) { target.Connect(sources.Take(1), isAbsolute: true); return(true); }
public void Connect(ConnectOperation connect) => nats.Send(NatsOperationId.CONNECT, connect);
private static void WriteConnect(ref BufferWriter <IBufferWriter <byte> > writer, ConnectOperation op) { writer.WriteString("CONNECT "); writer.WriteJson(op); writer.Write(CRLF); }
protected override bool ConnectOverride(Signal target, IEnumerable <Signal> sources, ConnectOperation operation) { sources = sources.Take(1); var firstSource = sources.FirstOrDefault(); if (firstSource != null) { foreach (var signal in Targets) { if (signal.ConnectedSources.Contains(firstSource)) { signal.Connect(Enumerable.Empty <Signal>(), true); Dispatcher.NotifyMatrixConnection(this, signal, null); } } target.Connect(sources, isAbsolute: true); return(true); } return(false); }
public bool Connect(Signal target, IEnumerable <Signal> sources, object state, ConnectOperation operation = ConnectOperation.Absolute) { if (_targets.Contains(target) == false) { throw new ArgumentException("target"); } var firstSource = sources.FirstOrDefault(); if (firstSource != null) { if (_sources.Contains(firstSource) == false) { throw new ArgumentException("sources"); } } var result = ConnectOverride(target, sources, operation); if (result) { Dispatcher.NotifyMatrixConnection(this, target, state); } return(result); }
protected abstract bool ConnectOverride(Signal target, IEnumerable <Signal> sources, ConnectOperation operation);
public bool Connect(Signal target, IEnumerable <Signal> sources, object state, ConnectOperation operation = ConnectOperation.Absolute) { if (_targets.Contains(target) == false) { throw new ArgumentException("target"); } var firstSource = sources.FirstOrDefault(); if (firstSource != null) { if (_sources.Contains(firstSource) == false) { throw new ArgumentException("sources"); } } var result = ConnectOverride(target, sources, operation); if (result) { // absolute(0) // Default.This value indicates that the list of source numbers in the sources property of // the encompassing Connection object is absolute.When a provider tallies a connection, it // must always use this value, independent of the value of the disposition property. // Dispatcher.NotifyMatrixConnection(this, target, state, operation); Dispatcher.NotifyMatrixConnection(this, target, state, ConnectOperation.Absolute); } return(result); }
protected override bool ConnectOverride(Signal target, IEnumerable <Signal> sources, ConnectOperation operation) { switch (operation) { case ConnectOperation.Absolute: // Get the first source that should be "On" var onSource = sources.Take(1); if (target.HasConnectedSources) { if (target.ConnectedSources.Contains(onSource.FirstOrDefault())) { // Trying to connect a connected source target.Connect(onSource, true); } else if (sources.Any() == false) { // On "right-click disconnect" in ember viewer sources might be empty target.Connect(new Signal[] { BlindSource }, true); } else { target.Connect(onSource, true); } } else { target.Connect(onSource, true); } break; case ConnectOperation.Connect: // Connect to the first source that is not blind target.Connect(sources.Take(1), true); break; case ConnectOperation.Disconnect: target.Connect(new Signal[] { BlindSource }, true); break; default: break; } return(true); }