********************************************************** @Name('Crash') context SegmentedByMotorbikeId insert into Crash select a2.timestamp as timestamp, a1.motorbikeId as motorbikeId, a2.location as location, a1.speed as speed_a1, a2.speed as speed_a2, a1.prob * a2.prob * com.cor.cep.util.UReals.lt(a1.timestamp,a2.timestamp).getC() * com.cor.cep.util.UBooleans.uand(com.cor.cep.util.UReals.ge(a1.speed,50.0), com.cor.cep.util.UReals.uEqualsZero(a2.speed)).getC() * P_CrashRule as prob from pattern [every a1 = MotorbikeEvent(com.cor.cep.util.UBooleans.toBoolean(com.cor.cep.util.UReals.ge(a1.speed,50))) -> a2 = MotorbikeEvent(com.cor.cep.util.UReals.equalsZero(a2.speed)) where timer:within(3 milliseconds)]; ********************************************************** @Name('BlowOutTire') " context SegmentedByMotorbikeId " insert into BlowOutTire " select current_timestamp() as timestamp, a2.motorbikeId as motorbikeId, " a1.location as location_a1, " a1.tirePressure1 as tirePressure1_a1, " a1.tirePressure2 as tirePressure2_a1, " a2.location as location_a2, " a2.tirePressure1 as tirePressure1_a2, " a2.tirePressure2 as tirePressure2_a2, " a1.prob * a1.prob * a2.prob * a2.prob * com.cor.cep.util.UBooleans.uor( com.cor.cep.util.UBooleans.uand( com.cor.cep.util.UReals.ge(a1.tirePressure1,2.0), com.cor.cep.util.UReals.le(a2.tirePressure1,1.2)), com.cor.cep.util.UBooleans.uand( com.cor.cep.util.UReals.ge(a1.tirePressure2,2.0), com.cor.cep.util.UReals.le(a2.tirePressure2,1.2))).getC() * com.cor.cep.util.UReals.lt(a1.timestamp, a2.timestamp).getC() * P_BlowOutTireRule as prob from pattern [(every a1 = MotorbikeEvent(com.cor.cep.util.UBooleans.toBoolean(com.cor.cep.util.UReals.ge(a1.tirePressure1, 2.0))) -> a2 = MotorbikeEvent(com.cor.cep.util.UBooleans.toBoolean(com.cor.cep.util.UReals.le(a2.tirePressure1,1.2))) where timer:within(5 milliseconds)) or (every a1 = MotorbikeEvent(com.cor.cep.util.UBooleans.toBoolean(com.cor.cep.util.UReals.ge(a1.tirePressure2, 2.0))) -> a2 = MotorbikeEvent(com.cor.cep.util.UBooleans.toBoolean(com.cor.cep.util.UReals.le(a2.tirePressure2,1.2))) where timer:within(5 milliseconds))]"; ********************************************************** @Name('DriverLeftSeat') context SegmentedByMotorbikeId insert into DriverLeftSeat select current_timestamp() as timestamp, a2.motorbikeId as motorbikeId, a2.location as location, a1.seat as seat_a1, a2.seat as seat_a2, a1.prob * a2.prob * com.cor.cep.util.UBooleans.uand(a1.seat, com.cor.cep.util.UBooleans.unot(a2.seat)).getC() * com.cor.cep.util.UReals.lt(a1.timestamp, a2.timestamp).getC() * P_DriverLeftSeatRule as prob from pattern [every a1 = MotorbikeEvent(com.cor.cep.util.UBooleans.toBoolean(a1.seat))-> a2 = MotorbikeEvent(com.cor.cep.util.UBooleans.toBoolean(com.cor.cep.util.UBooleans.unot(a2.seat)))]; ********************************************************** @Name('GhostRider') insert into GhostRider select e.timestamp as timestamp, e.motorbikeId as motorbikeId, e.prob * com.cor.cep.util.UBooleans.uand(com.cor.cep.util.UBooleans.unot(e.seat),com.cor.cep.util.UReals.gt(e.speed,0.0)).getC() * P_GhostRiderRule as prob from pattern [every e = MotorbikeEvent(com.cor.cep.util.UBooleans.toBoolean( com.cor.cep.util.UBooleans.uand( com.cor.cep.util.UBooleans.unot(e.seat), com.cor.cep.util.UReals.gt(e.speed,0))))]; ********************************************************** @Name('DangerousLocation') insert into DangerousLocation select current_timestamp() as timestamp, a1.location as location, a1.prob * P_DangerousLocationtRule as prob from pattern [every a1 = Crash(a1.location = 'Cadiz')].win:length_batch(100) group by a1.location; ********************************************************** @Name('OccupantThrownAccident') insert into OccupantThrownAccident select current_timestamp() as timestamp, a3.motorbikeId as motorbikeId, a3.location as location, a1.prob * a2.prob * a3.prob * com.cor.cep.util.UBooleans.uand(com.cor.cep.util.UReals.gt(a2.timestamp, a1.timestamp), com.cor.cep.util.UReals.lt(a2.timestamp, a3.timestamp)).getC() * P_AccidentRule as prob from pattern [every-distinct(a1.motorbikeId, a1.timestamp) a1 = BlowOutTire -> (a2 = Crash(a1.motorbikeId = a2.motorbikeId) -> a3 = DriverLeftSeat(a1.motorbikeId = a3.motorbikeId)) where timer:within(3 milliseconds)]; ********************************************************** @Name('AccidentsReport') select current_timestamp() as timestamp, a1.location as location, count(*) as count, a1.prob * P_AccidentReportRule as prob from pattern [every a1 = OccupantThrownAccident].win:time_batch(86400 milliseconds) group by a1.location;