Kinda working

This commit is contained in:
2022-11-01 13:38:17 +01:00
parent 49c70b08b8
commit bafa1ceead
3 changed files with 25 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ root_content_path = 'dashboard_static'
# 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")
start_offline_tweets('sports1.txt', event_name="tweet")
ctx.count = 0
# fire('sample', {'previous': 0.0})
@@ -21,21 +21,22 @@ def setup(ctx, e):
def clip(lower, value, upper):
return max(lower, min(value, upper))
@event('sample')
def generate_sample(ctx, e):
@event('tweet')
def generate_tweet(ctx, e):
ctx.count += 1
if ctx.count % 50 == 0:
emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'})
print('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)
# emit to outside world
emit('sample',{
emit('tweet', {
'action': 'add',
'value': tweet
})
# chain event
fire('sample', {'previous': tweet}, delay=0.05)
# # chain event
# fire('tweet', {'previous': tweet}, delay=0.05)