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

📄 frmmain.frm

📁 SRI international 发布的OAA框架软件
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmMain 
   Caption         =   "AddAgent"
   ClientHeight    =   3330
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4710
   LinkTopic       =   "Form1"
   ScaleHeight     =   3330
   ScaleWidth      =   4710
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Caption         =   "Solveables"
      Height          =   2895
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   4335
      Begin VB.ListBox SolveablesList 
         Height          =   2400
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   4095
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public WithEvents myOaaEvents As Oaa2JavaNet.LibOaaEvents
Attribute myOaaEvents.VB_VarHelpID = -1
Dim oaaUtil As Oaa2JavaNet.ILibOaaUtil
Dim comFactory As Oaa2COMFactory
Dim comFactoryImpl As Oaa2COMFactoryImpl
Const AGENT_NAME = "vb_addAgent"
Const CONNECTION_ID = "parent"

Private Sub Command1_Click()
    myOaaEvents.CauseEvent 1, 2
End Sub

Private Sub Form_Load()
    Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
    Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
    Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
    Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
    
    Call initOaa
End Sub

Private Sub initOaa()
    Set oaaUtil = New LibOaaUtil
    
    ' To set the connect address and port of the dotnetproxyagent, uncomment these lines:
    ' These lines must be the first lines of the application, executed before any
    ' .NET objects are created.
    ' oaaUtil.setConnectAddress ("128.18.233.111")
    ' oaaUtil.setConnectPort (4080)
    
    Set comFactoryImpl = New Oaa2COMFactoryImpl
    Set comFactory = comFactoryImpl
    Set myOaaEvents = New Oaa2JavaNet.LibOaaEvents
    Dim ievents As Oaa2JavaNet.ILibOaaEvents
    Set ievents = myOaaEvents
    
    Dim protocol As Oaa2JavaNet.LibComTcpProtocol
    Set protocol = New Oaa2JavaNet.LibComTcpProtocol
    Dim libCom As Oaa2JavaNet.libCom
    Dim strArray() As String
    
    ReDim strArray(1)
    strArray(0) = "-oaa_listen"
    strArray(1) = "tcp('localhost',4020)"
    
    Set libCom = comFactoryImpl.newLibCom(protocol, strArray)
    
    Set myOaa = comFactory.newLibOaa(libCom)
    If Not myOaa.oaaSetupCommunication(AGENT_NAME) Then
        MsgBox ("Error: Failed to setup OAA")
    End If
    
    Dim solveables As Oaa2JavaNet.IclTerm
    Set solveables = oaaUtil.fromString("[add(Num1, Num2, Sum)]")
    
    myOaa.oaaRegister CONNECTION_ID, AGENT_NAME, solveables, New Oaa2JavaNet.IclList
    myOaa.oaaReady True
    
    ievents.setLibOaa myOaa
    ievents.oaaRegisterCallback "app_do_event"
End Sub

Private Sub myOaaEvents_DoOAAEvent(ByVal goalTerm As Oaa2JavaNet.IclTerm, ByVal params As Oaa2JavaNet.IclList, ByVal solutions As Oaa2JavaNet.IclList)
    AddItemToList (goalTerm.ToString())
    'MsgBox ("Got Event: " & goalTerm.ToIdentifyingString() & ", " & params.ToIdentifyingString() & ", " & solutions.ToIdentifyingString())
    Dim goalStr As String
    goalStr = goalTerm.ToIdentifyingString
    
    If goalStr = "add" Then
        Dim term1 As Oaa2JavaNet.IclTerm
        Dim term2 As Oaa2JavaNet.IclTerm
        Dim num1 As Long
        Dim num2 As Long
        Set term1 = goalTerm.getTerm(0)
        Set term2 = goalTerm.getTerm(1)
        num1 = term1.IclInt()
        num2 = term2.IclInt()
        Dim sum As Long
        sum = num1 + num2
        Dim sumTerm As Oaa2JavaNet.IclInt
        Set sumTerm = comFactory.newIclIntB(sum)
        
        Dim answerTerm As Oaa2JavaNet.IclStruct
        Set answerTerm = comFactory.newIclStructF("add", term1, term2, sumTerm)
        oaaUtil.Add solutions, answerTerm
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim i As Integer


    'close all sub forms
    For i = Forms.Count - 1 To 1 Step -1
        Unload Forms(i)
    Next
    If Me.WindowState <> vbMinimized Then
        SaveSetting App.Title, "Settings", "MainLeft", Me.Left
        SaveSetting App.Title, "Settings", "MainTop", Me.Top
        SaveSetting App.Title, "Settings", "MainWidth", Me.Width
        SaveSetting App.Title, "Settings", "MainHeight", Me.Height
    End If
End Sub

Private Sub AddItemToList(ByRef item As String)
    SolveablesList.AddItem (item)
    If SolveablesList.ListCount > 20 Then
        SolveablesList.RemoveItem (0)
    End If
    If SolveablesList.ListCount > 1 Then
        SolveablesList.Selected(SolveablesList.ListCount - 2) = False
    End If
    SolveablesList.Selected(SolveablesList.ListCount - 1) = True
End Sub

⌨️ 快捷键说明

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