本文介绍了嘿我试图在visual basic.net上调试这个代码的任何想法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一项心电图程序vbgeneral>心电图计划[]



我试图调试的代码:



This is an ECG Program vbgeneral">ECG Program[^]

the code I am trying to debug:

Imports System.Windows.Forms.DataVisualization.Charting
Imports System.Threading

Public Class StreamChart
    Private addDataRunner As Thread
    Private rand As New Random()
    Public Delegate Sub AddDataDelegate()
    Public addDataDel As AddDataDelegate

    Private Sub Form3_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
        Dim addDataThreadStart As New ThreadStart(AddressOf AddDataThreadLoop)
        addDataRunner = New Thread(addDataThreadStart)
        addDataDel = New AddDataDelegate(AddressOf AddData)

        Chart1.BackColor = Color.FromArgb(211, 223, 240)
        Chart1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom
        Chart1.BackSecondaryColor = System.Drawing.Color.White
        Chart1.BorderlineColor = Color.FromArgb(26, 59, 105)  'System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
        Chart1.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid
        Chart1.BorderlineWidth = 2
        Chart1.BorderSkin.SkinStyle = System.Windows.Forms.DataVisualization.Charting.BorderSkinStyle.Emboss

        With Chart1.ChartAreas(0)
            .AxisX.LabelStyle.Font = New System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold)
            .AxisX.LabelStyle.Format = "hh:mm:ss"
            .AxisX.LabelStyle.Interval = 10
            .AxisX.LabelStyle.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Seconds
            .AxisX.LineColor = Color.LightGray
            .AxisX.Title = "Time"
            .AxisX.MajorGrid.LineColor = Color.LightBlue
            .AxisX.MajorGrid.Interval = 10
            .AxisX.MajorGrid.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Seconds
            .AxisX.MajorTickMark.Interval = 10
            .AxisX.MajorTickMark.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Seconds

            .AxisY.Title = "Velocity"
            .AxisY.IsLabelAutoFit = False
            .AxisY.IsStartedFromZero = False
            .AxisY.LabelStyle.Font = New System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold)
            .AxisY.LineColor = Color.LightGray
            .AxisY.MajorGrid.LineColor = Color.LightGray
            .AxisY.Maximum = 25
            .AxisY.Minimum = 0

            .BackColor = Color.FromArgb(64, 165, 191, 228)
            .BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom
            .BackSecondaryColor = System.Drawing.Color.White
            .BorderColor = Color.FromArgb(64, 165, 191, 228)
            .BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid

            .InnerPlotPosition.Auto = False
            .InnerPlotPosition.Height = 80
            .InnerPlotPosition.Width = 90
            .InnerPlotPosition.X = 9
            .InnerPlotPosition.Y = 4

            .Position.Auto = False
            .Position.Height = 86
            .Position.Width = 88
            .Position.X = 6
            .Position.Y = 6

        End With

        Chart1.Legends(0).BackColor = System.Drawing.Color.Transparent

    End Sub

    Private Sub startTrending_Click(sender As Object, e As System.EventArgs) Handles startTrending.Click
        startTrending.Enabled = False
        stopTrending.Enabled = True

        Dim minValue = New Date(100)
        minValue = DateTime.Now
        Dim maxValue As New Date(100)
        maxValue = minValue.AddSeconds(100)

        Chart1.ChartAreas(0).AxisX.Minimum = minValue.ToOADate()
        Chart1.ChartAreas(0).AxisX.Maximum = maxValue.ToOADate()
        Chart1.Series.Clear()
        Chart1.Series.Add("Streaming Data")
        With Chart1.Series(0)
            'Chart1.Series(0).IsVisibleInLegend = False
            .ChartType = SeriesChartType.Line
            .BorderWidth = 2
            .Color = Color.OrangeRed
            .BorderColor = Color.FromArgb(224, 64, 10)
            .ShadowOffset = 1
        End With


        ' start worker threads.
        If addDataRunner.IsAlive = True Then
            addDataRunner.Resume()
        Else
            addDataRunner.Start()
        End If

    End Sub 'startTrending_Click 

    Private Sub stopTrending_Click(sender As Object, e As System.EventArgs) Handles stopTrending.Click
        If addDataRunner.IsAlive = True Then
            addDataRunner.Suspend()
        End If

        startTrending.Enabled = True
        stopTrending.Enabled = False

    End Sub
    Private Sub AddDataThreadLoop()
        While True
            chart1.Invoke(addDataDel)

            Thread.Sleep(200)
        End While
    End Sub

    Public Sub AddData()
        Dim timeStamp As DateTime = DateTime.Now

        Dim ptSeries As Series
        For Each ptSeries In chart1.Series
            AddNewPoint(timeStamp, ptSeries)
        Next ptSeries
    End Sub
    Public Sub AddNewPoint(timeStamp As DateTime, ptSeries As System.Windows.Forms.DataVisualization.Charting.Series)
        Dim newVal As Double = 0

        If ptSeries.Points.Count > 0 Then
            newVal = ptSeries.Points((ptSeries.Points.Count - 1)).YValues(0) + (rand.NextDouble() * 2 - 1)
        End If

        If newVal < 0 Then
            newVal = 0
        End If
        ' Add new data point to its series.
        ptSeries.Points.AddXY(timeStamp.ToOADate(), rand.Next(10, 20))

        ' remove all points from the source series older than 1.5 minutes.
        Dim removeBefore As Double = timeStamp.AddSeconds((CDbl(10) * -1)).ToOADate()
        'remove oldest values to maintain a constant number of data points
        While ptSeries.Points(0).XValue < removeBefore
            ptSeries.Points.RemoveAt(0)
        End While

        chart1.ChartAreas(0).AxisX.Minimum = ptSeries.Points(0).XValue
        Chart1.ChartAreas(0).AxisX.Maximum = DateTime.FromOADate(ptSeries.Points(0).XValue).AddMinutes(0.3).ToOADate()

        chart1.Invalidate()
    End Sub
End Class





我尝试过:



i试图在我的视觉工作室2017上运行它,我不明白如何调试它。

请帮忙。谢谢。



What I have tried:

i have tried to run it on my visual studio 2017 and I did not understand how to debug it.
please help. thanks.

推荐答案



这篇关于嘿我试图在visual basic.net上调试这个代码的任何想法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:05