Example #1
0
        public void SetTask(PeriodicTask task, double startTime, double endTime)
        {
            _task      = task;
            _startTime = startTime;
            _endTime   = endTime;

            _listReleaseTime  = _task.GetReleaseTime(_startTime, _endTime);
            _listSoftDeadline = _task.GetSoftDeadline(_startTime, _endTime);
            _listHardDeadline = _task.GetHardDeadline(_startTime, _endTime);
        }
Example #2
0
        public TimeDiagram()
        {
            InitializeComponent();

            _startTime = 0;
            _endTime   = 100;
            _task      = new PeriodicTask("task", 5, 3, 3, 0.8, 5, 0);

            _listReleaseTime  = _task.GetReleaseTime(_startTime, _endTime);
            _listSoftDeadline = _task.GetSoftDeadline(_startTime, _endTime);
            _listHardDeadline = _task.GetHardDeadline(_startTime, _endTime);
        }
        private double GetUtilizationOfWorkload(DataTable dt)
        {
            double SumUtilization = 0;

            foreach (DataRow dr in dt.Rows)
            {
                PeriodicTask t = new PeriodicTask(dr);
                SumUtilization += t.Utilization;
            }

            return(SumUtilization);
        }
        private long GetLCM_forWorkload(DataTable dt)
        {
            PeriodicTask firstTask = new PeriodicTask(dt.Rows[0]);
            long         LCM       = (long)firstTask.Period;

            foreach (DataRow dr in dt.Rows)
            {
                PeriodicTask t = new PeriodicTask(dr);
                LCM = GetLCM(LCM, (long)t.Period);
            }

            return(LCM);
        }
Example #5
0
        internal void SetTask(PeriodicTask periodicTask, int startTime, long endTime)
        {
            TimeDiagram diagram = new TimeDiagram();

            diagram.BackColor   = System.Drawing.Color.White;
            diagram.Location    = new System.Drawing.Point(3, 3);
            diagram.MinimumSize = new System.Drawing.Size(100, 100);
            diagram.Size        = new System.Drawing.Size(582, 100);
            diagram.Dock        = DockStyle.Fill;

            diagram.SetTask(periodicTask, startTime, endTime);

            tableLayoutPanel1.Controls.Add(diagram);
        }
Example #6
0
        private void DrawTaskEvents(PaintEventArgs e)
        {
            Pen penBlack = new Pen(Brushes.Black, (float)(this.Width * 0.001));
            Pen penRed   = new Pen(Brushes.Red, (float)(this.Width * 0.002));
            Pen penBlue  = new Pen(Brushes.Blue, (float)(this.Width * 0.002));

            Font fontBig     = new Font("Times new roman", (float)(this.Width * 0.03), FontStyle.Regular, GraphicsUnit.Pixel);
            Font fontRegular = new Font("Times new roman", (float)(this.Width * 0.015), FontStyle.Regular, GraphicsUnit.Pixel);
            Font fontBold    = new Font("Times new roman", (float)(this.Width * 0.015), FontStyle.Bold, GraphicsUnit.Pixel);

            // 베이스 라인 길이
            int timelineWidth = (int)(this.Width * 0.8);
            int boxHeight     = (int)(this.Height * 0.3);
            int arrowHeight   = (int)(this.Height * 0.4);

            // 단위 유닛
            float unit = (float)(timelineWidth / (_endTime - _startTime));

            // 베이스 라인
            Point timeline1 = new Point((int)(this.Width * 0.08), (int)(this.Height * 0.6));
            Point timeline2 = new Point(timeline1.X + timelineWidth, timeline1.Y);

            // Task 박스 그리기
            foreach (JobEvent evnt in _listTaskEvent)
            {
                float startX         = (float)(timeline1.X + (evnt.AbsStartTime * unit));
                float executionWidth = (float)((evnt.AbsCompleteTime - evnt.AbsStartTime) * unit) - 1;

                RectangleF rectBox = new RectangleF(startX, timeline1.Y - boxHeight, executionWidth, boxHeight);
                Brush      gradientBrush;
                Pen        penOutline;
                if (evnt.IsHardDeadlineMissed)
                {
                    gradientBrush = new LinearGradientBrush(rectBox, colorHardDeadlineMissTop, colorHardDeadlineMissBottom, LinearGradientMode.Vertical);
                    penOutline    = new Pen(colorHardDeadlineMissBottom, 1);
                }
                else if (evnt.IsSoftDeadlineMissed)
                {
                    gradientBrush = new LinearGradientBrush(rectBox, colorSoftDeadlineMissTop, colorSoftDeadlineMissBottom, LinearGradientMode.Vertical);
                    penOutline    = new Pen(colorSoftDeadlineMissBottom, 1);
                }
                else
                {
                    gradientBrush = new LinearGradientBrush(rectBox, colorTaskTop, colorTaskBottom, LinearGradientMode.Vertical);
                    penOutline    = new Pen(colorTaskBottom, 1);
                }

                e.Graphics.FillRectangle(gradientBrush, rectBox);
                e.Graphics.DrawRectangle(penOutline, Rectangle.Ceiling(rectBox));
            }

            // 베이스 라인 그리기
            e.Graphics.DrawLine(penBlack, timeline1, timeline2);

            int arrowSize = (int)Math.Max((this.Width * 0.008), 3);

            // 눈금 그리기
            float gridUnit = (float)(_endTime - _startTime) / 10;

            for (int i = 0; i <= 10; i++)
            {
                Point p1 = new Point((int)(timeline1.X + unit * gridUnit * i), timeline1.Y);
                Point p2 = new Point((int)(timeline1.X + unit * gridUnit * i), timeline1.Y + arrowSize);

                e.Graphics.DrawLine(penBlack, p1, p2);

                // 단위 숫자 그리기
                String number     = String.Format("{0:F0}", (_startTime + gridUnit * i));
                SizeF  sizeNumber = e.Graphics.MeasureString(number, fontRegular);
                e.Graphics.DrawString(number, fontRegular, Brushes.Black,
                                      new PointF((timeline1.X + unit * gridUnit * i) - sizeNumber.Width / 2, timeline1.Y + sizeNumber.Height / 2));
            }

            // 화살표 그리기
            foreach (double time in _listReleaseTime)
            {
                float startX            = (float)(timeline1.X + (time * unit));
                int   softDeadlineWidth = (int)((_listTaskEvent[0].ParentTask.SoftDeadline * unit));

                // Release time 표시
                e.Graphics.DrawLine(penBlue,
                                    new Point((int)startX, (int)(timeline1.Y - arrowHeight)),
                                    new Point((int)startX, timeline1.Y));

                e.Graphics.DrawLine(penBlue,
                                    new Point((int)startX - arrowSize, (int)timeline1.Y - arrowHeight + arrowSize),
                                    new Point((int)startX, (int)(timeline1.Y - arrowHeight)));

                e.Graphics.DrawLine(penBlue,
                                    new Point((int)startX + arrowSize, (int)timeline1.Y - arrowHeight + arrowSize),
                                    new Point((int)startX, (int)(timeline1.Y - arrowHeight)));

                // Soft Deadline 표시
                e.Graphics.DrawLine(penRed,
                                    new Point((int)startX + softDeadlineWidth, (int)(timeline1.Y - arrowHeight)),
                                    new Point((int)startX + softDeadlineWidth, timeline1.Y));

                e.Graphics.DrawLine(penRed,
                                    new Point((int)startX + softDeadlineWidth - arrowSize, (int)timeline1.Y - arrowSize),
                                    new Point((int)startX + softDeadlineWidth, timeline1.Y));

                e.Graphics.DrawLine(penRed,
                                    new Point((int)startX + softDeadlineWidth + arrowSize, (int)timeline1.Y - arrowSize),
                                    new Point((int)startX + softDeadlineWidth, timeline1.Y));
            }

            // Task 이름 표시
            {
                PeriodicTask task = _listTaskEvent[0].ParentTask;

                String name       = String.Format("τ");
                SizeF  sizeNumber = e.Graphics.MeasureString(name, fontBig);
                e.Graphics.DrawString(name, fontBig, Brushes.Black,
                                      new PointF((float)(this.Width * 0.02), (float)((this.Height - sizeNumber.Height) * 0.5)));

                String nameSub       = String.Format("{0}", task.TaskNumber + 1);
                SizeF  sizeNumberSub = e.Graphics.MeasureString(name, fontRegular);
                e.Graphics.DrawString(nameSub, fontRegular, Brushes.Black,
                                      new PointF((float)(this.Width * 0.04), (float)((this.Height - sizeNumberSub.Height) * 0.55)));
            }

            // 성공률 표시
            {
                PeriodicTask task  = _listTaskEvent[0].ParentTask;
                int          total = (int)(_endTime / task.Period);
                float        rate  = 1 - ((float)task.MissCount / total);

                String achievement     = String.Format("Achievement");
                SizeF  sizeAchievement = e.Graphics.MeasureString(achievement, fontRegular);
                e.Graphics.DrawString(achievement, fontBold, Brushes.Black,
                                      new PointF((float)(this.Width * 0.9), (float)(this.Height * 0.4) - sizeAchievement.Height));

                String number     = String.Format("{0:F2}", rate);
                SizeF  sizeNumber = e.Graphics.MeasureString(number, fontBold);
                e.Graphics.DrawString(number, fontBold, Brushes.Black,
                                      new PointF((float)(this.Width * 0.9) + sizeNumber.Width, (float)(this.Height * 0.4)));
            }
        }
Example #7
0
 public JobEvent(PeriodicTask parentTask)
 {
     _parentTask = parentTask;
 }