Use of MeasurementFragment

I have a use case where i wanted to use MeasurementFragment as mentioned below
Step -1
monitor.subscribe(MeasurementFragment.SUBSCRIBE_CHANNEL);
on all MeasurementFragment(type=“Test1”,valueFragment=“Test1”)
as mf {

Output - will get the mf object or reference MeasurementFragment.
Note - I am not using the (valueSeries = “xyz”) here , as the valueSeries is not available currently .

Step -2 – Now i got the (valueSeries = “xyz”) value as xyz , can i use value series as filter or as criteria for above mf object or reference to get the value.

Any help will highly appreciated

If I understood correctly, the question is “Are we able to filter MeasurementFragment with valueSeries when it values as null or some specific value?”

If Yes, then no we can not filter with null values. we should use the object to fetch “valueSeries” field value.

Example,

on all MeasurementFragment(type= "type", valueFragment="fragment") as mf {
    // if its not NULL value
    if not mf.valueSeries = "" {
        // do stuff
    }
}

If we are interested to filter the fragment and Series with value, can use filter as

on all MeasurementFragment(type= "type", valueFragment="fragment", valueSeries = "XYZ") as mf {
// do stuff
}
1 Like

I am looking for below use case .

Initially i don’t have type, valueFragment and valueSeries.
I subscribed like below

on all MeasurementFragment() as mf {

Now i got the type, valueFragment and valueSerices values form other sources.

Now i am looking to filter out above mf object

like : mf.type = “ABC” and mf.valueFragment = “XYZ” and mf.valueSeries = “DEF”
{
// do stuff
}

}

OK, We can do it in a couple of ways.
Case 1. if you are interested in both value-specific listeners (like type, fragment and series ) and other measurements. then you go with both filter bases and unmatched listeners.
Example:

on all MeasurementFragment(type="ABC", valueFragment ="XYZ", valueSeries ="DEF") as {
	//do stuff 
}
		
on all unmatched MeasurementFragment()  {
	log "Received unmatched measurements  " at INFO.
//do stuff 
}

Case 2: only interested in the value-specific listener and not bother with other measurements once it identified type, fragment and series value.

Listener l := on all MeasurementFragment() as mf {  
// i.e : mf.type = “ABC” and mf.valueFragment = “XYZ” and mf.valueSeries = “DEF”
  if (//get the measurement you want){
        l.quit();
        on all MeasurementFragment(type= mf.type, valueFragment=mf.fragment, valueSeries = mf.valueSeries) as matchingMF {
      //do -stuff
       }
    }
}

2 Likes

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