Ejemplo n.º 1
0
 public static MetaTBManifest Deserialize(string fileName)
 {
     MetaTBManifest manifest = JsonConvert.DeserializeObject<MetaTBManifest>(System.IO.File.ReadAllText(fileName));
     manifest.Artifacts = manifest.Artifacts ?? new List<Artifact>();
     manifest.Dependencies = manifest.Dependencies ?? new List<Dependency>();
     manifest.Metrics = manifest.Metrics ?? new List<Metric>();
     manifest.Parameters = manifest.Parameters ?? new List<Parameter>();
     manifest.Steps = manifest.Steps ?? new List<Step>();
     manifest.VisualizationArtifacts = manifest.VisualizationArtifacts ?? new List<Artifact>();
     return manifest;
 }
Ejemplo n.º 2
0
        public static MetaTBManifest OpenForUpdate(string outputDir = "")
        {
            string fullPathFileName = Path.Combine(outputDir, TESTBENCH_FILENAME);

            if (System.IO.File.Exists(fullPathFileName))
            {
                MetaTBManifest oldManifest = Deserialize(fullPathFileName);
                return(oldManifest);
            }

            return(new MetaTBManifest());
        }
Ejemplo n.º 3
0
        protected void CopyManifest(MetaTBManifest other)
        {
            this.Created         = other.Created;
            this.DesignID        = other.DesignID;
            this.DesignName      = other.DesignName;
            this.CfgID           = other.CfgID;
            this.TestBench       = other.TestBench;
            this.TierLevel       = other.TierLevel;
            this.CopyTestResults = other.CopyTestResults;

            foreach (var item in other.Artifacts)
            {
                this.Artifacts.Add(item);
            }

            foreach (var item in other.Metrics)
            {
                this.Metrics.Add(item);
            }

            foreach (var item in other.Parameters)
            {
                this.Parameters.Add(item);
            }

            foreach (var item in other.Steps)
            {
                this.Steps.Add(item);
            }

            foreach (var item in other.Dependencies)
            {
                this.Dependencies.Add(item);
            }
            foreach (var item in other.FileInputs)
            {
                this.FileInputs.Add(item);
            }
            foreach (var item in other.FileOutputs)
            {
                this.FileOutputs.Add(item);
            }
        }
