Ejemplo n.º 1
0
        private void UpdateTraceColorLegend()
        {
            SIGNAL_TYPE signal = m_visibleSignal;

            foreach (KeyValuePair <int, MultiChartArray_TraceItem> item in m_vm.traces)
            {
                int   id    = item.Value.id;
                Color color = m_vm.traceColors[Tuple.Create <int, SIGNAL_TYPE>(id, signal)];

                // find the visibility checkbox stackpanel with this id
                foreach (UIElement child1 in VisibilityStackPanel.Children)
                {
                    if (child1.GetType() == typeof(StackPanel))
                    {
                        StackPanel stackpanel = (StackPanel)child1;
                        foreach (UIElement child2 in stackpanel.Children)
                        {
                            if (child2.GetType() == typeof(Rectangle))
                            {
                                Rectangle rect = (Rectangle)child2;
                                if ((int)rect.Tag == id)
                                {
                                    rect.Fill = new SolidColorBrush(color);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
            public IndicatorItem(int indID, int methID, string desc, ref ObservableCollection <SignalTypeContainer> signalTypeList, ref ObservableCollection <FilterContainer> exFiltList, ref ObservableCollection <FilterContainer> emFiltList)
            {
                _indicatorID = indID;
                _methodID    = methID;
                _description = desc;

                _excitationFilterList = exFiltList;
                _emissionsFilterList  = emFiltList;
                _signalTypeList       = signalTypeList;

                if (_excitationFilterList.Count() > 0)
                {
                    FilterContainer filter = _excitationFilterList.ElementAt(0);
                    _excitationFilterPosition = filter.PositionNumber;
                }

                if (_emissionsFilterList.Count() > 0)
                {
                    FilterContainer filter = _emissionsFilterList.ElementAt(0);
                    _emissionsFilterPosition = filter.PositionNumber;
                }

                if (_signalTypeList.Count() > 0)
                {
                    SignalTypeContainer st = _signalTypeList.ElementAt(0);
                    _signalType = st.Value;
                }
            }
Ejemplo n.º 3
0
 private void radioButtonSignalY_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButtonConstantY.Checked)
     {
         m_signalType2D_Y = SIGNAL_TYPE.CONSTANT;
     }
     else if (radioButtonSquareY.Checked)
     {
         m_signalType2D_Y = SIGNAL_TYPE.SQUARE;
     }
     else if (radioButtonSinusY.Checked)
     {
         m_signalType2D_Y = SIGNAL_TYPE.SINE;
     }
     else if (radioButtonTriY.Checked)
     {
         m_signalType2D_Y = SIGNAL_TYPE.SAW;
     }
     else if (radioButtonSincY.Checked)
     {
         m_signalType2D_Y = SIGNAL_TYPE.SINC;
     }
     else if (radioButtonRandomY.Checked)
     {
         m_signalType2D_Y = SIGNAL_TYPE.RANDOM;
     }
 }
Ejemplo n.º 4
0
 public void AppendData(float[] x, float[] y, SIGNAL_TYPE signal, int id)
 {
     // add data to chart array (the x array is superfluous since it contains all the same values, should just be an int, not int[])
     //m_chartArrays[signal].AppendData(x, y);
     if (m_traces.ContainsKey(id))
     {
         m_dataPipeline.Post(Tuple.Create <float[], float[], SIGNAL_TYPE, int>(x, y, signal, m_traces[id].traceNum));
         m_newDataAdded = true;
     }
 }
Ejemplo n.º 5
0
 public IndicatorItem(int indID, int methID, string desc, int exFiltPos, int emFiltPos, SIGNAL_TYPE signalType, ref ObservableCollection <SignalTypeContainer> signalTypeList, ref ObservableCollection <FilterContainer> exFiltList, ref ObservableCollection <FilterContainer> emFiltList)
 {
     _indicatorID = indID;
     _methodID    = methID;
     _description = desc;
     _excitationFilterPosition = exFiltPos;
     _emissionsFilterPosition  = emFiltPos;
     _excitationFilterList     = exFiltList;
     _emissionsFilterList      = emFiltList;
     _signalTypeList           = signalTypeList;
     _signalType = signalType;
 }
Ejemplo n.º 6
0
        // //////////////////////////////////////////////////////////////////////////////////////
        // //////////////////////////////////////////////////////////////////////////////////////

        public void BuildChartArray()
        {
            m_chartArrays = new Dictionary <SIGNAL_TYPE, ChartArray>();
            int initialYmax     = 1;
            int initialXmax     = 10;
            int aggregateWidth  = 256;
            int aggregateHeight = 256;

            if (m_aggregateChart != null)
            {
                aggregateWidth = m_aggregateChart.m_width; aggregateHeight = m_aggregateChart.m_height;
            }

            foreach (int value in Enum.GetValues(typeof(SIGNAL_TYPE)))
            {
                SIGNAL_TYPE signal = (SIGNAL_TYPE)value;
                m_chartArrays.Add(signal, new ChartArray());
                m_chartArrays[signal].Init(m_rows, m_cols, m_chartArrayWidth, m_chartArrayHeight, m_margin, m_padding,
                                           aggregateWidth, aggregateHeight,
                                           Colors.DarkBlue, Colors.Black, Color.FromArgb(255, 85, 85, 85), Colors.Black, Colors.White,
                                           Colors.Yellow,
                                           0, initialXmax, 0, initialYmax, m_maxPoints, m_numTraces);
                m_chartArrays[signal].Redraw();
                m_chartArrays[signal].RedrawAggregate();
            }

            int maxTraces = m_chartArrays[SIGNAL_TYPE.RAW].GetMaxNumberOfTraces();

            if (m_numTraces > maxTraces)
            {
                m_numTraces = maxTraces;
            }

            WriteableBitmap bmap = m_bitmap;

            m_chartArrays[m_visibleSignal].Refresh(ref bmap);


            if (m_aggregateChart != null)
            {
                WriteableBitmap aggregateBitmapRef = m_aggregateChart.m_bitmap;
                m_chartArrays[m_visibleSignal].RefreshAggregate(ref aggregateBitmapRef);
            }

            // creat the range of each series
            m_chartSelected = new bool[m_rows, m_cols];

            m_allChartsInColumnSelected = new bool[m_cols];
            m_allChartsInRowSelected    = new bool[m_rows];
            SetUpChartArrayButtons();
        }
Ejemplo n.º 7
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


        public ITargetBlock <Tuple <float[], float[], SIGNAL_TYPE, int> > CreateDataPipeline(CancellationToken cancelToken,
                                                                                             Dictionary <SIGNAL_TYPE, ChartArray> _charts)
        {
            Dictionary <SIGNAL_TYPE, ChartArray> charts = _charts;

            float[] axisRange = new float[4];


            var AddData = new ActionBlock <Tuple <float[], float[], SIGNAL_TYPE, int> >(inputData =>
            {
                // INPUTS:
                //  item 1 - x data array
                //  item 2 - y data array
                //  item 3 - the data's signal type, i.e. RAW, STATIC_RATIO, CONTROL_SUBTRACTION, or DYNAMIC_RATIO
                //  item 4 - the index of the indicator to which this data belongs


                float[] x = inputData.Item1;
                float[] y = inputData.Item2;
                SIGNAL_TYPE signalType = inputData.Item3;
                int indicatorNdx       = inputData.Item4;

                try
                {
                    if (signalType == SIGNAL_TYPE.RAW)
                    {
                        m_totalPoints++;
                    }

                    charts[signalType].AppendData(x, y, indicatorNdx);
                }
                catch (OperationCanceledException)
                {
                    return;
                }
            },
                                                                                        new ExecutionDataflowBlockOptions
            {
                // TaskScheduler = uiTask,
                CancellationToken      = cancelToken,
                MaxDegreeOfParallelism = 1
            });


            return(AddData);
        }
Ejemplo n.º 8
0
        public void SetTraceColor(SIGNAL_TYPE signal, int traceNum, Color color)
        {
            m_chartArrays[signal].SetTraceColor(traceNum, color);

            // find trace id from the given signal and traceNum
            foreach (KeyValuePair <int, MultiChartArray_TraceItem> item in m_traces)
            {
                if (item.Value.traceNum == traceNum)
                {
                    int id = item.Value.id;
                    m_traceColors[Tuple.Create <int, SIGNAL_TYPE>(id, signal)] = color;
                    break;
                }
            }

            UpdateTraceColorLegend();
        }
Ejemplo n.º 9
0
        private void AnalysisRadioButton_Click(object sender, RoutedEventArgs e)
        {
            if (sender.GetType() != typeof(RadioButton))
            {
                return;
            }

            RadioButton rb  = (RadioButton)sender;
            string      tag = (string)rb.Tag;

            switch (tag)
            {
            case "Raw":
                m_visibleSignal = SIGNAL_TYPE.RAW;
                m_aggregateChart.SetHeaderText("Raw");
                break;

            case "StaticRatio":
                m_visibleSignal = SIGNAL_TYPE.STATIC_RATIO;
                m_aggregateChart.SetHeaderText("Static Ratio");
                break;

            case "ControlSubtraction":
                m_visibleSignal = SIGNAL_TYPE.CONTROL_SUBTRACTION;
                m_aggregateChart.SetHeaderText("Control Subtraction");
                break;

            case "DynamicRatio":
                m_visibleSignal = SIGNAL_TYPE.DYNAMIC_RATIO;
                m_aggregateChart.SetHeaderText("Dynamic Ratio");
                break;

            default:
                m_visibleSignal = SIGNAL_TYPE.RAW;
                m_aggregateChart.SetHeaderText("Raw");
                break;
            }

            m_guiPipeline.Post(Tuple.Create <int[], int[], SIGNAL_TYPE, int, COMMAND_TYPE>(null, null, m_visibleSignal, 0, COMMAND_TYPE.REFRESH));

            UpdateTraceColorLegend();
        }
Ejemplo n.º 10
0
 private void radioButtonSquare_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButtonSquare.Checked)
     {
         m_signalType1D = SIGNAL_TYPE.SQUARE;
     }
     else if (radioButtonSine.Checked)
     {
         m_signalType1D = SIGNAL_TYPE.SINE;
     }
     else if (radioButtonTriangle.Checked)
     {
         m_signalType1D = SIGNAL_TYPE.SAW;
     }
     else if (radioButtonSinc.Checked)
     {
         m_signalType1D = SIGNAL_TYPE.SINC;
     }
     else if (radioButtonRandom.Checked)
     {
         m_signalType1D = SIGNAL_TYPE.RANDOM;
     }
 }
Ejemplo n.º 11
0
        public void Init(int rows, int cols, int margin, int padding, int maxNumPoints, List <MultiChartArray_TraceItem> traces)
        {
            int numTraces = traces.Count;

            m_vm        = new MultiChartArray_ViewModel(rows, cols, padding, margin, maxNumPoints, traces);
            DataContext = m_vm;

            ////////////////////////////////////////////////////////////////////////////////////////

            m_mouseDownRow = -1;
            m_mouseDownCol = -1;

            m_numPoints = 0;

            InitializeComponent();

            m_visibleSignal = SIGNAL_TYPE.RAW;

            m_buttonColorNotSelected = Colors.LightGray;
            m_buttonColorSelected    = Colors.Red;

            m_rowButton    = new List <Button>();
            m_columnButton = new List <Button>();


            BuildChartArray();
            SetupVisiblityCheckBoxes(m_vm.traces);

            m_refreshTimer          = new DispatcherTimer();
            m_refreshTimer.Tick    += M_refreshTimer_Tick;
            m_refreshTimer.Interval = TimeSpan.FromMilliseconds(100);
            m_refreshTimer.Start();

            m_newDataAdded = false;
            m_dataPipeline = CreateDataPipeline(m_tokenSource.Token, m_chartArrays);
            m_guiPipeline  = CreateGuiPipeline(m_uiTask, m_tokenSource.Token, m_chartArrays, m_vm);
        }
Ejemplo n.º 12
0
 private void radioButton_arb_ch2_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButton_arb_ch2.Checked)
     {
         takeGenSemaphore(5005);
         signal_leng_ch2 = arb_signal_ch2.Length;
         signalType_ch2 = SIGNAL_TYPE.ARB;
         validateArbLength();
         giveGenSemaphore();
     }
 }
Ejemplo n.º 13
0
        public void Init(int rows, int cols, int maxNumPoints, List <MultiChartArray_TraceItem> traces, AggregateChart aggregateChart)
        {
            int numTraces = traces.Count;
            int margin    = 1;
            int padding   = 3;

            ////////////////////////////////////////////////////////////////////////////////////////////////


            m_chartArrayWidth  = 0;
            m_chartArrayHeight = 0;

            m_cols           = cols;
            m_rows           = rows;
            m_padding        = padding;
            m_margin         = margin;
            m_maxPoints      = maxNumPoints;
            m_numTraces      = traces.Count;
            m_aggregateChart = aggregateChart;

            // initialize traces and trace colors
            int traceNum = 0;

            m_traces      = new Dictionary <int, MultiChartArray_TraceItem>();
            m_traceColors = new Dictionary <Tuple <int, MultiChartArray.SIGNAL_TYPE>, Color>();
            foreach (MultiChartArray_TraceItem item in traces)
            {
                item.traceNum = traceNum;
                m_traces.Add(item.id, item);
                traceNum++;

                // initialize trace colors
                foreach (int value in Enum.GetValues(typeof(MultiChartArray.SIGNAL_TYPE)))
                {
                    MultiChartArray.SIGNAL_TYPE signal = (MultiChartArray.SIGNAL_TYPE)value;
                    m_traceColors.Add(Tuple.Create <int, MultiChartArray.SIGNAL_TYPE>(item.id, signal), Colors.Yellow);  // default to yellow
                }
            }



            int pixelsPerChart = 42;

            int newWidth  = (pixelsPerChart * m_cols) + ((m_cols - 1) * m_padding) + (2 * m_margin);
            int newHeight = (pixelsPerChart * m_rows) + ((m_rows - 1) * m_padding) + (2 * m_margin);

            byte[] img = SynthesizeImage(newWidth, newHeight);

            SetBitmap(img, newWidth, newHeight);

            if (aggregateChart != null)
            {
                aggregateChart.SetBitmap(img, newWidth / 2, newHeight / 2);
                aggregateChart.SetRanges(1, 0, 1);
            }


            ////////////////////////////////////////////////////////////////////////////////////////

            m_mouseDownRow = -1;
            m_mouseDownCol = -1;

            m_numPoints = 0;

            InitializeComponent();

            m_visibleSignal = SIGNAL_TYPE.RAW;

            m_buttonColorNotSelected = Colors.LightGray;
            m_buttonColorSelected    = Colors.Red;

            m_rowButton    = new List <Button>();
            m_columnButton = new List <Button>();


            BuildChartArray();

            SetupVisiblityCheckBoxes(m_traces);

            m_refreshTimer          = new DispatcherTimer();
            m_refreshTimer.Tick    += M_refreshTimer_Tick;
            m_refreshTimer.Interval = TimeSpan.FromMilliseconds(100);
            m_refreshTimer.Start();

            m_newDataAdded = false;
            m_dataPipeline = CreateDataPipeline(m_tokenSource.Token, m_chartArrays);
            m_guiPipeline  = CreateGuiPipeline(m_uiTask, m_tokenSource.Token, m_chartArrays, aggregateChart);

            if (aggregateChart != null)
            {
                aggregateChart.SizeChanged += AggregateChart_SizeChanged;
            }
        }
Ejemplo n.º 14
0
 private void radioButton_sine_ch1_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButton_sine_ch1.Checked)
     {
         takeGenSemaphore(5001);
         signalType_ch1 = SIGNAL_TYPE.SINE;
         validateArbLength();
         giveGenSemaphore();
     }
 }
