2016-04-21 18 views
0

当心率保持在160分钟以上5分钟时,我有以下规则。Esper规则语言:从模式中返回类的数据字段

EPStatement cepStatementRule3 = cepRule.createEPL("context PartitionByMacHeartRate " 
       + "select * from pattern[every(HeartRate(heartrate > 160) " 
       + "-> (timer:interval(5 min) " 
       + "and not HeartRate(heartrate<=160)))]"); 
     cepStatementRule3.addListener(new rule3Listener()); 

我的心率类具有以下字段:

int heartrate; 
String heartratesTimestamp; 
String macAddress; 

我要的是能够得到MACADDRESS我ruleListener。然而这个 返回一个空的散列表。所以我的问题是如何返回HeartRate的macAddress?

回答

1

模式保留,并返回标记的事件,即这会做:

// we assign the 'h' tag to the first event and the engine now retains that 
// the select clause could use "h.macAddress as macAddress", for example 
...every(h=HeartRate(...