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

📄 directmultifrm.frm

📁 数控切割控制系统,需要DLPORTIO,通过控制8位的并口的电位高低来4路控制数控切割机
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DirectMultiFrm 
   BackColor       =   &H00C0E0FF&
   BorderStyle     =   0  'None
   Caption         =   "直线多头"
   ClientHeight    =   7200
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   9600
   LinkTopic       =   "Form1"
   ScaleHeight     =   7200
   ScaleWidth      =   9600
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.Timer Timer_Beep 
      Enabled         =   0   'False
      Interval        =   10
      Left            =   6420
      Top             =   3480
   End
   Begin VB.CommandButton StopCmd 
      Caption         =   "停止切割"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   6540
      TabIndex        =   15
      Top             =   5640
      Width           =   1755
   End
   Begin VB.CommandButton StopGoOnCmd 
      Caption         =   "暂停"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   4020
      TabIndex        =   14
      Top             =   5640
      Width           =   1875
   End
   Begin VB.Frame Frame1 
      Caption         =   "方向"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   1320
      TabIndex        =   10
      Top             =   3540
      Width           =   4035
      Begin VB.OptionButton OptionBack 
         Caption         =   "向后"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   2280
         TabIndex        =   12
         Top             =   300
         Width           =   795
      End
      Begin VB.OptionButton OptionFront 
         Caption         =   "向前"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   660
         TabIndex        =   11
         Top             =   300
         Value           =   -1  'True
         Width           =   915
      End
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Left            =   7560
      Top             =   1500
   End
   Begin VB.CommandButton SetCmd 
      Caption         =   "保存切割参数"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   2100
      TabIndex        =   9
      Top             =   4620
      Width           =   2355
   End
   Begin VB.CommandButton BackCmd 
      Caption         =   "返回"
      Height          =   375
      Left            =   8340
      TabIndex        =   8
      Top             =   6720
      Width           =   1095
   End
   Begin VB.CommandButton BeginCmd 
      Caption         =   "开始"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   1500
      TabIndex        =   7
      Top             =   5640
      Width           =   1755
   End
   Begin VB.TextBox txtLength 
      Height          =   435
      Left            =   2700
      TabIndex        =   5
      Top             =   2640
      Width           =   2115
   End
   Begin VB.TextBox txtSpeed 
      Height          =   435
      Left            =   2700
      TabIndex        =   3
      Top             =   1680
      Width           =   2115
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0E0FF&
      Caption         =   "数控切割控制系统"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   24
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   615
      Left            =   2040
      TabIndex        =   13
      Top             =   120
      Width           =   4095
   End
   Begin VB.Label Label6 
      BackColor       =   &H00C0E0FF&
      Caption         =   "米"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4920
      TabIndex        =   6
      Top             =   2700
      Width           =   495
   End
   Begin VB.Label Label5 
      BackColor       =   &H00C0E0FF&
      Caption         =   "米/分钟"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4920
      TabIndex        =   4
      Top             =   1740
      Width           =   1275
   End
   Begin VB.Label Label4 
      BackColor       =   &H00C0E0FF&
      Caption         =   "切割长度:"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   1080
      TabIndex        =   2
      Top             =   2640
      Width           =   1515
   End
   Begin VB.Label Label3 
      BackColor       =   &H00C0E0FF&
      Caption         =   "切割速度:"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1080
      TabIndex        =   1
      Top             =   1680
      Width           =   1515
   End
   Begin VB.Label Label2 
      BackColor       =   &H00C0E0FF&
      Caption         =   "直线多头切割"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   840
      Width           =   2235
   End
End
Attribute VB_Name = "DirectMultiFrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim dX2, dY2 As Long

Private Sub BackCmd_Click()
    Unload Me
    MainFrm.Show vbModal
End Sub

Private Sub BeginCmd_Click()
    Dim iInterval As Double
    
    iInterval = Ax * 60 / DirectMultiSpeed
    If (iInterval < 1) Then
        Timer1.Interval = 1
    Else
        Timer1.Interval = iInterval
    End If
    Timer1.Enabled = True
    BeginCmd.Enabled = False
    StopGoOnCmd.Enabled = True
    stopCmd.Enabled = True
End Sub

Private Sub Form_Load()
    Dim Mystr As String
    Dim sSpeed As String
    Dim sLength As String
    
    sSpeed = "0"
    sLength = "0"
    
    dX2 = 0
    dY2 = 0
    On Error GoTo errHandler
    Open App.Path + "\设置文件\LineMultiSpeed.txt" For Input As #1
    Do While Not EOF(1)
        Input #1, Mystr
        If (Mystr = "[Speed]") Then
            If Not EOF(1) Then
                Input #1, sSpeed
                sSpeed = ReadRightString(sSpeed)
            End If
        End If
        If (Mystr = "[Length]") Then
            If Not EOF(1) Then
                Input #1, sLength
                sLength = ReadRightString(sLength)
            End If
        End If
    Loop
    Close #1
    txtSpeed.Text = sSpeed
    txtLength.Text = sLength
    
    DirectMultiSpeed = sSpeed
    DirectMultiLength = sLength
