def setUp(self): self.ib = ipaaca.InputBuffer('TestIn', ['sensorcategory', 'decisioncategory']) self.ob = ipaaca.OutputBuffer('TestOut') self.sensor_iu = ipaaca.IU('sensorcategory') self.sensor_iu.payload = {'data': 'sensordata'} self.ob.add(self.sensor_iu)
def __init__(self): self.ob = ipaaca.OutputBuffer('PingOut') self.iu = ipaaca.IU('ping') self.iu.payload = {'data': '0'} self.ob.add(self.iu) self.ob.register_handler(self.handle_iu_event) self.counter = 0 self.last_time = time.time()
def setUp(self): self.ib = ipaaca.InputBuffer('TestIn', ['sensorcategory']) self.ib.register_handler(handle_iu_event) self.ob = ipaaca.OutputBuffer('TestOut') self.sensor_iu = ipaaca.IU('sensorcategory') self.sensor_iu.payload = {'data': 'sensordata'} time.sleep(0.1) self.ob.add(self.sensor_iu) time.sleep(0.1)
def publish_new_word(self, word): previous_iu = self.find_last_iu() iu = ipaaca.IU(SEND_CATEGORY) iu.payload = {'WORD': word} self.ob.add(iu) if previous_iu is not None: previous_iu.add_links('SUCCESSOR', [iu.uid]) iu.add_links('PREDECESSOR', [previous_iu.uid]) return iu.uid
def __init__(self, send_frequency): self.ob = ipaaca.OutputBuffer('PowerOut') self.iu = ipaaca.IU('spam') self.data_prefix = 'A' * 1024 self.iu.payload = {'data': '0'} self.ob.add(self.iu) self.counter = 0 self.frequency = send_frequency self.delay = 1.0 / send_frequency
def testSetSingleLink(self): time.sleep(0.1) self.decision_iu = ipaaca.IU('decisioncategory') self.decision_iu.payload = {'data': 'decision'} self.decision_iu.set_links({'grin': [self.sensor_iu.uid]}) self.ob.add(self.decision_iu) time.sleep(0.1) # test received version hc.assert_that(self.ib.iu_store, hc.has_key(self.decision_iu.uid)) received_iu = self.ib.iu_store[self.decision_iu.uid] grinlinks = received_iu.get_links('grin') hc.assert_that(grinlinks, hc.has_item(self.sensor_iu.uid)) self.assertEqual(len(grinlinks), 1)
def publish_text_to_print(self, text, parent_iu_uid=None): previous_iu = self.find_last_iu() if previous_iu is not None: # insert a blank if we already have words in the buffer iu = ipaaca.IU(SEND_CATEGORY) iu.payload = {'CONTENT': ' '} self.ob.add(iu) previous_iu.add_links('SUCCESSOR', [iu.uid]) iu.add_links('PREDECESSOR', [previous_iu.uid]) if parent_iu_uid is not None: iu.add_links('GRIN', [parent_iu_uid]) previous_iu = iu for c in text: iu = ipaaca.IU(SEND_CATEGORY) iu.payload = {'CONTENT': c} self.ob.add(iu) if previous_iu is not None: previous_iu.add_links('SUCCESSOR', [iu.uid]) iu.add_links('PREDECESSOR', [previous_iu.uid]) if parent_iu_uid is not None: iu.add_links('GRIN', [parent_iu_uid]) if previous_iu is not None: print previous_iu.get_all_links() previous_iu = iu
def setUp(self): self.ib = ipaaca.InputBuffer('TestIn', ['sensorcategory']) self.ob = ipaaca.OutputBuffer('TestOut') self.iu = ipaaca.IU('sensorcategory')
import time import logging import ipaaca iu_to_write = None def my_update_handler(iu, event_type, local): global iu_to_write print(event_type + ': ' + str(iu)) iu_to_write = iu ob = ipaaca.OutputBuffer('CoolListenerOut') my_iu = ipaaca.IU() my_iu.payload = {'some': 'info'} ob.add(my_iu) ib = ipaaca.InputBuffer('CoolListenerIn', ['undef']) ib.register_handler(my_update_handler) counter = 0 #time.sleep(5) while True: if iu_to_write is not None: try: counter += 1 iu = iu_to_write #if counter == 1: # iu.payload['a'] = 'remote'
# Forschungsgemeinschaft (DFG) in the context of the German # Excellence Initiative. import time import ipaaca def remote_change_dumper(iu, event_type, local): if local: print 'remote side ' + event_type + ': ' + str(iu) ob = ipaaca.OutputBuffer('CoolInformerOut') ob.register_handler(remote_change_dumper) iu_top = ipaaca.IU() iu_top.payload = {'data': 'raw'} ob.add(iu_top) iu = ipaaca.IU() iu.payload = {'a': 'a1'} ob.add(iu) iu.payload = {'a': 'a2', 'b': 'b1'} #OK del (iu.payload['b']) iu.payload['c'] = 'c1' iu.payload['a'] = 'a3' iu.add_links('sameold', iu_top.uid) time.sleep(1) iu.commit()