protected override void OnMatrix(GlowMatrixBase glow, int[] path) { IDynamicPathHandler dummy; var matrix = _dispatcher.Root.ResolveChild(path, out dummy) as Matrix; if (matrix != null) { var connections = glow.Connections; if (connections != null) { foreach (var connection in glow.TypedConnections) { var target = matrix.GetTarget(connection.Target); if (target != null) { var glowSources = connection.Sources; var sources = glowSources != null ? from sourceNumber in glowSources let source = matrix.GetSource(sourceNumber) where source != null select source : Enumerable.Empty <Signal>(); var operation = connection.Operation != null ? (ConnectOperation)connection.Operation.Value : ConnectOperation.Absolute; matrix.Connect(target, sources, _source, operation); } } } } }
void RemapMatrixParameterPaths(GlowMatrixBase glow) { var parametersLocation = glow.ParametersLocation; if (parametersLocation != null && parametersLocation.Kind == GlowParametersLocationKind.BasePath) { var newPath = PrependPathWithEndPointNumber(parametersLocation.BasePath); glow.ParametersLocation = new GlowParametersLocation(newPath); } var labels = glow.Labels; if (labels != null) { foreach (var label in glow.TypedLabels) { label.BasePath = PrependPathWithEndPointNumber(label.BasePath); } } }
protected override void OnMatrix(GlowMatrixBase glow, int[] path) { }
void ConvertMatrix(GlowMatrixBase glow, XmlWriter writer) { if (glow.HasContents) { writer.WriteStartElement("contents"); glow.Identifier.Do(value => writer.WriteElementString("identifier", value)); glow.Description.Do(value => writer.WriteElementString("description", value)); glow.MatrixType.Do(value => writer.WriteElementString("type", XmlConvert.ToString(value))); glow.AddressingMode.Do(value => writer.WriteElementString("addressingMode", XmlConvert.ToString(value))); glow.TargetCount.Do(value => writer.WriteElementString("targetCount", XmlConvert.ToString(value))); glow.SourceCount.Do(value => writer.WriteElementString("sourceCount", XmlConvert.ToString(value))); glow.MaximumTotalConnects.Do(value => writer.WriteElementString("maximumTotalConnects", XmlConvert.ToString(value))); glow.MaximumConnectsPerTarget.Do(value => writer.WriteElementString("maximumConnectsPerTarget", XmlConvert.ToString(value))); var parametersLocation = glow.ParametersLocation; if (parametersLocation != null) { writer.WriteStartElement("parametersLocation"); if (parametersLocation.Kind == GlowParametersLocationKind.BasePath) { writer.WriteAttributeString("type", "RELATIVE-OID"); writer.WriteString(ConvertPath(parametersLocation.BasePath)); } else if (parametersLocation.Kind == GlowParametersLocationKind.Inline) { writer.WriteAttributeString("type", "INTEGER"); writer.WriteString(XmlConvert.ToString(parametersLocation.Inline)); } writer.WriteEndElement(); } glow.GainParameterNumber.Do(value => writer.WriteElementString("gainParameterNumber", XmlConvert.ToString(value))); var labels = glow.TypedLabels; if (labels != null) { writer.WriteStartElement("labels"); foreach (var label in labels) { writer.WriteStartElement("Label"); writer.WriteAttributeString("basePath", ConvertPath(label.BasePath)); writer.WriteAttributeString("description", label.Description); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); } var children = glow.Children; if (children != null) { writer.WriteStartElement("children"); children.Accept(this, writer); writer.WriteEndElement(); } var targets = glow.TypedTargets; if (targets != null) { writer.WriteStartElement("targets"); foreach (var target in targets) { writer.WriteStartElement("Target"); writer.WriteAttributeString("number", XmlConvert.ToString(target.Number)); writer.WriteEndElement(); } writer.WriteEndElement(); } var sources = glow.TypedSources; if (sources != null) { writer.WriteStartElement("sources"); foreach (var source in sources) { writer.WriteStartElement("Source"); writer.WriteAttributeString("number", XmlConvert.ToString(source.Number)); writer.WriteEndElement(); } writer.WriteEndElement(); } var connections = glow.TypedConnections; if (connections != null) { writer.WriteStartElement("connections"); foreach (var connection in connections) { writer.WriteStartElement("Connection"); writer.WriteAttributeString("target", XmlConvert.ToString(connection.Target)); var connectionSources = connection.Sources; if (connectionSources != null) { writer.WriteElementString("sources", ConvertPath(connectionSources)); } connection.Operation.Do(value => writer.WriteElementString("operation", XmlConvert.ToString(value))); connection.Disposition.Do(value => writer.WriteElementString("disposition", XmlConvert.ToString(value))); writer.WriteEndElement(); } writer.WriteEndElement(); } }
void FillMatrix(GlowMatrixBase glow, XElement xml) { var contentsXml = xml.Element("contents"); if(contentsXml != null) { contentsXml.Element("identifier").Do(value => glow.Identifier = value); contentsXml.Element("description").Do(value => glow.Description = value); contentsXml.Element("type").Do(value => glow.MatrixType = XmlConvert.ToInt32(value)); contentsXml.Element("addressingMode").Do(value => glow.AddressingMode = XmlConvert.ToInt32(value)); contentsXml.Element("targetCount").Do(value => glow.TargetCount = XmlConvert.ToInt32(value)); contentsXml.Element("sourceCount").Do(value => glow.SourceCount = XmlConvert.ToInt32(value)); contentsXml.Element("maximumTotalConnects").Do(value => glow.MaximumTotalConnects = XmlConvert.ToInt32(value)); contentsXml.Element("maximumConnectsPerTarget").Do(value => glow.MaximumConnectsPerTarget = XmlConvert.ToInt32(value)); var parametersLocationXml = contentsXml.Element("parametersLocation"); if(parametersLocationXml != null) { var attrib = parametersLocationXml.Attribute("type"); if(attrib.Value == "RELATIVE-OID") { glow.ParametersLocation = new GlowParametersLocation(ConvertPath(parametersLocationXml.Value)); } else if(attrib.Value == "INTEGER") { glow.ParametersLocation = new GlowParametersLocation(XmlConvert.ToInt32(parametersLocationXml.Value)); } } contentsXml.Element("gainParameterNumber").Do(value => glow.GainParameterNumber = XmlConvert.ToInt32(value)); var labelsXml = contentsXml.Element("labels"); if(labelsXml != null) { var glowLabels = from xmlChild in labelsXml.Elements("Label") select new GlowLabel { BasePath = ConvertPath(xmlChild.Attribute("basePath").Value), Description = xmlChild.Attribute("description").Value, }; var glowLabelsCollection = new EmberSequence(GlowTags.MatrixContents.Labels); foreach(var glowLabel in glowLabels) glowLabelsCollection.Insert(glowLabel); glow.Labels = glowLabelsCollection; } } var childrenXml = xml.Element("children"); if(childrenXml != null) FillElementCollection(glow.EnsureChildren(), childrenXml); var targetsXml = xml.Element("targets"); if(targetsXml != null) { var glowTargets = from xmlChild in targetsXml.Elements("Target") select new GlowTarget(XmlConvert.ToInt32(xmlChild.Attribute("number").Value)); var collection = glow.EnsureTargets(); foreach(var glowTarget in glowTargets) collection.Insert(glowTarget); } var sourcesXml = xml.Element("sources"); if(sourcesXml != null) { var glowSources = from xmlChild in sourcesXml.Elements("Source") select new GlowSource(XmlConvert.ToInt32(xmlChild.Attribute("number").Value)); var collection = glow.EnsureSources(); foreach(var glowSource in glowSources) collection.Insert(glowSource); } var connectionsXml = xml.Element("connections"); if(connectionsXml != null) { var collection = glow.EnsureConnections(); foreach(var xmlChild in connectionsXml.Elements("Connection")) { var glowConnection = new GlowConnection(XmlConvert.ToInt32(xmlChild.Attribute("target").Value)); xmlChild.Element("sources").Do(value => glowConnection.Sources = ConvertPath(value)); xmlChild.Element("operation").Do(value => glowConnection.Operation = XmlConvert.ToInt32(value)); xmlChild.Element("disposition").Do(value => glowConnection.Disposition = XmlConvert.ToInt32(value)); collection.Insert(glowConnection); } } }
void FillMatrix(GlowMatrixBase glow, XElement xml) { var contentsXml = xml.Element("contents"); if (contentsXml != null) { contentsXml.Element("identifier").Do(value => glow.Identifier = value); contentsXml.Element("description").Do(value => glow.Description = value); contentsXml.Element("type").Do(value => glow.MatrixType = XmlConvert.ToInt32(value)); contentsXml.Element("addressingMode").Do(value => glow.AddressingMode = XmlConvert.ToInt32(value)); contentsXml.Element("targetCount").Do(value => glow.TargetCount = XmlConvert.ToInt32(value)); contentsXml.Element("sourceCount").Do(value => glow.SourceCount = XmlConvert.ToInt32(value)); contentsXml.Element("maximumTotalConnects").Do(value => glow.MaximumTotalConnects = XmlConvert.ToInt32(value)); contentsXml.Element("maximumConnectsPerTarget").Do(value => glow.MaximumConnectsPerTarget = XmlConvert.ToInt32(value)); var parametersLocationXml = contentsXml.Element("parametersLocation"); if (parametersLocationXml != null) { var attrib = parametersLocationXml.Attribute("type"); if (attrib.Value == "RELATIVE-OID") { glow.ParametersLocation = new GlowParametersLocation(ConvertPath(parametersLocationXml.Value)); } else if (attrib.Value == "INTEGER") { glow.ParametersLocation = new GlowParametersLocation(XmlConvert.ToInt32(parametersLocationXml.Value)); } } contentsXml.Element("gainParameterNumber").Do(value => glow.GainParameterNumber = XmlConvert.ToInt32(value)); var labelsXml = contentsXml.Element("labels"); if (labelsXml != null) { var glowLabels = from xmlChild in labelsXml.Elements("Label") select new GlowLabel { BasePath = ConvertPath(xmlChild.Attribute("basePath").Value), Description = xmlChild.Attribute("description").Value, }; var glowLabelsCollection = new EmberSequence(GlowTags.MatrixContents.Labels); foreach (var glowLabel in glowLabels) { glowLabelsCollection.Insert(glowLabel); } glow.Labels = glowLabelsCollection; } } var childrenXml = xml.Element("children"); if (childrenXml != null) { FillElementCollection(glow.EnsureChildren(), childrenXml); } var targetsXml = xml.Element("targets"); if (targetsXml != null) { var glowTargets = from xmlChild in targetsXml.Elements("Target") select new GlowTarget(XmlConvert.ToInt32(xmlChild.Attribute("number").Value)); var collection = glow.EnsureTargets(); foreach (var glowTarget in glowTargets) { collection.Insert(glowTarget); } } var sourcesXml = xml.Element("sources"); if (sourcesXml != null) { var glowSources = from xmlChild in sourcesXml.Elements("Source") select new GlowSource(XmlConvert.ToInt32(xmlChild.Attribute("number").Value)); var collection = glow.EnsureSources(); foreach (var glowSource in glowSources) { collection.Insert(glowSource); } } var connectionsXml = xml.Element("connections"); if (connectionsXml != null) { var collection = glow.EnsureConnections(); foreach (var xmlChild in connectionsXml.Elements("Connection")) { var glowConnection = new GlowConnection(XmlConvert.ToInt32(xmlChild.Attribute("target").Value)); xmlChild.Element("sources").Do(value => glowConnection.Sources = ConvertPath(value)); xmlChild.Element("operation").Do(value => glowConnection.Operation = XmlConvert.ToInt32(value)); xmlChild.Element("disposition").Do(value => glowConnection.Disposition = XmlConvert.ToInt32(value)); collection.Insert(glowConnection); } } }