Example #1
0
        public ICPTracerDelegate CreateTracer(ulong id, string varName /*, Color color*/)
        {
            ICPTracerDelegate cpDelegate = null;

            if (table.InvokeRequired)
            {
                if (table.IsHandleCreated)
                {
                    table.Invoke((MethodInvoker)(() =>
                    {
                        cpDelegate = AddTracer(id, varName /*, color*/);
                    }));
                }
                else
                {
                    Console.WriteLine("");
                }
            }
            else
            {
                cpDelegate = AddTracer(id, varName /*, color*/);
            }

            return(cpDelegate);
        }
        public ICPTracerDelegate RegTraceEnt(ulong elem_id, string elem_name)
        {
            ICPTracerDelegate deleg = null;

            lock (regLockObj)
            {
                int numDuplicates = 0;
                if (duplNames.TryGetValue(elem_name, out numDuplicates))
                {
                    duplNames[elem_name] = ++numDuplicates;
                }
                else
                {
                    duplNames.Add(elem_name, numDuplicates);
                }

                deleg = cpViewTW.CreateTracer(elem_id, name + "[" + id.ToString() + "]:" + elem_name + " [" + numDuplicates.ToString() + "]");
            }

            return(deleg);
        }
Example #3
0
        private ICPTracerDelegate AddTracer(ulong id, string varName)
        {
            Series ser = chart.Series.Add(varName);

            ser.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
            ser.YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
            ser.ChartType  = SeriesChartType.FastLine;
            ser.LegendText = varName;
            ICPTraceConsumer cons       = new CPChartTraceConsumer(chart, ser);
            CPTracerDelegate cpDelegate = new CPTracerDelegate(cons);

            chart.ApplyPaletteColors();
            cpDelegate.properties.Add("color", ser.Color);
            IList <Tuple <ICPTracerDelegate, Series> > delegs = null;

            if (!serDelegates.TryGetValue(id, out delegs))
            {
                delegs = new List <Tuple <ICPTracerDelegate, Series> >();
                serDelegates.Add(id, delegs);
            }
            delegs.Add(new Tuple <ICPTracerDelegate, Series>(cpDelegate, ser));
            ICPTracerDelegate cpDepDelegate = traceConsumer.CreateTracer(id, varName);

            cpDepDelegate.SetProperty("color", ser.Color);
            depDelegates.Add(chart.Series.Count - 1, cpDepDelegate);

            if (updateTimer == null)
            {
                updateTimer          = new Timer();
                updateTimer.Interval = 500;
                updateTimer.Tick    += UpdateView;
                updateTimer.Start();
            }

            return(cpDelegate);
        }
Example #4
0
        private void Chart_MouseMove(object sender, MouseEventArgs e)
        {
            if ((mode & EChartViewMode.Drag) == EChartViewMode.Drag)
            {
                //chart.Invoke((MethodInvoker)(() =>
                //{
                double dx1 = chart.ChartAreas[0].AxisX.PixelPositionToValue(Math.Max(Math.Min(e.X, chart.Size.Width - 1), 0));
                double dx2 = chart.ChartAreas[0].AxisX.PixelPositionToValue(Math.Max(Math.Min(startDragPoint.X, chart.Size.Width - 1), 0));
                double dy1 = chart.ChartAreas[0].AxisY.PixelPositionToValue(Math.Max(Math.Min(e.Y, chart.Size.Height - 1), 0));
                double dy2 = chart.ChartAreas[0].AxisY.PixelPositionToValue(Math.Max(Math.Min(startDragPoint.Y, chart.Size.Height - 1), 0));
                double dx  = dx2 - dx1;
                double dy  = dy2 - dy1;
                if (double.IsNaN(chart.ChartAreas[0].AxisX.ScaleView.Position))
                {
                    chart.ChartAreas[0].AxisX.Minimum += dx;
                    chart.ChartAreas[0].AxisX.Maximum += dx;
                    chart.ChartAreas[0].AxisY.Minimum += dy;
                    chart.ChartAreas[0].AxisY.Maximum += dy;
                }
                else
                {
                    chart.ChartAreas[0].AxisX.ScaleView.Position += dx;
                    chart.ChartAreas[0].AxisY.ScaleView.Position += dy;
                }
                startDragPoint = e.Location;
                //}));
            }
            //else
            if ((mode & EChartViewMode.Spy) == EChartViewMode.Spy)
            {
                Point mousePoint = new Point(e.X, e.Y);

                chart.ChartAreas[0].CursorX.SetCursorPixelPosition(mousePoint, true);
                var xValue = chart.ChartAreas[0].AxisX.PixelPositionToValue(e.X);
                int serInd = 0;
                foreach (Series ser in chart.Series)
                {
                    if (ser.Enabled)
                    {
                        DataPoint ltPnt  = ser.Points.LastOrDefault((elem) => (elem.XValue < xValue));
                        DataPoint gtPnt  = ser.Points.FirstOrDefault((elem) => (elem.XValue > xValue));
                        double    ltDiff = double.MaxValue;
                        double    gtDiff = double.MaxValue;
                        if (ltPnt != null)
                        {
                            ltDiff = xValue - ltPnt.XValue;
                        }
                        else
                        {
                            ltDiff = double.NaN;
                        }
                        if (gtPnt != null)
                        {
                            gtDiff = gtPnt.XValue - xValue;
                        }
                        DataPoint curPnt = null;
                        if (!double.IsNaN(ltDiff))
                        {
                            if (!double.IsNaN(gtDiff))
                            {
                                if (ltDiff < gtDiff)
                                {
                                    curPnt = ltPnt;
                                }
                                else
                                {
                                    curPnt = gtPnt;
                                }
                            }
                            else
                            {
                                curPnt = ltPnt;
                            }
                        }
                        else if (!double.IsNaN(gtDiff))
                        {
                            curPnt = gtPnt;
                        }
                        if (curPnt != null)
                        {
                            //Debug.WriteLine(curPnt.YValues[0].ToString());
                            ICPTracerDelegate deleg = null;
                            if (depDelegates.TryGetValue(serInd, out deleg))
                            {
                                TraceEnt te = new TraceEnt();
                                te.tm  = (ulong)curPnt.XValue;
                                te.val = curPnt.YValues[0];
                                deleg.Trace(te.tm, te.val);
                            }
                        }
                    }
                    ++serInd;
                }
            }
        }
 private void RegElem(string name, UInt64 elem_id, UInt16 typeID)
 {
     //Debug.WriteLine("[*** CPTraceHandler::RegElem ***]; thread id: " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
     //outputWindowPane.OutputString("$$$$$$$$$$[RegElem]; name: " + name + "\tid: " + elem_id + "\ttypeID: " + typeID + "\n");
     ICPTracerDelegate cpDelegate = localProcTracer?.RegTraceEnt(elem_id, name);
 }