Skip to content

MAPI service MorpheeRuntimeControl

To get MorpheeRuntimeControl service use:

with MAPIServices.instance.get_service("MorpheeRuntimeControl") as mrc:

Bases: MAPIServiceWithSignalR

MorpheeRuntimeControl MAPI service allows to start/stop MORPHEE modes. Call init_signalr if you intend to use the signalr hub events and with keyword on the MorpheeRuntimeControlServiceProxy object to be sure that the communication is closed at the end.

Source code in restmapi\restmapi\services.py
class MorpheeRuntimeControlProxy(MAPIServiceWithSignalR):
	"""MorpheeRuntimeControl MAPI service allows to start/stop MORPHEE modes.
	Call init_signalr if you intend to use the signalr hub events and with keyword on the MorpheeRuntimeControlServiceProxy object to be sure that the communication is closed at the end.
		"""
	def __init__(self, url):
		"""DO NOT create MorpheeRuntimeControlServiceProxy by yourself. Always use MAPIServices.get_service("MorpheeRuntimeControl") method to create it.

		Parameters
		----------
		url : string
			Base URL to create of the REST service.
		"""
		super().__init__(url, "MorpheeRuntimeControl")

	def get_current_mode(self):
		"""Get Morphee current mode.
		* 0 for Unknown
		* 1 for bench
		* 2 for campaign
		* 3 for test

		Returns
		-------
		int
			Returns Morphee current mode.
		"""
		return self.invoke_web_get_request("CurrentMode")

	def get_current_status(self):
		"""Get MORPHEE status. Be carefull it is differeent MORPHEE kernel status. It is a new set of values:
		<div class="grid table-desc" markdown>
		| Integer value | MORPHEE Status                 |
		|---------------|--------------------------------|
		|     0         | Loading/Unloading              |
		|     1         | Running                        |
		|     2         | Security                       |
		|     3         | Restarting                     |
		|     4         | Manual                         |
		</div>

		Returns
		-------
		int
			Returns MORPHEE status
		"""
		return self.invoke_web_get_request("CurrentStatus")

	def get_main_window_handle(self):
		"""Get MainWindow handle of morphee.

		Returns
		-------
		int
			Returns MainWindow handle of morphee. You can use them to show/hide/activate MORPHEE main window.
		"""
		return self.invoke_web_get_request("Windows/Main")["value"]

	def get_monproc_window_handle(self):
		"""Get procedure monitor Window handle of morphee.

		Returns
		-------
		int
			Returns procedure monitor handle of morphee. You can use them to show/hide/activate MORPHEE procedure monitor window.
		"""
		return self.invoke_web_get_request("Windows/MonitorProc")["value"]

	def can_stop_mode(self) -> bool:
		"""Check if MORPHEE can stop current mode.

		Returns
		-------
		int
			Returns true if MORPHEE can stop current mode.
		"""
		return self.invoke_web_get_request("CanStopCurrentMode")	

	def stop_current_mode(self):
		"""Stop current running mode.
		"""
		self.invoke_web_post_request("StopCurrentMode")		

	def can_change_mode(self, newMode) -> bool:
		"""Check if MORPHEE can start a specific mode.

		Parameters
		----------
		int/string : new mode (Bench, Campaign, Test) or (1, 2, 3)

		Returns
		-------
		int
			Returns true if MORPHEE can stop current mode.
		"""
		return self.invoke_web_get_request(f"CanChangeMode?mode={newMode}")	

	def start_campaign(self, filename: str = "default", silent: bool = True):
		"""Start a campaign.

		Parameters
		----------
		string : campaign file name (without extension) or campaign full path (with extension)
		bool : silent. True for silent mode (loading report error dialog are skipped).

		"""
		self.invoke_web_post_request(f"StartCampaign?filename={filename}&startType=Start&silent={silent}")

	def start_test(self, filename: str, silent: bool = True, startType: eStartWorkSpaceType = eStartWorkSpaceType.Start, manualStartOption: eManualStartOption = eManualStartOption._None, chainingIndex: int = -1, chainingMax: int = 0):
		"""Start a test. Note that if MORPHEE is in bench mode, it will automatically start the default campaign first.

		Parameters
		----------
		string : test file name (without extension) or test full path (with extension)
		bool : silent. True for silent mode (loading report error dialog are skipped).
		eStartWorkSpaceType : startType. How to start the test.
		eManualStartOption : manualStartOption. If startType is ManualStart, use manualStartOption enum to set the configuration of the context handling. Note that it a flag enum si values can be combined (e.g. eManualStartOption.Silent+eManualStartOption.RestartFromBeginning)
		int : chainingIndex. Index of current test during a TM chaining (-1 is the default value)</param>
		int : chainingMax. Number of test of the current TM chaining (0 is the default value)</param>		

		"""
		self.invoke_web_post_request(f"StartTest?filename={filename}&startType={int(startType)}&silent={silent}&manualStartOption={int(manualStartOption)}&chainingIndex={chainingIndex}&chainingMax={chainingMax}")

	def set_foreground(self):
		"""Set MORPHEE to foreground (Note that MORPHEE has to be allowed to go to front of the current process. For instance TestManager allows MORPHEE to go to front.).
		"""
		self.invoke_web_post_request("SetForeGround")	

	def lock_menu_items(self):
		""" Deactivate start test and start campaigne menu items
		"""
		self.invoke_web_post_request("LockStartMenuItems")

	def unlock_menu_items(self):
		""" Reactivate start test and start campaigne menu items
		"""
		self.invoke_web_post_request("UnlockStartMenuItems")

	def update_test_run_xpar(self):
		""" Update the contents of the testrun.xpar file (Parameters file) of the current mode
		"""
		self.invoke_web_post_request("UpdateTestRunXpar")

	def client_connected(self):
		""" If MORPHEE is started with -v, MORPHEE waits for ClientConnected to be called!
		"""
		self.invoke_web_post_request("ClientConnected")

	def register_started_callback(self, action):
		"""Register a signalR callback to be called when a MORPHEE mode is started.
		init_signalr() method has to be called before to initialize signalR communication.

		Parameters
		----------
		action : Function with an int parameter
			A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode)
		"""
		self.hub.client.on('OnModeStarted', action)

	def register_stopped_callback(self, action):
		"""Register a signalR callback to be called when a MORPHEE mode is stopped.
		init_signalr() method has to be called before to initialize signalR communication.

		Parameters
		----------
		action : Function with an int parameter
			A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode, reason)
		"""
		self.hub.client.on('OnModeStopped', action)

	def register_error_callback(self, action):
		"""Register a signalR callback to be called when a MORPHEE mode failed to start.
		init_signalr() method has to be called before to initialize signalR communication.

		Parameters
		----------
		action : Function with an int parameter
			A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode).
		"""
		self.hub.client.on('OnModeError', action)

