Understanding timer:within

View: New views
7 Messages — Rating Filter:   Alert me  

Understanding timer:within

by Matthes R.-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everyone,

In my web-service the clients are able to make subscriptions to different things. one thing is to receive a notification if:

- cEvent happend
- another cEvent happens in the next x seconds.

I tried the following statement to realize this pattern:
"select cEvent as value from pattern [every (((cEvent=cEvent) and (cEvent=cEvent)) where timer:within(10000 msec))]".

But this statement starts directly after creation and waits 10 secs and then stops forever. Is there a way to "reset" it? Like starting every time when cEvent occurs and then waiting for 10 secs for another cEvent - then stopping, but starting again if a new cEvent comes in - independet from the initial start time of the statement? Is the timer:within a good solution or is there any other way to realize this problem?

Regards,
Matthes

Re: Understanding timer:within

by Alexandre Vasseur :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

timer:within is good but you need to use a followed-by and not an and:
every (A -> B where timer:within(x seconds))
http://esper.codehaus.org/esper-3.2.0/doc/reference/en/html/event_patterns.html#pattern-temporal-followed-by
Alex

On Wed, Sep 23, 2009 at 12:46 PM, Matthes R. <m.rieke.mailing@...> wrote:
Hello everyone,

In my web-service the clients are able to make subscriptions to different things. one thing is to receive a notification if:

- cEvent happend
- another cEvent happens in the next x seconds.

I tried the following statement to realize this pattern:
"select cEvent as value from pattern [every (((cEvent=cEvent) and (cEvent=cEvent)) where timer:within(10000 msec))]".

But this statement starts directly after creation and waits 10 secs and then stops forever. Is there a way to "reset" it? Like starting every time when cEvent occurs and then waiting for 10 secs for another cEvent - then stopping, but starting again if a new cEvent comes in - independet from the initial start time of the statement? Is the timer:within a good solution or is there any other way to realize this problem?

Regards,
Matthes


Re: Understanding timer:within

by Thomas Everding :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone!

Actually our problem (I am a collegue of Matthes) seems not that easy to solve. At least for me...

We want to build a pattern that takes in general two events (types) as input. The pattern shall match if both events are found within a certain duration but the order does not matter. If I am correct your pattern would match if A arrives and B arrives within x seconds but not if B comes in first.

Thus I think the pattern we need would have to rely on AND as operator. The timer condition should work in a way that for a pattern 'every (A and B)' the timer starts counting if one of the events A or B was received and reset/stop the pattern after the specified duration. Then the every operator should restart the pattern.

The example Matthes gave above is a special case where A is the same as B.

Following Alex approach we could try a pattern like the following if there is no way to build it with touching A and B just once:
every ((A -> B where timer:within(...)) or (B -> A where timer:within(...)))


Thanks for your help,
Thomas

2009/9/23 Alexandre Vasseur <avasseur@...>
timer:within is good but you need to use a followed-by and not an and:
every (A -> B where timer:within(x seconds))
http://esper.codehaus.org/esper-3.2.0/doc/reference/en/html/event_patterns.html#pattern-temporal-followed-by
Alex


On Wed, Sep 23, 2009 at 12:46 PM, Matthes R. <m.rieke.mailing@...> wrote:
Hello everyone,

In my web-service the clients are able to make subscriptions to different things. one thing is to receive a notification if:

- cEvent happend
- another cEvent happens in the next x seconds.

I tried the following statement to realize this pattern:
"select cEvent as value from pattern [every (((cEvent=cEvent) and (cEvent=cEvent)) where timer:within(10000 msec))]".

But this statement starts directly after creation and waits 10 secs and then stops forever. Is there a way to "reset" it? Like starting every time when cEvent occurs and then waiting for 10 secs for another cEvent - then stopping, but starting again if a new cEvent comes in - independet from the initial start time of the statement? Is the timer:within a good solution or is there any other way to realize this problem?

