Esempio n. 1
0
        private void AddDiscreteTimeExecution(CDiscreteTimeExecutionData dted)
        {
            CTaskExecutionTrace executionTrace;
            int   ii = 0;
            CTask task;

            if (!checkBoxDisplayDiscreteTimeExecution.Checked)
            {
                return;
            }

            UpdateStatus("Displaying discrete time execution ...");

            if (textDiscreteTaskExecution.InvokeRequired)
            {
                textDiscreteTaskExecution.Invoke(new AddDiscreteTimeExecutionDelegate(this.AddDiscreteTimeExecution), dted);
            }
            else
            {
                textDiscreteTaskExecution.Text = "---->" + dted.sFileName + ", Hyperperiod = " + dted.hp.ToString() + "\r\n";
                executionTrace = dted.executionTrace;

                for (ii = 0; ii < executionTrace.Count; ii++)
                {
                    task = executionTrace.Get(ii);
                    Application.DoEvents();

                    if (task != null)
                    {
                        textDiscreteTaskExecution.Text = textDiscreteTaskExecution.Text + ii.ToString() +
                                                         "\t" + task.ID + "\r\n";
                    }
                    //Scroll to Last Message
                    textDiscreteTaskExecution.SelectionStart = textDiscreteTaskExecution.Text.Length;
                    textDiscreteTaskExecution.ScrollToCaret();
                }
            }
        }
Esempio n. 2
0
        private void RunSimulation()
        {
            bool            bStatus;
            IExecutionModel em = (IExecutionModel)_internalConfig.selectedExecutionModel.objMain;
            IFileFormatter  ff = (IFileFormatter)_internalConfig.selectedFileFormatter.objMain;
            IDiscreteExecutionTraceWriter etw = (IDiscreteExecutionTraceWriter)_internalConfig.selectedExecutionTraceWriter.objMain;

            string   sFileContents;
            string   sFileName;
            CTaskSet ts;

            if (textFolderName.Text.Trim() == "")
            {
                MessageBox.Show("Please select a Valid Folder");
                return;
            }

            DirectoryInfo di = new DirectoryInfo(textFolderName.Text);


            if (!di.Exists)
            {
                MessageBox.Show("Selected folder does not exists");
                return;
            }

            FileInfo[] rgFiles = di.GetFiles("*.*");

            foreach (FileInfo fi in rgFiles)
            {
                //Iterate over Task Set

                Application.DoEvents();
                UpdateStatus("Reading and parsing file " + fi.Name);
                sFileContents = ReadFromFile(fi.FullName);
                ts            = ff.ParseTaskSet(sFileContents);

                UpdateStatus("Processing file " + fi.Name + " till " + ts.HyperPeriod + " steps ...");
                bStatus = em.SimulateExecution(ts);

                if (bStatus)
                {
                    AddTaskSetSchedulability(fi.Name + ", TRUE" + ", Last Time: " + em.LastDiscreteTimeValue.ToString());
                }
                else
                {
                    AddTaskSetSchedulability(fi.Name + ", FALSE" + ", Last Time: " + em.LastDiscreteTimeValue.ToString());
                }


                CDiscreteTimeExecutionData dted = new CDiscreteTimeExecutionData();
                dted.hp             = ts.HyperPeriod;
                dted.sFileName      = fi.Name;
                dted.executionTrace = em.ExecutionTrace;

                AddDiscreteTimeExecution(dted);

                if (textTraceFolder.Text.Trim() != "")
                {
                    //Convert 1.txt to 1_txt
                    sFileName = fi.Name.Replace('.', '_');

                    //Write to File
                    etw.WriteFile(dted.executionTrace,
                                  textTraceFolder.Text.Trim(), sFileName, _config);
                }
            }
            UpdateStatus("Completed processing of all files");
        }