def test_api(self, crossbar): publish_opt = PublishOptions(exclude_me=False) @register('api.api.rpc') def rpc(): self.rpc_called = True @subscribe('api.api.event') def sub(): self.sub_called = True with pytest.raises(NotRunningError): call('api.api.rpc') with pytest.raises(NotRunningError): publish('api.api.event', options=publish_opt) assert not self.rpc_called assert not self.sub_called run() call('api.api.rpc') publish('api.api.event', options=publish_opt) sleep(0.1) # Dirty way to wait for on_event to be called... assert self.rpc_called assert self.sub_called
def main(args): url = u'ws://{}:{}/ws'.format(args.host, args.port) print('Connecting to "{}".'.format(url)) autobahn_sync.run(url=url, realm=args.realm) try: Shell(autobahn_sync.call).cmdloop() except KeyboardInterrupt: print('Shutting down.')
from time import sleep from autobahn_sync import publish, run from devices.kpro import Kpro from devices.time import Time from devices.odometer import Odometer from mapper import Mapper while True: try: run() break except: continue kpro = Kpro() time = Time() odo = Odometer() map = Mapper() iat_unit = map.get_unit('iat') ect_unit = map.get_unit('ect') vss_unit = map.get_unit('vss') o2_unit = map.get_unit('o2') map_unit = map.get_unit('map') an0_unit = map.get_unit('an0') an0_formula = map.get_formula('an0') an1_unit = map.get_unit('an1') an1_formula = map.get_formula('an1') an2_unit = map.get_unit('an2')
def main(): autobahn_sync.run(blocking=True, authid="app", authmethods=[u"ticket"])
import random from time import sleep from autobahn_sync import publish, run from devices.formula import Formula from devices.odometer import Odometer from devices.time import Time run() time = Time() odo = Odometer() while True: odo.save(random.randint(0, 200)) publish('com.app.idea', {'bat': random.uniform(0, 15), 'map': {'bar': random.uniform(0, 2), 'mbar': random.uniform(0, 2), 'psi': random.uniform(0, 2)}, 'gear': random.randint(0, 6), 'iat': {'celsius': random.randint(0, 50), 'fahrenheit': random.randint(0, 50)}, 'tps': random.randint(0, 100), 'ect': {'celsius': random.randint(0, 50), 'fahrenheit': random.randint(0, 50)}, 'rpm': random.randint(0, 9000), 'vss': {'kmh': random.randint(0, 200), 'mph': random.randint(0, 200)}, 'o2': {'afr': random.uniform(0, 20), 'lambda': random.uniform(0, 1)}, 'cam': random.randint(0, 50), 'mil': random.choice([True, False]), 'bksw': random.choice([True, False]), 'an0': Formula.psi_to_bar(Formula.ebay_150_psi(random.uniform(0, 5))), 'an1': Formula.autometer_2246(random.uniform(0, 5)), 'an2': random.uniform(0, 5), 'an3': random.uniform(0, 5),