コード例 #1
0
ファイル: SoTImpl.cs プロジェクト: neemask/meta-core
        public void Run()
        {
            if (string.IsNullOrEmpty(this.WorkingDirectory) ||
                Directory.Exists(this.WorkingDirectory) == false)
            {
                // nothing needs to be done.
                return;
            }

            // TODO: exception handling... 

            // get manifest file
            string manifestFile = Path.Combine(this.WorkingDirectory, "manifest.sot.json");
            if (File.Exists(manifestFile) == false)
            {
                Trace.TraceError("{0} file does not exist", manifestFile);
                return;
            }

            // this could fail... exception handling!
            sotConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<CyPhySoT.SotConfig>(File.ReadAllText(manifestFile));

            // get mga filename
            string mgaFileName = Path.Combine(this.WorkingDirectory, sotConfig.ProjectFileName);

            if (File.Exists(mgaFileName) == false)
            {
                Trace.TraceError("{0} file does not exist", mgaFileName);
                return;
            }

            this.ProjectConnStr = "MGA=" + mgaFileName;

            Semaphore sem = null;

            if (criticalSection.TryGetValue(this.ProjectConnStr, out sem) == false)
            {
                criticalSection[this.ProjectConnStr] = new Semaphore(1, 1);
            }

            // Load GME model
            this.OpenProject();

            if (sotConfig.MultiJobRun)
            {
                Project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_READ_ONLY);
                try
                {
                    this.TestBenches = GetMultiJobRunTestBenches(CurrentObj, Path.GetDirectoryName(sotConfig.ProjectFileName));
                }
                finally
                {
                    Project.AbortTransaction();
                }
            }
            else
            {
                CyPhySoT.CyPhySoTInterpreter sotInterpreter = new CyPhySoT.CyPhySoTInterpreter();
                this.TestBenches = sotInterpreter.GetTestbenchesFromModel(this.Project, (MgaModel)this.CurrentObj, Path.GetDirectoryName(this.WorkingDirectory));
                Project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_NON_NESTED);
                try
                {
                    // replace tb in TestBenches that corresponds to the MultiJobRun with the tbs from GetMultiJobRunTestBenches
                    foreach (var tb in TestBenches.ToList<CyPhySoT.TestBench>())
                    {
                        var modelProcessor = AnalysisModelProcessor.GetAnalysisModelProcessor((IMgaModel)tb.CurrentObj);
                        if (modelProcessor is MultiJobRunProcessor)
                        {
                            List<CyPhySoT.TestBench> multiTbs = GetMultiJobRunTestBenches(tb.CurrentObj, tb.OutputDirectory);
                            foreach (var upstreamTb in tb.UpstreamTestBenches)
                            {
                                upstreamTb.DownstreamTestBenches.Remove(tb);
                                upstreamTb.DownstreamTestBenches.Add(multiTbs[0]);
                                multiTbs[0].UpstreamTestBenches.Add(upstreamTb);
                            }
                            foreach (var downstreamTb in tb.DownstreamTestBenches)
                            {
                                downstreamTb.UpstreamTestBenches.Remove(tb);
                                downstreamTb.UpstreamTestBenches.Add(multiTbs[multiTbs.Count - 1]);
                                multiTbs[multiTbs.Count - 1].DownstreamTestBenches.Add(downstreamTb);
                            }
                            this.TestBenches.AddRange(multiTbs);
                            this.TestBenches.Remove(tb);
                        }
                    }
                }
                finally
                {
                    Project.AbortTransaction();
                }
            }

            // TODO: update value flow!

            // Test bench/job map
            foreach (var testbench in this.TestBenches)
            {
                JobImpl job = new JobImpl(this.Server);

                this.TestBenchJobMap.Add(testbench, job);
            }

            try
            {
                // propagate the values between test benches
                PropagateValueFlow();
            }
            catch (JobFailure ex)
            {
                // FIXME: add some GUI notification
                string failed_txt = Path.Combine(this.WorkingDirectory, "_FAILED.txt");
                File.WriteAllText(failed_txt, String.Format("SoT {0} failed: {1}", this.sotName, ex.ToString()));
                this.CloseProject();
                return;
            }

            // get all testbenches from sot that can be run without dependency
            foreach (var testbench in this.TestBenches.Where(x => x.UpstreamTestBenches.Count == 0))
            {
                // call interpreters for this test bench and post it to the job manager
                RunTestBenchAndStart(testbench);
            }

            this.CloseProject();
        }
コード例 #2
0
 public override Job CreateJob()
 {
     Job job = new JobImpl(this);
     return job;
 }