This commit is contained in:
Tim Wijma
2022-10-31 17:14:36 +01:00
18 changed files with 10 additions and 7 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
./sports1.txt

View File

@@ -1,18 +1,20 @@
from eca import *
from eca.generators import start_offline_tweets
import random
## You might have to update the root path to point to the correct path
## (by default, it points to <rules>_static)
# root_content_path = 'template_static'
root_content_path = 'dashboard_static'
# binds the 'setup' function as the action for the 'init' event
# the action will be called with the context and the event
@event('init')
def setup(ctx, e):
start_offline_tweets('sports1.txt', event_name="sample")
ctx.count = 0
fire('sample', {'previous': 0.0})
# fire('sample', {'previous': 0.0})
# define a normal Python function
@@ -24,16 +26,16 @@ def generate_sample(ctx, e):
ctx.count += 1
if ctx.count % 50 == 0:
emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'})
tweet = e.data
print(tweet)
# base sample on previous one
sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100)
# sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100)
# emit to outside world
emit('sample',{
'action': 'add',
'value': sample
'value': tweet
})
# chain event
fire('sample', {'previous': sample}, delay=0.05)
fire('sample', {'previous': tweet}, delay=0.05)