MORPHEERuntimeControl
Below a sample that
- starts MORPHEE
- reply to any MORPHEE report window
- wait for bench mode is ready to start a campaign.
- start the default campaign
- wait for bench mode is ready to start a test description.
- start the test description named "MyTestDescription"
- wait for MORPHEE to stop.
from restmapi.services import MAPIServices
import time
global started
global morphee_process_control
started = 0
def morphee_started(instance):
global started
print(f"MORPHEE instance {instance} started")
started = 1
def morphee_stopped(instance):
global started
print(f"MORPHEE instance {instance} stopped")
started = 0
def morphee_report_updated(instance):
global morphee_process_control
if morphee_process_control.is_report_pending(instance):
print(f"MORPHEE instance {instance} report:")
print(morphee_process_control.get_report_messages(instance))
morphee_process_control.close_report(instance, "OK")
else:
print("report closed")
print(MAPIServices.instance.mapi_base_url)
print(MAPIServices.instance.get_version())
with MAPIServices.instance.get_service("MorpheeProcessControl") as morphee_process_control:
morphee_process_control.init_signalr()
morphee_process_control.register_started_callback(morphee_started)
morphee_process_control.register_stopped_callback(morphee_stopped)
morphee_process_control.register_report_updated_callback(morphee_report_updated)
if (morphee_process_control.is_morphee_process_started()):
started = 1
else:
print(f"Start MORPHEE: {morphee_process_control.start()}")
while started == 0:
time.sleep(1)
with MAPIServices.instance.get_service("MorpheeRuntimeControl") as mrc:
mrc.init_signalr()
mrc.register_started_callback(lambda instance, mode:print(f"Mode {mode} started on instance {instance}") )
mrc.register_stopped_callback(lambda instance, mode:print(f"Mode {mode} stopped on instance {instance}") )
mrc.register_error_callback(lambda instance, mode:print(f"Mode {mode} start failed on instance {instance}") )
while(mrc.can_change_mode('Campaign') == False or mrc.get_current_mode() != 1):
time.sleep(1)
mrc.start_campaign("default", False)
while(mrc.can_change_mode('Test') == False or mrc.get_current_mode() != 2):
time.sleep(1)
mrc.start_test("MyTestDescription", False)
while started == 1:
time.sleep(1)