def loop(): node = Service('node') apps = ['Echo{}'.format(i) for i in xrange(1, 2)] channels = dict() #for a in apps: # print ('registering app {}'.format(a)) # channels[a] = yield node.control(a) ch = yield node.control('Echo1') print('before seq') #yield [ch.tx.write(sin_square(AMPH, t * 10)) for t in xrange(1,10)] print('DONE after seq') x = 0.0 while True: try: print('Sending control.') # yield [channels[a].tx.write(sin_square(AMPH, x)) for a in apps] yield ch.tx.write(sin_square(AMPH, 10)) except Exception as e: print 'error {}'.format(e) yield gen.sleep(ERR_SLEEP) ch = yield node.control('Echo1') else: print 'control is done' yield gen.sleep(LOOP_TO) x += DELTA
def control(times): node = Service('node') logger = Service('logging') try: ch = yield node.start_app(APP_NAME, PROFILE) result = yield ch.rx.get() print('start res {}'.format(result)) yield logger.emit except Exception: pass control_channel = yield node.control(APP_NAME) for i in xrange(0, times): # print('running {}'.format(i)) yield control_channel.tx.write(i % 10)