Changes between Version 1 and Version 2 of IpaacaTutorial


Ignore:
Timestamp:
12/10/13 11:46:31 (6 years ago)
Author:
yaghoubzadeh
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IpaacaTutorial

    v1 v2  
    1010An IU is an object characterized by the following basic attributes: 
    1111* ''uid'' - a globally unique identifier 
    12 * ''category'' - a string representing the broad category of data, e.g. "asrresults" for transmitting the results of ASR 
     12* '''''category''''' - a string representing the broad category of data, e.g. "asrresults" for transmitting the results of ASR 
    1313* ''owner'' - the buffer name (see below) that initially produced this IU 
    14 * ''payload'' - the IU payload: a hash of string->string, free to use by the application 
     14* ''committed'' - a flag that specifies whether the owner is committed to this IU and its contents (that it will remain valid and is final) 
     15* '''''payload''''' - the IU payload: a hash of string->string, free to use by the application 
    1516* ''links'' - a hash of string->string, representing the links of the IU (see below) 
    1617 
     
    3435corresponding !InputBuffers will receive a notification of this, along with the updated IU contents. 
    3536 
     37Changes to IUs that are not marked as read-only can be effected at both ends of the pipeline: by simply writing to an IU present in a Buffer. 
     38When an IU has been written to from the remote side, the owner of that IU will also be able to receive a notification of this on the !OutputBuffer where the IU was originally placed. 
     39IUs that have not yet been published can be written to at leisure without generating any events anywhere. 
     40 
     41== Full minimal code examples with annotations == 
     42 
     43[[span(style=color: #a0a0a0, `grey`)]] \\ 
     44[[span(style=color: #a0a0a0, `grey`)]] \\ 
     45 
     46{{{ 
     47import ipaaca 
     48import time 
     49 
     50def my_first_iu_handler(iu, event_type, local): 
     51        if event_type in ['ADDED', 'MESSAGE']: 
     52                print( u'Received a new IU or Message of category: ' + iu.category ) 
     53                print( u'  The UID is: ' + iu.uid ) 
     54                print( u'  The payload is: ' + unicode(iu.payload) ) 
     55                 
     56 
     57my_inbuffer = ipaaca.InputBuffer('MyArbitraryName', ['interestingCategory']) 
     58my_inbuffer.register_handler(my_first_iu_handler) 
     59 
     60print('Doing nothing and waiting for IUs (or you to press Ctrl-C) ...') 
     61while True: 
     62        time.sleep(1) 
     63}}} 
     64 
     65