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

📄 module1.bas

📁 用于控制氧乐果生产的程序
💻 BAS
📖 第 1 页 / 共 2 页
字号:
Attribute VB_Name = "Module1"
Option Explicit
'*******************************
'全局变量
'*******************************

'*********************************
'与仿真有关的语句在本模块、zkhmfrm、
'clsInputData代码模块中,实际运行时
'请注释掉
'*********************************
'Public Interval(9) As Long '该数组用于仿真,实际运行时请注释掉

Public K As Integer
Public gblnIsAuto(1 To 3) As Boolean
Public gstrUserName, gstrCaoZuo, gstrUserType As String
Public gsngManualToAutoKaiDu(1 To 3) As Single
Public gsngAutoToManualKaiDu(1 To 3) As Single
Public gJiaoBanInterval, gLiuDongInterval As Single
Public Aad, Bad As Single
Public gsngLiuLiangLvBo(1 To 3) As Single
Public gsngJZToYJARatio As Single
Public gblnBeginSet(1 To 3) As Boolean
Public gintKaiDuXiaXian(3) As Integer
'*******************************
'数据库、记录集变量
'*******************************
Public Lsdb As Database
Public Batchlsrs(1 To 3) As Recordset
Public Statrs As Recordset
Public Detaillsrs(1 To 3) As Recordset
Public Continousrs(1 To 3) As Recordset
Public BlackBoxRec As Recordset

Public Csdb As Database
Public Csrs(1 To 4) As Recordset

Public Baojingdb As Database
Public Bjrs As Recordset

Public UserDB As Database
Public UserRec As Recordset
'*******************************
'温度、开度等全局变量
'*******************************
Public gfyfWenDu(1 To 3) As Single
Public gtlfaKaiDu(1 To 3) As Single
Public gjlgStartYewei(1 To 3) As Single
Public gjlgEndYewei(1 To 3) As Single
Public gjlgYeWei(1 To 3) As Single
Public gyjaLiuLiang(1 To 3) As Single
Public glqysWenDu As Single
Public gGongZuoZhuangTai(1 To 3) As Boolean
Public gIsTouLiao(1 To 3) As Boolean
Public gJingZhiLiang(1 To 3) As Single
Public gyjaTouLiaoLiang(1 To 3) As Single
Public gdteStartTime(1 To 3) As Date
Public gintkdSheDing(1 To 3) As Integer
'*******************************
'滤波系数
'*******************************
Public Kfyfwd(1 To 3) As Single
Public Ktlfkd(1 To 3) As Single
Public Kyjall(1 To 3) As Single
Public Kjlgyw(1 To 3) As Single
Public Klqyswd(1 To 3) As Single

'*******************************
'
'*******************************
Public gjlgYeWei2(1 To 3, 19) As Single
Public Sum(1 To 3) As Single
'*******************************
'曲线颜色值
'*******************************
Public Const fyfWenDu_Color = 14
Public Const jlgYeWei_Color = 15
Public Const tlfaKaiDu_Color = 12
Public Const yjaLiuLiang_Color = 11
Public Const lqysWenDu_Color = 9
Public Const fyfWenDuSheDing_Color = &HE0E0E0

Public Const PI = 3.1416
'*******************************
'主控窗口中曲线变化上下限
'*******************************
Public gsngfyfwdScaleTop(1 To 3), gsngfyfwdScaleBottom(1 To 3) As Single
Public gsngjlgywScaleTop(1 To 3), gsngjlgywScaleBottom(1 To 3) As Single
Public gsngtlfkdScaleTop(1 To 3), gsngtlfkdScaleBottom(1 To 3) As Single
Public gsngyjallScaleTop(1 To 3), gsngyjallScaleBottom(1 To 3) As Single
Public gsnglqyswdScaleTop, gsnglqyswdScaleBottom As Single
'*******************************
'历史记录窗口中重设曲线变化上下限
'*******************************
Public gsngwdScale(1 To 3, 1 To 2) As Single
Public gsngswdScale(1 To 3, 1 To 2) As Single
Public gsngkdScale(1 To 3, 1 To 2) As Single
Public gsngywScale(1 To 3, 1 To 2) As Single
Public gsngllScale(1 To 3, 1 To 2) As Single

Public glsjlPictureScaleWidth As Single

Public gsngyjaInYeWei(1 To 3) As Single
'*******************************
'工艺参数
'*******************************
Public gsngyjaMiDu As Single
Public gsngjlgZhiJing(1 To 3) As Single

Public Declare Function MyInportb Lib "MyPort.dll" (ByVal Addr As Integer) As Byte
Public Declare Sub MyOutportb Lib "MyPort.dll" (ByVal Addr As Integer, ByVal Value As Byte)
Public Sub Main()
mainfrm.Show
gstrUserName = "无用户名"
gstrCaoZuo = "进入系统"
Call WriteBlackBox
End Sub
'**********************************************************
'该过程实现流动动画,为此必须先创建图片框和时钟控件,并在Timer
'事件中建立从0,1,2,0的循环,然后调用该过程。
'**********************************************************
Public Sub LiuDong(Picture As PictureBox, Counter As Integer)
Picture.Cls
Dim i As Integer
i = 0
'**************
'水平方向
'**************
If Picture.ScaleWidth > Picture.ScaleHeight Then
Select Case Counter
Case 0
    Do
    Picture.Line (640 * i - 420, 0)-(640 * i - 420 + 390, Picture.ScaleHeight), _
    RGB(0, 0, 250), BF
    i = i + 1
    Loop Until (640 * i - 420 + 390) > Picture.ScaleWidth + 450
Case 1
    Do
    Picture.Line (640 * i - 220, 0)-(640 * i - 220 + 390, Picture.ScaleHeight), _
    RGB(0, 0, 250), BF
    i = i + 1
    Loop Until (640 * i - 220 + 390) > Picture.ScaleWidth + 350
Case 2
    Do
    Picture.Line (640 * i + 30, 0)-(640 * i + 30 + 390, Picture.ScaleHeight), _
    RGB(0, 0, 250), BF
    i = i + 1
    Loop Until (640 * i + 30 + 390) > Picture.ScaleWidth + 400
End Select
'**********************
'垂直方向,本软件中未用到
'**********************
Else
Select Case Counter
Case 0
    Do
    Picture.Line (0, 640 * i - 420)-(Picture.ScaleWidth, 640 * i - 420 + 390), _
    RGB(0, 0, 250), BF
    i = i + 1
    Loop Until (640 * i - 420 + 390) > Picture.ScaleHeight + 450
Case 1
    Do
    Picture.Line (0, 640 * i - 220)-(Picture.ScaleWidth, 640 * i - 220 + 390), _
    RGB(0, 0, 250), BF
    i = i + 1
    Loop Until (640 * i - 220 + 390) > Picture.ScaleHeight + 350
Case 2
    Do
    Picture.Line (0, 640 * i + 30)-(Picture.ScaleWidth, 640 * i + 30 + 390), _
    RGB(0, 0, 250), BF
    i = i + 1
    Loop Until (640 * i + 30 + 390) > Picture.ScaleHeight + 400
End Select
End If
End Sub
'********************
'计量罐液位动画
'********************
Public Sub YeWeiDongHua(ByVal Picture As PictureBox, ByVal y As Single)
    Picture.Cls
    Picture.Scale (0, 0)-(Picture.Width, 500)
    Picture.Line (0, 500)-(Picture.Width, y), RGB(0, 0, 250), BF
