UserApplicationControl
Each started MORPHEE provides a UserApplicationControl MAPI service. MORPHEE master names it "UserApplicationControl" and MORPHEE instance XX names it "UserApplicationControl_XX".
Note that UserApplicationControl inherit from UserApplicationMonitoring.
Below a sample that covers UserApplicationControl specificities.
from restmapi.services import MAPIServices
from restmapi.services import SetPoint
import time
with MAPIServices.instance.get_service("UserApplicationControl") as uac:
# Set a channel value
uac.set_channel_value("channel1", 500, 10)
# set multiple channel values
uac.set_channels_values([SetPoint("channel2", 1, 0), SetPoint("channnel", 2, 0)])
# Start bench "getval" method and stop it after 5 sec.
uac.start_method("bench", "getval")
time.sleep(5)
uac.stop_method("bench", "getval")
# change table quantity content
uac.set_quantity_table("table1", [[10,20],[30,40]])
# Test point file management
# Add a single point
uac.storage_key_add_point("StorageKey1", "bench")
time.sleep(2)
# Add a start acquition for 1 sec. at 1 ms
uac.storage_key_start_acquisition("StorageKey1", "bench",1,1000)
time.sleep(5)
# Add a start acquition for 10 sec. at 1 ms
# But interrupt it after 5 sec.
uac.storage_key_start_acquisition("StorageKey1", "bench",1,10000)
time.sleep(5)
uac.storage_key_stop_acquisition("StorageKey1", "bench")
time.sleep(5)
# Remove last point
uac.storage_key_undo_last_point("StorageKey1", "bench")
time.sleep(5)
# initialize a new file
uac.storage_key_create_new_file("StorageKey1", "bench")
Below a sample that demonstrates UserApplicationControl event capabilities.
from restmapi.services import MAPIServices
import time
def on_morphee_event(instance, name, params):
print(f"MORPHEE Event {name} raised from instance {instance} with parameters {params}")
with MAPIServices.instance.get_service("UserApplicationControl") as uac:
uac.init_signalr()
uac.register_callback("MyEvent", on_morphee_event)
uac.register_callback("$CampaignLoading", on_morphee_event);
uac.register_callback("$TestLoading", on_morphee_event);
uac.register_callback("$BenchStarted", on_morphee_event);
uac.register_callback("$CampaignStarted", on_morphee_event);
uac.register_callback("$TestStarted", on_morphee_event);
uac.register_callback("$CampaignTerminated", on_morphee_event);
uac.register_callback("$TestTerminated", on_morphee_event);
uac.register_callback("$CampaignInterrupted", on_morphee_event);
uac.register_callback("$TestInterrupted", on_morphee_event);
uac.register_callback("$CampaignLoadingError", on_morphee_event);
uac.register_callback("$TestLoadingError", on_morphee_event);
uac.register_callback("$UserChanged", on_morphee_event);
uac.register_callback("$RedAlarmRaised", on_morphee_event);
uac.register_callback("$OrangeAlarmRaised", on_morphee_event);
uac.register_callback("$YellowAlarmRaised", on_morphee_event);
uac.register_callback("$AlarmStateChanged", on_morphee_event);
uac.register_callback("$BenchResumed", on_morphee_event);
uac.register_callback("$CampaignResumed", on_morphee_event);
uac.register_callback("$TestResumed", on_morphee_event);
uac.register_callback("$FileClosed", on_morphee_event);
uac.register_callback("$InternalError", on_morphee_event);
uac.register_callback("$BenchTerminated", on_morphee_event);
uac.register_callback("$BenchInterrupted", on_morphee_event);
time.sleep(60)