__init__(url)

DO NOT create MorpheeRuntimeControlServiceProxy by yourself. Always use MAPIServices.get_service("MorpheeRuntimeControl") method to create it.

Parameters:

  • url (string) –
    Base URL to create of the REST service.
    
Source code in restmapi\restmapi\services.py
def __init__(self, url):
	"""DO NOT create MorpheeRuntimeControlServiceProxy by yourself. Always use MAPIServices.get_service("MorpheeRuntimeControl") method to create it.

	Parameters
	----------
	url : string
		Base URL to create of the REST service.
	"""
	super().__init__(url, "MorpheeRuntimeControl")

can_change_mode(newMode)

Check if MORPHEE can start a specific mode.

Parameters:

  • int

Returns:

  • int

    Returns true if MORPHEE can stop current mode.

Source code in restmapi\restmapi\services.py
def can_change_mode(self, newMode) -> bool:
	"""Check if MORPHEE can start a specific mode.

	Parameters
	----------
	int/string : new mode (Bench, Campaign, Test) or (1, 2, 3)

	Returns
	-------
	int
		Returns true if MORPHEE can stop current mode.
	"""
	return self.invoke_web_get_request(f"CanChangeMode?mode={newMode}")	

can_stop_mode()

Check if MORPHEE can stop current mode.

Returns:

  • int

    Returns true if MORPHEE can stop current mode.

Source code in restmapi\restmapi\services.py
def can_stop_mode(self) -> bool:
	"""Check if MORPHEE can stop current mode.

	Returns
	-------
	int
		Returns true if MORPHEE can stop current mode.
	"""
	return self.invoke_web_get_request("CanStopCurrentMode")	

client_connected()

If MORPHEE is started with -v, MORPHEE waits for ClientConnected to be called!

Source code in restmapi\restmapi\services.py
def client_connected(self):
	""" If MORPHEE is started with -v, MORPHEE waits for ClientConnected to be called!
	"""
	self.invoke_web_post_request("ClientConnected")

get_current_mode()

Get Morphee current mode. * 0 for Unknown * 1 for bench * 2 for campaign * 3 for test