End Sub
'********************
'绘历史曲线
'********************
Public Sub DrawLishiChart1(ByVal myPicture As PictureBox, _
ByVal myData As Data, ByVal wdScaleMax As Single, ByVal wdScaleMin As _
Single, ByVal ywScaleMax As Single, ByVal ywScaleMin As Single, ByVal _
kdScaleMax As Single, ByVal kdScaleMin As Single, ByVal llScaleMax As _
Single, ByVal llScaleMin As Single, ByVal lqyswdScaleMax As Single, _
ByVal lqyswdScaleMin As Single, ByVal myLabel0 As Label, ByVal myLabel1 _
As Label, ByVal myLabel2 As Label, ByVal myLabel3 As Label, ByVal _
myLabel4 As Label, ByVal myLabel5 As Label, ByVal myLabel6 As Label)
    Dim i, Max As Integer
    Dim yw() As Single
    Dim kd() As Single
    Dim fwd() As Single
    Dim swd() As Single
    Dim ll() As Single
    Dim time0 As Date
    With myPicture
        .Cls
        .DrawWidth = 1
    End With
    With myData.Recordset
        .MoveLast
        Max = .RecordCount
        .MoveFirst
    End With
    ReDim yw(1 To Max)
    ReDim kd(1 To Max)
    ReDim fwd(1 To Max)
    ReDim swd(1 To Max)
    ReDim ll(1 To Max)
    With myData.Recordset
        yw(1) = .Fields("jlgyewei")
        kd(1) = .Fields("tlfkaidu")
        fwd(1) = .Fields("fyfwendu")
        swd(1) = .Fields("lqyswendu")
        ll(1) = .Fields("yjaliuliang")

        myLabel0.Caption = Format(.Fields("currenttime"), "short time")
        time0 = .Fields("currenttime")
    End With
    myLabel1.Caption = Format(time0 + "00:10:00", "short time")
    myLabel2.Caption = Format(time0 + "00:20:00", "short time")
    myLabel3.Caption = Format(time0 + "00:30:00", "short time")
    myLabel4.Caption = Format(time0 + "00:40:00", "short time")
    myLabel5.Caption = Format(time0 + "00:50:00", "short time")
    myLabel6.Caption = Format(time0 + "01:00:00", "short time")
    myData.Recordset.MoveNext
    For i = 2 To Max
    With myData.Recordset
        yw(i) = .Fields("jlgyewei")
        kd(i) = .Fields("tlfkaidu")
        fwd(i) = .Fields("fyfwendu")
        swd(i) = .Fields("lqyswendu")
        ll(i) = .Fields("yjaliuliang")
        .MoveNext
    End With
    myPicture.Scale (0, ywScaleMax)-(glsjlPictureScaleWidth, ywScaleMin)
    myPicture.Line (i - 2, 500 - yw(i - 1))-(i - 1, 500 - yw(i)), QBColor(jlgYeWei_Color)
    
    myPicture.Scale (0, kdScaleMax)-(glsjlPictureScaleWidth, kdScaleMin)
    myPicture.Line (i - 2, kd(i - 1))-(i - 1, kd(i)), QBColor(tlfaKaiDu_Color)
    
    myPicture.Scale (0, lqyswdScaleMax)-(glsjlPictureScaleWidth, lqyswdScaleMin)
    myPicture.Line (i - 2, swd(i - 1))-(i - 1, swd(i)), QBColor(lqysWenDu_Color)
    
    myPicture.Scale (0, llScaleMax)-(glsjlPictureScaleWidth, llScaleMin)
    myPicture.Line (i - 2, ll(i - 1))-(i - 1, ll(i)), QBColor(yjaLiuLiang_Color)
    
    myPicture.Scale (0, wdScaleMax)-(glsjlPictureScaleWidth, wdScaleMin)
    myPicture.Line (i - 2, fwd(i - 1))-(i - 1, fwd(i)), QBColor(fyfWenDu_Color)

    Next
End Sub
'********************
'报警过程
'********************
Public Sub nowAlarm(ByVal InputDataName As String, ByVal IsOutOfRange As Boolean)
Dim strWenDu As String
Dim str1, str2, str3, strUp, strOK, strCanShu, strType As String
Dim BaoJingTime As Date
Dim fyfNum As Integer

strWenDu = "反应釜温度"
strUp = "越上限"
strOK = "恢复正常"
str1 = "1#"
str2 = "2#"
str3 = "3#"
BaoJingTime = Time
Select Case InputDataName
Case "fyf1_fyfWenDu"
    With baojingfrm.List1
        If IsOutOfRange Then
        .List(1) = CStr(BaoJingTime) + "  " + str1 + strWenDu + "  " + strUp
        strType = strUp
        Else
        .List(1) = CStr(BaoJingTime) + "  " + str1 + strWenDu + "  " + strOK
        strType = strOK
        End If
    End With
    fyfNum = 1
    strCanShu = strWenDu
Case "fyf2_fyfWenDu"
    With baojingfrm.List1
        If IsOutOfRange Then
        .List(2) = CStr(BaoJingTime) + "  " + str2 + strWenDu + "  " + strUp
        strType = strUp
        Else
        strType = strOK
        .List(2) = CStr(BaoJingTime) + "  " + str2 + strWenDu + "  " + strOK

⌨️ 快捷键说明

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