I wanted to create measurement based on location update event in EPL app

I have written the code for create measurement for creating measurement on managed object update but I wanted to create measurement only for location update event

action onload() {
	 	string device := "";
	 	on all ManagedObject() as mo {
  	 	if(mo.isCreate() or mo.isUpdate() and mo.params.hasKey("c8y_IsDevice")) {
	 			device := mo.id;

	action listenAndActOnMeasurements(string deviceId)
			requestIface := CumulocityRequestInterface.connectToCumulocity();
				string REQUEST_ROOT:= "/service/demo-microservice/api/custom/" + deviceId;
				Request demoserviceRequest:=requestIface.createRequest("GET", 
				REQUEST_ROOT, any());
				log "EPL execution completed." at INFO;	

That would look like this

on all Event(type="c8y_LocationUpdate") as loc {


if you want to only react to new and not to updated events you would have to check in addition is loc.isCreate() is true. But I think updates for location events are very unusual and you should be able to skip this step.

1 Like

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