Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import print_function
- from __future__ import unicode_literals
- from twisted.internet.defer import inlineCallbacks
- from twisted.logger import Logger
- from autobahn.twisted.util import sleep
- from autobahn.twisted.wamp import ApplicationSession
- import time
- import json
- #generator that yields values from file
- def ekg_gen(f):
- row = f.readline()
- while row:
- yield row
- row = f.readline()
- if len(row) == 0:
- f.seek(0,0)
- row = f.readline()
- class AppSession(ApplicationSession):
- log = Logger()
- @inlineCallbacks
- def onJoin(self, details):
- self.log.info("ECG node up")
- with open("../ECG_data.txt", "r") as f: #simulated sample of an ECG-curve
- value = ekg_gen(f)
- while True:
- yield self.publish('com.testlab.ecg_update', json.dumps(next(value)))
- yield sleep(0.02)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement