********************************************************** @Name("TempIncrease") insert into TempIncrease select h2.ts as ts, h1.id as id, h2.temp as temp, h2.temp - h1.temp as incr from pattern [(every (h1 = HomeEvent() -> h2=HomeEvent(h2.temp - h1.temp >= 2 and h2.id = h1.id)) ) where timer:within(1 minutes)]; ********************************************************** @Name ("TempWarning") insert into TempWarning select t4.ts as ts, t1.id as id, t4.temp from pattern [(every (t1 = TempIncrease(t1.temp>=33)) -> (t2 = TempIncrease(t2.temp>t1.temp and t2.id = t1.id)) -> (t3 = TempIncrease(t3.temp>t2.temp and t3.id = t1.id)) -> (t4 = TempIncrease(t4.temp>t3.temp and t4.id = t1.id))) where timer:within(5 minutes)]; ********************************************************** @Name("HighCo") insert into HighCo select h1.ts as ts, h1.id as id from pattern [(every (h1 = HomeEvent(h1.co >= 5000)))]; ********************************************************** @Name("FireWarning") insert into FireWarning select tw.id as id, coh.ts as ts from pattern [(every (coh = COHigh())-> every (tw = TempWarning(tw.id = coh.id))) where timer:within(5 seconds)]; ********************************************************** @Name("NobodyHome") insert into NobodyHome select p.ts as ts, h.x as x, h.y as y, h.id as id, p.id as pid from pattern [(every h =HomeEvent(not dopen) -> every (p=PersonEvent( (p.x <= (h.x - Math.sqrt(h.sqre)/2)) or (p.x >= (h.x + Math.sqrt(h.sqre)/2)) or (p.y <= (h.y - Math.sqrt(h.sqre)/2)) or (p.y >= (h.y + Math.sqrt(h.sqre)/2))) )) where timer:within(3 seconds)]; ********************************************************** @Name("CallFireDepartment") insert into CallFireDepartment select fw.id as id, fw.ts as ts from pattern [(every (nh = NobodyHome())-> (fw = FireWarning(fw.id = nh.id))) where timer:within(5 seconds)];