示例#1
0
        private void ViewModel_CommandHandler(object sender, string e)
        {
            switch (e)
            {
            case "Plot.Refresh":
                PlotViewModel.InvalidatePlot(true);
                break;

            case "Table.Refresh":
                TableViewModel.Refresh();
                break;

            case "DataGrid.Refresh":
                SeriesOnlineDataGridModelView.Refresh();
                break;

            case "Main.ImportXML":
                ImportSeriesXML(SeriesOnlineDataGridModelView.FilePath);
                break;

            case "Main.ExportXML":
                ExportSeriesXML(SeriesOnlineDataGridModelView.FilePath);
                break;
            }
        }
        //Dodac powyższe w ścieżce niżej

        private void GetValuesTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (plc.ConnectionStatus == ConnectionStatusEnum.CONNECTED)
            {
                for (int i = 0; i < SeriesOnline.Count; i++)
                {
                    SerieOnline serie = SeriesOnline[i] as SerieOnline;
                    if (serie != null)
                    {
                        int?     value = plc.GetValue(serie.Dm);
                        DateTime now   = DateTime.Now;
                        if (value != null)
                        {
                            int _value = (int)value;
                            now = new DateTime(
                                now.Year,
                                now.Month,
                                now.Day,
                                now.Hour,
                                now.Minute,
                                now.Second);
                            serie.add(now, _value);

                            try
                            {
                                StringBuilder.Clear();
                                using (FileStream fs = new FileStream(Path.Combine(LogsFolderPath ?? string.Empty, StringBuilder.Append(LogsFilePrefix).Append(DateTime.Now.ToString("yyyy.MM.dd")).Append(".txt").ToString()), FileMode.Append))
                                {
                                    StringBuilder.Clear();
                                    var    lineToWrite  = StringBuilder.Append(serie.Name).Append("\t").Append(now).Append("\t").Append(_value * serie.Multiplier).Append("\r\n").ToString();
                                    byte[] bytesToWrite = new UTF8Encoding(true).GetBytes(lineToWrite);
                                    fs.Write(bytesToWrite, 0, bytesToWrite.Length);
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine($"{ex.Message}");
                            }
                        }
                    }
                }
                try
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() => CollectionViewSource.GetDefaultView(SeriesOnline).Refresh()));
                    PlotViewModel.ChartMove();
                    PlotViewModel.InvalidatePlot(true);
                }
                catch { }

                //if (SelectedItemTableView == null)
                //{
                TableViewModel.Refresh();
                //}
            }
        }
示例#3
0
        private void GetValuesTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (plc.ConnectionStatus == ConnectionStatusEnum.CONNECTED)
            {
                for (int i = 0; i < Series.Count; i++)
                {
                    SerieOnline serie = Series[i] as SerieOnline;
                    if (serie != null)
                    {
                        int?     value = plc.getValue(serie.Dm);
                        DateTime now   = DateTime.Now;
                        if (value != null)
                        {
                            int _value = (int)value;
                            now = new DateTime(
                                now.Year,
                                now.Month,
                                now.Day,
                                now.Hour,
                                now.Minute,
                                now.Second);
                            serie.add(now, _value);
                        }
                    }
                }
                try
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() => CollectionViewSource.GetDefaultView(Series).Refresh()));
                    PlotViewModel.ChartMove();
                    PlotViewModel.InvalidatePlot(true);
                }
                catch { }

                //if (SelectedItemTableView == null)
                //{
                TableViewModel.Refresh();
                //}
            }
        }
        private void ViewModel_CommandHandler(object sender, string e)
        {
            switch (e)
            {
            case "Plot.Refresh":
                PlotViewModel.InvalidatePlot(true);
                PlotArchiveViewModel.InvalidatePlot(true);
                PlotUsbViewModel.InvalidatePlot(true);
                break;

            case "Table.Refresh":
                TableViewModel.Refresh();
                TableArchiveViewModel.Refresh();
                TableUsbViewModel.Refresh();
                break;

            case "DataGrid.Refresh":
                SeriesOnlineDataGridViewModel.Refresh();
                SeriesArchiveDataGridViewModel.Refresh();
                SeriesUsbDataGridViewModel.Refresh();
                break;
            }
        }