Skip to content

MAPI service UserApplicationControl

To get UserApplicationControl service use:

with MAPIServices.instance.get_service("UserApplicationControl") as uac:

Bases: UserApplicationMonitoringProxy

UserApplicationControl MAPI service allows to control a running MORPHEE application. For example, get MORPHEE status, get or set channel value, start component method... Call init_signalr if you intend to use the signalr hub events and with keyword on the UserApplicationControl object to be sure that the communication is closed at the end.

Source code in restmapi\restmapi\services.py
class UserApplicationControlProxy(UserApplicationMonitoringProxy):
	"""UserApplicationControl MAPI service allows to control a running MORPHEE application.
	For example, get MORPHEE status, get or set channel value, start component method...
	Call init_signalr if you intend to use the signalr hub events and with keyword on the UserApplicationControl object to be sure that the communication is closed at the end.
		"""
	def __init__(self, url):
		"""DO NOT create UserApplicationControlProxy by yourself. Always use MAPIServices.get_service("UserApplicationControl") method to create it.

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

	def set_channel_value(self, channel_name, value, duration_in_seconds):
		"""Set the value of a channel.

		Parameters
		----------
		channel_name : string
			Id of a numerical quantity channel
		value : double
			new value.
		duration_in_seconds : double
			Duration of the slope. Put 0 to set the channel immediatly.
		"""
		self.invoke_web_post_request(f"Channels/{channel_name}/SetValue?value={value}&duration={duration_in_seconds}")

	def set_channels_values(self, set_point_array):
		"""Set multiple channel value

		Parameters
		----------
		set_point_array : Array of SetPoint
			List of set points to be applied in one request. A setpoint contains a channel identifier, the target value and the duration in second.
		"""
		self.invoke_web_request(f"SetChannelsValues", "POST", [x.__dict__ for x in set_point_array])

	def start_method(self, component_name, method_name, loop = False, exit_proc = True):
		"""Start a method in a MORPHEE service.
		To start a method from the current test description use "TEST" keywords and for campaign description use "CAMPAIGN" keyword and for bench mode use "BENCH" keyword.

		Parameters
		----------
		component_name : string
			The component name that owns the method (only the father name is sufficient).
		method_name : string
			Method name to be started.
		loop : bool, optional
			true to use an autorepeat service, by default False
		exit_proc : bool, optional
			true to use a service "Hold with procedure", by default True
		"""
		self.invoke_web_post_request(f"Components/Component/{component_name}/Methods/{method_name}/Start?loop={loop}&exitWithProc={exit_proc}")		

	def stop_method(self, component_name, method_name):
		"""Stop a method that runs in a MORPHEE service

		Parameters
		----------
		component_name : string
			The component name that owns the method (only the father name is sufficient).
		method_name : string
			Method name to be stopped.
		"""
		self.invoke_web_post_request(f"Components/Component/{component_name}/Methods/{method_name}/Stop")		

	def set_quantity_table(self, quantity_name, values):
		"""Set quantity table/LUT content values

		Parameters
		----------
		quantity_name : string
			Quantity table/lut id.
		values : double array array
			Matrix values
		"""
		self.invoke_web_request(f"QuantityTable/{quantity_name}/SetValue", "POST", values)				

	def storage_key_add_point(self, name, index):
		"""Add new point in current file.

		Parameters
		----------
		name : string
			Name of the storageKey (you can get available storage keys by calling get_storage_keys())
		index : string
			name of the mode (bench, campaign, test, current)
		"""
		self.invoke_web_post_request(f"StorageKeys/{index}/{name}/AddPoint")	

	def storage_key_start_acquisition(self, name, index, period_ms, duration_ms):
		"""Start periodic acquisition into current file

		Parameters
		----------
		name : string
			Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
		index : string
			name of the mode (bench, campaign, test, current).
		period_ms : double
			acquisition period in milliseconde
		duration_ms : double
			duration in millisecondes. -1 for infinite
		"""
		self.invoke_web_post_request(f"StorageKeys/{index}/{name}/StartAcquisition?periodMs={period_ms}&durationMs={duration_ms}")	

	def storage_key_stop_acquisition(self, name, index):
		"""Stop pending acquisition.

		Parameters
		----------
		name : string
			Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
		index : string
			name of the mode (bench, campaign, test, current).
		"""
		self.invoke_web_post_request(f"StorageKeys/{index}/{name}/StopAcquisition")	

	def storage_key_undo_last_point(self, name, index):
		"""Remove last point (Note that some file format such as MDF do not support that method)

		Parameters
		----------
		name : string
			Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
		index : string
			name of the mode (bench, campaign, test, current).
		"""
		self.invoke_web_post_request(f"StorageKeys/{index}/{name}/UndoLastPoint")

	def storage_key_create_new_file(self, name, index):
		"""Initialize a brand new file.

		Parameters
		----------
		name : string
			Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
		index : string
			name of the mode (bench, campaign, test, current).
		"""
		self.invoke_web_post_request(f"StorageKeys/{index}/{name}/CreateNewFile")			

__init__(url)

DO NOT create UserApplicationControlProxy by yourself. Always use MAPIServices.get_service("UserApplicationControl") 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 UserApplicationControlProxy by yourself. Always use MAPIServices.get_service("UserApplicationControl") method to create it.

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

set_channel_value(channel_name, value, duration_in_seconds)

Set the value of a channel.

Parameters:

  • channel_name (string) –
    Id of a numerical quantity channel
    
  • value (double) –
    new value.
    
  • duration_in_seconds (double) –
    Duration of the slope. Put 0 to set the channel immediatly.
    
Source code in restmapi\restmapi\services.py
def set_channel_value(self, channel_name, value, duration_in_seconds):
	"""Set the value of a channel.

	Parameters
	----------
	channel_name : string
		Id of a numerical quantity channel
	value : double
		new value.
	duration_in_seconds : double
		Duration of the slope. Put 0 to set the channel immediatly.
	"""
	self.invoke_web_post_request(f"Channels/{channel_name}/SetValue?value={value}&duration={duration_in_seconds}")

set_channels_values(set_point_array)

Set multiple channel value

Parameters:

  • set_point_array (Array of SetPoint) –
    List of set points to be applied in one request. A setpoint contains a channel identifier, the target value and the duration in second.
    
Source code in restmapi\restmapi\services.py
def set_channels_values(self, set_point_array):
	"""Set multiple channel value

	Parameters
	----------
	set_point_array : Array of SetPoint
		List of set points to be applied in one request. A setpoint contains a channel identifier, the target value and the duration in second.
	"""
	self.invoke_web_request(f"SetChannelsValues", "POST", [x.__dict__ for x in set_point_array])

set_quantity_table(quantity_name, values)

Set quantity table/LUT content values

Parameters:

  • quantity_name (string) –
    Quantity table/lut id.
    
  • values (double array array) –
    Matrix values
    
Source code in restmapi\restmapi\services.py
def set_quantity_table(self, quantity_name, values):
	"""Set quantity table/LUT content values

	Parameters
	----------
	quantity_name : string
		Quantity table/lut id.
	values : double array array
		Matrix values
	"""
	self.invoke_web_request(f"QuantityTable/{quantity_name}/SetValue", "POST", values)				

start_method(component_name, method_name, loop=False, exit_proc=True)

Start a method in a MORPHEE service. To start a method from the current test description use "TEST" keywords and for campaign description use "CAMPAIGN" keyword and for bench mode use "BENCH" keyword.

Parameters:

  • component_name (string) –
    The component name that owns the method (only the father name is sufficient).
    
  • method_name (string) –
    Method name to be started.
    
  • loop (bool, default: False ) –
    true to use an autorepeat service, by default False
    
  • exit_proc (bool, default: True ) –
    true to use a service "Hold with procedure", by default True
    
Source code in restmapi\restmapi\services.py
def start_method(self, component_name, method_name, loop = False, exit_proc = True):
	"""Start a method in a MORPHEE service.
	To start a method from the current test description use "TEST" keywords and for campaign description use "CAMPAIGN" keyword and for bench mode use "BENCH" keyword.

	Parameters
	----------
	component_name : string
		The component name that owns the method (only the father name is sufficient).
	method_name : string
		Method name to be started.
	loop : bool, optional
		true to use an autorepeat service, by default False
	exit_proc : bool, optional
		true to use a service "Hold with procedure", by default True
	"""
	self.invoke_web_post_request(f"Components/Component/{component_name}/Methods/{method_name}/Start?loop={loop}&exitWithProc={exit_proc}")		

stop_method(component_name, method_name)

Stop a method that runs in a MORPHEE service

Parameters:

  • component_name (string) –
    The component name that owns the method (only the father name is sufficient).
    
  • method_name (string) –
    Method name to be stopped.
    
Source code in restmapi\restmapi\services.py
def stop_method(self, component_name, method_name):
	"""Stop a method that runs in a MORPHEE service

	Parameters
	----------
	component_name : string
		The component name that owns the method (only the father name is sufficient).
	method_name : string
		Method name to be stopped.
	"""
	self.invoke_web_post_request(f"Components/Component/{component_name}/Methods/{method_name}/Stop")		

storage_key_add_point(name, index)

Add new point in current file.

Parameters:

  • name (string) –
    Name of the storageKey (you can get available storage keys by calling get_storage_keys())
    
  • index (string) –
    name of the mode (bench, campaign, test, current)
    
Source code in restmapi\restmapi\services.py
def storage_key_add_point(self, name, index):
	"""Add new point in current file.

	Parameters
	----------
	name : string
		Name of the storageKey (you can get available storage keys by calling get_storage_keys())
	index : string
		name of the mode (bench, campaign, test, current)
	"""
	self.invoke_web_post_request(f"StorageKeys/{index}/{name}/AddPoint")	

storage_key_create_new_file(name, index)

Initialize a brand new file.

Parameters:

  • name (string) –
    Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
    
  • index (string) –
    name of the mode (bench, campaign, test, current).
    
Source code in restmapi\restmapi\services.py
def storage_key_create_new_file(self, name, index):
	"""Initialize a brand new file.

	Parameters
	----------
	name : string
		Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
	index : string
		name of the mode (bench, campaign, test, current).
	"""
	self.invoke_web_post_request(f"StorageKeys/{index}/{name}/CreateNewFile")			

storage_key_start_acquisition(name, index, period_ms, duration_ms)

Start periodic acquisition into current file

Parameters:

  • name (string) –
    Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
    
  • index (string) –
    name of the mode (bench, campaign, test, current).
    
  • period_ms (double) –
    acquisition period in milliseconde
    
  • duration_ms (double) –
    duration in millisecondes. -1 for infinite
    
Source code in restmapi\restmapi\services.py
def storage_key_start_acquisition(self, name, index, period_ms, duration_ms):
	"""Start periodic acquisition into current file

	Parameters
	----------
	name : string
		Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
	index : string
		name of the mode (bench, campaign, test, current).
	period_ms : double
		acquisition period in milliseconde
	duration_ms : double
		duration in millisecondes. -1 for infinite
	"""
	self.invoke_web_post_request(f"StorageKeys/{index}/{name}/StartAcquisition?periodMs={period_ms}&durationMs={duration_ms}")	

storage_key_stop_acquisition(name, index)

Stop pending acquisition.

Parameters:

  • name (string) –
    Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
    
  • index (string) –
    name of the mode (bench, campaign, test, current).
    
Source code in restmapi\restmapi\services.py
def storage_key_stop_acquisition(self, name, index):
	"""Stop pending acquisition.

	Parameters
	----------
	name : string
		Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
	index : string
		name of the mode (bench, campaign, test, current).
	"""
	self.invoke_web_post_request(f"StorageKeys/{index}/{name}/StopAcquisition")	

storage_key_undo_last_point(name, index)

Remove last point (Note that some file format such as MDF do not support that method)

Parameters:

  • name (string) –
    Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
    
  • index (string) –
    name of the mode (bench, campaign, test, current).
    
Source code in restmapi\restmapi\services.py
def storage_key_undo_last_point(self, name, index):
	"""Remove last point (Note that some file format such as MDF do not support that method)

	Parameters
	----------
	name : string
		Name of the storageKey (you can get available storage keys by calling get_storage_keys()).
	index : string
		name of the mode (bench, campaign, test, current).
	"""
	self.invoke_web_post_request(f"StorageKeys/{index}/{name}/UndoLastPoint")