📄 form1.frm
字号:
Top = 840
Width = 915
End
Begin VB.TextBox hywd
DataField = "firetemp"
Height = 270
Left = 1500
TabIndex = 5
Top = 420
Width = 915
End
Begin VB.Label Label4
Caption = "火焰 温度:"
Height = 255
Left = 360
TabIndex = 4
Top = 480
Width = 1095
End
Begin VB.Label Label3
Caption = "冷却机电流:"
Height = 315
Left = 360
TabIndex = 3
Top = 1740
Width = 1095
End
Begin VB.Label Label2
Caption = "主机 电流:"
Height = 315
Left = 360
TabIndex = 2
Top = 1320
Width = 1095
End
Begin VB.Label Label1
Caption = "窑头 温度:"
Height = 255
Left = 360
TabIndex = 1
Top = 900
Width = 1155
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 735
Left = 180
Top = 2280
Width = 2835
_ExtentX = 5001
_ExtentY = 1296
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\biyesheji\vbdesign\xzy.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\biyesheji\vbdesign\xzy.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "getdata"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSAdodcLib.Adodc Adodc2
Height = 1635
Left = 7380
Top = 3900
Width = 1335
_ExtentX = 2355
_ExtentY = 2884
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\biyesheji\vbdesign\xzy.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\biyesheji\vbdesign\xzy.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "results"
Caption = "Adodc2"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rc As Integer
Dim tf As Integer
Dim Term As Long
Dim Cnxzy As New ADODB.Connection
Dim Rsxzy As New ADODB.Recordset
Dim Rsrst As New ADODB.Recordset
Dim RsEstoCs As New ADODB.Recordset '数据库记录
Dim lastfiretemp As Integer '数据指针指示的最后一行(当前)firetemp值
Dim prefiretemp As Integer '数据指针指示的上一行firetemp值
Dim lastheadtemp As Integer '数据指针指示的最后一行(当前)headtemp值
Dim preheadtemp As Integer '数据指针指示的上一行headtemp值
Dim lastcoolcurrent As Integer '数据指针指示的最后一行(当前)coolcurrent值
Dim precoolcurrent As Integer '数据指针指示的上一行coolcurrent值
Dim lasthostcurrent As Integer '数据指针指示的最后一行(当前)hostcurrent值
Dim prehostcurrent As Integer '数据指针指示的上一行hostcurrent值
Dim Dvfiretemp As Integer '火焰温度变化值
Dim Dvheadtemp As Integer '窑头温度变化值
Dim Dvcoolcurrent As Integer '冷机电流变化值
Dim Dvhostcurrent As Integer '主机电流变化值
Dim FiretempState As String '窑内温度状态:上升、不变或下降状态
Dim HeadState As String '窑头温度状态
Dim CoolState As String '冷却机电流状态
Dim HostState As String '主机电流状态
Dim thistemprank As String '当前温度档
Dim Pretemprank As String '上一次温度档thisspeed
Dim thisspeed As String
Dim thetemprank As String
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Form_Load()
'建立数据库连接
strcn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False" & ";Data Source=" + App.Path + "\xzy.mdb"
Cnxzy.ConnectionString = strcn
Cnxzy.Open
'创建xzy_recordset对象获取数据
Set Rsxzy.ActiveConnection = Cnxzy
Rsxzy.CursorLocation = adUseClient
Rsxzy.CursorType = adOpenDynamic
Rsxzy.LockType = adLockBatchOptimistic
'在数据库中打开表getdata
Rsxzy.Open "select * from getdata", Cnxzy
'创建Rsrst_recordset对象获取数据
Set Rsrst.ActiveConnection = Cnxzy
Rsrst.CursorLocation = adUseClient
Rsrst.CursorType = adOpenDynamic
Rsrst.LockType = adLockBatchOptimistic
'在数据库中打开表results
Rsrst.Open "select * from results", Cnxzy
End Sub
Private Sub Command1_Click()
'输入框无数据提示
If hywd.Text = "" Or ytwd.Text = "" Or zjdl.Text = "" Or ljdl.Text = "" Then
MsgBox "请输入数据!", vbOKOnly + vbExclamation, "警告!"
Exit Sub
End If
'从输入框输入数据存入数据表中
Rsxzy.AddNew
Rsxzy!firetemp = hywd
Rsxzy!headtemp = ytwd
Rsxzy!coolcurrent = ljdl
Rsxzy!hostcurrent = zjdl
Rsxzy.UpdateBatch
End Sub
Private Sub Command3_Click()
'数据指针指最后一行,获取各列最新数据
Rsxzy.MoveLast
lastfiretemp = Rsxzy.Fields("firetemp").Value
lastheadtemp = Rsxzy.Fields("headtemp").Value
lastcoolcurrent = Rsxzy.Fields("coolcurrent").Value
lasthostcurrent = Rsxzy.Fields("hostcurrent").Value
'数据指针指上移一行,获取各列早前数据
Rsxzy.MovePrevious
prefiretemp = Rsxzy.Fields("firetemp").Value
preheadtemp = Rsxzy.Fields("headtemp").Value
precoolcurrent = Rsxzy.Fields("coolcurrent").Value
prehostcurrent = Rsxzy.Fields("hostcurrent").Value
'数据指针归位,指示最后一行
Dvfiretemp = lastfiretemp - prefiretemp
Dvheadtemp = lastheadtemp - preheadtemp
Dvcoolcurrent = lastcoolcurrent - precoolcurrent
Dvhostcurrent = lasthostcurrent - prehostcurrent
Rsxzy.MoveLast
Select Case Dvfiretemp = lastfiretemp - prefiretemp
Case Dvfiretemp > 0
hywdbh.Text = "上升"
FiretempState = "goup"
Case Dvfiretemp = 0
hywdbh.Text = "不变"
FiretempState = "immove"
Case Dvfiretemp < 0
hywdbh.Text = "下降"
FiretempState = "godown"
End Select
Select Case Dvheadtemp = lastheadtemp - preheadtemp
Case Dvheadtemp > 0
ytwdbh.Text = "上升"
HeadState = "goup"
Case Dvheadtemp = 0
ytwdbh.Text = "不变"
HeadState = "immove"
Case Dvheadtemp < 0
ytwdbh.Text = "下降"
HeadState = "godown"
End Select
Select Case Dvcoolcurrent = lastcoolcurrent - precoolcurrent
Case Dvcoolcurrent > 0
ljdlbh.Text = "上升"
CoolState = "goup"
Case Dvcoolcurrent = 0
ljdlbh.Text = "不变"
CoolState = "immove"
Case Dvcoolcurrent < 0
ljdlbh.Text = "下降"
CoolState = "godown"
End Select
Select Case Dvhostcurrent = lasthostcurrent - prehostcurrent
Case Dvhostcurrent > 0
zjdlbh.Text = "上升"
HostState = "goup"
Case Dvhostcurrent = 0
zjdlbh.Text = "不变"
HostState = "immove"
Case Dvhostcurrent < 0
zjdlbh.Text = "下降"
HostState = "godown"
End Select
End Sub
Private Sub Command4_Click()
'初始化逻辑服务器
Call InitLS("")
MsgBox "Prolog Initialized", MB_OK
'加载 xpl 文件到逻辑服务器
LoadLS ("D:\biyesheji\vbdesign\rules.xpl")
MsgBox "Hello.XPL Loaded", MB_OK
'把前一周期的温度档、窑头温度、冷却机电流和主机电流的上升、下降或是不变的状态送推理机
Rsrst.MoveLast
Pretemprank = Rsrst.Fields("temprank").Value
tf = CallStrLS(Term, "asserta(lasttemp(" & Pretemprank & "))")
tf = CallStrLS(Term, "asserta(mostate(headtemp," & HeadState & "))")
tf = CallStrLS(Term, "asserta(mostate(coolcurrent," & CoolState & "))")
tf = CallStrLS(Term, "asserta(mostate(hostcurrent," & HostState & "))")
'提问,根据规则和上面所送之事实,确定当前温度档
tf = CallStrLS(Term, "noncetemp(X)")
If tf Then
thistemprank = GetStrArgLS(Term, 1)
End If
ynwdd.Text = EStrToCStr(thistemprank)
'将获取当前温度档存入数据表中
Rsrst.AddNew
Rsrst!temprank = thistemprank
Rsrst.UpdateBatch
Rsrst.MoveLast
thetemprank = Rsrst.Fields("temprank").Value
'把当前温度档,火焰温度上升、下降或是不变的状态送推理机
rc = CallStrLS(Term, "asserta(noncetemp(" & thetemprank & "))")
rc = CallStrLS(Term, "asserta(mostate(firetemp," & FiretempState & "))")
'提问,根据当前温度档和火焰温度之事实,确定当前给煤转速建议
rc = CallStrLS(Term, "givspeed(Y)")
If rc Then
thisspeed = GetStrArgLS(Term, 1)
End If
Call CloseLS
'将当前给煤转速建议用中文显示于gmzsjy
gmzsjy.Text = EStrToCStr(thisspeed)
End Sub
Function EStrToCStr(EStr As String) As String
'英文转换成中文,转换字典保存在数据库表EStrToCStr中
RsEstoCs.Open "select * from estrtocstr where estr ='" & EStr & "'", Cnxzy, 1, 3
If Not RsEstoCs.EOF Then
EStrToCStr = RsEstoCs.Fields("cstr")
Else
EStrToCStr = ""
End If
RsEstoCs.Close
Set RsEstoCs = Nothing
End Function
Private Sub Option1_Click()
Form2.Show
End Sub
Private Sub Option2_Click()
Form3.Show
End Sub
Private Sub Option3_Click()
Form5.Show
End Sub
Private Sub Option4_Click()
Form4.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -