The combination of RFID technology and an event language provides a means to automate retail and inventory management, saving tremendous human effort and expediting various processes.
Query 1 detects shoplifting activities, i.e., items that were picked at a shelf and then taken out of the store without being checked out.
PATTERN SEQ(ShelfReading x, ! CounterReading y, ExitReading z)
WHERE x.id = y. id AND x.id = z.id /* equivalently, [id] */
WITHIN 16 hours
The PATTERN clause of this query uses the SEQ construct to specify a sequence that consists of the occurrence of a ShelfReading event followed by the non-occurrence of a CounterReading event followed by the occurrence of an ExitReading event. Non-occurrences of events, also referred to as negation, are expressed using the ‘!’ symbol.
The predicates in the WHERE clause compare the id attributes of all three events in the SEQ construct for equality. We refer to these predicates collectively as an equivalence test and provide a shorthand notation, [id], for the equivalence test.
Finaly, the query uses the WITHIN clause to specify a time period, referred to as a sliding window, in which the events of interest must occur.
The output of this query contains a sequence of composite events. Each result event represents a unique match of the query, e.g., a ShelfReading event, stored in x, and an ExitReading event, stored in z, that satisfy the PATTERN, WHERE, and WITHIN clauses. By default, the result event contains the concatenation of all the attributes of the events constituting a match.
Query 2 can be used to detect misplaced inventory.
PATTERN SEQ(ShelfReading x, ShelfReading y, ! (ANY(CounterReading, ShelfReading) z) )
WHERE [id] AND x.shelf_id ≠ y.shelf_id AND x.shelf_id = z.shelf_id
WITHIN 1 hour
The query specifies that a misplacement case consists of a reading of an item at Shelf 1, followed by a reading of the same item at Shelf 2, which is not followed by any reading of the item at a checkout counter or back at shelf 1. The predicate “x.shelf_id ≠ y.shelf_id” ensures that the two first ShelfReading events refer to different shelves. The predicate “x.shelf_id = z.shelf_id”, with z referring to a negative component of SEQ, ensures that if the ANY operator returns a ShelfReading event, the reading is not from Shelf 1.
Query 3 counts the pallets read by an RFID reader at a loading dock.
PATTERN (StartLoading a, RfidReading+ b[ ], EndLoading c)
AND a.session_id = c.session_id
AND b[i].packaging_level = ‘pallet’
RETURN a.session_id, count(b[ ]), b[ ].tag_id
The PATTERN clause specifies a sequence pattern with three components: the first and the third refer to the events sent by the control system to signal the start and the end of a loading session; the second component addresses one or more readings in the session using the Kleene plus operator ‘+’.
As before, the WHERE clause further refines the constraints on the addressed events. The third predicate, used with the Kleene plus, selects only the readings of pallets; it uses the b[i] variable (where i >= 1) to specify the requirement that “every” relevant reading refer to a pallet.
Each match of the pattern consists of a unique sequence of events, stored in a, b[ ], and c. For each match, the RETURN clause creates a result event with three new attributes. In particular, b.tag id selects the tag id of each pallet reading, resulting in an attribute of the sequence type.
Last updated: 07/16/14 11:35:20