Ejemplo n.º 1
0
        public void AutoLoadNext()
        {
            int powerDistance = 50;

            if (this.isLoaded)
            {
                List <PowerFrequency>[] pfList = new List <PowerFrequency> [TimeSlotUtils.TimeSlotToSize(this.timeslot)];

                for (int p = 0; p < this.dayStore[(int)this.day][0].data.timeSlot.Length; p++)
                {
                    pfList[p] = new List <PowerFrequency>();
                }


                for (int d = 0; d < this.dayStore[(int)this.day].Count; d++)
                {
                    for (int t = 0; t < this.dayStore[(int)this.day][d].data.timeSlot.Length; t++)
                    {
                        PowerFrequency findPf = pfList[t].Find(
                            (pf) => pf.wh == Math.Floor((Math.Round(this.dayStore[(int)this.day][d].data.timeSlot[t] / 10) * 10) / powerDistance) * powerDistance);

                        if (findPf == null)
                        {
                            pfList[t].Add(new PowerFrequency(Math.Floor((Math.Round(this.dayStore[(int)this.day][d].data.timeSlot[t] / 10) * 10) / powerDistance) * powerDistance));
                        }
                        else
                        {
                            findPf.IncFrequency();
                        }
                    }
                }

                for (int p = 0; p < this.dayStore[(int)this.day][0].data.timeSlot.Length; p++)
                {
                    pfList[p].Sort();

                    if (pfList[p][pfList[p].Count() - 1].wh >= maxWh)
                    {
                        maxWh = pfList[p][pfList[p].Count() - 1].wh;
                    }
                }

                if (++this.autoCount >= 10)
                {
                    this.changed.Invoke(this, new ModelEventArgs(COMMON_ACTIONS.STOP_LOADING));
                    this.changed.Invoke(this, new ModelEventArgs(VIEW_ACTIONS.AUTO_LOAD_LAST, this.keyword, pfList, this.timeslot));
                }
                else
                {
                    this.changed.Invoke(this, new ModelEventArgs(VIEW_ACTIONS.AUTO_LOAD_NEXT_SUCCESS, this.keyword, pfList, this.timeslot));
                }
            }
        }
Ejemplo n.º 2
0
        public ClusterComponent(List <PowerFrequency>[] cpf, TimeSlot ts)
        {
            InitializeComponent();
            this.VisibleGrp = new List <MetroFramework.Controls.MetroCheckBox>()
            {
                this.Visible1,
                this.Visible2,
                this.Visible3,
                this.Visible4,
                this.Visible5,
                this.Visible6,
                this.Visible7,
                this.Visible8
            };

            int startHours = 0;

            for (int p = 0; p < cpf.Length; p++)
            {
                ChartValues <ObservablePoint> cv = new ChartValues <ObservablePoint>();
                cpf[p].ForEach((pp) =>
                {
                    cv.Add(new ObservablePoint(pp.wh, pp.frequency));
                });

                LineSeries ls = new LineSeries
                {
                    Title  = string.Format("Cluster {0}~{1}h Power Frequency", startHours, startHours + TimeSlotUtils.TimeSlotToHours(ts)),
                    Values = cv
                };

                this.ClusterChart.Series.Add(ls);
                this.VisibleGrp[p].Text =
                    string.Format("{0}~{1}h", startHours, startHours += TimeSlotUtils.TimeSlotToHours(ts));
                this.VisibleGrp[p].Checked = true;
                this.VisibleGrp[p].Click  += Visible_Toggled;
                this.VisibleContainer.Controls.Add(this.VisibleGrp[p]);
            }
        }
Ejemplo n.º 3
0
        public void ConfigChart(List <PowerFrequency>[] pf, double maxWh, TimeSlot ts)
        {
            this.Invoke((System.Action)(() => {
                int startHours = 0;
                for (int p = 0; p < pf.Length; p++)
                {
                    ChartValues <ObservablePoint> cv = new ChartValues <ObservablePoint>();
                    // cv.Add(new ObservablePoint(0, 0));
                    pf[p].ForEach((pp) =>
                    {
                        cv.Add(new ObservablePoint(pp.wh, pp.frequency));
                    });

                    /*
                     * if (pf[p][pf[p].Count() - 1].wh < maxWh)
                     *      cv.Add(new ObservablePoint(maxWh, 0));
                     */
                    LineSeries ls = new LineSeries
                    {
                        Title  = string.Format("{0}~{1}h Power Frequency", startHours, startHours + TimeSlotUtils.TimeSlotToHours(ts)),
                        Values = cv
                    };
                    this.Chart.Series.Add(ls);
                    this.VisibleGroup[p].Checked = true;
                    this.VisibleGroup[p].Text    = string.Format("{0}~{1}h", startHours, startHours += TimeSlotUtils.TimeSlotToHours(ts));
                    this.CheckBoxContainer.Controls.Add(this.VisibleGroup[p]);
                }
            }));
        }
Ejemplo n.º 4
0
        public async void RequestSimPf()
        {
            int powerDistance = 50;
            await Task.Run(() =>
            {
                this.similarDatas.ForEach(async(sm) =>
                {
                    List <Data> datas = new List <Data>();

                    for (int d = 0; d < this.dayStore[(int)this.day].Count; d++)
                    {
                        string path     = System.Windows.Forms.Application.StartupPath + @"\" + this.timeslot + @"\clustering_" + this.dayStore[(int)this.day][d].date.ToString("yyyyMMdd") + ".csv";
                        StreamReader sr = new StreamReader(path, Encoding.GetEncoding("euc-kr"));

                        while (!sr.EndOfStream)
                        {
                            string line = await sr.ReadLineAsync();
                            string uid  = line.Split(',')[0];

                            if (uid == sm.uid)
                            {
                                datas.Add(new Data(line.Split(',').ToList()));
                                break;
                            }
                        }
                        sr.Close();
                    }

                    // datas 가 전부 만들어졌을 거임
                    List <PowerFrequency>[] pfList = new List <PowerFrequency> [TimeSlotUtils.TimeSlotToSize(this.timeslot)];
                    for (int p = 0; p < datas[0].timeSlot.Length; p++)
                    {
                        pfList[p] = new List <PowerFrequency>();
                    }
                    for (int d = 0; d < datas.Count; d++)
                    {
                        for (int t = 0; t < datas[d].timeSlot.Length; t++)
                        {
                            PowerFrequency findPf = pfList[t].Find(
                                (pf) => pf.wh == Math.Floor((Math.Round(datas[d].timeSlot[t] / 10) * 10) / powerDistance) * powerDistance);

                            if (findPf == null)
                            {
                                pfList[t].Add(new PowerFrequency(Math.Floor((Math.Round(datas[d].timeSlot[t] / 10) * 10) / powerDistance) * powerDistance));
                            }
                            else
                            {
                                findPf.IncFrequency();
                            }
                        }
                    }

                    for (int p = 0; p < datas[0].timeSlot.Length; p++)
                    {
                        pfList[p].Sort();
                    }

                    // PowerFrequency 도 구성 끝!
                    this.changed.Invoke(this, new ModelEventArgs(VIEW_ACTIONS.REQUEST_SIMPF_SUCCESS, string.Format("{0} ({1})", sm.uid, sm.frequency), pfList, this.timeslot));
                });
            });
        }
Ejemplo n.º 5
0
        public void RequestDayData(bool isNotify = true)
        {
            this.maxWh = 0;
            int powerDistance = 50;

            if (this.isLoaded)
            {
                Console.WriteLine(string.Format("{0} --- DayData", this.day));
                List <PowerFrequency>[] pfList = new List <PowerFrequency> [TimeSlotUtils.TimeSlotToSize(this.timeslot)];
                // cluster Power Frequency
                List <PowerFrequency>[] cpfList = new List <PowerFrequency> [TimeSlotUtils.TimeSlotToSize(this.timeslot)];

                for (int p = 0; p < this.dayStore[(int)this.day][0].data.timeSlot.Length; p++)
                {
                    pfList[p]  = new List <PowerFrequency>();
                    cpfList[p] = new List <PowerFrequency>();
                }

                for (int d = 0; d < this.dayStore[(int)this.day].Count; d++)
                {
                    for (int t = 0; t < this.dayStore[(int)this.day][d].data.timeSlot.Length; t++)
                    {
                        PowerFrequency findPf = pfList[t].Find(
                            (pf) => pf.wh == Math.Floor((Math.Round(this.dayStore[(int)this.day][d].data.timeSlot[t] / 10) * 10) / powerDistance) * powerDistance);

                        if (findPf == null)
                        {
                            pfList[t].Add(new PowerFrequency(Math.Floor((Math.Round(this.dayStore[(int)this.day][d].data.timeSlot[t] / 10) * 10) / powerDistance) * powerDistance));
                        }
                        else
                        {
                            findPf.IncFrequency();
                        }
                    }


                    for (int t = 0; t < this.dayStore[(int)this.day][d].cluster.timeSlot.Length; t++)
                    {
                        PowerFrequency findPf = cpfList[t].Find(
                            (pf) => pf.wh == Math.Floor((Math.Round(this.dayStore[(int)this.day][d].cluster.timeSlot[t] / 10) * 10) / powerDistance) * powerDistance);

                        if (findPf == null)
                        {
                            cpfList[t].Add(new PowerFrequency(Math.Floor((Math.Round(this.dayStore[(int)this.day][d].cluster.timeSlot[t] / 10) * 10) / powerDistance) * powerDistance));
                        }
                        else
                        {
                            findPf.IncFrequency();
                        }
                    }
                }

                for (int p = 0; p < this.dayStore[(int)this.day][0].data.timeSlot.Length; p++)
                {
                    pfList[p].Sort();
                    cpfList[p].Sort();

                    if (pfList[p][pfList[p].Count() - 1].wh >= maxWh)
                    {
                        maxWh = pfList[p][pfList[p].Count() - 1].wh;
                    }
                }

                /*
                 * for (int p = 0; p < this.dayStore[(int)this.day][0].data.timeSlot.Length; p++)
                 * {
                 *      pfList[p].ForEach((pf) =>
                 *      {
                 *              Console.WriteLine(pf.ToString());
                 *      });
                 * }
                 */

                this.powerFrequencies        = pfList;
                this.clusterPowerFrequencies = cpfList;

                if (isNotify)
                {
                    this.changed.Invoke(this, new ModelEventArgs(VIEW_ACTIONS.REQUEST_DAYDATA_SUCCESS, this.dayStore[(int)this.day].ToArray(), this.powerFrequencies, this.clusterPowerFrequencies, this.timeslot, this.maxWh));
                }
            }
        }
Ejemplo n.º 6
0
        public DataComponent(string uid, List <PowerFrequency>[] pf, TimeSlot ts)
        {
            InitializeComponent();

            this.Text = uid;

            int startHours = 0;

            for (int p = 0; p < pf.Length; p++)
            {
                ChartValues <ObservablePoint> cv = new ChartValues <ObservablePoint>();
                // cv.Add(new ObservablePoint(0, 0));
                pf[p].ForEach((pp) =>
                {
                    cv.Add(new ObservablePoint(pp.wh, pp.frequency));
                });

                LineSeries ls = new LineSeries
                {
                    Title  = string.Format(uid + " {0}~{1}h Power Frequency", startHours, startHours += TimeSlotUtils.TimeSlotToHours(ts)),
                    Values = cv
                };

                this.DataChart.Series.Add(ls);
            }
        }