Ejemplo n.º 1
0
        GlowContainer Model.IElementVisitor <ElementToGlowOptions, GlowContainer> .Visit(Model.NToNMatrix element, ElementToGlowOptions state)
        {
            var glow = MatrixToGlow(element, state);

            if (state.DirFieldMask == GlowFieldFlags.All)
            {
                glow.AddressingMode = GlowMatrixAddressingMode.NonLinear;
                glow.MatrixType     = GlowMatrixType.NToN;

                if (element.ParametersNode != null)
                {
                    glow.ParametersLocation = new GlowParametersLocation(element.ParametersNode.Path);
                }

                if (state.IsCompleteMatrixEnquired)
                {
                    var glowTargets = glow.EnsureTargets();
                    var glowSources = glow.EnsureSources();

                    foreach (var signal in element.Targets)
                    {
                        glowTargets.Insert(new GlowTarget(signal.Number));
                    }

                    foreach (var signal in element.Sources)
                    {
                        glowSources.Insert(new GlowSource(signal.Number));
                    }
                }
            }

            return(glow);
        }
Ejemplo n.º 2
0
        static void CreateNToN(Model.Node router, int nodeNumber, Dispatcher dispatcher)
        {
            var nToN = new Model.Node(nodeNumber, router, "nToN")
            {
                Description = "Non-Linear N:N",
            };

            var labels       = new Model.Node(1, nToN, "labels");
            var targetLabels = new Model.Node(1, labels, "targets");
            var sourceLabels = new Model.Node(2, labels, "sources");

            var parameters   = new Model.Node(2, nToN, "parameters");
            var targetParams = new Model.Node(1, parameters, "targets");
            var sourceParams = new Model.Node(2, parameters, "sources");
            var xpointParams = new Model.Node(3, parameters, "connections");

            var targets = new List <Model.Signal>();
            var sources = new List <Model.Signal>();
            var number  = 0;

            for (int index = 0; index < 4; index++)
            {
                number += 3;

                var targetLabel = new Model.StringParameter(number, targetLabels, IdentOf("t", number), dispatcher, isWriteable: true)
                {
                    Value = IdentOf("AES-T", number)
                };
                targets.Add(new Model.Signal(number, targetLabel));
                var targetNode = new Model.Node(number, targetParams, IdentOf("t", number));
                new Model.IntegerParameter(1, targetNode, "targetGain", dispatcher, -128, 15, isWriteable: true);
                new Model.StringParameter(2, targetNode, "targetMode", dispatcher, isWriteable: true)
                {
                    Value = "something"
                };

                var sourceLabel = new Model.StringParameter(number, sourceLabels, IdentOf("s", number), dispatcher, isWriteable: true)
                {
                    Value = IdentOf("AES-S", number)
                };
                sources.Add(new Model.Signal(number, sourceLabel));
                var sourceNode = new Model.Node(number, sourceParams, IdentOf("s", number));
                new Model.IntegerParameter(1, sourceNode, "sourceGain", dispatcher, -128, 15, isWriteable: true);
            }

            foreach (var target in targets)
            {
                var targetNode = new Model.Node(target.Number, xpointParams, IdentOf("t", target.Number));

                foreach (var source in sources)
                {
                    var sourceNode = new Model.Node(source.Number, targetNode, IdentOf("s", source.Number));
                    new Model.IntegerParameter(1, sourceNode, "gain", dispatcher, -128, 15, isWriteable: true);
                }
            }

            var matrix = new Model.NToNMatrix(
                3,
                nToN,
                "matrix",
                dispatcher,
                targets,
                sources,
                labels,
                parameters);

            foreach (var target in matrix.Targets)
            {
                if (target.Number % 2 == 0)
                {
                    matrix.Connect(target, new[] { matrix.GetSource(target.Number) }, null);
                }
            }
        }