예제 #1
0
 public void DrawXY(Graphics g, int w, int h, OscilloscopeLine ly)
 {
     if ((dataMax == null) || (dataMax.Length < 2))
     {
         return;
     }
     if (ly == null)
     {
         return;
     }
     if (!show || !ly.show)
     {
         return;
     }
     if ((ly.dataMax == null) || (ly.dataMax.Length < 2))
     {
         return;
     }
     if (ly.dataMax.Length != dataMax.Length)
     {
         return;
     }
     if ((points == null) || (points.Length != dataMax.Length))
     {
         points = new PointF[dataMax.Length]; // reAlloc
     }
     for (int i = 0; i < dataMax.Length; i++)
     {
         points[i].X = (float)(w / 2.0 + w * (dataMax[i] / yScale + yOffset));
         points[i].Y = (float)(h / 2.0 - h * (ly.dataMax[i] / ly.yScale + ly.yOffset));
     }
     g.DrawLines(penLine, points);
 }
예제 #2
0
        public void initOscilloscope(Oscilloscope _oscilloscope, int _channels, int _FIFOdepth)
        {
            inputs = new FIFO[_channels];
            for (int i = 0; i < _channels; i++)
            {
                inputs[i] = new FIFO(_FIFOdepth);
            }
            lines        = new OscilloscopeLine[_channels];
            osciFIFO     = new OsciFIFO[_channels];
            inputsActive = new Boolean[_channels];
            yScale       = new YScale[_channels];
            for (int i = 0; i < _channels; i++)
            {
                lines[i] = new OscilloscopeLine(oscilloscopeScreen);
                switch (i % 4)
                {
                case 0: lines[i].color = Color.Red; break;

                case 1: lines[1].color = Color.Green; break;

                case 2: lines[2].color = Color.Cyan; break;

                case 3: lines[3].color = Color.Magenta; break;
                }
                osciFIFO[i] = new OsciFIFO(_oscilloscope.owner.sampleRate / 2);
                yScale[i]   = YScale.Div100m;
            }
            FIFOdepth       = _FIFOdepth;
            oscilloscope    = _oscilloscope;
            timer.Interval  = 100;       // ms
            timer.Tick     += Timer_Tick;
            channels        = _channels; // Triggers start
            selectedChannel = 0;

            timeScale = TimeScale.Div1ms;
            OsciHorzScale.SelectedIndex = (int)timeScale;


            triggerMode             = TriggerMode.Auto;
            OsciTriggerAuto.Checked = true;
            triggerFromChannel      = 0;
            triggerLevel            = 0;
            trigSlope = TrigSlope.Rising;

            for (int i = 0; i < channels; i++)
            {
                lines[i].yScale = getYScale(i);
            }

            xOffset = 0;
            oscilloscopeScreen.initOscilloscopeScreen(this, channels, lines);
            UpdateChannelScales();

            OsciChannelSelectA.Checked = true;
            selectChannel(selectedChannel);
            OsciVertScale.SelectedIndex = (int)yScale[selectedChannel];

            OsciChannelOnA.Checked = lines[0].show;
            OsciChannelOnB.Checked = lines[1].show;
            OsciChannelOnC.Checked = lines[2].show;
            OsciChannelOnD.Checked = lines[3].show;

            XYDisplay.Checked = false;
            xydisplay         = false;

            EnGrid.Checked = true;
            drawGrid       = true;

            timer.Enabled = true;
        }