Regards,
Matthes




--
Dipl.-Geoinf. Thomas Everding
Research Associate
Institute for Geoinformatics, University of Muenster
http://ifgi.uni-muenster.de
http://swsl.uni-muenster.de

Re: Understanding timer:within

by Matthes R.-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi again,

thx alex for your reply. i tried that modification of the pattern before and it did not work. i think the problem is that the statement is stopped forever after the x seconds. im afraid the pattern Thomas suggests will not fix this problem, or am i wrong?

regards,
Matthes

2009/9/23 Thomas Everding <t.everding@...>
Hi everyone!

Actually our problem (I am a collegue of Matthes) seems not that easy to solve. At least for me...

We want to build a pattern that takes in general two events (types) as input. The pattern shall match if both events are found within a certain duration but the order does not matter. If I am correct your pattern would match if A arrives and B arrives within x seconds but not if B comes in first.

Thus I think the pattern we need would have to rely on AND as operator. The timer condition should work in a way that for a pattern 'every (A and B)' the timer starts counting if one of the events A or B was received and reset/stop the pattern after the specified duration. Then the every operator should restart the pattern.

The example Matthes gave above is a special case where A is the same as B.

Following Alex approach we could try a pattern like the following if there is no way to build it with touching A and B just once:
every ((A -> B where timer:within(...)) or (B -> A where timer:within(...)))


Thanks for your help,
Thomas

2009/9/23 Alexandre Vasseur <avasseur@...>

timer:within is good but you need to use a followed-by and not an and:
every (A -> B where timer:within(x seconds))
http://esper.codehaus.org/esper-3.2.0/doc/reference/en/html/event_patterns.html#pattern-temporal-followed-by
Alex


On Wed, Sep 23, 2009 at 12:46 PM, Matthes R. <m.rieke.mailing@...> wrote:
Hello everyone,

In my web-service the clients are able to make subscriptions to different things. one thing is to receive a notification if:

- cEvent happend
- another cEvent happens in the next x seconds.

I tried the following statement to realize this pattern:
"select cEvent as value from pattern [every (((cEvent=cEvent) and (cEvent=cEvent)) where timer:within(10000 msec))]".

But this statement starts directly after creation and waits 10 secs and then stops forever. Is there a way to "reset" it? Like starting every time when cEvent occurs and then waiting for 10 secs for another cEvent - then stopping, but starting again if a new cEvent comes in - independet from the initial start time of the statement? Is the timer:within a good solution or is there any other way to realize this problem?

Regards,
Matthes




--
Dipl.-Geoinf. Thomas Everding
Research Associate
Institute for Geoinformatics, University of Muenster
http://ifgi.uni-muenster.de
http://swsl.uni-muenster.de


Re: Understanding timer:within

by Thomas Bernhardt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi Matthes,

are the A and B events not related to each other in some way? What is the relationship i.e. what makes them a pair (same property of what) or is it just arrival order?
If there is no relationship, it seems "every (A or B)" and why use a timer?

-Tom

From: Matthes R. <m.rieke.mailing@...>
To: user@...
Sent: Thursday, September 24, 2009 2:43:54 AM
Subject: Re: [esper-user] Understanding timer:within

Hi again,

thx alex for your reply. i tried that modification of the pattern before and it did not work. i think the problem is that the statement is stopped forever after the x seconds. im afraid the pattern Thomas suggests will not fix this problem, or am i wrong?

regards,
Matthes

2009/9/23 Thomas Everding <t.everding@...>
Hi everyone!

Actually our problem (I am a collegue of Matthes) seems not that easy to solve. At least for me...

We want to build a pattern that takes in general two events (types) as input. The pattern shall match if both events are found within a certain duration but the order does not matter. If I am correct your pattern would match if A arrives and B arrives within x seconds but not if B comes in first.

Thus I think the pattern we need would have to rely on AND as operator. The timer condition should work in a way that for a pattern 'every (A and B)' the timer starts counting if one of the events A or B was received and reset/stop the pattern after the specified duration. Then the every operator should restart the pattern.

The example Matthes gave above is a special case where A is the same as B.

Following Alex approach we could try a pattern like the following if there is no way to build it with touching A and B just once:
every ((A -> B where timer:within(...)) or (B -> A where timer:within(...)))


Thanks for your help,
Thomas

2009/9/23 Alexandre Vasseur <avasseur@...>

timer:within is good but you need to use a followed-by and not an and:
every (A -> B where timer:within(x seconds))
http://esper.codehaus.org/esper-3.2.0/doc/reference/en/html/event_patterns.html#pattern-temporal-followed-by
Alex


On Wed, Sep 23, 2009 at 12:46 PM, Matthes R. <m.rieke.mailing@...> wrote:
Hello everyone,

In my web-service the clients are able to make subscriptions to different things. one thing is to receive a notification if:

- cEvent happend
- another cEvent happens in the next x seconds.

I tried the following statement to realize this pattern:
"select cEvent as value from pattern [every (((cEvent=cEvent) and (cEvent=cEvent)) where timer:within(10000 msec))]".

But this statement starts directly after creation and waits 10 secs and then stops forever. Is there a way to "reset" it? Like starting every time when cEvent occurs and then waiting for 10 secs for another cEvent - then stopping, but starting again if a new cEvent comes in - independet from the initial start time of the statement? Is the timer:within a good solution or is there any other way to realize this problem?

Regards,
Matthes




--
Dipl.-Geoinf. Thomas Everding
Research Associate
Institute for Geoinformatics, University of Muenster
http://ifgi.uni-muenster.de
http://swsl.uni-muenster.de



Re: Understanding timer:within

by Thomas Everding :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Maybe an example from aeronautics may help to understand our problem:

Imagine three events that may occur during the flight of an aircraft: "altitude" events report the current flight altitude, "v_speed" events report the current vertical speed and "undercarriage" events report the status of the undercarriage.

Now we want to build a ground proximity warning system which releases an alert whenever the altitude is below 2000 feet, the plane is descending (v_speed below 0 feet / minute) and the undercarriage is not down and locked.

Without timing conditions this is very simple to solve as all events have to be connected using AND and property guards can do the rest (where altitude.value < 2000,...). But timing gets important when you want to have this system activated during the complete flight where the following order of event might occur:

//take off:
1. altitude: 0
2. v_speed > 0
3. undercarriage: d&l

//during the flight change to a lower altitude
4. altitude : 25.000
5. v_speed < 0
6. undercarriage: retracted

//pre-landing (warning situation)
7a. altitude: 1500
8a. v_speed < 0
9a. undercarriage: retracted

//pre-landing (no warning)
7b. altitude: 1500
8b. v_speed < 0
9b. undercarriage: d&l

When using a pattern without timing conditions it would match at number 6 because a low altitude was found (at the start, number 1), a descend was found (number 5) and the undercarriage was retracted (number 6). So we would get an false alert since the altitude is not dangerous anymore.

What we need in this case is a timer condition that checks if the three events that are used to satisfy the pattern occur within a certain (short) time. In the example above only the triple 7a, 8a and 9a should match.

In more generally we need patterns to be reset after a certain time if they were only partly matched. The duration shall start at the time when the first partly match is found.

Thanks,
Thomas

2009/9/24 Thomas Bernhardt <bernhardttom@...>
Hi Matthes,

are the A and B events not related to each other in some way? What is the relationship i.e. what makes them a pair (same property of what) or is it just arrival order?
If there is no relationship, it seems "every (A or B)" and why use a timer?

-Tom

From: Matthes R. <m.rieke.mailing@...>
To: user@...
Sent: Thursday, September 24, 2009 2:43:54 AM
Subject: Re: [esper-user] Understanding timer:within

Hi again,

