Skip to content
Snippets Groups Projects
Commit 4bbaf470 authored by Herwin van Welbergen's avatar Herwin van Welbergen
Browse files

added further methods of the map interface

parent ca913881
No related branches found
No related tags found
No related merge requests found
......@@ -8,10 +8,12 @@ import ipaaca.LocalIU;
import ipaaca.OutputBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
......@@ -78,11 +80,11 @@ public class Blackboard
return iu.getPayload().put(key, value);
}
public void putAll(Map<String,String> newItems)
public void putAll(Map<String, String> newItems)
{
iu.getPayload().putAll(newItems);
}
/**
* Get the value corresponding to the key, or null if it is not available
*/
......@@ -95,4 +97,19 @@ public class Blackboard
{
listeners.add(listener);
}
public Set<String> keySet()
{
return iu.getPayload().keySet();
}
public Set<Map.Entry<String, String>> entrySet()
{
return iu.getPayload().entrySet();
}
public Collection<String> values()
{
return iu.getPayload().values();
}
}
#!/usr/bin/env python
import ipaaca
print "{this is the IpaacaPython run.py doing nothing at all}"
#!/usr/bin/env python
# This file is part of IPAACA, the
# "Incremental Processing Architecture
# for Artificial Conversational Agents".
#
# Copyright (c) 2009-2013 Sociable Agents Group
# CITEC, Bielefeld University
#
# http://opensource.cit-ec.de/projects/ipaaca/
# http://purl.org/net/ipaaca
#
# This file may be licensed under the terms of of the
# GNU Lesser General Public License Version 3 (the ``LGPL''),
# or (at your option) any later version.
#
# Software distributed under the License is distributed
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
# express or implied. See the LGPL for the specific language
# governing rights and limitations.
#
# You should have received a copy of the LGPL along with this
# program. If not, go to http://www.gnu.org/licenses/lgpl.html
# or write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The development of this software was supported by the
# Excellence Cluster EXC 277 Cognitive Interaction Technology.
# The Excellence Cluster EXC 277 is a grant of the Deutsche
# 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()
while True:
time.sleep(1)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of IPAACA, the
# "Incremental Processing Architecture
# for Artificial Conversational Agents".
#
# Copyright (c) 2009-2013 Sociable Agents Group
# CITEC, Bielefeld University
#
# http://opensource.cit-ec.de/projects/ipaaca/
# http://purl.org/net/ipaaca
#
# This file may be licensed under the terms of of the
# GNU Lesser General Public License Version 3 (the ``LGPL''),
# or (at your option) any later version.
#
# Software distributed under the License is distributed
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
# express or implied. See the LGPL for the specific language
# governing rights and limitations.
#
# You should have received a copy of the LGPL along with this
# program. If not, go to http://www.gnu.org/licenses/lgpl.html
# or write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The development of this software was supported by the
# Excellence Cluster EXC 277 Cognitive Interaction Technology.
# The Excellence Cluster EXC 277 is a grant of the Deutsche
# Forschungsgemeinschaft (DFG) in the context of the German
# Excellence Initiative.
import logging
import sys
import time
import os
import platform
import ipaaca
def my_update_handler(iu, event_type, local):
print(event_type+': '+str(iu))
if len(sys.argv)<2:
print "Please use the program as follows:"
print " "+sys.argv[0]+" [--class IU|Message] [--timeout <sec>] <categoryname> [<payloadkey> <payloadvalue>] [<k2> <v2>] ..."
sys.exit(1)
iu_class = 'Message'
timeout = 3.0
idx = 1
keep_going = True
while keep_going:
keep_going = False
if sys.argv[idx]=='--class':
t = sys.argv[idx+1]
if t in ['Message', 'IU']:
iu_class = t
else:
print "Unknown IU class: "+t
sys.exit(1)
idx += 2
keep_going = True
elif sys.argv[idx]=='--timeout':
timeout = float(sys.argv[idx+1])
idx += 2
keep_going = True
cate = sys.argv[idx]
idx += 1
pl={}
while len(sys.argv)>idx+1:
pl[sys.argv[idx]] = sys.argv[idx+1]
idx+=2
try:
print "Sending "+iu_class+" of category "+cate
print " with payload "+str(pl)
ob = ipaaca.OutputBuffer('IUInjector')
ob.register_handler(my_update_handler)
iu_top = ipaaca.IU(cate)
iu_top.payload = pl
ob.add(iu_top)
print iu_class+" sent."
if iu_class=="IU":
print "Waiting "+str(timeout)+" sec for remote modifications..."
time.sleep(timeout)
else:
time.sleep(0.1)
print "done."
except KeyboardInterrupt:
pass
if platform.system() == 'Windows':
os._exit(0)
else:
sys.exit(0)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of IPAACA, the
# "Incremental Processing Architecture
# for Artificial Conversational Agents".
#
# Copyright (c) 2009-2013 Sociable Agents Group
# CITEC, Bielefeld University
#
# http://opensource.cit-ec.de/projects/ipaaca/
# http://purl.org/net/ipaaca
#
# This file may be licensed under the terms of of the
# GNU Lesser General Public License Version 3 (the ``LGPL''),
# or (at your option) any later version.
#
# Software distributed under the License is distributed
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
# express or implied. See the LGPL for the specific language
# governing rights and limitations.
#
# You should have received a copy of the LGPL along with this
# program. If not, go to http://www.gnu.org/licenses/lgpl.html
# or write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The development of this software was supported by the
# Excellence Cluster EXC 277 Cognitive Interaction Technology.
# The Excellence Cluster EXC 277 is a grant of the Deutsche
# Forschungsgemeinschaft (DFG) in the context of the German
# Excellence Initiative.
from __future__ import print_function
import logging
import re
import sys
import time
import os
import platform
import ipaaca
color = False
regex = False
max_size = 2048
def highlight_if_color(s, c='1'):
return s if not color else '['+c+'m'+s+''
def pretty_printed_iu_payload(iu):
s='{ '
for k,v in iu.payload.items():
v2 = (('\''+v+'\'') if len(v)<=max_size else ('\''+v[:max_size]+'\'<excess length omitted>')).replace('\\','\\\\').replace('\n',highlight_if_color('\\n'))
s += '\n' + '\t\t\'' + highlight_if_color(unicode(k),'1')+'\': '+unicode(v2)+', '
s+=' }'
return s
def event_type_color(typ):
colors={'ADDED':'32;1', 'RETRACTED':'31;1', 'UPDATED':'33;1', 'MESSAGE':'34;1'}
return '1' if typ not in colors else colors[typ]
def pretty_printed_iu_event(iu, event_type, local):
s=''
t=time.time()
lt=time.localtime(t)
s += highlight_if_color('%.3f'%t, '1')+' '+"%02d:%02d:%02d"%(lt.tm_hour, lt.tm_min, lt.tm_sec)
s += ' '+highlight_if_color('%-9s'%event_type,event_type_color(event_type))+' category='+highlight_if_color(iu.category,event_type_color(event_type))+' uid='+iu.uid+' owner='+iu.owner_name+' payload='+pretty_printed_iu_payload(iu)
return s
def my_update_handler(iu, event_type, local):
if regex:
for cat in cats: # actually now regexs, not cats
if re.match(cat, iu.category):
break
else:
return
t=time.localtime()
print(pretty_printed_iu_event(iu, event_type, local))
cats = []
keep_going=True
idx = 1
while keep_going:
opt = sys.argv[idx] if idx<len(sys.argv) else None
if opt=='--help':
print('IU sniffer - usage:')
print(' '+sys.argv[0]+' [--options] [<category1> [<category2 ...]]')
print(' Listen to specified categories (default: all)')
print(' Option --color : colorize output')
print(' Option --regex : match categories by regular expressions')
print(' Option --size-limit <size> : limit payload display, chars (def: 2048)')
sys.exit(0)
elif opt=='--color':
color = True
idx += 1
elif opt=='--regex':
regex = True
idx += 1
elif opt=='--size-limit':
if len(sys.argv)<idx+2:
print('Please specify a max size')
sys.exit(1)
max_size = int(sys.argv[idx+1])
idx += 2
else:
cats = sys.argv[idx:]
keep_going = False
ib = ipaaca.InputBuffer('SnifferIn', [''] if (len(cats) == 0 or regex) else cats)
ib.register_handler(my_update_handler)
print('')
print('Ipaaca IU Sniffer - run with --help to see options')
print('Listening for IU events of ', end='')
if len(cats) == 0:
print('any category ...')
else:
if regex:
print('whose category matches one of the regexes:')
else:
print('categories:')
for cat in cats:
print('\t' + cat)
print('')
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
if platform.system() == 'Windows':
os._exit(0)
else:
sys.exit(0)
# Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='ipaaca.proto',
package='ipaaca.protobuf',
serialized_pb='\n\x0cipaaca.proto\x12\x0fipaaca.protobuf\"\x1b\n\nIntMessage\x12\r\n\x05value\x18\x01 \x02(\x11\"(\n\x07LinkSet\x12\x0c\n\x04type\x18\x01 \x02(\t\x12\x0f\n\x07targets\x18\x02 \x03(\t\"<\n\x0bPayloadItem\x12\x0b\n\x03key\x18\x01 \x02(\t\x12\r\n\x05value\x18\x02 \x02(\t\x12\x11\n\x04type\x18\x03 \x02(\t:\x03str\"\xe3\x02\n\x02IU\x12\x0b\n\x03uid\x18\x01 \x02(\t\x12\x10\n\x08revision\x18\x02 \x02(\r\x12\x17\n\x08\x63\x61tegory\x18\x03 \x02(\t:\x05undef\x12\x19\n\x0cpayload_type\x18\x04 \x02(\t:\x03MAP\x12\x12\n\nowner_name\x18\x05 \x02(\t\x12\x18\n\tcommitted\x18\x06 \x02(\x08:\x05\x66\x61lse\x12\x39\n\x0b\x61\x63\x63\x65ss_mode\x18\x07 \x02(\x0e\x32\x1e.ipaaca.protobuf.IU.AccessMode:\x04PUSH\x12\x18\n\tread_only\x18\x08 \x02(\x08:\x05\x66\x61lse\x12-\n\x07payload\x18\t \x03(\x0b\x32\x1c.ipaaca.protobuf.PayloadItem\x12\'\n\x05links\x18\n \x03(\x0b\x32\x18.ipaaca.protobuf.LinkSet\"/\n\nAccessMode\x12\x08\n\x04PUSH\x10\x00\x12\n\n\x06REMOTE\x10\x01\x12\x0b\n\x07MESSAGE\x10\x02\"\xa7\x01\n\x0fIUPayloadUpdate\x12\x0b\n\x03uid\x18\x01 \x02(\t\x12\x10\n\x08revision\x18\x02 \x02(\r\x12/\n\tnew_items\x18\x03 \x03(\x0b\x32\x1c.ipaaca.protobuf.PayloadItem\x12\x16\n\x0ekeys_to_remove\x18\x04 \x03(\t\x12\x17\n\x08is_delta\x18\x05 \x02(\x08:\x05\x66\x61lse\x12\x13\n\x0bwriter_name\x18\x06 \x02(\t\"-\n\x0cIURetraction\x12\x0b\n\x03uid\x18\x01 \x02(\t\x12\x10\n\x08revision\x18\x02 \x02(\r\"B\n\x0cIUCommission\x12\x0b\n\x03uid\x18\x01 \x02(\t\x12\x10\n\x08revision\x18\x02 \x02(\r\x12\x13\n\x0bwriter_name\x18\x03 \x02(\t\"\xbb\x01\n\x0cIULinkUpdate\x12\x0b\n\x03uid\x18\x01 \x02(\t\x12\x10\n\x08revision\x18\x02 \x02(\r\x12+\n\tnew_links\x18\x03 \x03(\x0b\x32\x18.ipaaca.protobuf.LinkSet\x12\x31\n\x0flinks_to_remove\x18\x04 \x03(\x0b\x32\x18.ipaaca.protobuf.LinkSet\x12\x17\n\x08is_delta\x18\x05 \x02(\x08:\x05\x66\x61lse\x12\x13\n\x0bwriter_name\x18\x06 \x02(\t')
_IU_ACCESSMODE = descriptor.EnumDescriptor(
name='AccessMode',
full_name='ipaaca.protobuf.IU.AccessMode',
filename=None,
file=DESCRIPTOR,
values=[
descriptor.EnumValueDescriptor(
name='PUSH', index=0, number=0,
options=None,
type=None),
descriptor.EnumValueDescriptor(
name='REMOTE', index=1, number=1,
options=None,
type=None),
descriptor.EnumValueDescriptor(
name='MESSAGE', index=2, number=2,
options=None,
type=None),
],
containing_type=None,
options=None,
serialized_start=475,
serialized_end=522,
)
_INTMESSAGE = descriptor.Descriptor(
name='IntMessage',
full_name='ipaaca.protobuf.IntMessage',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='value', full_name='ipaaca.protobuf.IntMessage.value', index=0,
number=1, type=17, cpp_type=1, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=33,
serialized_end=60,
)
_LINKSET = descriptor.Descriptor(
name='LinkSet',
full_name='ipaaca.protobuf.LinkSet',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='type', full_name='ipaaca.protobuf.LinkSet.type', index=0,
number=1, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='targets', full_name='ipaaca.protobuf.LinkSet.targets', index=1,
number=2, type=9, cpp_type=9, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=62,
serialized_end=102,
)
_PAYLOADITEM = descriptor.Descriptor(
name='PayloadItem',
full_name='ipaaca.protobuf.PayloadItem',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='key', full_name='ipaaca.protobuf.PayloadItem.key', index=0,
number=1, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='value', full_name='ipaaca.protobuf.PayloadItem.value', index=1,
number=2, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='type', full_name='ipaaca.protobuf.PayloadItem.type', index=2,
number=3, type=9, cpp_type=9, label=2,
has_default_value=True, default_value=unicode("str", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=104,
serialized_end=164,
)
_IU = descriptor.Descriptor(
name='IU',
full_name='ipaaca.protobuf.IU',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='uid', full_name='ipaaca.protobuf.IU.uid', index=0,
number=1, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='revision', full_name='ipaaca.protobuf.IU.revision', index=1,
number=2, type=13, cpp_type=3, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='category', full_name='ipaaca.protobuf.IU.category', index=2,
number=3, type=9, cpp_type=9, label=2,
has_default_value=True, default_value=unicode("undef", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='payload_type', full_name='ipaaca.protobuf.IU.payload_type', index=3,
number=4, type=9, cpp_type=9, label=2,
has_default_value=True, default_value=unicode("MAP", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='owner_name', full_name='ipaaca.protobuf.IU.owner_name', index=4,
number=5, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='committed', full_name='ipaaca.protobuf.IU.committed', index=5,
number=6, type=8, cpp_type=7, label=2,
has_default_value=True, default_value=False,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='access_mode', full_name='ipaaca.protobuf.IU.access_mode', index=6,
number=7, type=14, cpp_type=8, label=2,
has_default_value=True, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='read_only', full_name='ipaaca.protobuf.IU.read_only', index=7,
number=8, type=8, cpp_type=7, label=2,
has_default_value=True, default_value=False,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='payload', full_name='ipaaca.protobuf.IU.payload', index=8,
number=9, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='links', full_name='ipaaca.protobuf.IU.links', index=9,
number=10, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
_IU_ACCESSMODE,
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=167,
serialized_end=522,
)
_IUPAYLOADUPDATE = descriptor.Descriptor(
name='IUPayloadUpdate',
full_name='ipaaca.protobuf.IUPayloadUpdate',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='uid', full_name='ipaaca.protobuf.IUPayloadUpdate.uid', index=0,
number=1, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='revision', full_name='ipaaca.protobuf.IUPayloadUpdate.revision', index=1,
number=2, type=13, cpp_type=3, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='new_items', full_name='ipaaca.protobuf.IUPayloadUpdate.new_items', index=2,
number=3, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='keys_to_remove', full_name='ipaaca.protobuf.IUPayloadUpdate.keys_to_remove', index=3,
number=4, type=9, cpp_type=9, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='is_delta', full_name='ipaaca.protobuf.IUPayloadUpdate.is_delta', index=4,
number=5, type=8, cpp_type=7, label=2,
has_default_value=True, default_value=False,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='writer_name', full_name='ipaaca.protobuf.IUPayloadUpdate.writer_name', index=5,
number=6, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=525,
serialized_end=692,
)
_IURETRACTION = descriptor.Descriptor(
name='IURetraction',
full_name='ipaaca.protobuf.IURetraction',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='uid', full_name='ipaaca.protobuf.IURetraction.uid', index=0,
number=1, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='revision', full_name='ipaaca.protobuf.IURetraction.revision', index=1,
number=2, type=13, cpp_type=3, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=694,
serialized_end=739,
)
_IUCOMMISSION = descriptor.Descriptor(
name='IUCommission',
full_name='ipaaca.protobuf.IUCommission',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='uid', full_name='ipaaca.protobuf.IUCommission.uid', index=0,
number=1, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='revision', full_name='ipaaca.protobuf.IUCommission.revision', index=1,
number=2, type=13, cpp_type=3, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='writer_name', full_name='ipaaca.protobuf.IUCommission.writer_name', index=2,
number=3, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=741,
serialized_end=807,
)
_IULINKUPDATE = descriptor.Descriptor(
name='IULinkUpdate',
full_name='ipaaca.protobuf.IULinkUpdate',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='uid', full_name='ipaaca.protobuf.IULinkUpdate.uid', index=0,
number=1, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='revision', full_name='ipaaca.protobuf.IULinkUpdate.revision', index=1,
number=2, type=13, cpp_type=3, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='new_links', full_name='ipaaca.protobuf.IULinkUpdate.new_links', index=2,
number=3, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='links_to_remove', full_name='ipaaca.protobuf.IULinkUpdate.links_to_remove', index=3,
number=4, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='is_delta', full_name='ipaaca.protobuf.IULinkUpdate.is_delta', index=4,
number=5, type=8, cpp_type=7, label=2,
has_default_value=True, default_value=False,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='writer_name', full_name='ipaaca.protobuf.IULinkUpdate.writer_name', index=5,
number=6, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=unicode("", "utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=810,
serialized_end=997,
)
_IU.fields_by_name['access_mode'].enum_type = _IU_ACCESSMODE
_IU.fields_by_name['payload'].message_type = _PAYLOADITEM
_IU.fields_by_name['links'].message_type = _LINKSET
_IU_ACCESSMODE.containing_type = _IU;
_IUPAYLOADUPDATE.fields_by_name['new_items'].message_type = _PAYLOADITEM
_IULINKUPDATE.fields_by_name['new_links'].message_type = _LINKSET
_IULINKUPDATE.fields_by_name['links_to_remove'].message_type = _LINKSET
DESCRIPTOR.message_types_by_name['IntMessage'] = _INTMESSAGE
DESCRIPTOR.message_types_by_name['LinkSet'] = _LINKSET
DESCRIPTOR.message_types_by_name['PayloadItem'] = _PAYLOADITEM
DESCRIPTOR.message_types_by_name['IU'] = _IU
DESCRIPTOR.message_types_by_name['IUPayloadUpdate'] = _IUPAYLOADUPDATE
DESCRIPTOR.message_types_by_name['IURetraction'] = _IURETRACTION
DESCRIPTOR.message_types_by_name['IUCommission'] = _IUCOMMISSION
DESCRIPTOR.message_types_by_name['IULinkUpdate'] = _IULINKUPDATE
class IntMessage(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _INTMESSAGE
# @@protoc_insertion_point(class_scope:ipaaca.protobuf.IntMessage)
class LinkSet(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _LINKSET
# @@protoc_insertion_point(class_scope:ipaaca.protobuf.LinkSet)
class PayloadItem(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _PAYLOADITEM
# @@protoc_insertion_point(class_scope:ipaaca.protobuf.PayloadItem)
class IU(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _IU
# @@protoc_insertion_point(class_scope:ipaaca.protobuf.IU)
class IUPayloadUpdate(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _IUPAYLOADUPDATE
# @@protoc_insertion_point(class_scope:ipaaca.protobuf.IUPayloadUpdate)
class IURetraction(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _IURETRACTION
# @@protoc_insertion_point(class_scope:ipaaca.protobuf.IURetraction)
class IUCommission(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _IUCOMMISSION
# @@protoc_insertion_point(class_scope:ipaaca.protobuf.IUCommission)
class IULinkUpdate(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _IULINKUPDATE
# @@protoc_insertion_point(class_scope:ipaaca.protobuf.IULinkUpdate)
# @@protoc_insertion_point(module_scope)
#!/usr/bin/env python
# This file is part of IPAACA, the
# "Incremental Processing Architecture
# for Artificial Conversational Agents".
#
# Copyright (c) 2009-2013 Sociable Agents Group
# CITEC, Bielefeld University
#
# http://opensource.cit-ec.de/projects/ipaaca/
# http://purl.org/net/ipaaca
#
# This file may be licensed under the terms of of the
# GNU Lesser General Public License Version 3 (the ``LGPL''),
# or (at your option) any later version.
#
# Software distributed under the License is distributed
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
# express or implied. See the LGPL for the specific language
# governing rights and limitations.
#
# You should have received a copy of the LGPL along with this
# program. If not, go to http://www.gnu.org/licenses/lgpl.html
# or write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The development of this software was supported by the
# Excellence Cluster EXC 277 Cognitive Interaction Technology.
# The Excellence Cluster EXC 277 is a grant of the Deutsche
# Forschungsgemeinschaft (DFG) in the context of the German
# Excellence Initiative.
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'
if counter == 10:
iu.add_links('special', my_iu.uid)
elif counter % 3 == 1:
iu.payload['a'] = 'REMOTELY SET '+str(counter)
elif counter % 3 == 2:
del iu.payload['a']
else:
iu.payload = {'a': 'reset'}
except ipaaca.IUUpdateFailedError, e:
ipaaca.logger.warning("Payload update failed (IU changed in the mean time)")
time.sleep(0.1)
exit(0)
[transport.spread]
host = localhost # default type is string
port = 4803 # types can be specified in angle brackets
enabled = true
#!/usr/bin/env python
import ipaaca
print "{this is the IpaacaPython run.py doing nothing at all}"
#!/bin/bash
if [ -d /vol/soa/opt64/spread ]; then
echo "Starting local-only spread daemon for ipaaca (from soa volume) ..."
LD_LIBRARY_PATH=/vol/soa/opt64/spread/current/lib
/vol/soa/opt64/spread/current/sbin/spread -n localhost &
else
echo "Starting local-only spread daemon for ipaaca ..."
spr=`which spread`
[ $? -eq 0 ] || {
echo spread not found in PATH - searching in /usr/sbin and /usr/local/sbin
spr=''
[ -e /usr/local/sbin/spread ] && spr="/usr/local/sbin/spread"
[ -e /usr/sbin/spread ] && spr="/usr/sbin/spread"
[ "$spr" = "" ] && echo "Could not find spread"
echo $spr
}
${spr} -n localhost &
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment