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

📄 autochariot.bas

📁 利用RS232做通訊 可以執行自動功能 謝謝大家使用
💻 BAS
📖 第 1 页 / 共 2 页
字号:
        protocol(i) = Cmd_Arr(7 + PairNumber(i) + (i - 1) * (6 + PairNumber(i - 1)))
        ScriptFile(i) = Cmd_Arr(8 + PairNumber(i) + (i - 1) * (6 + PairNumber(i - 1)))
    Next i
    
   
    
    
    
    
    
    
  '--------------------------------------------------------------------Program start
      
    
    ChariotStatus.List1.AddItem "Chariot Api initialize"
     
    rc = DLL_CHR_api_initialize_show_rc()
   
    If rc <> CHR_OK Then
        ChariotStatus.List1.AddItem "Initialization failed : rc = " + rc
        Errorinfo = DLL_CHR_api_initialize_show_error()
        ChariotStatus.List1.AddItem "Extended error info : " + Errorinfo
    Else
        ChariotStatus.List1.AddItem "Chariot API initialize success"
    End If
    
    '//  Create a new test  //
    ChariotStatus.List1.AddItem "Create the test"
    rc = DLL_CHR_test_new_show_rc()
    If rc <> CHR_OK Then
        Call show_error(rc, "Test_new")
    Else
        TestHandle = DLL_CHR_test_new_return_handle()
    End If
    
    rc = DLL_CHR_test_get_dgopts_show_rc()
    If rc <> CHR_OK Then
        Call show_error(rc, "get_dgopt")
    Else
        DgoptHandle = DLL_CHR_test_get_dgopts_return_handle()
    End If
    
    
    
    
    rc = DLL_CHR_test_set_filename_show_rc(TestHandle, Cmd_Arr(1))
    If rc <> CHR_OK Then
        Call show_error(rc, "test_set_filename")
    End If
    
    rc = DLL_CHR_test_get_runopts_show_rc(TestHandle)
    If rc <> CHR_OK Then
        Call show_error(rc, "tset_get_runopts")
    Else
        RunoptsHandle = DLL_CHR_test_get_runopts_return_handle()
    End If
    
    rc = DLL_CHR_runopts_set_stop_on_init_failure_show_rc(RunoptsHandle)
    If rc <> CHR_OK Then
    Call show_error(rc, "unopts_set_stop_on_init_failure")
    End If
    
    rc = DLL_CHR_runopts_set_validate_on_recv_show_rc(RunoptsHandle)
    If rc <> CHR_OK Then
    Call show_error(rc, "runopts_set_validate_on_recv")
    End If
    
      
    
    '// Create a group //
    
    ChariotStatus.List1.AddItem "Create Groups   ...  "
    
    paircount = 0
    
    
    For i = 1 To MulticastNumber
        ChariotStatus.List1.AddItem "Create a mgroups   ...  "
        rc = DLL_CHR_mgroup_new_show_rc()
            If rc <> CHR_OK Then
                Call show_error(rc, "mgroup_new")
            Else
                GroupHandle(i) = DLL_CHR_mgroup_new_return_handle()
            End If
        ChariotStatus.List1.AddItem "Set mgroup attributes ..."
        ChariotStatus.List1.AddItem "MGroup " + Str(i)
        
        rc = DLL_CHR_mgroup_set_name_show_rc(GroupHandle(i), "Group" + Str(i))
        If rc <> CHR_OK Then
            Call show_error(rc, "mgroup_set_name")
        End If
        
        rc = DLL_CHR_mgroup_set_e1_addr_show_rc(GroupHandle(i), E1Point(i))
        If rc <> CHR_OK Then
            Call show_error(rc, "mgroup_set_e1_addr")
        End If
        
        rc = DLL_CHR_mgroup_set_multicast_addr_show_rc(GroupHandle(i), MulticastAddr(i))
        If rc <> CHR_OK Then
            Call show_error(rc, "mgroup_set_multicast_addr")
        End If
        
        rc = DLL_CHR_mgroup_set_multicast_port_show_rc(GroupHandle(i), MulticastPort(i))
        If rc <> CHR_OK Then
            Call show_error(rc, "mgroup_set_multicast_port")
        End If
        
        rc = DLL_CHR_mgroup_set_protocol_show_rc(GroupHandle(i), protocol(i))
        If rc <> CHR_OK Then
            Call show_error(rc, "mgroup_set_protocol")
        End If
               
        rc = DLL_CHR_mgroup_use_script_filename_show_rc(GroupHandle(i), ScriptFile(i))
        If rc <> CHR_OK Then
            Call show_error(rc, "mgroup_use_script_filename")
        End If
        
        rc = DLL_CHR_mgroup_set_script_variable_show_rc(GroupHandle(i), "number_of_timing_records", "100")
        If rc <> CHR_OK Then
            Call show_error(rc, "mgroup_set_script_variable")
        End If
        
        '//Define mpairs for the group//
        For j = 1 To PairNumber(i)
        
            paircount = paircount + PairNumber(i - 1)
            index = j + paircount
            
        
        
            ChariotStatus.List1.AddItem "Create a mpair " + Str(j)
            rc = DLL_CHR_mpair_new_show_rc()
            If rc <> CHR_OK Then
                Call show_error(rc, "mPair_new")
            Else
                mPairHandle(index) = DLL_CHR_mpair_new_return_handle()
            End If
            ChariotStatus.List1.AddItem "Set mpair attributes ..."
            ChariotStatus.List1.AddItem "mPair " + Str(i) + " Created"
       

            rc = DLL_CHR_mpair_set_e2_addr_show_rc(mPairHandle(index), MulticastGMember(index))
            If rc <> CHR_OK Then
                Call show_error(rc, "mpair_set_e2_address")
            End If
            
     '//Add the mpair to the test //
            rc = DLL_CHR_mgroup_add_mpair_show_rc(GroupHandle(i), mPairHandle(index))
            If rc <> CHR_OK Then
                Call show_error(rc, "mgroup_add_mpair")
            End If
        
        Next j
        
     '//Add the Group to the test //
        rc = DLL_CHR_test_add_mgroup_show_rc(TestHandle, GroupHandle(i))
        If rc <> CHR_OK Then
            Call show_error(rc, "test_add_mgroup")
        End If
            
    Next i
    
        rc = DLL_CHR_dgopts_set_TTL_show_rc(DgoptHandle)
        If rc <> CHR_OK Then
            Call show_error(rc, "set_TTL")
        End If
        
      
    '//  The test is defined, Begin to run //
    
    ChariotStatus.List1.AddItem "Run the test ... "
    rc = DLL_CHR_test_start_show_rc(TestHandle)
    If rc <> CHR_OK Then
       Call show_error(rc, "start_test")
    End If
      
    ChariotStatus.List1.AddItem "Wait for the test to stop ..."
    isStopped = False
    Timer = 0
    
    Do While (Not isStopped And Timer < MaxWait)
        rc = DLL_CHR_test_query_stop_show_rc(TestHandle, Timeout)
        If rc = CHR_OK Then
        isStopped = True
        ElseIf rc = CHR_TIMED_OUT Then
                    Timer = Timer + Timeout
                    ChariotStatus.List1.AddItem "Waiting for test to stop" + "(" + Str(Timer) + ")"
               Else
                    Call show_error(rc, "test_query_stop")
        End If
    Loop
    
    If (Not isStopped) Then Call show_error(CHR_TIMED_OUT, "test_query_stop")
    
    '// Show Avg,Max,Min
    
    
    paircount = 0
     
    For i = 1 To MulticastNumber
        For j = 1 To PairNumber(i)
            paircount = paircount + PairNumber(i - 1)
            index = j + paircount
            
            rc = DLL_CHR_pair_results_get_average_show_rc(mPairHandle(index))
            If rc <> CHR_OK Then
                Call show_error(rc, "pair_results_get_average")
            Else
                avg(index) = DLL_CHR_pair_results_get_average_return_value()
            End If
        
        rc = DLL_CHR_pair_results_get_maximum_show_rc(mPairHandle(index))
            If rc <> CHR_OK Then
                Call show_error(rc, "pair_results_get_maximum")
            Else
                max(index) = DLL_CHR_pair_results_get_maximum_return_value()
            End If
            
        rc = DLL_CHR_pair_results_get_minimum_show_rc(mPairHandle(index))
            If rc <> CHR_OK Then
                Call show_error(rc, "pair_results_get_minimum")
            Else
                min(index) = DLL_CHR_pair_results_get_minimum_return_value()
            End If
        
         ChariotStatus.List1.AddItem "Throughtput : " + "Group" + Str(i) + " Avg =" + Str(avg(index)) + " Max =" + Str(max(index)) + "  Min =" + Str(min(index))
         
         Next j
         
         
        
    
    Next i
    
    
    ChariotStatus.List1.AddItem "Save the test ..."
    
    rc = DLL_CHR_test_save(TestHandle)
    If rc <> CHR_OK Then
        Call show_error(rc, "test_save")
    End If
    
       
    
     
    
    
    

End Sub
Public Sub show_error(code As Integer, where As String)
    
    rc = DLL_CHR_api_get_return_msg_show_rc(code)
    If rc <> CHR_OK Then
        ChariotStatus.List1.AddItem where + " failed"
        ChariotStatus.List1.AddItem "Unable to get message for return code " + Str(code) + " rc = " + Str(rc)
    Else
        ChariotStatus.List1.AddItem where + "failed : rc = " + rc
    End If
    
 End Sub
 
 
 ' Application path for frmPlay    '
Public Function ApplPath() As String
  Dim Temp As String
  Temp = App.Path
  If Right(Temp, 1) <> "\" Then Temp = Temp & "\"
  ApplPath = Temp
End Function

⌨️ 快捷键说明

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