Ejemplo n.º 4
0
        public void MakeManifest(
            ISIS.GME.Common.Interfaces.FCO testBench,
            string outputDir = "",
            bool update      = true)
        {
            Contract.Requires(testBench != null);

            string fullPathFileName = Path.Combine(outputDir, TESTBENCH_FILENAME);
            bool   shouldUpdate     = false;

            if (update && System.IO.File.Exists(fullPathFileName))
            {
                MetaTBManifest oldManifest = Deserialize(fullPathFileName);
                this.CopyManifest(oldManifest);
                shouldUpdate = true;
            }

            this.TestBench = string.IsNullOrEmpty((testBench.Impl as MgaFCO).RegistryValue["TestBenchUniqueName"]) ?
                             testBench.Name :
                             (testBench.Impl as MgaFCO).RegistryValue["TestBenchUniqueName"];

            this.Created = DateTime.UtcNow.ToString("o");
            // FIXME: put design name here...
            this.DesignName = testBench.Name;

            if (testBench is CyPhy.BallisticTestBench)
            {
                this.TierLevel = (int)(testBench as CyPhy.BallisticTestBench).Attributes.Tier;
            }

            if (testBench is CyPhy.TestBenchType)
            {
                var testBenchType = ISIS.GME.Dsml.CyPhyML.Classes.TestBenchType.Cast(testBench.Impl);

                foreach (var item in testBenchType.Children.MetricCollection)
                {
                    if (shouldUpdate)
                    {
                        var oldData = this.Metrics.FirstOrDefault(x => x.ID == item.Guid.ToString());
                        if (oldData != null)
                        {
                            this.Metrics.Remove(oldData);
                        }
                    }

                    AVM.DDP.MetaTBManifest.Metric metric = new AVM.DDP.MetaTBManifest.Metric();
                    metric.Name = item.Name.Trim();
                    metric.Unit = (item.Impl as MgaReference).Referred == null ?
                                  string.Empty :
                                  (item.Impl as MgaReference).Referred.Name;

                    // TODO: add the displayed name
                    metric.Value       = item.Attributes.Value;
                    metric.ID          = item.Guid.ToString();
                    metric.GMEID       = item.ID;
                    metric.Description = item.Attributes.Description;
                    this.Metrics.Add(metric);
                }

                foreach (var item in testBenchType.Children.ParameterCollection)
                {
                    if (shouldUpdate)
                    {
                        var oldData = this.Parameters.FirstOrDefault(x => x.ID == item.Guid.ToString());
                        if (oldData != null)
                        {
                            this.Parameters.Remove(oldData);
                        }
                    }

                    AVM.DDP.MetaTBManifest.Parameter parameter = new AVM.DDP.MetaTBManifest.Parameter();
                    parameter.Name = item.Name;
                    parameter.Unit = (item.Impl as MgaReference).Referred == null ?
                                     string.Empty :
                                     (item.Impl as MgaReference).Referred.Name;

                    parameter.Description = item.Attributes.Description;
                    parameter.GMEID       = item.ID;
                    parameter.ID          = item.Guid.ToString();
                    parameter.Range       = item.Attributes.Range;
                    parameter.Value       = item.Attributes.Value;

                    this.Parameters.Add(parameter);
                }

                foreach (var item in testBenchType.Children.FileInputCollection)
                {
                    if (shouldUpdate)
                    {
                        var oldData = this.FileInputs.FirstOrDefault(x => x.Name == item.Name);
                        if (oldData != null)
                        {
                            this.FileInputs.Remove(oldData);
                        }
                    }

                    AVM.DDP.MetaTBManifest.FileInput fileInput = new AVM.DDP.MetaTBManifest.FileInput();
                    fileInput.Name     = item.Name;
                    fileInput.FileName = item.Attributes.FileName != "" ? item.Attributes.FileName : fileInput.Name;

                    this.FileInputs.Add(fileInput);
                }

                foreach (var item in testBenchType.Children.FileOutputCollection)
                {
                    if (shouldUpdate)
                    {
                        var oldData = this.FileOutputs.FirstOrDefault(x => x.Name == item.Name);
                        if (oldData != null)
                        {
                            this.FileOutputs.Remove(oldData);
                        }
                    }

                    AVM.DDP.MetaTBManifest.FileOutput fileOutput = new AVM.DDP.MetaTBManifest.FileOutput();
                    fileOutput.Name     = item.Name;
                    fileOutput.FileName = item.Attributes.FileName != "" ? item.Attributes.FileName : item.Name;

                    this.FileOutputs.Add(fileOutput);
                }

                // get designID
                string designID = null;
                var    tlsut    = testBenchType.Children.TopLevelSystemUnderTestCollection.FirstOrDefault();
                var    catlsut  = testBenchType.Children.ComponentAssemblyCollection.FirstOrDefault();
                if (tlsut != null)
                {
                    // if it is a reference
                    if (tlsut.Referred.DesignEntity != null)
                    {
                        designID = tlsut.Referred.DesignEntity.Properties.Guid.ToString("B");
                        if (tlsut.Referred.DesignEntity is CyPhy.ComponentAssembly)
                        {
                            catlsut = tlsut.Referred.ComponentAssembly;
                            var cid = catlsut.Attributes.ConfigurationUniqueID;
                            //this.ConfigurationUniqueID = cid;

                            if (string.IsNullOrWhiteSpace(cid))
                            {
                                cid = Guid.NewGuid().ToString("B");
                                catlsut.Attributes.ConfigurationUniqueID = cid;
                            }

                            if (!string.IsNullOrEmpty(cid))
                            {
                                try
                                {
                                    Guid guid = new Guid(cid);
                                    designID = guid.ToString("B");
                                }
                                catch (System.FormatException ex)
                                {
                                    Trace.TraceError("{0} is not a vaild GUID.", cid);
                                    Trace.TraceError(ex.ToString());
                                }
                            }
                        }
                    }
                }
                else if (catlsut != null)
                {
                    // if it is an instance
                    var cid = catlsut.Attributes.ConfigurationUniqueID;

                    if (!string.IsNullOrEmpty(cid))
                    {
                        Guid guid = new Guid(cid);
                        designID = guid.ToString("B");
                    }
                }

                // this.CopyTestResults = testBench.Attributes.CopyResults;

                this.DesignID = designID;
            }
        }
Ejemplo n.º 5
0
        protected void CopyManifest(MetaTBManifest other)
        {
            this.Created = other.Created;
            this.DesignID = other.DesignID;
            this.DesignName = other.DesignName;
            this.CfgID = other.CfgID;
            this.TestBench = other.TestBench;
            this.TierLevel = other.TierLevel;
            this.CopyTestResults = other.CopyTestResults;

            foreach (var item in other.Artifacts)
            {
                this.Artifacts.Add(item);
            }

            foreach (var item in other.Metrics)
            {
                this.Metrics.Add(item);
            }

            foreach (var item in other.Parameters)
            {
                this.Parameters.Add(item);
            }

            foreach (var item in other.Steps)
            {
                this.Steps.Add(item);
            }

            foreach (var item in other.Dependencies)
            {
                this.Dependencies.Add(item);
            }
        }