Exemplo n.º 1
0
        void bt_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <TimeTrend, System.Data.DataTable> tables = new Dictionary <TimeTrend, System.Data.DataTable>();

            foreach (TimeTrend trend in Trends)
            {
                Archiver.ChannelInfo ci   = new Archiver.ChannelInfo();
                String[]             strs = trend.Channel.Split('.');
                ci.PluginId    = strs[0];
                ci.ChannelName = strs[1];
                List <Archiver.ChannelInfo> channels = new List <FreeSCADA.Archiver.ChannelInfo>();
                channels.Add(ci);
                System.Data.DataTable dt = Archiver.ArchiverMain.Current.GetChannelData(_from.SelectedDate.Value, _to.SelectedDate.Value, channels);
                //System.Data.DataTable dt = new System.Data.DataTable();
                trend.ChartData.Clear();
                foreach (System.Data.DataRow row in dt.Rows)
                {
                    DateTime date = new DateTime();
                    double   val  = double.NaN;
                    DateTime.TryParse(row["Time"].ToString(), out date);
                    double.TryParse(row["Value"].ToString(), out val);

                    trend.ChartData.Add(
                        new TimeChartData
                    {
                        _time  = date,
                        _value = val
                    });
                }
                trend.DataSource.RaiseDataChanged();
            }
            _chart.FitToView();
        }
Exemplo n.º 2
0
        void _mode_Checked(object sender, RoutedEventArgs e)
        {
            List <Archiver.ChannelInfo> channels = new List <FreeSCADA.Archiver.ChannelInfo>();

            foreach (TimeTrend trend in Trends)
            {
                Archiver.ChannelInfo ci   = new Archiver.ChannelInfo();
                String[]             strs = trend.Channel.Split('.');
                ci.PluginId    = strs[0];
                ci.ChannelName = strs[1];
                channels.Add(ci);
            }
            _from.BlackoutDates.Clear();
            _to.BlackoutDates.Clear();

            DateTime dt = Archiver.ArchiverMain.Current.GetChannelsOlderDate(channels);

            _from.BlackoutDates.Add(new CalendarDateRange(DateTime.MinValue, dt.AddDays(-1)));
            _to.BlackoutDates.Add(new CalendarDateRange(DateTime.Now.AddDays(1), DateTime.MaxValue));
            _from.SelectedDate = dt;
            _to.SelectedDate   = DateTime.Now;
        }