EPL - moving from a measurement output to managed object output

after completing the task of generating a measurement I am now adding the same for generating a managed object (as a fragment and associating it with the sensor’s managed object). what would be the correct syntax?

maybe since we are trying to add a new custom fragment to the device which is the main managed object, the syntax would be

monitor.subscribe(ManagedObject.SUBSCRIBE_CHANNEL);
//here there is a missing line where we should be able to choose the particular managed //object which corresponds to workerid just like how we linked the measurement to the //workerID in the measurement example
managedObject.params.add(“CUSTOM_PROPERTY”, PROPERTY_VALUE);
send managedObject to com.apama.cumulocity.ManagedObject.SEND_CHANNEL

Hi,

There is no ManagedObjectValue event to be passed values on it. You can simply add the value to the params.

If you want to create a new managed object, sample code can be,

	action publishManagedObject(string workerId, string dictId, string text1, dictionary<string,float> worker_per_floor_time_dict) {
		// https://cumulocity.com/docs/streaming-analytics/epl-apps/#listening-to-events
		// no need to subscribe channel as we are not listening to any events here.
		//monitor.subscribe(ManagedObject.SUBSCRIBE_CHANNEL);
		
		// If there is no worker simply return.
		if not worker_per_floor_time_dict.hasKey(dictId){ return;}
		
		string motype := "Productive_zones_time_Tower#Floor#" + text1 + "_EPL_MO";
		
		ManagedObject mo := new ManagedObject;
		mo.type := motype;
		mo.params:= {"value": worker_per_floor_time_dict.getOrDefault(dictId)};
		send mo to ManagedObject.SEND_CHANNEL;
	}

Or if you want to update the existing managed object that is corresponds to worker id,

action publishManagedObject(string workerId, string dictId, string text1, dictionary<string,float> worker_per_floor_time_dict) {
		// https://cumulocity.com/docs/streaming-analytics/epl-apps/#listening-to-events
		// no need to subscribe channel as we are not listening to any events here.
		//monitor.subscribe(ManagedObject.SUBSCRIBE_CHANNEL);
		
		// If there is no worker simply return.
		if not worker_per_floor_time_dict.hasKey(dictId){ return;}
		
		string motype := "Productive_zones_time_Tower#Floor#" + text1 + "_EPL_MO";
		
		ManagedObject mo := new ManagedObject;
		mo.type := motype;
		mo.params:= {"value": worker_per_floor_time_dict.getOrDefault(dictId)};
		mo.id := workerId;
		send mo to ManagedObject.UPDATE_CHANNEL;
	}