'    FFBQuick = AtoL(sQuickSpeed)
'    FFBSlow = AtoL(sSlowlySpeed)
errHandler:
    If Err.Number = 53 Then
        MsgBox "'LineMultiSpeed.txt'文件不存在,请与管理员联系", vbInformation, "提示"
        Unload Me
        MainFrm.Show vbModal
    End If

End Sub

Private Sub SetCmd_Click()
    If (txtSpeed.Text = "") Or (txtLength.Text = "") Then
        MsgBox "请输入数据", vbInformation, "提示"
        Exit Sub
    End If
    
    Open App.Path + "\设置文件\LineMultiSpeed.txt" For Output As #1
        Print #1, "[Speed]"
        Print #1, "Speed = " + Trim(txtSpeed.Text)
        Print #1, "[Length]"
        Print #1, "Length = " + Trim(txtLength.Text)
    Close #1
    SetCmd.Enabled = False
    
    BeginCmd.Enabled = True
    DirectMultiSpeed = Trim(txtSpeed.Text)
    DirectMultiLength = Trim(txtLength.Text)
End Sub

Private Sub stopCmd_Click()
    Timer1.Enabled = False
    dX2 = 0
    BeginCmd.Enabled = True
    StopGoOnCmd.Enabled = False
    StopGoOnCmd.Caption = "暂停"
    stopCmd.Enabled = False
End Sub

Private Sub StopGoOnCmd_Click()
    If (StopGoOnCmd.Caption = "暂停") Then
        Timer1.Enabled = False
        StopGoOnCmd.Caption = "继续切割"
    Else
        Timer1.Enabled = True
        StopGoOnCmd.Caption = "暂停"
    End If
End Sub

Private Sub Timer_Beep_Timer()
    Beep
End Sub

Private Sub Timer1_Timer()
    If (Abs(dX2) >= DirectMultiLength * 1000) Then
        Timer1.Enabled = False
        StopGoOnCmd.Enabled = False
        BeginCmd.Enabled = True
        stopCmd.Enabled = False
        MsgBox "切割完成", vbInformation, "提示"
        dX2 = 0
        Exit Sub
    End If
    dX2 = dX2 + Ax
    If (OptionFront.Value = True) Then
        WritePortDirect 2, 1
        Result = WriteOneSignal(2, 1)
    Else
        WritePortDirect 2, 2
        Result = WriteOneSignal(2, 1)
    End If
    
    Call Judge
End Sub

Private Sub txtLength_KeyPress(KeyAscii As Integer)
    If ((KeyAscii < Asc(0)) Or (KeyAscii > Asc(9))) And (KeyAscii <> 8) And (KeyAscii <> 46) Then
        KeyAscii = 0
    End If
End Sub

Private Sub txtLength_KeyUp(KeyCode As Integer, Shift As Integer)
'    If (Trim(txtLength.Text) <> "") Then
'        SetCmd.Enabled = True
'    Else
'        If (Trim(txtLength.Text) = "") Then
            SetCmd.Enabled = True
'        End If
'    End If
End Sub

Private Sub txtSpeed_KeyPress(KeyAscii As Integer)
    If ((KeyAscii < Asc(0)) Or (KeyAscii > Asc(9))) And (KeyAscii <> 8) And (KeyAscii <> 46) Then
        KeyAscii = 0
    End If
End Sub

Private Sub txtSpeed_KeyUp(KeyCode As Integer, Shift As Integer)
'    If (Trim(txtSpeed.Text) <> "") Then
'        SetCmd.Enabled = True
'    Else
'        If (Trim(txtSpeed.Text) = "") Then
            SetCmd.Enabled = True
'        End If
'    End If
End Sub

Private Sub Judge()
    If (Result = 2) Then
        Timer1.Enabled = False
        MsgBox "X轴到头!返回", vbInformation, "提示"
        Unload Me
        MainFrm.Show vbModal
        Exit Sub
    End If
    
    If (Result = 3) Then
        Timer1.Enabled = False
        MsgBox "Y轴到头!返回", vbInformation, "提示"
        Unload Me
        MainFrm.Show vbModal
        Exit Sub
    End If
    
    If (Result = 1) Then
        Timer1.Enabled = False
        Timer_Beep.Enabled = True
        MsgBox "出现故障", vbInformation, "提示"
        Timer_Beep.Enabled = False
        Unload Me
        MainFrm.Show vbModal
        Exit Sub
    End If
End Sub

⌨️ 快捷键说明

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