Beispiel #1
0
        public double DrawWork(int j, int need_proc_id, List <work_view> dependWorkList)
        {
            double start = 50;

            for (int o = 0; o < dependWorkList.Count; o++)
            {
                foreach (sub_work_view sub_work in SubWorkList)
                {
                    if (sub_work.to_id == TopListNew[j].id && sub_work.end_x > start)
                    {
                        start = sub_work.end_x;
                    }
                }
            }

            if (start == 50 && dependWorkList.Count > 0)
            {
                start = dependWorkList[0].end_x;
            }

            List <work_view> _work_new   = new List <work_view>();
            double           weight_node = interval_vertical * (int)TopListNew[j].weight;

            Dictionary <work_view, double> _dict_work = new Dictionary <work_view, double>();

            for (int m = 0; m < WorkList.Count; m++)
            {
                if (WorkList[m].end_y == LinesHorizontal.Find(x => x.id.Equals(need_proc_id)).startY)
                {
                    if (WorkList[m].end_x > start)
                    {
                        _dict_work.Add(WorkList[m], WorkList[m].end_x);
                    }
                }
            }

            _dict_work = _dict_work.OrderBy(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);

            foreach (var n_c in _dict_work)
            {
                _work_new.Add(n_c.Key);
            }

            if (_work_new.Count > 0)
            {
                for (int m = 0; m < _work_new.Count; m++)
                {
                    double other_start_x = _work_new[m].end_x - _work_new[m].rect_width;

                    if ((start < other_start_x && (start + weight_node) >
                         other_start_x) || (start < _work_new[m].end_x &&
                                            (start + weight_node) > other_start_x) || start == other_start_x)
                    {
                        start = _work_new[m].end_x;
                    }
                }
            }

            _w_view = new work_view(this, TopListNew[j].id.ToString(), weight_node, start,
                                    LinesHorizontal.Find(x => x.id.Equals(need_proc_id)).startY - 20, need_proc_id);
            status[j] = true;

            return(_w_view.end_x);
        }
Beispiel #2
0
        public void Planning(int destination_algorithm)
        {
            CSQueue();
            FillDependentNodes();
            MatrixCS();

            for (int i = 0, j = 0; j < TopListNew.Count && i < TopListCSNew.Count; j++)
            {
                if (neighbors_nodes[TopListNew[j].id].Count == 0)
                {
                    double startY = LinesHorizontal.Find(x => x.id.Equals(TopListCSNew[i].id)).startY;

                    _w_view = new work_view(this, TopListNew[j].id.ToString(),
                                            interval_vertical * (int)TopListNew[j].weight, 50,
                                            startY - 20, TopListCSNew[i].id);
                    status[j] = true;
                    i++;
                }
            }


            for (int j = 0; j < TopListNew.Count; j++)
            {
                if (!status[j])
                {
                    List <int> depend            = neighbors_nodes[TopListNew[j].id];
                    int        count_depend_done = 0;
                    for (int k = 0; k < depend.Count; k++)
                    {
                        int index = 0;
                        for (index = 0; index < TopListNew.Count; index++)
                        {
                            if (TopListNew[index].id == depend[k])
                            {
                                break;
                            }
                        }
                        if (status[index])
                        {
                            count_depend_done++;
                        }
                    }
                    if (count_depend_done == depend.Count)
                    {
                        List <work_view> dependWorkList = new List <work_view>();
                        for (int k = 0; k < depend.Count; k++)
                        {
                            dependWorkList.Add(WorkList.Find(x => x.rect_id.Equals(depend[k])));
                        }

                        int need_proc_id = -1;
                        if (destination_algorithm == 4 || destination_algorithm == 5)
                        {
                            need_proc_id = FindNeedProcAlg4(j, depend, dependWorkList);
                        }
                        else if (destination_algorithm == 6)
                        {
                            need_proc_id = FindNeedProcAlg6(j, dependWorkList);
                        }
                        DrawSubWorks(destination_algorithm, j, need_proc_id, dependWorkList);
                        DrawWork(j, need_proc_id, dependWorkList);

                        for (int k = 0; k < j; k++)
                        {
                            if (!status[k])
                            {
                                j = k - 1;
                                break;
                            }
                        }
                    }
                }
            }
        }