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

📄 frmpowercontrol.frm

📁 艾诺97030变频电源远程通讯程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   2160
         TabIndex        =   14
         Top             =   3240
         Width           =   1455
      End
      Begin VB.Label PhaseLabel 
         BackColor       =   &H00E0E0E0&
         Caption         =   "单相"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00400000&
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   10
         Top             =   600
         Width           =   615
      End
      Begin VB.Label PhaseLabel 
         BackColor       =   &H00E0E0E0&
         Caption         =   "三相"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00400000&
         Height          =   255
         Index           =   1
         Left            =   1920
         TabIndex        =   9
         Top             =   600
         Width           =   615
      End
   End
   Begin VB.Frame FreqFrame 
      BackColor       =   &H00E0E0E0&
      Caption         =   "频率控制"
      Height          =   1455
      Left            =   240
      TabIndex        =   3
      Top             =   5040
      Width           =   3855
      Begin isDigitalLibrary.iSwitchToggleX FreqSelect 
         Height          =   540
         Left            =   720
         TabIndex        =   4
         TabStop         =   0   'False
         Top             =   480
         Width           =   1095
         Active          =   0   'False
         DragToToggle    =   0   'False
         MouseControlStyle=   0
         ShowFocusRect   =   0   'False
         SwitchBevelStyle=   1
         SwitchHeight    =   22
         SwitchOrientation=   1
         BorderStyle     =   0
         Object.Visible         =   -1  'True
         Enabled         =   -1  'True
         UpdateFrameRate =   60
         OptionSaveAllProperties=   0   'False
         AutoFrameRate   =   0   'False
         OPCItemCount    =   0
      End
      Begin isAnalogLibrary.iSevenSegmentAnalogX ShowFreq 
         Height          =   540
         Left            =   2640
         TabIndex        =   5
         TabStop         =   0   'False
         Top             =   480
         Width           =   1020
         Precision       =   0
         Value           =   0
         ShowSign        =   0   'False
         DigitCount      =   3
         LeadingStyle    =   2
         AutoSize        =   -1  'True
         DigitSpacing    =   6
         SegmentMargin   =   5
         SegmentColor    =   255
         SegmentSeperation=   1
         SegmentSize     =   1
         ShowOffSegments =   -1  'True
         PowerOff        =   0   'False
         BackGroundColor =   0
         BorderStyle     =   2
         Object.Visible         =   -1  'True
         SegmentOffColor =   8421504
         AutoSegmentOffColor=   -1  'True
         Transparent     =   0   'False
         UpdateFrameRate =   60
         OptionSaveAllProperties=   0   'False
         AutoFrameRate   =   0   'False
         OPCItemCount    =   0
      End
      Begin VB.Label FreqLabel 
         BackColor       =   &H00E0E0E0&
         Caption         =   "60HZ"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   1
         Left            =   1920
         TabIndex        =   13
         Top             =   600
         Width           =   495
      End
      Begin VB.Label FreqLabel 
         BackColor       =   &H00E0E0E0&
         Caption         =   "50HZ"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   0
         Left            =   120
         TabIndex        =   12
         Top             =   600
         Width           =   495
      End
   End
   Begin Threed.SSCommand StartButton 
      Height          =   735
      Index           =   0
      Left            =   240
      TabIndex        =   1
      TabStop         =   0   'False
      Top             =   7080
      Width           =   1695
      _Version        =   65536
      _ExtentX        =   2990
      _ExtentY        =   1296
      _StockProps     =   78
      Caption         =   "设置并启动"
      BevelWidth      =   3
      Font3D          =   3
   End
   Begin Threed.SSCommand StartButton 
      Height          =   735
      Index           =   1
      Left            =   2400
      TabIndex        =   2
      TabStop         =   0   'False
      Top             =   7080
      Width           =   1695
      _Version        =   65536
      _ExtentX        =   2990
      _ExtentY        =   1296
      _StockProps     =   78
      Caption         =   "停止输出"
      BevelWidth      =   3
      Font3D          =   3
   End
   Begin VB.Label Readme 
      BackColor       =   &H00E0E0E0&
      Caption         =   "说明:改变电源频率及相状态需先停止输出!"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   255
      Left            =   240
      TabIndex        =   19
      Top             =   6720
      Width           =   3855
   End
