VERSION 5.00
Begin VB.Form frmMain 
   Caption         =   "Robot"
   ClientHeight    =   4485
   ClientLeft      =   60
   ClientTop       =   510
   ClientWidth     =   5880
   LinkTopic       =   "Form1"
   ScaleHeight     =   4485
   ScaleWidth      =   5880
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdStop 
      Caption         =   "Stop"
      Height          =   855
      Left            =   1920
      TabIndex        =   4
      Top             =   1560
      Width           =   1695
   End
   Begin VB.CommandButton cmdRight 
      Caption         =   "Right"
      Height          =   855
      Left            =   3720
      TabIndex        =   3
      Top             =   1560
      Width           =   1695
   End
   Begin VB.CommandButton cmdLeft 
      Caption         =   "Left"
      Height          =   855
      Left            =   120
      TabIndex        =   2
      Top             =   1560
      Width           =   1695
   End
   Begin VB.CommandButton cmdBwd 
      Caption         =   "Backward"
      Height          =   855
      Left            =   1920
      TabIndex        =   1
      Top             =   2760
      Width           =   1695
   End
   Begin VB.CommandButton cmdFwd 
      Caption         =   "Forward"
      Height          =   855
      Left            =   1920
      TabIndex        =   0
      Top             =   360
      Width           =   1695
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public WithEvents RC As SpSharedRecoContext
Attribute RC.VB_VarHelpID = -1
Public myGrammar As ISpeechRecoGrammar
Public Voice As New SpVoice

Dim mCome As Boolean
Dim mKitchen As Boolean


Private Sub cmdBwd_Click()
 Call DriveDCMotors(0, 0, 0, 0, 1)
    Call DriveDCMotors(0, 0, -1, -1, 1)
End Sub

Private Sub cmdFwd_Click()
Call DriveDCMotors(0, 0, 0, 0, 1)
    Call DriveDCMotors(0, 0, 1, 1, 1)
End Sub

Private Sub cmdLeft_Click()
    Call DriveDCMotors(0, 0, 0, 0, 1)
    Call DriveDCMotors(0, 0, -1, 1, 1)
End Sub

Private Sub cmdPart1_Click()
    'move forward
    'Call DriveDCMotors(0, 0, 1, 1, 1)
    Call DriveDCMotors(0, 0, 0, 0, 1)
    Call DriveDCMotors(0, 0, 1, 1, 1)
End Sub

Private Sub cmdPart2_Click()
    'move backward
   ' Call DriveDCMotors(0, 0, -1, -1, 1)
    Call DriveDCMotors(0, 0, 0, 0, 1)
    Call DriveDCMotors(0, 0, -1, -1, 1)
    
    'rest
    'Call DriveDCMotors(0, 0, 0, 0, 1)
    
    'turning
    'Call DriveDCMotors(0, 0, -1, 1, 0.5)
    'Call DriveDCMotors(0, 0, 0, 0, 1)
   ' Call DriveDCMotors(0, 0, -1, 1, 0.5)
    
    'Call DriveDCMotors(0, 0, 0, 0, 1)
    'Call DriveDCMotors(0, 0, 1, 1, 1)
    'Call DriveDCMotors(0, 0, 0, 0, 1)
    'Call DriveDCMotors(0, 0, 1, 1, 1.8)
    
    'Call DriveDCMotors(0, 0, 0, 0, 1)
    'Call DriveDCMotors(0, 0, 1, -1, 0.5)
    
 'Call DriveDCMotors(0, 0, 0, 0, 1)
  '  Call DriveDCMotors(0, 0, 1, -1, 0.5)
    
   ' Call DriveDCMotors(0, 0, 0, 0, 1)
    'Call DriveDCMotors(0, 0, 1, 1, 2)
    
End Sub

Private Sub cmdRight_Click()
Call DriveDCMotors(0, 0, 0, 0, 1)
    Call DriveDCMotors(0, 0, 1, -1, 1)
End Sub

Private Sub cmdStop_Click()
Call DriveDCMotors(0, 0, 0, 0, 1)

End Sub

Private Sub Form_Load()
    Call SetAddresses(&H378)
    

'    Set RC = New SpSharedRecoContext
 '   Set myGrammar = RC.CreateGrammar
  '  myGrammar.CmdLoadFromFile "C:\Yap VB Projects\XML\PartnerRobot1.xml", SLODynamic
   ' myGrammar.CmdSetRuleIdState 0, SGDSActive
    
    'mCome = False
    'mKitchen = False
End Sub

Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
    Dim str As String
    
    str = Result.PhraseInfo.GetText
    lblResult.Caption = str
    Me.Refresh
    If str = "Michelle Come Here" Then
        mCome = True
        Voice.Speak "Master, are you sure?"
        
    ElseIf str = "Yes Michelle" Then
        If mCome = True Then
            Voice.Speak "Yes Master I am coming now."
            cmdPart1_Click
            mCome = False
        End If
    
    ElseIf str = "No Michelle" Then
        If mCome = True Then
            mCome = False
            Voice.Speak "Ok master"
        If mKitchen = False Then
            mKitchen = False
            Voice.Speak "Ok master"
        End If
    End If
    
    ElseIf str = "Yes Kitchen" Then
        If mKitchen = True Then
            Voice.Speak "Go to kitchen now."
            cmdPart2_Click
            mKitchen = False
        End If
    
    ElseIf str = "Michelle Go To Kitchen" Then
        mKitchen = True
        Voice.Speak "Master, are you sure?"
    End If
End Sub


Private Sub RC_FalseRecognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal Result As SpeechLib.ISpeechRecoResult)
    lblResult.Caption = "(no recognition)"
End Sub