Ejemplo n.º 15
0
 public void SetTraceVisibility(SIGNAL_TYPE signal, int traceNum, bool isVisible)
 {
     m_chartArrays[signal].SetTraceVisibility(traceNum, isVisible);
 }
Ejemplo n.º 16
0
        private void radioButton_square_ch2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton_square_ch2.Checked)
            {

                takeGenSemaphore(5007);
                signalType_ch2 = SIGNAL_TYPE.SQUARE;
                validateArbLength();
                giveGenSemaphore();
            }
        }
Ejemplo n.º 17
0
        public void SetDefaultChartRanges(SIGNAL_TYPE signal, float xmin, float xmax, float ymin, float ymax)
        {
            m_chartArrays[signal].SetIntialRanges((int)signal, xmin, xmax, ymin, ymax);

            m_guiPipeline.Post(Tuple.Create <int[], int[], SIGNAL_TYPE, int, COMMAND_TYPE>(null, null, signal, 0, COMMAND_TYPE.RESET));
        }
Ejemplo n.º 18
0
        public ITargetBlock <Tuple <int[], int[], SIGNAL_TYPE, int, COMMAND_TYPE> > CreateGuiPipeline(TaskScheduler uiTask,
                                                                                                      CancellationToken cancelToken,
                                                                                                      Dictionary <SIGNAL_TYPE, ChartArray> _charts,
                                                                                                      AggregateChart _aggregateChart)
        {
            Dictionary <SIGNAL_TYPE, ChartArray> charts = _charts;
            AggregateChart aggregateChart = _aggregateChart;
            SIGNAL_TYPE    visibleSignal  = SIGNAL_TYPE.RAW;

            float[] axisRange = new float[4];

            var GuiUpdates = new ActionBlock <Tuple <int[], int[], SIGNAL_TYPE, int, COMMAND_TYPE> >(inputData =>
            {
                // INPUTS:
                //  item 1 - x data array
                //  item 2 - y data array
                //  item 3 - the data's signal type, i.e. RAW, STATIC_RATIO, CONTROL_SUBTRACTION, or DYNAMIC_RATIO
                //  item 4 - the index of the indicator to which this data belongs
                //  item 5 - command type that is put on the queue. Depending on what this is, the previous parameters are
                //           interpreted differently.  For example, if it is RESIZE, the new bitmap dimensions should be
                //           in x and y (items 1 and 2 above).  The new chartArray should be x[0], y[0],
                //           and the new aggregate chart should be x[1], y[1].

                if (inputData == null)
                {
                    return;
                }

                int[] x = inputData.Item1;
                int[] y = inputData.Item2;
                SIGNAL_TYPE signalType   = inputData.Item3;
                int indicatorNdx         = inputData.Item4;
                COMMAND_TYPE commandType = inputData.Item5;

                try
                {
                    switch (commandType)
                    {
                    case COMMAND_TYPE.RESIZE:
                        // resize chartArray and aggregate bitmaps
                        // find the optimal size to best fit the Actual window size

                        int pixelWidthPerChart  = (x[0] - (2 * m_margin) - ((m_cols - 1) * m_padding)) / m_cols;
                        int pixelHeightPerChart = (y[0] - (2 * m_margin) - ((m_rows - 1) * m_padding)) / m_rows;

                        int w = (pixelWidthPerChart * m_cols) + ((m_cols - 1) * m_padding) + (2 * m_margin);
                        int h = (pixelHeightPerChart * m_rows) + ((m_rows - 1) * m_padding) + (2 * m_margin);

                        if (w != m_chartArrayWidth || h != m_chartArrayHeight)
                        {
                            m_chartArrayWidth  = w;
                            m_chartArrayHeight = h;
                            if (aggregateChart != null)
                            {
                                aggregateChart.SetBitmap(BitmapFactory.New(x[1], y[1]));
                            }

                            m_bitmap             = BitmapFactory.New(w, h);
                            m_overlay            = BitmapFactory.New(w, h);
                            imageBitmap.Source   = m_bitmap;
                            overlayBitmap.Source = m_overlay;


                            foreach (int value in Enum.GetValues(typeof(SIGNAL_TYPE)))
                            {
                                SIGNAL_TYPE signal = (SIGNAL_TYPE)value;
                                charts[signal].Resize(w, h, x[1], y[1]);
                            }
                        }

                        // refresh chart array
                        charts[visibleSignal].Redraw();
                        WriteableBitmap bitmapRef4 = m_bitmap;
                        charts[visibleSignal].Refresh(ref bitmapRef4);

                        // refresh aggregate chart
                        if (aggregateChart != null)
                        {
                            charts[visibleSignal].RedrawAggregate();
                            WriteableBitmap aggregateBitmapRef4 = aggregateChart.m_bitmap;
                            charts[visibleSignal].RefreshAggregate(ref aggregateBitmapRef4);
                        }

                        break;

                    case COMMAND_TYPE.REFRESH:
                        visibleSignal = signalType;

                        // refresh chart array image
                        charts[visibleSignal].Redraw();
                        WriteableBitmap bitmapRef1 = m_bitmap;
                        charts[visibleSignal].Refresh(ref bitmapRef1);

                        // refresh aggregate image
                        if (aggregateChart != null)
                        {
                            charts[visibleSignal].RedrawAggregate();
                            WriteableBitmap aggregateBitmapRef4 = aggregateChart.m_bitmap;
                            charts[visibleSignal].RefreshAggregate(ref aggregateBitmapRef4);

                            // update the range labels
                            charts[visibleSignal].GetRanges(ref axisRange, indicatorNdx);
                            aggregateChart.SetRanges(axisRange[1], axisRange[2], axisRange[3]);
                        }

                        break;

                    case COMMAND_TYPE.RESET:
                        // clears data from all charts

                        foreach (int value in Enum.GetValues(typeof(SIGNAL_TYPE)))
                        {
                            SIGNAL_TYPE signal = (SIGNAL_TYPE)value;
                            charts[signal].Reset();

                            charts[signal].Redraw();
                            charts[signal].RedrawAggregate();
                        }


                        WriteableBitmap bitmapRef2 = m_bitmap;
                        charts[visibleSignal].Refresh(ref bitmapRef2);

                        if (aggregateChart != null)
                        {
                            WriteableBitmap aggregateBitmapRef2 = aggregateChart.m_bitmap;
                            charts[visibleSignal].RefreshAggregate(ref aggregateBitmapRef2);

                            // update the range labels
                            charts[visibleSignal].GetRanges(ref axisRange, indicatorNdx);
                            aggregateChart.SetRanges(axisRange[1], axisRange[2], axisRange[3]);
                        }

                        m_totalPoints = 0;
                        break;

                    case COMMAND_TYPE.SET_SELECTED:
                        // have to convert to a 1D bool array, because that's what is needed by the C++ function
                        bool[] temp = new bool[m_rows * m_cols];
                        for (int r = 0; r < m_rows; r++)
                        {
                            for (int c = 0; c < m_cols; c++)
                            {
                                temp[r * m_cols + c] = m_chartSelected[r, c];
                            }
                        }

                        foreach (int value in Enum.GetValues(typeof(SIGNAL_TYPE)))
                        {
                            SIGNAL_TYPE signal = (SIGNAL_TYPE)value;

                            // refresh chart array
                            charts[signal].Redraw();

                            if (signal == visibleSignal)
                            {
                                WriteableBitmap bitmapRef3 = m_bitmap;
                                charts[signal].SetSelectedCharts(temp, ref bitmapRef3);
                            }
                            else
                            {
                                charts[signal].SetSelectedCharts(temp);
                            }


                            if (aggregateChart != null)
                            {
                                // refresh aggregate chart
                                charts[signal].RedrawAggregate();

                                if (signal == visibleSignal)
                                {
                                    WriteableBitmap aggregateBitmapRef3 = aggregateChart.m_bitmap;
                                    charts[visibleSignal].RefreshAggregate(ref aggregateBitmapRef3);
                                }
                            }
                        }



                        break;
                    }
                }
                catch (OperationCanceledException)
                {
                    return;
                }
            },
                                                                                                     new ExecutionDataflowBlockOptions
            {
                TaskScheduler          = uiTask,
                CancellationToken      = cancelToken,
                MaxDegreeOfParallelism = 4
            });


            return(GuiUpdates);
        }