End
Attribute VB_Name = "PowerSource"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private mComAddr As String
Private mComm As String
Private mVoltage As String
Private mFreq As String
Const sPort As Integer = 6

Private Sub Form_Load()

ShowVoltage.Value = Abs(QuickVoltage.Position = 0) * 110 + _
                        Abs(QuickVoltage.Position = 1) * 220 + _
                        Abs(QuickVoltage.Position = 2) * 230
ShowFreq.Value = Abs(FreqSelect.Active = False) * 50 + Abs(FreqSelect.Active = True) * 60
VoltageSelect.Position = ShowVoltage.Value
InputVoltage.Text = ShowVoltage.Value
End Sub

Private Sub Form_Unload(Cancel As Integer)
sio_close sPort
End Sub

Private Sub FreqSelect_OnChange()
ShowFreq.Value = Abs(FreqSelect.Active = False) * 50 + Abs(FreqSelect.Active = True) * 60
End Sub

Private Sub InputVoltage_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
    SetVoltage_Click
End If
End Sub

Private Sub QuickVoltage_OnPositionChange()
Dim VoltageNow As Integer

VoltageNow = Abs(QuickVoltage.Position = 0) * 110 + _
                Abs(QuickVoltage.Position = 1) * 220 + _
                Abs(QuickVoltage.Position = 2) * 230

ShowVoltage.Value = VoltageNow
VoltageSelect.Position = VoltageNow
End Sub

Private Sub SetVoltage_Click()
If IsNumeric(InputVoltage.Text) Then
    If InputVoltage.Text >= 0 And InputVoltage.Text <= 300 And Not InputVoltage.Text Like "*.*" Then
        ShowVoltage.Value = InputVoltage.Text
        VoltageSelect.Position = ShowVoltage.Value
    Else
        InputVoltage.Text = ShowVoltage.Value
    End If
Else
    InputVoltage.Text = ShowVoltage.Value
End If
End Sub

Private Sub StartButton_Click(Index As Integer)
Dim ComStr As String
Dim CRC As Integer
Dim Buffer As String * 256
Dim IsOK As Boolean
Dim i As Integer

mComAddr = "00"
mVoltage = Format(ShowVoltage.Value, "000")
mFreq = Format(ShowFreq.Value * 10, "0000")

sio_close sPort
Sleep 500
If sio_open(sPort) = SIO_OK Then
    sio_ioctl sPort, B1200, P_NONE + BIT_8 + STOP_1
    If Index = 0 Then
        mComm = "05"
        GoSub DoGet
        Select Case PhaseSelect.Active
            Case False
                mComm = "01"
            Case True
                mComm = "04"
        End Select
        GoSub DoGet
    ElseIf Index = 1 Then
        mComm = "00"
        GoSub DoGet
    End If
End If

Select Case IsOK
    Case True
        MsgBox "OK", vbInformation + vbOKOnly
    Case False
        MsgBox "ERR", vbInformation + vbOKOnly
End Select
Exit Sub

DoGet:
ComStr = "{" & mComAddr & "," & mComm & "," & mVoltage & "," & mFreq & ","
CRC = 0
For i = 2 To 16
    CRC = CRC + Asc(Mid(ComStr, i, 1))
Next
  ComStr = ComStr & VBA.Right(Hex(CRC), 2) & "}"
sio_flush sPort, 2
sio_write sPort, ComStr, Len(ComStr)
i = 0
Do
    Sleep 100
    m = sio_iqueue(sPort)
    i = i + 1
Loop While m <> 4 And m <> 5 And i < 40

IsOK = False
If m = 4 Or m = 5 Then sio_read sPort, Buffer, m
If VBA.Left(Buffer, m) = "{OK}" Then IsOK = True
Return
End Sub

Private Sub VoltageSelect_OnPositionChange()
ShowVoltage.Value = VoltageSelect.Position
InputVoltage.Text = VoltageSelect.Position
End Sub

⌨️ 快捷键说明

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