Returns:

  • int

    Returns Morphee current mode.

Source code in restmapi\restmapi\services.py
def get_current_mode(self):
	"""Get Morphee current mode.
	* 0 for Unknown
	* 1 for bench
	* 2 for campaign
	* 3 for test

	Returns
	-------
	int
		Returns Morphee current mode.
	"""
	return self.invoke_web_get_request("CurrentMode")

get_current_status()

Get MORPHEE status. Be carefull it is differeent MORPHEE kernel status. It is a new set of values:

Integer value MORPHEE Status
0 Loading/Unloading
1 Running
2 Security
3 Restarting
4 Manual

Returns:

  • int

    Returns MORPHEE status

Source code in restmapi\restmapi\services.py
def get_current_status(self):
	"""Get MORPHEE status. Be carefull it is differeent MORPHEE kernel status. It is a new set of values:
	<div class="grid table-desc" markdown>
	| Integer value | MORPHEE Status                 |
	|---------------|--------------------------------|
	|     0         | Loading/Unloading              |
	|     1         | Running                        |
	|     2         | Security                       |
	|     3         | Restarting                     |
	|     4         | Manual                         |
	</div>

	Returns
	-------
	int
		Returns MORPHEE status
	"""
	return self.invoke_web_get_request("CurrentStatus")

get_main_window_handle()

Get MainWindow handle of morphee.

Returns:

  • int

    Returns MainWindow handle of morphee. You can use them to show/hide/activate MORPHEE main window.

Source code in restmapi\restmapi\services.py
def get_main_window_handle(self):
	"""Get MainWindow handle of morphee.

	Returns
	-------
	int
		Returns MainWindow handle of morphee. You can use them to show/hide/activate MORPHEE main window.
	"""
	return self.invoke_web_get_request("Windows/Main")["value"]

get_monproc_window_handle()

Get procedure monitor Window handle of morphee.

Returns:

  • int

    Returns procedure monitor handle of morphee. You can use them to show/hide/activate MORPHEE procedure monitor window.

Source code in restmapi\restmapi\services.py
def get_monproc_window_handle(self):
	"""Get procedure monitor Window handle of morphee.

	Returns
	-------
	int
		Returns procedure monitor handle of morphee. You can use them to show/hide/activate MORPHEE procedure monitor window.
	"""
	return self.invoke_web_get_request("Windows/MonitorProc")["value"]

lock_menu_items()

Deactivate start test and start campaigne menu items

Source code in restmapi\restmapi\services.py
def lock_menu_items(self):
	""" Deactivate start test and start campaigne menu items
	"""
	self.invoke_web_post_request("LockStartMenuItems")

register_error_callback(action)

Register a signalR callback to be called when a MORPHEE mode failed to start. init_signalr() method has to be called before to initialize signalR communication.

Parameters:

  • action (Function with an int parameter) –
    A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode).
    
Source code in restmapi\restmapi\services.py
def register_error_callback(self, action):
	"""Register a signalR callback to be called when a MORPHEE mode failed to start.
	init_signalr() method has to be called before to initialize signalR communication.

	Parameters
	----------
	action : Function with an int parameter
		A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode).
	"""
	self.hub.client.on('OnModeError', action)

register_started_callback(action)

Register a signalR callback to be called when a MORPHEE mode is started. init_signalr() method has to be called before to initialize signalR communication.

Parameters:

  • action (Function with an int parameter) –
    A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode)
    
Source code in restmapi\restmapi\services.py
def register_started_callback(self, action):
	"""Register a signalR callback to be called when a MORPHEE mode is started.
	init_signalr() method has to be called before to initialize signalR communication.

	Parameters
	----------
	action : Function with an int parameter
		A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode)
	"""
	self.hub.client.on('OnModeStarted', action)

register_stopped_callback(action)

Register a signalR callback to be called when a MORPHEE mode is stopped. init_signalr() method has to be called before to initialize signalR communication.

Parameters:

  • action (Function with an int parameter) –
    A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode, reason)
    
Source code in restmapi\restmapi\services.py
def register_stopped_callback(self, action):
	"""Register a signalR callback to be called when a MORPHEE mode is stopped.
	init_signalr() method has to be called before to initialize signalR communication.

	Parameters
	----------
	action : Function with an int parameter
		A callback function with 2 parameters (instance number who send the event (0 for master instance), morphee mode, reason)
	"""
	self.hub.client.on('OnModeStopped', action)

set_foreground()

