Need help with APAMA model for measurement calculation

What product/components do you use and which version/fix level are you on?

10.11.12

Is your question related to the free trail, or to a production (customer) instance?

Production

What are you trying to achieve? Please describe in detail.

We have a device where we are ingesting multiple mesurement but we need to add one more measurement into the same device which will be calculated version of one existing mesurement.

Calculation go by like this :

Name of the new measurment : Biofilm Heat Transfer
N = measuremnt which already exist.

If N < -0.00007061743 Then 0
Else If N > 0.1207575 Then 20
Else
Biofilm Heat Transfer = 0.0151 + 213.8 * N- 400 - V2

I’m really down to use APAMA insted of writing any microservice for this. Any help how to achive would be appriciated.

Do you get any error messages? Please provide a full error message screenshot and log file.

Have you installed all the latest fixes of the products and systems you are using?

This should be easily achievable by Analytics Builder!

Any suggestion which connector should be helpful?

Add the Input device to the model from where you will be receiving the measurements .
Use the AB’s standard blocks to achieve it.
Use Extract Property block from Utility to extract the required property value
Use Range block(under calculation group) by providing the lower limit and upper limit setting and send out the values.
In this case Out-of-range will send out value 0 and crossed range will send out value 20 and for range In-range , you can use Expression block(under calculation group) and provide the expression which will calculate and send out the value.

Is this helpful?

Won’t this send ‘out of range’ for values lower and higher than those specified. How can we then discern if 0 or 20 is needed (value is lower than range or higher)? Similarly if range is crossed - how do we know if it has gone from low to high or high to low?

Range Lookup block looks promising but I can’t work out how to pass the input value unchanged - it seems this block will only pass out an explicit value rather than a value it has received.

As Sasmita and Robert pointed out, you can easily build this rule using the analytics builder.

If you want to use EPL-Apps/Apama for this, you can use the following monitor to calculate the value:

using com.apama.cumulocity.MeasurementFragment;
using com.apama.cumulocity.Measurement;
using com.apama.cumulocity.MeasurementValue;


monitor measurementCalculation {	
	
	action onload() {
		// Subscribe to MeasurementFragment.SUBSCRIBE_CHANNEL 
		// to receive all measurements
		monitor.subscribe(MeasurementFragment.SUBSCRIBE_CHANNEL);
		
		//listen on all measurements of a specific type/fragment,series/
		on all MeasurementFragment(type="MeasurementType",valueFragment="MeasurementFragment", valueSeries = "MeasurementSeries") as mf {
			string newType :="MyNewMeasurementType";
			string newFragment :="MyNewMeasurementFragment";
			string newSeries := "MyNewSeries";
			string newUnit :="UnitOfMyNewMeasurement";
			float newValue;
			
			if (mf.value < 0.0) {
				newValue := 0.0;
				} else if (mf.value > 0.0) {
					newValue := 20.0;
				} else {
					newValue := 1.0;
				}
			//send new measurement	
			 send Measurement("", newType,mf.source, mf.time, {
			    	newFragment:{
			    		newSeries: MeasurementValue(newValue, newUnit, new dictionary<string,any>)
			    	}
			    }, new dictionary<string,any>) to Measurement.SEND_CHANNEL;			
		}
	}
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.