⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmg.frm

📁 MPC2810是乐创自动化技术有限公司开发的一款高性能四轴运动控制器。 MPC2810基于PC机PCI总线
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmG 
   AutoRedraw      =   -1  'True
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   8430
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6555
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   8430
   ScaleWidth      =   6555
   Begin VB.Frame Frame1 
      Caption         =   "速度变化曲线:(红色--X  绿色--Y  兰色--Z)"
      Height          =   1815
      Left            =   0
      TabIndex        =   4
      Top             =   6120
      Width           =   6495
      Begin VB.PictureBox picSpeed 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   1215
         Left            =   240
         ScaleHeight     =   1215
         ScaleWidth      =   6015
         TabIndex        =   5
         Top             =   480
         Width           =   6015
      End
   End
   Begin VB.TextBox txtFactor 
      Height          =   270
      Left            =   4920
      TabIndex        =   2
      Text            =   "0.2"
      Top             =   8040
      Width           =   735
   End
   Begin VB.CommandButton cmdClear 
      Caption         =   "清除"
      Height          =   255
      Left            =   5760
      TabIndex        =   1
      Top             =   8040
      Width           =   735
   End
   Begin VB.Label Label29 
      Caption         =   "图形显示缩放比例:"
      Height          =   255
      Left            =   3120
      TabIndex        =   3
      Top             =   8040
      Width           =   1695
   End
   Begin VB.Label labMsg 
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Label1"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   8040
      Width           =   2895
   End
End
Attribute VB_Name = "frmG"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim lCenterX As Long
Dim lCenterY As Long

Dim lLastPosX As Long
Dim lLastPosY As Long

Dim lFactor As Double

Dim lLastSpeedX As Long
Dim lLastSpeedY As Long
Dim lLastSpeedZ As Long
Dim lLastSpeedA As Long
Dim lLastSpeedXAxes As Long

Dim lMaxSpeed As Double

Public Sub SetF(F As Double)
    lFactor = F
End Sub
Public Sub SetMaxSpeed(maxspeed As Double)
    If maxspeed = 0 Then
        lMaxSpeed = 1
    Else
        lMaxSpeed = maxspeed
    End If
End Sub

Private Sub cmdClear_Click()
    Me.Cls
    Me.Line (0, lCenterY)-(Me.Width, lCenterY), RGB(255, 0, 0)
    Me.Line (lCenterX, 0)-(lCenterX, lCenterY * 2), RGB(255, 0, 0)
End Sub

Private Sub Form_Load()
    Dim lMax As Long
    
    lCenterX = Me.Width / 2
    lCenterY = (Me.Height - labMsg.Height - picSpeed.Height) / 2
    Me.Line (0, lCenterY)-(Me.Width, lCenterY), RGB(255, 0, 0)
    Me.Line (lCenterX, 0)-(lCenterX, lCenterY * 2), RGB(255, 0, 0)
    
    lLastPosX = lCenterX
    lLastPosY = lCenterY
    Me.PSet (lCenterX, lCenterY)
    
    lMax = lCenterX
    If lMax < lCenterY Then lMax = lCenterY
    
    txtFactor_Change
    lMaxSpeed = 24000
    
    Me.Hide
End Sub

Public Sub MoveToP(x As Double, Y As Double)
    Me.PSet (x * lFactor + lCenterX, (-Y) * lFactor + lCenterY)
    lLastPosX = x * lFactor + lCenterX
    lLastPosY = (-Y) * lFactor + lCenterY
End Sub

Public Sub LineToP(x As Double, Y As Double)
    Me.Line (lLastPosX, lLastPosY)-(x * lFactor + lCenterX, (-Y) * lFactor + lCenterY)
    labMsg.Caption = "X: " & (x) & "      Y: " & (Y)
    lLastPosX = (x) * lFactor + lCenterX
    lLastPosY = (-Y) * lFactor + lCenterY
End Sub

Public Sub DrawSpeed(SpeedX As Long, SpeedY As Long, SpeedZ As Long, SpeedA As Long)
    Dim Step As Integer
    Dim F As Double
    
    Step = 20
    F = lMaxSpeed
    F = F / (picSpeed.Height - 100)
    
    lLastSpeedXAxes = lLastSpeedXAxes + Step
    picSpeed.Line (lLastSpeedXAxes - Step, (picSpeed.Height - lLastSpeedX / F))-(lLastSpeedXAxes, picSpeed.Height - SpeedX / F), RGB(255, 0, 0)
    picSpeed.Line (lLastSpeedXAxes - Step, (picSpeed.Height - lLastSpeedY / F))-(lLastSpeedXAxes, picSpeed.Height - SpeedY / F), RGB(0, 255, 0)
    picSpeed.Line (lLastSpeedXAxes - Step, (picSpeed.Height - lLastSpeedZ / F))-(lLastSpeedXAxes, picSpeed.Height - SpeedZ / F), RGB(0, 0, 255)
    picSpeed.Line (lLastSpeedXAxes - Step, (picSpeed.Height - lLastSpeedA / F))-(lLastSpeedXAxes, picSpeed.Height - SpeedA / F), RGB(0, 0, 0)
    
    lLastSpeedX = SpeedX
    lLastSpeedY = SpeedY
    lLastSpeedZ = SpeedZ
    lLastSpeedA = SpeedA
    If lLastSpeedXAxes > picSpeed.Width Then
        picSpeed.Cls
        lLastSpeedXAxes = 0
    End If
End Sub

Private Sub txtFactor_Change()
    Dim Fc As Double
    Fc = Val(txtFactor.Text)
    If Fc <> 0 Then
        SetF Fc
    End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -