예제 #1
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);
                    }
                }
            }
        }