330 likes | 646 Views
About the Use of Correlations in Component Based Frameworks. Georg Jung jung@cis.ksu.edu Department of Computing and Information Sciences Kansas State University. Why Using Correlators?. Consider the following situation:. Component C is receiving from two components A and B
E N D
About the Use of Correlations in Component Based Frameworks Georg Jung jung@cis.ksu.edu Department of Computing and Information Sciences Kansas State University
Why Using Correlators? Consider the following situation: • Component C is receiving from two components A and B • A and B send at different rates • C needs both inputs to become active A a C ab b B
Why Using Correlators! If we add correlations to the infrastructure Consider the following situation: We can: • Reduce network traffic • Simplify computation inside the component • Clarify the design • Define the components in a more general way A a a + b C ab b B
Hello World! A C B Scenario: Example scenario from introduction slides: • Three Components A, B, and C • Component C receives • A and B send at different rates
Hello World! Head Filter Transformer φCcorrelation HelloWorld (φAa, φBb) a + b { case true: push new φC { x := a.data, y := b.data } }
The Two-Phase Model Filter Stream of incoming events Transformer e1 e3 e1 e2 e2 Conceptually, the correlator divides into two distinct phases: • The Filter • The Transformer Reacting to a detected pattern • Information about: • which events arrived • what data is present Filter Transformer Generates new output events eout eout Detection of event patterns And performs internal actions • Information about: • which events arrived • what data is present
Back to “Hello World!” φCcorrelation HelloWorld (φAa, φBb) a + b { case true: push new φC { x := a.data, y := b.data } } In this simple example the transformer does a type conversion!
Examples This presentation will include: • How to prevent a race condition • How to chose the most recent/earliest in a sequence • How to handle a double match • How to catch interleaving events • How to deal with redundant-device-components • How to introduce mode-dependent behavior • How to bridge the gap between periodic and aperiodic systems
Race Condition Scenario: Components A and B carry out a task and deliver the results to C. Component C expects the results to come in first from A, then from B. The resulting race condition between A and C can be caught with a correlator.
Race Condition Solution: φdatacorrelation CatchRacing (φdata a, φdata b) a + b { case true: push a; push b; }
Examples This presentation will include: • How to prevent a race condition • How to chose the most recent/earliest in a sequence • How to handle a double match • How to catch interleaving events • How to deal with redundant-device-components • How to introduce mode-dependent behavior • How to bridge the gap between periodic and aperiodic systems
Most Recent / Earliest Scenario: A component C receives from A and B. a + b when both events arrive, C wants the most recent (earliest) of both forwarded. We change the filter expression to: la:(a ; b) | lb:(b ; a)
Most Recent / Earliest φDatacorrelation First (φData a; φDatab) la:(a; b) | lb:(b; a) { case la: push a; case lb: push b; }
Examples This presentation will include: • How to prevent a race condition • How to chose the most recent/earliest in a sequence • How to handle a double match • How to catch interleaving events • How to deal with redundant-device-components • How to introduce mode-dependent behavior • How to bridge the gap between periodic and aperiodic systems
Double Match Consider the following filter expression: (a + b) | (a + c) And the following streams: matches: a + b a b a a c c … matches: a + c a c a b b a … matches: a + b and a + c c b b c a a …
Double Match l1:(a + b) | l2:(a + c) Adding Labels to the expression (a + b) | (a + c)
Double Match l1:(a + b) | l2:(a + c) Transformer 1: Send a general notification { case true: push new φnote{}; }
Double Match l1:(a + b) | l2:(a + c) Transformer 2: Send two outputs { case l1: push b; case l2: push c; }
Double Match l1:(a + b) | l2:(a + c) Transformer 3: Send one output, with priority on b if present. { case l1: push b; case l2 & !l1: push c; }
Examples This presentation will include: • How to prevent a race condition • How to chose the most recent/earliest in a sequence • How to handle a double match • How to catch interleaving events • How to deal with redundant-device-components • How to introduce mode-dependent behavior • How to bridge the gap between periodic and aperiodic systems
Interleaving Event We consider three subexpressions x1, x2, x3. x2 shall not interleave between x1 and x3. x1 ; (l2:(x2 ; x3) | l3:x3) φcorrelation Interleaving (...) x1 ; (l2:(x2 ; x3) | l3:x3) { case l2: push some error event; case l3 & !l2: pushsome success event; }
Examples This presentation will include: • How to prevent a race condition • How to chose the most recent/earliest in a sequence • How to handle a double match • How to catch interleaving events • How to deal with redundant-device-components • How to introduce mode-dependent behavior • How to bridge the gap between periodic and aperiodic systems
Redundant-Sensor-Array … + An A3 A2 A1 Consider an array of redundant components A1, A2,…, An. and a single receiving component B, interested in the accumulation of all events a1, a2,…, an. The filter expression is then a1 + a2 + … + an B
Redundant-Sensor-Array … + An A3 A2 A1 a1 + a2 + … + an In a component system some components can be temporarily unavailable! If one component does not send anymore the whole pattern is never satisfied! B
Redundant-Sensor-Array C … An A3 B A2 A1 Notify correlation SensorArray (Notify a1, …, Notify an, Control c1, …, Control cn) l1:a1 + … + ln:an || m1:c1 || … || mn:cn { case l1 & … & ln: push new Notify {} case m1: toggle l1 … case mn: toggle ln } Sensor Array
Examples This presentation will include: • How to prevent a race condition • How to chose the most recent/earliest in a sequence • How to handle a double match • How to catch interleaving events • How to deal with redundant-device-components • How to introduce mode-dependent behavior • How to bridge the gap between periodic and aperiodic systems
Mode-Awareness Scenario: This scenario generalizes the previous. Instead of single devices to switch on or off, we have a several modes to chose from. The same mechanism is used to switch between modes as previously to switch the different devices on and off.
Mode Awareness n filter expressions, labeled with n labels: m1:e1 || … || mn:en n labeled control events: l1:c1 || … || ln:cn
Mode Awareness φoutcorrelation Modal3 (φc c1, φ c c2, φ c c3, arguments for ei…) m1: e1 || m2: e2 || m3: e3 || l1: c1 || l2: c2 || l3: c3 { abort (m2, m3); clauses for e1, e2, e3… case l1: revive (m1); abort (m2, m3); case l2: revive (m2); abort (m1, m3); case l3: revive (m3); abort (m1, m2); }
Examples This presentation will include: • How to prevent a race condition • How to chose the most recent/earliest in a sequence • How to handle a double match • How to catch interleaving events • How to deal with redundant-device-components • How to introduce mode-dependent behavior • How to bridge the gap between periodic and aperiodic systems
Periodic Checks of Aperiodic Events Scenario: We introduce a periodic supervisor component into an aperiodic system. Whenever a clock-tick occurs, a sample is collected and sent to the supervisor.
Periodic Checks of Aperiodic Events φsamplecorrelation PeriodicChck (φtimer t, φaa, φbb, φcc) t ; (l1:(a + b + c) | l2:t) { case l1: push new φsample{d1 := a.data, d2 := b.data, d3 := c.data } case l2: push some error event (missed sample); }
Examples This presentation will include: • How to prevent a race condition • How to chose the most recent/earliest in a sequence • How to handle a double match • How to catch interleaving events • How to deal with redundant-device-components • How to introduce mode-dependent behavior • How to bridge the gap between periodic and aperiodic systems These are our examples. Feel free to add your own…