0
TestModule.Stop()
While TMExecuting
   WScript.Sleep(200)
Wend

Sub TestModule_OnStop(reason)
TMExecuting = False
  Select Case (reason)
    Case 0
      MsgBox "Test module was executed completely."
    Case 1
      MsgBox "Test module was stopped by the user."
    Case 2
      MsgBox "Test module was stopped by measurement stop"
  End Select
End Sub

我尝试在测试模块完成后使用它来停止测试模块,并使用WHILE循环启动第二个测试模块。但是在第一个测试模块完成后,我无法启动第二个测试模块。当我在文本文件中编写执行步骤时,我得到了它的原因。

TestModule.Start()
    While (Not TMStarted)
        WScript.Sleep(200)
        LogFile.WriteLine "Test started"
    wend    

    While (TMExecuting)
        WScript.Sleep(500)
        LogFile.write("Value of TMExecuting is:" & TMExecuting)
        LogFile.WriteLine "CANoe test is running"
    Wend

在第一个测试模块完成后,TMExecuting 应该是假的,这是在

Sub TestModule_Onstop(reason)
  TMExecuting = False
  TMStarted   = False
  Select Case (reason)
    Case 0
      MsgBox "Test module was executed completely."
    Case 1
      MsgBox "Test module was stopped by the user."
    Case 2
      MsgBox "Test module was stopped by measurement stop"
  End Select
  LogFile.WriteLine " CANoe test is finished"
End Sub

但它不会因为第二个测试模块没有启动而变得错误。如果有人有任何解决方案,请提供帮助。 我想使用 VBScript 在单个 Canoe 配置配置中运行多个测试模块和测试环境。

4

1 回答 1

0

这就是我所做的。

Meas.Start()
stApp = True
While (Not MeasStarted)
    WScript.Sleep(500)
    'LogFile.WriteLine "Measurement not yet started"
Wend

While Counter <= 2
    Set TestModule = App.Configuration.TestSetup.TestEnvironments.Item(1).Items(Counter)

    WScript.ConnectObject TestModule, "TestModule_"

    TestModule.Start()
    While (Not TMStarted)
        WScript.Sleep(200)
        'LogFile.WriteLine "Test started"
    wend    

    While (TMExecuting)
        WScript.Sleep(500)
        'LogFile.WriteLine "CANoe test is running"
    Wend

    TestModule.Stop()
    Counter = Counter + 1
    'LogFile.write("The Current Value of the Counter is : " & Counter)
Wend

Meas.Stop()
    'LogFile.WriteLine "Request to stop the CANoe measurement"
    While MeasStarted
    WScript.Sleep(200)
Wend

App.quit
'LogFile.WriteLine "Request to close CANoe"
WScript.Sleep(200)
'LogFile.WriteLine "CANoe has been closed"
WScript.Sleep(200)

Sub Meas_OnStart()
  MeasStarted = True
  LogFile.WriteLine " CANoe measurement is running"
End Sub

Sub Meas_OnStop()
  MeasStarted = False
  LogFile.WriteLine " CANoe measurement is stopped"
End Sub

Sub TestModule_OnStart()    
  TMStarted = True
  TMExecuting = True
  LogFile.WriteLine " CANoe test is started"
End Sub

Sub TestModule_Onstop(reason)
  TMExecuting = False
  TMStarted   = False
  LogFile.WriteLine " CANoe test is finished"
End Sub

Sub App_OnQuit()
  stApp = False
  LogFile.WriteLine " Closing CANoe"
End Sub

这些步骤是在独木舟配置开启之后。

于 2018-09-06T10:47:58.090 回答