示例#1
0
 private void ResetPB_Click(object sender, RoutedEventArgs e)
 {
     Dispatcher.BeginInvoke(new Action(() =>
     {
         ChartArray.Reset();
         StartPB.IsEnabled = true;
         m_x = 0;
     }), DispatcherPriority.Background);
 }
示例#2
0
        private void TestPB_Click(object sender, RoutedEventArgs e)
        {
            //Task.Run(() => TestRoutine());

            visible = !visible;
            ChartArray.SetTraceVisibility(WPFTools.MultiChartArray.SIGNAL_TYPE.RAW, 1, visible);

            ChartArray.Refresh();
            //ChartArray.Resize();

            //int w = 0, h = 0;
            //ChartArray.GetBestBitmapSize(ref w, ref h);

            InfoText.Text = m_duration.ToString() + "/" + ChartArray.m_totalPoints.ToString();
        }
示例#3
0
        public MainWindow()
        {
            InitializeComponent();

            m_vm        = new MainWindow_ViewModel();
            DataContext = m_vm;


            List <WPFTools.MultiChartArray_TraceItem> traces = new List <WPFTools.MultiChartArray_TraceItem>();

            traces.Add(new WPFTools.MultiChartArray_TraceItem("Indicator 1", 0, 100));
            traces.Add(new WPFTools.MultiChartArray_TraceItem("Indicator 2", 1, 200));

            ChartArray.Init(16, 24, 1, 3, 100000, traces);  // NOTE: allocate for expected max number of points
                                                            // ~ 120 Megabytes/trace of GPU memory required for every 10,000 points

            ChartArray.SetDefaultChartRanges(WPFTools.MultiChartArray.SIGNAL_TYPE.RAW, 0, 10, 0, 10);
            ChartArray.SetDefaultChartRanges(WPFTools.MultiChartArray.SIGNAL_TYPE.CONTROL_SUBTRACTION, 0, 20, 0, 20);
            ChartArray.SetDefaultChartRanges(WPFTools.MultiChartArray.SIGNAL_TYPE.STATIC_RATIO, 0, 30, 0, 30);
            ChartArray.SetDefaultChartRanges(WPFTools.MultiChartArray.SIGNAL_TYPE.DYNAMIC_RATIO, 0, 40, 0, 40);

            ChartArray.SetTraceColor(WPFTools.MultiChartArray.SIGNAL_TYPE.RAW, 0, System.Windows.Media.Colors.Yellow);
            ChartArray.SetTraceColor(WPFTools.MultiChartArray.SIGNAL_TYPE.CONTROL_SUBTRACTION, 0, System.Windows.Media.Colors.OrangeRed);
            ChartArray.SetTraceColor(WPFTools.MultiChartArray.SIGNAL_TYPE.STATIC_RATIO, 0, System.Windows.Media.Colors.CornflowerBlue);
            ChartArray.SetTraceColor(WPFTools.MultiChartArray.SIGNAL_TYPE.DYNAMIC_RATIO, 0, System.Windows.Media.Colors.LawnGreen);

            ChartArray.SetTraceColor(WPFTools.MultiChartArray.SIGNAL_TYPE.RAW, 1, System.Windows.Media.Colors.Purple);
            ChartArray.SetTraceColor(WPFTools.MultiChartArray.SIGNAL_TYPE.CONTROL_SUBTRACTION, 1, System.Windows.Media.Colors.Plum);
            ChartArray.SetTraceColor(WPFTools.MultiChartArray.SIGNAL_TYPE.STATIC_RATIO, 1, System.Windows.Media.Colors.LimeGreen);
            ChartArray.SetTraceColor(WPFTools.MultiChartArray.SIGNAL_TYPE.DYNAMIC_RATIO, 1, System.Windows.Media.Colors.Goldenrod);

            m_duration = 0;

            m_dummyDataSize = 50000;
            m_dummyData     = new int[m_dummyDataSize];

            for (int i = 0; i < m_dummyDataSize; i++)
            {
                double angle = ((double)i) / 80.0;
                m_dummyData[i] = (int)((100.0 + (double)i) * Math.Sin(angle));
            }
        }
示例#4
0
        private void BackgroundTask(int count, int delay)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                StartPB.IsEnabled = false;
                ResetPB.IsEnabled = false;
            }), DispatcherPriority.Background);


            int num = 0;

            long[] intervals = new long[count];
            long   last      = 0;
            bool   flip      = false;

            TimeSpan delayTime = TimeSpan.FromTicks(TimeSpan.TicksPerMillisecond / 2);

            int[] x = new int[ChartArray.NumRows() * ChartArray.NumCols()];

            int[] y1 = new int[ChartArray.NumRows() * ChartArray.NumCols()];
            int[] y2 = new int[ChartArray.NumRows() * ChartArray.NumCols()];
            int[] y3 = new int[ChartArray.NumRows() * ChartArray.NumCols()];
            int[] y4 = new int[ChartArray.NumRows() * ChartArray.NumCols()];

            int[] y5 = new int[ChartArray.NumRows() * ChartArray.NumCols()];
            int[] y6 = new int[ChartArray.NumRows() * ChartArray.NumCols()];
            int[] y7 = new int[ChartArray.NumRows() * ChartArray.NumCols()];
            int[] y8 = new int[ChartArray.NumRows() * ChartArray.NumCols()];


            Stopwatch sw = new Stopwatch();

            sw.Start();
            while (num < count)
            {
                while (sw.ElapsedMilliseconds - last < delay)
                {
                    Thread.Sleep(delayTime);
                }
                intervals[num] = sw.ElapsedMilliseconds - last;
                last           = sw.ElapsedMilliseconds;
                num++;

                for (int i = 0; i < ChartArray.NumRows() * ChartArray.NumCols(); i++)
                {
                    x[i] = m_x;

                    y1[i] = m_dummyData[num + i];
                    y2[i] = 2 * m_dummyData[num + i + 50];
                    y3[i] = 3 * m_dummyData[num + i + 75];
                    y4[i] = 4 * m_dummyData[num + i + 200];

                    y5[i] = m_dummyData[num + i + 300];
                    y6[i] = 2 * m_dummyData[num + i + 450];
                    y7[i] = 3 * m_dummyData[num + i + 675];
                    y8[i] = 4 * m_dummyData[num + i + 600];
                }

                if (flip)
                {
                    ChartArray.AppendData(x, y1, WPFTools.MultiChartArray.SIGNAL_TYPE.RAW, 100);
                    ChartArray.AppendData(x, y2, WPFTools.MultiChartArray.SIGNAL_TYPE.CONTROL_SUBTRACTION, 100);
                    ChartArray.AppendData(x, y3, WPFTools.MultiChartArray.SIGNAL_TYPE.STATIC_RATIO, 100);
                    ChartArray.AppendData(x, y4, WPFTools.MultiChartArray.SIGNAL_TYPE.DYNAMIC_RATIO, 100);
                }
                else
                {
                    ChartArray.AppendData(x, y5, WPFTools.MultiChartArray.SIGNAL_TYPE.RAW, 200);
                    ChartArray.AppendData(x, y6, WPFTools.MultiChartArray.SIGNAL_TYPE.CONTROL_SUBTRACTION, 200);
                    ChartArray.AppendData(x, y7, WPFTools.MultiChartArray.SIGNAL_TYPE.STATIC_RATIO, 200);
                    ChartArray.AppendData(x, y8, WPFTools.MultiChartArray.SIGNAL_TYPE.DYNAMIC_RATIO, 200);
                }

                flip = !flip;
                m_x++;
                m_y = m_x;
            }


            m_duration = sw.ElapsedMilliseconds;

            //Debug.Print("total time = " + sw.ElapsedMilliseconds.ToString() + "   for  " + count.ToString() + "  Points");

            Dispatcher.BeginInvoke(new Action(() =>
            {
                InfoText.Text     = m_duration.ToString() + "/" + ChartArray.m_totalPoints.ToString();
                ResetPB.IsEnabled = true;
            }), DispatcherPriority.Background);
        }