Difference between revisions of "Adding a computed measurement"
From Senfi Docs
(Marked this version for translation) |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | === Pre-requisites === | + | <translate> |
+ | |||
+ | === Pre-requisites === <!--T:1--> | ||
A computed measurement requires design and scripting in order for it to work correctly. If this is your first time creating a computed measurement, please read [[Computed_measurement|this guide]] first. | A computed measurement requires design and scripting in order for it to work correctly. If this is your first time creating a computed measurement, please read [[Computed_measurement|this guide]] first. | ||
+ | <!--T:2--> | ||
You should also be similar with the basic [[Measurement|measurements]] and its concepts. Please read [[Concepts#Measurement.2C_Metric.2C_Tag|this section]] if you require a refresher. | You should also be similar with the basic [[Measurement|measurements]] and its concepts. Please read [[Concepts#Measurement.2C_Metric.2C_Tag|this section]] if you require a refresher. | ||
+ | <!--T:3--> | ||
You should | You should | ||
− | * Note down the | + | * Note down the input measurements. |
* Note down the metrics you want to output. | * Note down the metrics you want to output. | ||
* Decide on a set of tags to use or re-use. Make sure that there is a combination of tags that will uniquely identify the unit/device/equipment that outputs those metrics. | * Decide on a set of tags to use or re-use. Make sure that there is a combination of tags that will uniquely identify the unit/device/equipment that outputs those metrics. | ||
Line 11: | Line 15: | ||
* (Optional) Have a set of test data for your computed measurement | * (Optional) Have a set of test data for your computed measurement | ||
− | === Adding a New Computed Measurement === | + | === Adding a New Computed Measurement === <!--T:4--> |
+ | <!--T:5--> | ||
# Login to the [https://ems.senfi.io/cms CMS] | # Login to the [https://ems.senfi.io/cms CMS] | ||
# Go to the '''Computed Measurement''' tab | # Go to the '''Computed Measurement''' tab | ||
Line 18: | Line 23: | ||
# Give the measurement a descriptive name. This will be shown to users of the dashboard. | # Give the measurement a descriptive name. This will be shown to users of the dashboard. | ||
# Specify a [[Measurement#Measurement_Code|measurement code]]. | # Specify a [[Measurement#Measurement_Code|measurement code]]. | ||
− | # Select your | + | # Select your Input Measurements |
# Add tags. | # Add tags. | ||
# Add metrics and specify the type of each metric. | # Add metrics and specify the type of each metric. | ||
Line 25: | Line 30: | ||
# Save when done. | # Save when done. | ||
− | === Writing the Computed Measurement Script === | + | <!--T:6--> |
+ | <div class="important">Note: The computed measurement will be instantiated and run immediately upon saving.</div> | ||
+ | |||
+ | === Writing the Computed Measurement Script === <!--T:7--> | ||
+ | <!--T:8--> | ||
Fill in the script of your computed measurement in the '''Script''' editor. When you add a new computed measurement, a template script will be pre-filled for you. | Fill in the script of your computed measurement in the '''Script''' editor. When you add a new computed measurement, a template script will be pre-filled for you. | ||
+ | <!--T:9--> | ||
# Fill in '''init()''', the initialization function | # Fill in '''init()''', the initialization function | ||
# Fill in '''compute()''', the computation function | # Fill in '''compute()''', the computation function | ||
# Declare any global variables, if your script requires them | # Declare any global variables, if your script requires them | ||
+ | <!--T:10--> | ||
+ | <div class="important">Note: You should not modify the function signatures of the initialization or computation functions.</div> | ||
− | + | <!--T:11--> | |
− | + | <div class="important">Tip: The script editor will interactively notify you of any syntax errors in your script.</div> | |
− | |||
− | === Testing the Computed Measurement === | + | === Testing the Computed Measurement === <!--T:12--> |
+ | <!--T:13--> | ||
# Enter sample measurement data in the '''Testing Value''' editor | # Enter sample measurement data in the '''Testing Value''' editor | ||
# Click the '''TEST''' button | # Click the '''TEST''' button | ||
# After 5 seconds, review the test output in the '''Testing Output''' panel and any console messages in the '''Testing Console''' panel. | # After 5 seconds, review the test output in the '''Testing Output''' panel and any console messages in the '''Testing Console''' panel. | ||
+ | |||
+ | </translate> |
Latest revision as of 15:24, 17 October 2019
Contents
Pre-requisites
A computed measurement requires design and scripting in order for it to work correctly. If this is your first time creating a computed measurement, please read this guide first.
You should also be similar with the basic measurements and its concepts. Please read this section if you require a refresher.
You should
- Note down the input measurements.
- Note down the metrics you want to output.
- Decide on a set of tags to use or re-use. Make sure that there is a combination of tags that will uniquely identify the unit/device/equipment that outputs those metrics.
- Have the computed measurement script ready.
- (Optional) Have a set of test data for your computed measurement
Adding a New Computed Measurement
- Login to the CMS
- Go to the Computed Measurement tab
- Click the + button to add a new computed measurement.
- Give the measurement a descriptive name. This will be shown to users of the dashboard.
- Specify a measurement code.
- Select your Input Measurements
- Add tags.
- Add metrics and specify the type of each metric.
- Write the computed measurement script. See Writing the Computed Measurement Script for more details.
- (Optional) Test the computed measurement. See Testing the Computed Measurement for more details.
- Save when done.
Note: The computed measurement will be instantiated and run immediately upon saving.
Writing the Computed Measurement Script
Fill in the script of your computed measurement in the Script editor. When you add a new computed measurement, a template script will be pre-filled for you.
- Fill in init(), the initialization function
- Fill in compute(), the computation function
- Declare any global variables, if your script requires them
Note: You should not modify the function signatures of the initialization or computation functions.
Tip: The script editor will interactively notify you of any syntax errors in your script.
Testing the Computed Measurement
- Enter sample measurement data in the Testing Value editor
- Click the TEST button
- After 5 seconds, review the test output in the Testing Output panel and any console messages in the Testing Console panel.