/**
         * Creates an XML Node of the signal mapping information for the source name provided.
         */
        public XPathNodeIterator LookupSourceSignalMap(string sourceName)
        {
            XPathNodeIterator   navigator     = null;
            XmlDocument         xPathDocument = new XmlDocument();
            XmlNamespaceManager mngr          = new XmlNamespaceManager(new NameTable());

            if (_sourceSignalMap.ContainsKey(sourceName))
            {
                SourceSignalMapBean sourceSignal = _sourceSignalMap[sourceName];
                Dictionary <object, SignalMappingNounModifier> modifiers = _signalMap[sourceName];
                XmlElement signalElement = xPathDocument.CreateElement("signal");
                signalElement.SetAttribute("sourceName", sourceSignal.sourceName);
                signalElement.SetAttribute("sourceType", sourceSignal.sourceType);
                signalElement.SetAttribute("targetName", sourceSignal.targetName);
                signalElement.SetAttribute("targetType", sourceSignal.targetType);
                foreach (var signalMappingNounModifier in modifiers.Values)
                {
                    XmlElement signalAttribute = xPathDocument.CreateElement("signal_attribute");
                    string     name            = signalMappingNounModifier.Name;
                    string     value           = signalMappingNounModifier.Attribute;
                    string     qualifier       = signalMappingNounModifier.Qualifier;
                    string     type            = signalMappingNounModifier.Type;
                    string     defaultValue    = signalMappingNounModifier.Default;
                    string     suffix          = signalMappingNounModifier.Suffix;
                    signalAttribute.SetAttribute("name", name);
                    signalAttribute.SetAttribute("value", value);
                    signalAttribute.SetAttribute("qualifier", qualifier);
                    signalAttribute.SetAttribute("type", type);
                    signalAttribute.SetAttribute("default", defaultValue);
                    signalAttribute.SetAttribute("suffix", suffix);
                    signalElement.AppendChild(signalAttribute);
                }
                xPathDocument.AppendChild(signalElement);
            }
            XPathNavigator nav = xPathDocument.CreateNavigator();

            navigator = nav.Select("/", mngr);
            return(navigator);
        }
Beispiel #2
0
        public void Process(byte[] aixmlDocument)
        {
            Dictionary <string, dbTSFSignal> signalLookup = new Dictionary <string, dbTSFSignal>();
            string        xmlMapping = CreateSignalMappingXml(aixmlDocument);
            SignalMapping mapping    = XmlUtils.DeserializeObject <SignalMapping>(xmlMapping);

            if (mapping != null)
            {
                string modelName  = mapping.ModelLibrary;
                string sourceType = mapping.SourceType;
                _usedSignalsList.Clear();
                dbTSFLibrary library = GetTestSignalLibrary(mapping.ModelLibrary);
                foreach (var noun in mapping.AtlasNouns)
                {
                    string nounName      = noun.Name;
                    string tsfSignalName = noun.Tsf;
                    _usedSignalsList.Add(nounName);

                    SourceSignalMapBean mapBean = _signalMappingDao.GetMappedSignal(sourceType, nounName);
                    if (mapBean == null)
                    {
                        mapBean           = new SourceSignalMapBean();
                        mapBean.DataState = BASEBean.eDataState.DS_ADD;
                    }
                    else
                    {
                        mapBean.DataState = BASEBean.eDataState.DS_EDIT;
                    }
                    mapBean.sourceName = nounName;
                    mapBean.sourceType = sourceType;
                    if (string.IsNullOrEmpty(mapBean.targetType))
                    {
                        mapBean.targetType = modelName;
                    }
                    if (string.IsNullOrEmpty(mapBean.targetName))
                    {
                        mapBean.targetName = tsfSignalName;
                    }
                    mapBean.save();

                    foreach (var modifier in noun.Modifiers)
                    {
                        SourceSignalAttributeMapBean attribute = _signalMappingDao.GetMappedSignalAttribute(
                            mapBean.id.ToString(), modifier.Name);
                        if (attribute == null)
                        {
                            attribute                 = new SourceSignalAttributeMapBean();
                            attribute.DataState       = BASEBean.eDataState.DS_ADD;
                            attribute.mapId           = mapBean.id;
                            attribute.sourceName      = modifier.Name;
                            attribute.sourceSuffix    = modifier.Suffix;
                            attribute.targetQualifier = modifier.Qualifier;
                            attribute.targetName      = modifier.Attribute;
                            attribute.save();
                        }
                        else
                        {
                            attribute.DataState = BASEBean.eDataState.DS_EDIT;
                        }
                    }

                    if (!string.IsNullOrEmpty(tsfSignalName))
                    {
                        List <TestSignalBean> signals = _signalDao.getTSFSignals(tsfSignalName);
                        foreach (TestSignalBean testSignalBean in signals)
                        {
                        }
                    }
                }



                if (library != null)
                {
                    //--- Create a lookup map for all the signals in the library ---//
                    foreach (dbTSFSignal tsfSignal in library.Signals)
                    {
                        if (!signalLookup.ContainsKey(tsfSignal.signalName))
                        {
                            signalLookup.Add(tsfSignal.signalName, tsfSignal);
                        }
                    }
                }
            }
        }