Set MORPHEE to foreground (Note that MORPHEE has to be allowed to go to front of the current process. For instance TestManager allows MORPHEE to go to front.).

Source code in restmapi\restmapi\services.py
def set_foreground(self):
	"""Set MORPHEE to foreground (Note that MORPHEE has to be allowed to go to front of the current process. For instance TestManager allows MORPHEE to go to front.).
	"""
	self.invoke_web_post_request("SetForeGround")	

start_campaign(filename='default', silent=True)

Start a campaign.

Parameters:

  • string (campaign file name (without extension) or campaign full path (with extension)) –
  • bool (silent. True for silent mode (loading report error dialog are skipped).) –
Source code in restmapi\restmapi\services.py
def start_campaign(self, filename: str = "default", silent: bool = True):
	"""Start a campaign.

	Parameters
	----------
	string : campaign file name (without extension) or campaign full path (with extension)
	bool : silent. True for silent mode (loading report error dialog are skipped).

	"""
	self.invoke_web_post_request(f"StartCampaign?filename={filename}&startType=Start&silent={silent}")

start_test(filename, silent=True, startType=eStartWorkSpaceType.Start, manualStartOption=eManualStartOption._None, chainingIndex=-1, chainingMax=0)

Start a test. Note that if MORPHEE is in bench mode, it will automatically start the default campaign first.

Parameters:

  • string (test file name (without extension) or test full path (with extension)) –
  • bool (silent. True for silent mode (loading report error dialog are skipped).) –
  • eStartWorkSpaceType (startType. How to start the test.) –
  • eManualStartOption (manualStartOption. If startType is ManualStart, use manualStartOption enum to set the configuration of the context handling. Note that it a flag enum si values can be combined (e.g. eManualStartOption.Silent+eManualStartOption.RestartFromBeginning)) –
  • int (chainingIndex. Index of current test during a TM chaining (-1 is the default value)</param>) –
  • int (chainingMax. Number of test of the current TM chaining (0 is the default value)</param>) –
Source code in restmapi\restmapi\services.py
def start_test(self, filename: str, silent: bool = True, startType: eStartWorkSpaceType = eStartWorkSpaceType.Start, manualStartOption: eManualStartOption = eManualStartOption._None, chainingIndex: int = -1, chainingMax: int = 0):
	"""Start a test. Note that if MORPHEE is in bench mode, it will automatically start the default campaign first.

	Parameters
	----------
	string : test file name (without extension) or test full path (with extension)
	bool : silent. True for silent mode (loading report error dialog are skipped).
	eStartWorkSpaceType : startType. How to start the test.
	eManualStartOption : manualStartOption. If startType is ManualStart, use manualStartOption enum to set the configuration of the context handling. Note that it a flag enum si values can be combined (e.g. eManualStartOption.Silent+eManualStartOption.RestartFromBeginning)
	int : chainingIndex. Index of current test during a TM chaining (-1 is the default value)</param>
	int : chainingMax. Number of test of the current TM chaining (0 is the default value)</param>		

	"""
	self.invoke_web_post_request(f"StartTest?filename={filename}&startType={int(startType)}&silent={silent}&manualStartOption={int(manualStartOption)}&chainingIndex={chainingIndex}&chainingMax={chainingMax}")

stop_current_mode()

Stop current running mode.

Source code in restmapi\restmapi\services.py
def stop_current_mode(self):
	"""Stop current running mode.
	"""
	self.invoke_web_post_request("StopCurrentMode")		

unlock_menu_items()

Reactivate start test and start campaigne menu items

Source code in restmapi\restmapi\services.py
def unlock_menu_items(self):
	""" Reactivate start test and start campaigne menu items
	"""
	self.invoke_web_post_request("UnlockStartMenuItems")

update_test_run_xpar()

Update the contents of the testrun.xpar file (Parameters file) of the current mode

Source code in restmapi\restmapi\services.py
def update_test_run_xpar(self):
	""" Update the contents of the testrun.xpar file (Parameters file) of the current mode
	"""
	self.invoke_web_post_request("UpdateTestRunXpar")

Enum eStartWorkSpaceType

Source code in restmapi\restmapi\services.py
class eStartWorkSpaceType:
	Start = 0
	Restart = 1
	ManualStart = 2

Enum eManualStartOption

Source code in restmapi\restmapi\services.py
class eManualStartOption:
	_None = 0
	Silent = 1
	NoQuantityValues = 2
	Safeties = 4
	RestartFromBeginning = 8