MAPI service MeasurementManager
To get MeasurementManager service use:
with MAPIServices.instance.get_service("UserApplicationMonitoring") as uam:
with uam.get_measurement_manager() as measurement_manager
with MAPIServices.instance.get_service("UserApplicationControl") as uac:
with uac.get_measurement_manager() as measurement_manager
Bases: MAPIServiceWithSignalR
MeasurementManagerProxy manages a MORPHEE acquisition by creating dynamically MeasurementProxy objects. Do not create it by ourself, it should be created by using a UserApplicationMonitoringProxy object or UserApplicationControlProxy object. Call init_signalr if you intend to use the signalr hub events and with keyword on the MeasurementManagerProxy object to be sure that the communication is closed at the end.
Source code in restmapi\restmapi\services.py
__init__(url)
DO NOT create MeasurementManagerProxy by yourself. Always use MAPIServices.get_service("UserApplicationMonitoring").get_measurement_manager() or MAPIServices.get_service("UserApplicationControl").get_measurement_manager() methods to create it.
Parameters:
-
url(string) –Base URL to create of the REST service.
Source code in restmapi\restmapi\services.py
create_ex(workspace_index)
Create a new measurement. The measurement will be disposed automatically when the associated workspace stops.
Parameters:
-
workspace_index(int) –0 based index of the workspace
Returns:
-
MeasurementProxy–Returns a MeasurementManagerProxy object. Use with keyword to automatically delete the object or use delete method explicitely.
Source code in restmapi\restmapi\services.py
get_version()
register_callback(measurement_id, event_name, action)
Register a callback function. inti_signalr() method should be called first.
Parameters:
-
measurement_id(int) –Id of the measurement. -
event_name(string) –Name of the event (BufferReady, BufferFull, StatusChanged, Disposed). -
action(function(instance, name, params)) –Callback function with 1 parameter (int: measurement_id) or with 2 (int: measurement_id, double[] values) for BufferReady.
Source code in restmapi\restmapi\services.py
Bases: MAPIService
MeasurementProxy is a dynamic object that manages a MORPHEE acquisition. Do not create it by ourself, it should be created by using a MeasurementManagerProxy object. Note that the object has to be deleted, so use with keyword on it!
Source code in restmapi\restmapi\services.py
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 | |
id
property
Unique id of the MORPHEE measurement object
__init__(url, id)
DO NOT create MeasurementProxy by yourself. Always use MeasurementManagerProxy.create() or MeasurementManagerProxy.create_ex() methods to create it.
Parameters:
-
url(string) –Base URL to create of the REST service.
Source code in restmapi\restmapi\services.py
activate()
Activate the measurement. During the activation, MORPHEE checks the properties. To activate the measurement, the Status should be Created. If it works the Status is set to Activated.
Returns:
-
bool–Returns True if all properties are correct.
Source code in restmapi\restmapi\services.py
deactivate()
Deactivate the measurement. During the activation, MORPHEE checks the properties. To Deactivate the measurement, the Status should be Activated. If it works the Status is set to Created.
Returns:
-
bool–Returns False if the operation could not be performed. Use LastError property to have the description of the error.
Source code in restmapi\restmapi\services.py
delete()
Delete/Release Measurement object. After that, any call to the measurement raise an exception
get_duration()
Get duration of the measurement. Duration = NumberOfValues * Period.
Returns:
-
double–Duration of the acquisition buffer.
get_last_error()
String error description of the last error. For example, after Activate method call, the user can get the reason why the activation was performed.
Returns:
-
string–Last error message.
Source code in restmapi\restmapi\services.py
get_measurement_mode()
Get the Measurement Mode. If MeasurementMode is OneShot (1), the measurement stop at the end of the Duration and NumberOfBlocValues is ignored. If MeasurementMode is Continuous (0), the measurement does not stop until you read the values with GetValues. If MeasurementMode is StepByStep (2), values are acquired at each TriggerGetValues call.
Returns:
-
uint–Continuous (0), OneShot (1), StepByStep (2).
Source code in restmapi\restmapi\services.py
get_number_of_bloc_values()
Get bloc number of values. Each time the buffer size reaches NumberOfBlocValues the event MeasurementBufferReady is raised.
Returns:
-
uint–Number of values per bloc.
Source code in restmapi\restmapi\services.py
get_number_of_values()
Get total number of values. It defines the size of the internal buffer.
Returns:
-
unit–Total number of values.
get_period()
Get sampling period in second.
Returns:
-
double–Sampling period in second.
get_properties()
Get Measurement object properties in Json format using one single request.
Returns:
-
MeasurementProperties–Returns an object with every properties of the measurement (only for read purpose).
Source code in restmapi\restmapi\services.py
get_quantities()
Get the list of quantities to measure. Only number quantities are supported.
Returns:
-
string array–Quantities id from the measurement.
Source code in restmapi\restmapi\services.py
get_status()
The current status of the Measurement. To change properties of the measurement, the Status should be Created.
| Created | 0 | Measurement is Created, properties can be set to configure it. | | Activated | 1 | Measurement is Activated, properties can not be set. Measurement is ready to start. | | Started | 2 | Measurement is Started. Use GetValues to retrieves the result buffer. | | Disposed | 3 | Measurement is Disposed. It could happen if the associated mode has stopped. | | Unknown | 4 | Unknown state indicates a serious internal error. |
Returns:
-
uint–Current status
Source code in restmapi\restmapi\services.py
get_values()
return buffered values with timestamp as first columns. If MeasurementMode is Continuous, the buffer is cleared in order to continue the acquistion. If MeasurementMode is OneShot, the buffer values remains in buffer until you starts again the measurement.
Returns:
-
double array–Measurement values.
Source code in restmapi\restmapi\services.py
set_duration(duration)
Set duration of the measurement. Duration = NumberOfValues * Period. Note that duration and number_of_values cannot be both set.
Parameters:
-
duration(double) –Duration of the acquisition buffer.
Source code in restmapi\restmapi\services.py
set_measurement_mode(measurement_mode)
Set the Measurement Mode. If MeasurementMode is OneShot (1), the measurement stop at the end of the Duration and NumberOfBlocValues is ignored. If MeasurementMode is Continuous (0), the measurement does not stop until you read the values with GetValues. If MeasurementMode is StepByStep (2), values are acquired at each TriggerGetValues call.
Parameters:
-
measurement_mode(uint) –Continuous (0), OneShot (1), StepByStep (2).
Source code in restmapi\restmapi\services.py
set_number_of_bloc_values(number_of_bloc_values)
Set bloc number of values. Each time the buffer size reaches NumberOfBlocValues the event MeasurementBufferReady is raised.
Parameters:
-
number_of_bloc_values(uint) –Number of values per bloc.
Source code in restmapi\restmapi\services.py
set_number_of_values(number_of_values)
Set total number of values. It defines the size of the internal buffer. Note that duration and number_of_values cannot be both set.
Parameters:
-
number_of_values(unit) –Total number of values.
Source code in restmapi\restmapi\services.py
set_period(period)
Set sampling period in second.
Parameters:
-
period(double) –Sampling period in second.
set_quantities(quantities)
Set the list of quantities to measure. Only number quantities are supported.
Parameters:
-
quantities(string array) –New quantity id list.
Source code in restmapi\restmapi\services.py
start()
Start the measurement. To start the measurement, the Status should be Activated. If it works the Status is set to Started.
Returns:
-
bool–Returns False if the operation could not be performed. Use LastError property to have the description of the error.
Source code in restmapi\restmapi\services.py
stop()
Stop the measurement. To stop the measurement, the Status should be Started. If it works the Status is set to Activated.
Returns:
-
bool–Returns False if the operation could not be performed. Use LastError property to have the description of the error.
Source code in restmapi\restmapi\services.py
trigger_get_values()
If MeasurementMode is StepByStep, it triggers the Measurement to get value at the next tick
Returns:
-
bool–Returns False if the operation could not be performed. Use LastError property to have the description of the error.