예제 #1
0
 public void AddTestStation(TestStationSignalAnalysis testStation)
 {
     _testStations.Add(testStation);
 }
        public string Analyze( string testDescriptionXml )
        {
            string xml = "";
            try
            {
                var dao = new InstrumentDAO();
                var testDescription = TestDescription.Deserialize( testDescriptionXml );
                var signalTypeLookup = new Dictionary<string, SignalAnalysisType>();
                var signalList = new List<string>();

                Dictionary<SignalRequirementsSignalRequirement, ICollection<object>> equips = Build( testDescription );

                foreach (SignalRequirementsSignalRequirement signalRequirement in testDescription.SignalRequirements)
                {
                    string name = signalRequirement.TsfClass.tsfClassName;
                    string id = signalRequirement.TsfClass.tsfLibraryID;
                    SignalRole role = signalRequirement.role;
                    if ("SHORT".Equals( name ))
                        continue;
                    if ("".Equals( name ))
                        continue;

                    SignalAnalysisType sat = null;
                    if (!signalTypeLookup.ContainsKey( name ))
                    {
                        sat = new SignalAnalysisType();
                        sat.Type = name;
                        signalTypeLookup.Add( name, sat );
                    }

                    sat = signalTypeLookup[name];
                    SignalInstance si = new SignalInstance();
                    si.Tsf = id;
                    foreach (
                        SignalRequirementsSignalRequirementTsfClassAttribute tsfClassAttribute in
                            signalRequirement.TsfClassAttribute)
                    {

                        SignalInstanceAttribute sia = new SignalInstanceAttribute();
                        sia.Name = tsfClassAttribute.Name.Value;
                        sia.Value = tsfClassAttribute.Value.ToString();
                        if (tsfClassAttribute.Value.Item is DatumType)
                        {
                            object v = Datum.GetNominalDatumValue( (DatumType) tsfClassAttribute.Value.Item );
                            sia.NominalValue = v==null?null:v.ToString();
                            sia.Qualifier = ( (DatumType) tsfClassAttribute.Value.Item ).unitQualifier;
                        }
                        si.AddAttribute(sia);
                    }
                    if (!signalList.Contains( name + id + si ))
                    {
                        signalList.Add( name + id + si );
                        sat.AddSignal( si );
                        Console.WriteLine( name + si );
                    }
                }

                SignalAnalysis signalAnalysis = new SignalAnalysis();
                signalAnalysis.Uut = new Uut();
                if (testDescription.UUT != null && testDescription.UUT.Description != null &&
                    testDescription.UUT.Description.Item != null)
                {
                    var id = testDescription.UUT.Description.Item as ItemDescription;
                    var docRef = testDescription.UUT.Description.Item as DocumentReference;
                    if (docRef != null)
                    {
                        signalAnalysis.Uut.Name = docRef.DocumentName;
                        signalAnalysis.Uut.Uuid = docRef.uuid;
                    }
                    else if (id != null)
                    {
                        signalAnalysis.Uut.Name = id.name;
                        signalAnalysis.Uut.Uuid = id.Identification.ModelName;
                        signalAnalysis.Uut.Version = id.version;
                    }

                }

                signalAnalysis.Tps = ATMLContext.CurrentProjectName;
                signalAnalysis.RunDateTime = String.Format("{0:yyyy-dd-MM HH:mm:ss}", DateTime.Now);

                foreach (var testStation in ATMLAllocator.Instance.SelectedTestStations)
                {
                    var tsa = new TestStationSignalAnalysis();
                    tsa.Name = testStation.name;
                    tsa.Uuid = testStation.uuid;
                    signalAnalysis.AddTestStation( tsa );

                    foreach (SignalAnalysisType signalType in signalTypeLookup.Values)
                    {
                        SignalAnalysisType copy = signalType.Copy();
                        tsa.AddSignal(copy);
                        foreach (var signalInstance in copy.SignalInstances)
                        {
                            foreach (var signalInstanceAttribute in signalInstance.Attributes)
                            {
                                try
                                {
                                    if (signalInstanceAttribute.NominalValue != null)
                                    {
                                        bool isValid = dao.TestAttribute( testStation.uuid,
                                                                          signalInstanceAttribute.Name,
                                                                          signalInstanceAttribute.NominalValue,
                                                                          signalInstanceAttribute.Qualifier);

                                        signalInstanceAttribute.IsValid = isValid;
                                    }
                                }
                                catch (Exception err)
                                {
                                    LogManager.SourceError(ATMLAllocator.SOURCE, err);
                                }
                            }
                        }

                    }
                }

                xml = XmlUtils.SerializeObject( signalAnalysis );
            }
            catch (Exception e)
            {
                LogManager.SourceError(ATMLAllocator.SOURCE, e);
            }
            return xml;
        }
예제 #3
0
 public void AddTestStation( TestStationSignalAnalysis testStation )
 {
     _testStations.Add( testStation );
 }