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

I tried using this to stop a test module after the completion of a test module and used a WHILE loop to start second test module. But after the completion of 1st test module i am not able to start second test module. I got the reason of it when i wrote the execution steps in a text file.

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

After the completion of 1st test module TMExecuting should be false which is done in

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

But its not becoming false due to which second test module is not starting. If anyone have any solution please help. I want to run multiple test module and test environment in a single Canoe Configuration configuration using VBScript.

user692942
  • 16,398
  • 7
  • 76
  • 175
Prakash
  • 27
  • 1
  • 9
  • Could you post the complete code? I think the connection of the OnStop handler to CANoe is missing, but this is hard to tell without seeing the complete code. – MSpiller Sep 06 '18 at 09:26
  • Sure i will post the main content of the code where i am starting measurement and and test module & stopping them. – Prakash Sep 06 '18 at 10:53

1 Answers1

0

This is what i did.

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

These steps are after the opening of canoe configuration.

Prakash
  • 27
  • 1
  • 9