thx alex for your reply. i tried that modification of the pattern before and it did not work. i think the problem is that the statement is stopped forever after the x seconds. im afraid the pattern Thomas suggests will not fix this problem, or am i wrong?

regards,
Matthes

2009/9/23 Thomas Everding <t.everding@...>
Hi everyone!

Actually our problem (I am a collegue of Matthes) seems not that easy to solve. At least for me...

We want to build a pattern that takes in general two events (types) as input. The pattern shall match if both events are found within a certain duration but the order does not matter. If I am correct your pattern would match if A arrives and B arrives within x seconds but not if B comes in first.

Thus I think the pattern we need would have to rely on AND as operator. The timer condition should work in a way that for a pattern 'every (A and B)' the timer starts counting if one of the events A or B was received and reset/stop the pattern after the specified duration. Then the every operator should restart the pattern.

The example Matthes gave above is a special case where A is the same as B.

Following Alex approach we could try a pattern like the following if there is no way to build it with touching A and B just once:
every ((A -> B where timer:within(...)) or (B -> A where timer:within(...)))


Thanks for your help,
Thomas

2009/9/23 Alexandre Vasseur <avasseur@...>

timer:within is good but you need to use a followed-by and not an and:
every (A -> B where timer:within(x seconds))
http://esper.codehaus.org/esper-3.2.0/doc/reference/en/html/event_patterns.html#pattern-temporal-followed-by
Alex


On Wed, Sep 23, 2009 at 12:46 PM, Matthes R. <m.rieke.mailing@...> wrote:
Hello everyone,

In my web-service the clients are able to make subscriptions to different things. one thing is to receive a notification if:

- cEvent happend
- another cEvent happens in the next x seconds.

I tried the following statement to realize this pattern:
"select cEvent as value from pattern [every (((cEvent=cEvent) and (cEvent=cEvent)) where timer:within(10000 msec))]".

But this statement starts directly after creation and waits 10 secs and then stops forever. Is there a way to "reset" it? Like starting every time when cEvent occurs and then waiting for 10 secs for another cEvent - then stopping, but starting again if a new cEvent comes in - independet from the initial start time of the statement? Is the timer:within a good solution or is there any other way to realize this problem?

Regards,
Matthes




--
Dipl.-Geoinf. Thomas Everding
Research Associate
Institute for Geoinformatics, University of Muenster
http://ifgi.uni-muenster.de
http://swsl.uni-muenster.de





--
Dipl.-Geoinf. Thomas Everding
Research Associate
Institute for Geoinformatics, University of Muenster
http://ifgi.uni-muenster.de
http://swsl.uni-muenster.de

Re: Understanding timer:within

by Thomas Bernhardt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
The trick is to combine timer:interval and the not-operator with the timer:within, and use the right "every" to control pattern life cycle, plus the filters for the events and their properties of course. I does take a little time and testing to get it right and within the user group we often get asked to provide a complete solution.
Best regards,
Tom

From: Thomas Everding <t.everding@...>
To: user@...
Sent: Thursday, September 24, 2009 7:20:49 AM
Subject: Re: [esper-user] Understanding timer:within

Hi!

Maybe an example from aeronautics may help to understand our problem:

Imagine three events that may occur during the flight of an aircraft: "altitude" events report the current flight altitude, "v_speed" events report the current vertical speed and "undercarriage" events report the status of the undercarriage.

Now we want to build a ground proximity warning system which releases an alert whenever the altitude is below 2000 feet, the plane is descending (v_speed below 0 feet / minute) and the undercarriage is not down and locked.

Without timing conditions this is very simple to solve as all events have to be connected using AND and property guards can do the rest (where altitude.value < 2000,...). But timing gets important when you want to have this system activated during the complete flight where the following order of event might occur:

//take off:
1. altitude: 0
2. v_speed > 0
3. undercarriage: d&l

//during the flight change to a lower altitude
4. altitude : 25.000
5. v_speed < 0
6. undercarriage: retracted

