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

📄 form1.frm

📁 主要用于控制三相电能表检验装置
💻 FRM
📖 第 1 页 / 共 3 页
字号:
            Exit Do
        Loop
     Next i
                
     For i = 0 To 23
        If CommSetJ(i).Comm <> "" Then
            Do While CommSetJ(i).Comm = CommDWIn(i).Comm
                Exit Do
            Loop
        End If
     Next i
            
     For i = 0 To 23
        If CommSetJ(i).Comm <> "" Then
            DataJieXi (CommSetJ(i).Comm)
            CommDWIn(i).Comm = ""
            CommDWIn(i).DataLen = 0
         End If
     Next i
            
     'ProcRDCoeffCommd
     'PutCommandBuff
     'Loop
        
    If DangQianHang2 <> 0 Then
        Exit Function
    End If
    
    AdOpNUM2 = AdOpNUM2 + 1
    If AdOpNUM2 <> AdOpNUM Then
        Exit Function
    End If
    MsgBox ("自动校正结束")
        'j = j + 1
    'Loop
        
 End Function

 Function CalCoeff()
    If Text1.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text2.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text3.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text4.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text5.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text6.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text7.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text8.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text9.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text10.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text11.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    If Text12.Text = "" Then
        MsgBox ("输入标准值")
        Exit Function
    End If
    StandMeterData.Voltage(0) = Val(XiaoChuxiaoshudian(Text1.Text, 2))
    StandMeterData.Voltage(1) = Val(XiaoChuxiaoshudian(Text2.Text, 2))
    StandMeterData.Voltage(2) = Val(XiaoChuxiaoshudian(Text3.Text, 2))
    StandMeterData.Current(0) = Val(XiaoChuxiaoshudian(Text4.Text, 4))
    StandMeterData.Current(1) = Val(XiaoChuxiaoshudian(Text5.Text, 4))
    StandMeterData.Current(2) = Val(XiaoChuxiaoshudian(Text6.Text, 4))
    StandMeterData.PF(1) = Val(XiaoChuxiaoshudian(Text7.Text, 3))
    StandMeterData.PF(2) = Val(XiaoChuxiaoshudian(Text8.Text, 3))
    StandMeterData.PF(3) = Val(XiaoChuxiaoshudian(Text9.Text, 3))
    StandMeterData.Power(1) = Val(XiaoChuxiaoshudian(Text10.Text, 5)) '4
    StandMeterData.Power(2) = Val(XiaoChuxiaoshudian(Text11.Text, 5)) '4
    StandMeterData.Power(3) = Val(XiaoChuxiaoshudian(Text12.Text, 5)) '4
    
    Dim Comm As String
    For i = 0 To 23
        If CommSetJ(i).Comm <> "" Then
            Comm = CommSetJ(i).Comm
            Cal_main Comm
        End If
    Next i
End Function
Function StatiOperate()
    Dim i As Byte
    Dim j As Byte
    Dim m As Byte
     j = 0
    Form1.MSFlexGrid1.Col = 1
    For i = 1 To 9
        Form1.MSFlexGrid1.Row = i
        If Form1.MSFlexGrid1.Text = ">>" Then
            Form1.MSFlexGrid1.Col = 0
            AdjustOperate(j) = Form1.MSFlexGrid1.Text
            j = j + 1
            Form1.MSFlexGrid1.Col = 1
        Else
            AdjustOperate(j) = ""
        End If
        AdjustOperate(j) = ""
    Next i
    AdOpNUM = j
    
    For i = 0 To AdOpNUM '操作步数
        m = 0
        For j = 0 To ZongHangShu
            If AdjustOperate(i) = JiaoZhengCanShu(j, 3) Then
                AdjustKEY(i, m) = JiaoZhengCanShu(j, 1)
                m = m + 1
            End If
            AdjustKEY(i, m) = ""
        Next j
    Next i
    
End Function
Private Sub Command4_Click()
    If BiaoWeiNum = 0 Then
        MsgBox ("请选择表位")
        Exit Sub
    End If
    Commpeizhi
    Command4.Enabled = False
    List2.Clear
    Dim i As Byte
    SavePeizhi "台体00", Combo3.Text, Combo1.Text
    List2.AddItem "台体00: " & Combo3.Text & "   " & Combo1.Text
    
    Open_Comm
End Sub
Function Clear_Scaned(Comm As String)
    Dim i As Byte
    For i = 0 To 23
        If Scancomm(i) = Comm Then
            Scancomm(i) = ""
            Exit For
        End If
    Next i
End Function
Function SavePeizhi(PD As String, Comm As String, Peizhi As String) '保存对象
    Dim file
    Dim fname
    Dim i As Byte
    Dim st(13) As String
    fname = App.Path & "\CanShu\" & "自动搜索.txt"
    i = 0
    
    Set file = FSO.OpenTextFile(fname, ForReading, False)
        Do While file.AtEndOfStream <> True
            
            st(i) = file.ReadLine
            If st(i) = "End" Then
               Exit Do
            End If
            i = i + 1
        Loop
    file.Close
    
    Dim cmpst As String
    For i = 0 To 12
        cmpst = Left(st(i), 4)
        If PD = cmpst Then
            cmpst = cmpst & ":" & Comm & ":" & Peizhi
            st(i) = cmpst
            Exit For
        End If
    Next i
    
    Set file = FSO.OpenTextFile(fname, ForWriting, False)
        For i = 0 To 13
            file.WriteLine st(i)
        Next i
    file.Close
End Function

Private Sub Form_Load()
    Dim fname
    Dim file
    Dim LenStrting As String
    Dim stt() As String
    Dim st As String

    Form1.Height = Screen.Height - 4000
    Form1.Width = Screen.Width - 1600
    Form1.Top = 500
    Form1.Left = 500
    CommNUM = 0
    Crc_Init
    BiaoShujuInit
    
    fname = App.Path & "\CanShu\Name.txt"
    Dim hang As Byte
    
    Form1.MSFlexGrid1.Clear
    Form1.List1.Clear
    Set file = FSO.OpenTextFile(fname, ForReading, False)
            LenStrting = file.ReadLine
            stt = Split(LenStrting, ",")
            Me.MSFlexGrid1.Rows = StringTwoToHex(stt(1)) + 1
            Form1.MSFlexGrid1.Row = 0
            Form1.MSFlexGrid1.Col = 0
            Form1.MSFlexGrid1.Text = "步骤"
            Form1.MSFlexGrid1.Row = 0
            Form1.MSFlexGrid1.Col = 1
            Form1.MSFlexGrid1.Text = "选项"
            
            hang = 0
            LenStrting = file.ReadLine
            stt = Split(LenStrting, ",")
            JiaoZhengCanShu(hang, 0) = Trim(stt(0))
            JiaoZhengCanShu(hang, 1) = Trim(stt(1))
            JiaoZhengCanShu(hang, 2) = Trim(stt(2))
            JiaoZhengCanShu(hang, 3) = Trim(stt(3))
            JiaoZhengCanShu(hang, 6) = Trim(stt(4)) '
            JiaoZhengCanShu(hang, 4) = 0 '不用
            JiaoZhengCanShu(hang, 5) = 0 '不用
            st = stt(3)
            
            Dim i As Byte
            i = 1
            hang = 1
            Do While file.AtEndOfStream <> True
                LenStrting = file.ReadLine
                stt = Split(LenStrting, ",")
                JiaoZhengCanShu(hang, 0) = Trim(stt(0))
                JiaoZhengCanShu(hang, 1) = Trim(stt(1))
                JiaoZhengCanShu(hang, 2) = Trim(stt(2))
                JiaoZhengCanShu(hang, 3) = Trim(stt(3))
                JiaoZhengCanShu(hang, 6) = Trim(stt(4)) '
                JiaoZhengCanShu(hang, 4) = 0 '不用
                JiaoZhengCanShu(hang, 5) = 0 '不用
                If st <> stt(3) Then
                    Form1.MSFlexGrid1.Row = i
                    Form1.MSFlexGrid1.Col = 0
                    Form1.MSFlexGrid1.Text = st
                    Form1.MSFlexGrid1.Col = 1
                    Form1.MSFlexGrid1.Text = ">>"
                    i = i + 1
                    st = stt(3)
                End If
                hang = hang + 1
            Loop
            Form1.MSFlexGrid1.Row = i
            Form1.MSFlexGrid1.Col = 0
            Form1.MSFlexGrid1.Text = stt(3)
            Form1.MSFlexGrid1.Col = 1
            Form1.MSFlexGrid1.Text = ">>"
            
            ZongHangShu = hang
    file.Close
    
    Combo3.Clear
    Combo3.AddItem "COM1"
    Combo3.AddItem "COM2"
    Combo3.AddItem "COM3"
    Combo3.AddItem "COM4"
    Combo3.AddItem "COM5"
    Combo3.AddItem "COM6"
    Combo3.AddItem "COM7"
    Combo3.AddItem "COM8"
    Combo3.AddItem "COM9"
    Combo3.AddItem "COM10"
    Combo3.AddItem "COM11"
    Combo3.AddItem "COM12"
    Combo3.AddItem "COM13"
    Combo3.AddItem "COM14"
    Combo3.AddItem "COM15"
    Combo3.AddItem "COM16"
    Combo3.AddItem "COM17"
    Combo3.AddItem "COM18"
    Combo3.AddItem "COM19"
    Combo3.AddItem "COM20"
    Combo3.AddItem "COM21"
    Combo3.AddItem "COM22"
    Combo3.AddItem "COM23"
    Combo3.AddItem "COM24"
    Combo3.ListIndex = 0

    Combo1.Clear
    Combo1.AddItem "9600,N,8,1"
    Combo1.AddItem "115200,N,8,1"
    Combo1.ListIndex = 1
    
    Combo2.Clear
    Combo2.AddItem "9600,N,8,1"
    Combo2.AddItem "115200,N,8,1"
    Combo2.ListIndex = 1
    
    'BiaoShuDuQu_Main
End Sub
Private Sub MSFlexGrid1_Click()
    Dim i As Byte
    Dim j As Byte
    i = Form1.MSFlexGrid1.Col
    j = Form1.MSFlexGrid1.Row
    If i = 1 Then
        If j = 0 Then
            Exit Sub
        End If
        SelecetStep j - 1
    End If
    
    StatiOperate
End Sub
  Function SelecetStep(index As Byte)
        
        If Form1.MSFlexGrid1.Text = ">>" Then
            Form1.MSFlexGrid1.Text = ""
        Else
            Form1.MSFlexGrid1.Text = ">>"
        End If
        
 End Function

 Function MeterComminit(index As Byte) '
    If BiaoWei(index).Comm <> "" Then
        CloseComm BiaoWei(index).Comm
        'BiaoWei(index).Peizhi = "9600,N,8,1"
        SetComm BiaoWei(index).Comm, "9600,N,8,1"
        'lcd_BiaoDoState(index) = 1 'LCD下载启动
        'lcd_BiaoWeiZhengShu(index) = 0
        'lcd_ChongFaCishu(index) = 0
  
        'If Main.Timer4.Enabled = False Then
        '   Main.Timer4.Enabled = True
        'End If
        'If Main.Timer2.Enabled = False Then
        '   Main.Timer2.Interval = 10
        '   Main.Timer2.Enabled = True
        'End If
    End If
End Function


Private Sub Timer1_Timer()
    fa_Main '发送扫描程序
    JieShou_Main '接收扫描程序
    ScanProcess
   ' Form1.Timer1.Enabled = Flase
End Sub

Private Sub Timer2_Timer()
AutoAdjustMeter '自动校表
End Sub

⌨️ 快捷键说明

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