//pre-landing (warning situation)
7a. altitude: 1500
8a. v_speed < 0
9a. undercarriage: retracted

//pre-landing (no warning)
7b. altitude: 1500
8b. v_speed < 0
9b. undercarriage: d&l

When using a pattern without timing conditions it would match at number 6 because a low altitude was found (at the start, number 1), a descend was found (number 5) and the undercarriage was retracted (number 6). So we would get an false alert since the altitude is not dangerous anymore.

What we need in this case is a timer condition that checks if the three events that are used to satisfy the pattern occur within a certain (short) time. In the example above only the triple 7a, 8a and 9a should match.

In more generally we need patterns to be reset after a certain time if they were only partly matched. The duration shall start at the time when the first partly match is found.

Thanks,
Thomas

2009/9/24 Thomas Bernhardt <bernhardttom@...>
Hi Matthes,

are the A and B events not related to each other in some way? What is the relationship i.e. what makes them a pair (same property of what) or is it just arrival order?
If there is no relationship, it seems "every (A or B)" and why use a timer?

-Tom

From: Matthes R. <m.rieke.mailing@...>
To: user@...
Sent: Thursday, September 24, 2009 2:43:54 AM
Subject: Re: [esper-user] Understanding timer:within

Hi again,

thx alex for your reply. i tried that modification of the pattern before and it did not work. i think the problem is that the statement is stopped forever after the x seconds. im afraid the pattern Thomas suggests will not fix this problem, or am i wrong?

regards,
Matthes

2009/9/23 Thomas Everding <t.everding@...>
Hi everyone!

Actually our problem (I am a collegue of Matthes) seems not that easy to solve. At least for me...

We want to build a pattern that takes in general two events (types) as input. The pattern shall match if both events are found within a certain duration but the order does not matter. If I am correct your pattern would match if A arrives and B arrives within x seconds but not if B comes in first.

Thus I think the pattern we need would have to rely on AND as operator. The timer condition should work in a way that for a pattern 'every (A and B)' the timer starts counting if one of the events A or B was received and reset/stop the pattern after the specified duration. Then the every operator should restart the pattern.

The example Matthes gave above is a special case where A is the same as B.

Following Alex approach we could try a pattern like the following if there is no way to build it with touching A and B just once:
every ((A -> B where timer:within(...)) or (B -> A where timer:within(...)))


Thanks for your help,
Thomas

2009/9/23 Alexandre Vasseur <avasseur@...>

timer:within is good but you need to use a followed-by and not an and:
every (A -> B where timer:within(x seconds))
http://esper.codehaus.org/esper-3.2.0/doc/reference/en/html/event_patterns.html#pattern-temporal-followed-by
Alex


On Wed, Sep 23, 2009 at 12:46 PM, Matthes R. <m.rieke.mailing@...> wrote:
Hello everyone,

In my web-service the clients are able to make subscriptions to different things. one thing is to receive a notification if:

- cEvent happend
- another cEvent happens in the next x seconds.

I tried the following statement to realize this pattern:
"select cEvent as value from pattern [every (((cEvent=cEvent) and (cEvent=cEvent)) where timer:within(10000 msec))]".

But this statement starts directly after creation and waits 10 secs and then stops forever. Is there a way to "reset" it? Like starting every time when cEvent occurs and then waiting for 10 secs for another cEvent - then stopping, but starting again if a new cEvent comes in - independet from the initial start time of the statement? Is the timer:within a good solution or is there any other way to realize this problem?

Regards,
Matthes




--
Dipl.-Geoinf. Thomas Everding
Research Associate
Institute for Geoinformatics, University of Muenster
http://ifgi.uni-muenster.de
http://swsl.uni-muenster.de





--
Dipl.-Geoinf. Thomas Everding
Research Associate
Institute for Geoinformatics, University of Muenster
http://ifgi.uni-muenster.de
http://swsl.uni-muenster.de