Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • android_compatible_0.14
  • ipaaca-json
  • ipaaca-rsb
  • ipaaca3-dev
  • ipaaca4
  • ipaaca4py3
  • kompass
  • legacy-str
  • master
  • mqtt_port
  • rsb0.11
  • rsb0.14
  • ryt-fullport
  • softwareweek2019
  • windows-compatibility
15 results

Target

Select target project
  • scs/ipaaca
  • ramin.yaghoubzadeh/ipaaca
2 results
Select Git revision
  • ipaaca-rsb
  • ipaaca3-dev
  • ipaaca4
  • kompass
  • master
  • rsb0.14
6 results
Show changes
Showing
with 788 additions and 157 deletions
/*
* This file is part of IPAACA, the
* "Incremental Processing Architecture
* for Artificial Conversational Agents".
*
* Copyright (c) 2009-2022 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.
*/
#include <../include/ipaaca/ipaaca.h>
#include <typeinfo>
#include <iostream>
using namespace ipaaca;
void my_first_iu_handler(IUInterface::ptr iu, IUEventType type, bool local)
{
std::cout<<"Update!"<<std::endl;
}
int main() {
try{
OutputBuffer::ptr output_buffer = OutputBuffer::create("Tester");
IU::ptr iu = IU::create("cat1");
output_buffer->add(iu);
InputBuffer::ptr input_buffer = InputBuffer::create("InputTester","cat1");
input_buffer->set_resend(true);
input_buffer->register_handler(my_first_iu_handler);
iu->payload()["key"]="Dummy";
sleep(1);
std::cout<<"Input buffer #of ius: "<<input_buffer->get_ius().size()<<std::endl;
} catch (ipaaca::Exception& e) {
std::cout << "== IPAACA EXCEPTION == " << e.what() << std::endl;
}
}
#include <ipaaca.h>
/*
* This file is part of IPAACA, the
* "Incremental Processing Architecture
* for Artificial Conversational Agents".
*
* Copyright (c) 2009-2022 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.
*/
#include <ipaaca/ipaaca.h>
#include <typeinfo>
using namespace ipaaca;
#define BOOST_TEST_MODULE TestIpaacaCpp
#include <boost/test/unit_test.hpp>
const char RECV_CATEGORY[] = "WORD";
const char SEND_CATEGORY[] = "TEXT";
using namespace ipaaca;
class TextSender {
protected:
OutputBuffer::ptr _ob;
InputBuffer::ptr _ib;
class TestReceiver {
public:
TextSender();
void outbuffer_handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local);
InputBuffer::ptr _ib;
std::string received_info;
TestReceiver();
void inbuffer_handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local);
IUInterface::ptr find_last_iu();
void publish_text_to_print(const std::string& text, const std::string& parent_iu_uid="");
};
TextSender::TextSender() {
_ob = OutputBuffer::create("TextSenderOut");
_ob->register_handler(boost::bind(&TextSender::outbuffer_handle_iu_event, this, _1, _2, _3));
_ib = InputBuffer::create("TextSenderIn", RECV_CATEGORY);
_ib->register_handler(boost::bind(&TextSender::inbuffer_handle_iu_event, this, _1, _2, _3));
TestReceiver::TestReceiver()
{
_ib = ipaaca::InputBuffer::create("TestReceiver", "cppTestCategory");
_ib->register_handler(boost::bind(&TestReceiver::inbuffer_handle_iu_event, this, _1, _2, _3));
received_info = "NOTHING RECEIVED YET";
}
void TextSender::outbuffer_handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local)
void TestReceiver::inbuffer_handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local)
{
std::cout << "(own IU event " << iu_event_type_to_str(event_type) << " " << iu->uid() << ")" << std::endl;
if (event_type == IU_UPDATED) {
std::set<std::string> parent_uids = iu->get_links("GRIN");
if (parent_uids.size() > 0) {
std::string parent_uid = *(parent_uids.begin());
std::cout << "updating parent ..." << std::endl;
std::set<std::string> next_uids = iu->get_links("SUCCESSOR");
if (next_uids.size() > 0) {
std::string next_uid = *(next_uids.begin());
IUInterface::ptr next_iu = _ob->get(next_uid);
std::set<std::string> next_letter_grin_links = next_iu->get_links("GRIN");
if (next_letter_grin_links.count(parent_uid) == 0) {
// next letter belongs to new word
IUInterface::ptr parent_iu = _ib->get(parent_uid);
parent_iu->payload()["STATE"] = "REALIZED";
} else {
IUInterface::ptr parent_iu = _ib->get(parent_uid);
parent_iu->payload()["STATE"] = "STARTED";
}
} else {
// there are no more letters, this is the end of the final word
IUInterface::ptr parent_iu = _ib->get(parent_uid);
parent_iu->payload()["STATE"] = "REALIZED";
}
std::cout << " ... done." << std::endl;
if (event_type == IU_ADDED) {
received_info = (std::string) iu->payload()["word"];
{
ipaaca::Locker locker(iu->payload());
iu->payload()["replyVector"] = std::vector<double> { 1.0, 2.0, 3.0 };
iu->payload()["replyComment"] = "OK";
}
} else {
}
}
void TextSender::inbuffer_handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local)
{
if (event_type == IU_LINKSUPDATED) {
std::cout << "links updated" << std::endl;
} else if (event_type == IU_ADDED) {
std::string word = iu->payload()["WORD"];
std::cout << "Received new word: " << word << std::endl;
publish_text_to_print(word, iu->uid());
} else if (event_type == IU_RETRACTED) {
std::string retracted_uid = iu->uid();
} else {
std::cout << "(IU event " << iu_event_type_to_str(event_type) << " " << iu->uid() << ")" << std::endl;
}
class TestSender {
public:
OutputBuffer::ptr _ob;
std::vector<double> double_vec;
std::string comment;
long num_replies;
TestSender();
void publish_one_message();
void outbuffer_handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local);
};
TestSender::TestSender() {
_ob = OutputBuffer::create("TestSender");
_ob->register_handler(boost::bind(&TestSender::outbuffer_handle_iu_event, this, _1, _2, _3));
comment = "NO COMMENT YET";
num_replies = 0;
}
IUInterface::ptr TextSender::find_last_iu() {
std::set<IUInterface::ptr> ius = _ob->get_ius();
for (std::set<IUInterface::ptr>::iterator it = ius.begin(); it!=ius.end(); ++it) {
if ((*it)->get_links("SUCCESSOR").size() == 0) return *it;
void TestSender::outbuffer_handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local)
{
if (event_type == IU_UPDATED) {
num_replies++;
double_vec = iu->payload()["replyVector"];
comment = (std::string) iu->payload()["replyComment"];
}
return IUInterface::ptr();
}
void TextSender::publish_text_to_print(const std::string& text, const std::string& parent_iu_uid) {
IUInterface::ptr previous_iu = find_last_iu();
if (previous_iu) {
// insert a blank if we already have words in the buffer
IU::ptr iu = IU::create( SEND_CATEGORY );
iu->payload()["CONTENT"] = " ";
_ob->add(iu);
previous_iu->add_link( "SUCCESSOR", iu->uid() );
iu->add_link( "PREDECESSOR", previous_iu->uid() );
if (parent_iu_uid != "") iu->add_link( "GRIN", parent_iu_uid );
previous_iu = iu;
}
for (int i=0; i<text.size(); ++i) {
IU::ptr iu = IU::create( SEND_CATEGORY );
iu->payload()["CONTENT"] = std::string(1, text.at(i));
_ob->add(iu);
if (previous_iu) {
previous_iu->add_link( "SUCCESSOR", iu->uid() );
iu->add_link( "PREDECESSOR", previous_iu->uid() );
if (parent_iu_uid != "") iu->add_link( "GRIN", parent_iu_uid );
}
if (previous_iu) std::cout << "previous IU: " << *previous_iu << std::endl;
previous_iu = iu;
}
void TestSender::publish_one_message()
{
ipaaca::IU::ptr iu = ipaaca::IU::create("cppTestCategory");
iu->payload()["word"] = "OK";
_ob->add(iu);
}
int old_main() {
TextSender sender;
BOOST_AUTO_TEST_SUITE (testIpaacaCpp)
BOOST_AUTO_TEST_CASE( testIpaacaCpp01 )
{
TestSender sender;
TestReceiver receiver;
std::cout << "Publishing one message and waiting 1s for replies from other module." << std::endl;
sender.publish_one_message();
sleep(1);
sender.publish_text_to_print("(INIT)");
std::cout << "Press Ctrl-C to cancel..." << std::endl;
while (true) sleep(1);
std::cout << "Checking for changes." << std::endl;
BOOST_CHECK( receiver.received_info == "OK" );
BOOST_CHECK( sender.num_replies == 1 );
BOOST_CHECK( sender.comment == "OK" );
BOOST_CHECK( sender.double_vec.size() == 3 );
std::cout << "Complete." << std::endl;
}
int main() {
std::cerr << "TODO: implement Ipaaca C++ test cases." << std::endl;
return 0;
}
BOOST_AUTO_TEST_SUITE_END( )
......@@ -6,3 +6,4 @@ dist
privateprops
.project
.classpath
/bin/
......@@ -2,8 +2,10 @@ language=java
resolve.status=beta
resource.path=
publish.resolver=soa.core.repository
#resource.path=${shared.repository}/Humanoids;${shared.repository}/3dmodels;${shared.repository}/HMI/HmiElckerlyc/resources;${shared.repository}/logbackconfig;${shared.repository}/shaders;
run.jvmargs= -Xms128m -Xmx512m -Xss5M
rebuild.list=
publish.resolver=asap.sftp.publish
dist.dir=../../dist
javac.source=1.8
javac.target=1.8
<?xml version="1.0" encoding="UTF-8"?>
<project name="ipaaca-java" default="run">
<import file="../../../soashared/ant/build.xml" />
<!-- import file="../../../HmiBuild/build.xml" / -->
<import file="../../../hmibuild/build.xml" />
<target name="-pre-compilation">
<echo message="Compiling protobuf file" />
......
<ivy-module version="2.0">
<info organisation="ipaaca" module="ipaaca-java"/>
<configurations>
<include file="${ivy.settings.dir}/configurations.xml"/>
</configurations>
<dependencies>
<dependency org="slf4j" name="slf4j-api" rev="latest.release" />
<dependency org="google" name="guava" rev="latest.release" />
<dependency org="google" name="protobuf-java" rev="latest.release" />
<dependency org="rsb" name="rsb" rev="latest.release" />
</dependencies>
</ivy-module>
<ivy-module version="2.0">
<info organisation="ipaaca" module="ipaaca-java"/>
<configurations>
<include file="${ivy.settings.dir}/configurations.xml"/>
</configurations>
<dependencies>
<dependency org="slf4j" name="slf4j-api" rev="latest.release" />
<dependency org="google" name="guava" rev="latest.release" />
<dependency org="google" name="protobuf-java" rev="2.6.1" />
<dependency org="rsb" name="rsb" rev="latest.release" />
<dependency org="lombok" name="lombok" rev="latest.release" />
<dependency org="apache" name="commons-lang" rev="latest.release" />
</dependencies>
</ivy-module>
Manifest-Version: 1.0
Main-Class: main
Name: IpaacaJava
Specification-Title: IpaacaJava
Specification-Version: 0.1
Specification-Vendor: ipaaca
Implementation-Title: IpaacaJava
Implementation-Version: July 27 2012 02:19 PM
Implementation-Vendor: ipaaca
\ No newline at end of file
[transport.spread]
host = localhost # default type is string
port = 4803 # types can be specified in angle brackets
enabled = true
/*
* 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.
*/
package ipaaca;
import ipaaca.protobuf.Ipaaca.IU;
import ipaaca.protobuf.Ipaaca.PayloadItem;
import java.util.ArrayList;
......@@ -25,10 +58,13 @@ public abstract class AbstractIU
protected Payload payload;
protected String category;
protected boolean committed = false;
protected boolean retracted = false;
private String uid;
protected int revision;
protected long revision;
private boolean readOnly = false;
public abstract IU.AccessMode getAccessMode();
protected SetMultimap<String, String> links = HashMultimap.create();
private final SetMultimap<String, String> EMPTYLINKS = HashMultimap.create();
......@@ -114,7 +150,7 @@ public abstract class AbstractIU
this.readOnly = readOnly;
}
public void setRevision(int revision)
public void setRevision(long revision)
{
this.revision = revision;
}
......@@ -154,7 +190,7 @@ public abstract class AbstractIU
return buffer;
}
public int getRevision()
public long getRevision()
{
return revision;
}
......@@ -169,6 +205,11 @@ public abstract class AbstractIU
return committed;
}
public boolean isRetracted()
{
return retracted;
}
public void setBuffer(Buffer buffer)
{
this.buffer = buffer;
......@@ -186,6 +227,8 @@ public abstract class AbstractIU
public abstract void commit();
public abstract void retract();
// XXX: might not be valid for all types of IUs
public abstract void commit(String writerName);
......@@ -199,7 +242,7 @@ public abstract class AbstractIU
List<PayloadItem> items = new ArrayList<PayloadItem>();
for (Entry<String, String> entry : newPayload.entrySet())
{
PayloadItem item = PayloadItem.newBuilder().setKey(entry.getKey()).setValue(entry.getValue()).setType("") // TODO:default type?
PayloadItem item = PayloadItem.newBuilder().setKey(entry.getKey()).setValue(entry.getValue()).setType("STR")
.build();
items.add(item);
}
......@@ -209,6 +252,8 @@ public abstract class AbstractIU
abstract void setPayload(List<PayloadItem> newItems, String writerName);
abstract void putIntoPayload(String key, String value, String writer);
abstract void putIntoPayload(Map<? extends String, ? extends String> newItems, String writer);
abstract void removeFromPayload(Object key, String writer);
......
/*
* 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.
*/
package ipaaca;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import ipaaca.Initializer;
/**
* Base class for InputBuffer and OutputBuffer.
*/
......@@ -12,9 +48,14 @@ public abstract class Buffer
private final String owningComponentName;
private List<IUEventHandler> eventHandlers = new ArrayList<IUEventHandler>();
protected final String uuid = UUID.randomUUID().toString().replaceAll("-", "");
protected final String uuid = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 8);
protected String uniqueName;
public String getUniqueShortName()
{
return owningComponentName + "ID" + uuid;
}
public String getUniqueName()
{
return uniqueName;
......@@ -46,6 +87,7 @@ public abstract class Buffer
*/
public Buffer(String owningComponentName)
{
Initializer.initializeIpaacaRsb();
this.owningComponentName = owningComponentName;
uniqueName = "undef-" + uuid;
}
......@@ -63,10 +105,40 @@ public abstract class Buffer
// """
// handler = IUEventHandler(handler_function=handler_function, for_event_types=for_event_types, for_categories=for_categories)
// self._iu_event_handlers.append(handler)
public void registerHandler(IUEventHandler handler)
{
eventHandlers.add(handler);
}
public void removeHandler(IUEventHandler handler)
{
eventHandlers.remove(handler);
}
public void registerHandler(HandlerFunctor func) {
IUEventHandler handler;
handler = new IUEventHandler(func);
registerHandler(handler);
}
public void registerHandler(HandlerFunctor func, Set<String> categories) {
IUEventHandler handler;
handler = new IUEventHandler(func, categories);
registerHandler(handler);
}
public void registerHandler(HandlerFunctor func, EnumSet<IUEventType> eventTypes) {
IUEventHandler handler;
handler = new IUEventHandler(func, eventTypes);
registerHandler(handler);
}
public void registerHandler(HandlerFunctor func, EnumSet<IUEventType> eventTypes, Set<String> categories) {
IUEventHandler handler;
handler = new IUEventHandler(func, eventTypes, categories);
registerHandler(handler);
}
// def call_iu_event_handlers(self, uid, local, event_type, category):
// """Call registered IU event handler functions registered for this event_type and category."""
......@@ -76,7 +148,7 @@ public abstract class Buffer
/**
* Call registered IU event handler functions registered for this event_type and category.
*/
public void callIuEventHandlers(String uid, boolean local, IUEventType type, String category)
protected void callIuEventHandlers(String uid, boolean local, IUEventType type, String category)
{
for (IUEventHandler h : eventHandlers)
{
......
/*
* 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.
*/
package ipaaca;
import java.util.HashSet;
import java.util.Set;
class BufferConfiguration {
String _owningComponentName;
Set<String> _category_interests;
String _channel;
boolean _resendActive;
// protected:
// IPAACA_MEMBER_VAR_EXPORT std::string _basename;
// IPAACA_MEMBER_VAR_EXPORT std::vector<std::string> _category_interests;
// IPAACA_MEMBER_VAR_EXPORT std::string _channel;
public BufferConfiguration(String owningComponentName) {
this._owningComponentName = owningComponentName;
this._channel = "default";
this._resendActive = false;
this._category_interests = new HashSet<String>();
}
public String getOwningComponentName() {
return this._owningComponentName;
}
public Set<String> getCategoryInterests() {
return this._category_interests;
}
public String getChannel() {
return this._channel;
}
public boolean getResendActive() {
return this._resendActive;
}
// public:
// IPAACA_HEADER_EXPORT inline BufferConfiguration(const std::string basename) { _basename = basename; }
// IPAACA_HEADER_EXPORT const std::string get_basename() const { return _basename; }
// IPAACA_HEADER_EXPORT const std::vector<std::string> get_category_interests() const { return _category_interests; }
// IPAACA_HEADER_EXPORT const std::string get_channel() const { return _channel; }
}
/*
* 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.
*/
package ipaaca;
public class BufferConfigurationBuilder extends BufferConfiguration {
public BufferConfigurationBuilder(String owningComponentName) {
super(owningComponentName);
}
public void setOwningComponentName(String owningComponentName) {
this._owningComponentName = owningComponentName;
}
public void addCategoryInterest(String category) {
this._category_interests.add(category);
}
public void setChannel(String channel) {
this._channel = channel;
}
public void setResendActive(boolean resendActive) {
this._resendActive = resendActive;
}
public BufferConfiguration getBufferConfiguration() {
return this;
}
// public:
// IPAACA_HEADER_EXPORT inline BufferConfigurationBuilder(const std::string basename):BufferConfiguration(basename) {}
// IPAACA_HEADER_EXPORT inline void set_basename(const std::string& basename)
// {
// _basename = basename;
// }
// IPAACA_HEADER_EXPORT inline void add_category_interest(const std::string& category)
// {
// _category_interests.push_back(category);
// }
// IPAACA_HEADER_EXPORT inline void set_channel(const std::string& channel)
// {
// _channel = channel;
// }
// IPAACA_HEADER_EXPORT const BufferConfiguration& get_BufferConfiguration() { return *this; }
}
/*
* 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.
*/
package ipaaca;
public interface HandlerFunctor
......
/*
* 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.
*/
package ipaaca;
public enum IUAccessMode
......
/*
* 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.
*/
package ipaaca;
/**
......
/*
* 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.
*/
package ipaaca;
import ipaaca.protobuf.Ipaaca.IU;
......@@ -10,20 +42,20 @@ import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.SetMultimap;
import com.google.protobuf.InvalidProtocolBufferException;
import rsb.converter.ConversionException;
import rsb.converter.Converter;
import rsb.converter.ConverterSignature;
import rsb.converter.UserData;
import rsb.converter.WireContents;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.SetMultimap;
import com.google.protobuf.InvalidProtocolBufferException;
/**
* Serializes AbstractIUs into protocolbuffer IUs and vice versa.
* @author hvanwelbergen
*
*
*/
public class IUConverter implements Converter<ByteBuffer>
{
......@@ -47,7 +79,7 @@ public class IUConverter implements Converter<ByteBuffer>
List<PayloadItem> payloadItems = new ArrayList<PayloadItem>();
for (Entry<String, String> entry : iua.getPayload().entrySet())
{
payloadItems.add(PayloadItem.newBuilder().setKey(entry.getKey()).setValue(entry.getValue()).setType("").build());
payloadItems.add(PayloadItem.newBuilder().setKey(entry.getKey()).setValue(entry.getValue()).setType("STR").build());
}
List<LinkSet> links = new ArrayList<LinkSet>();
......@@ -56,12 +88,15 @@ public class IUConverter implements Converter<ByteBuffer>
links.add(LinkSet.newBuilder().setType(entry.getKey()).addAllTargets(entry.getValue()).build());
}
IU iu = IU.newBuilder().setUid(iua.getUid()).setRevision(iua.getRevision()).setCategory(iua.getCategory())
.setOwnerName(iua.getOwnerName()).setCommitted(iua.isCommitted()).setAccessMode(IU.AccessMode.PUSH) // TODO for other access modes (also in Python version)
.setReadOnly(iua.isReadOnly()).setPayloadType("MAP").addAllPayload(payloadItems).addAllLinks(links).build();
return new WireContents<ByteBuffer>(ByteBuffer.wrap(iu.toByteArray()), "ipaaca-iu");
IU.AccessMode accessMode = iua.getAccessMode();
IU iu = IU.newBuilder().setUid(iua.getUid()).setRevision((int) iua.getRevision()).setCategory(iua.getCategory())
.setOwnerName(iua.getOwnerName()).setCommitted(iua.isCommitted()).setAccessMode(accessMode)
.setReadOnly(iua.isReadOnly()).setPayloadType("STR").addAllPayload(payloadItems).addAllLinks(links).build();
String wireFormat = (accessMode == IU.AccessMode.MESSAGE) ? "ipaaca-messageiu" : "ipaaca-iu";
return new WireContents<ByteBuffer>(ByteBuffer.wrap(iu.toByteArray()), wireFormat);
}
@Override
public UserData<?> deserialize(String wireSchema, ByteBuffer buffer) throws ConversionException
{
......@@ -69,6 +104,12 @@ public class IUConverter implements Converter<ByteBuffer>
try
{
iu = IU.newBuilder().mergeFrom(buffer.array()).build();
// If there are rsb buffer read-only issues in some build, use this code instead of the above line:
//int size = buffer.capacity();
//byte[] array = new byte[size];
//buffer.get(array, 0, size);
//iu = IU.newBuilder().mergeFrom(array).build();
}
catch (InvalidProtocolBufferException e)
{
......@@ -78,24 +119,36 @@ public class IUConverter implements Converter<ByteBuffer>
if (iu.getAccessMode() == IU.AccessMode.PUSH)
{
RemotePushIU iuout = new RemotePushIU(iu.getUid());
iuout.setCategory(iu.getCategory());
iuout.committed = iu.getCommitted();
iuout.setOwnerName(iu.getOwnerName());
iuout.setRevision(iu.getRevision());
iuout.setReadOnly(iu.getReadOnly());
iuout.payload = new Payload(iuout, iu.getPayloadList());
SetMultimap<String, String> links = HashMultimap.create();
for (LinkSet ls : iu.getLinksList())
{
links.putAll(ls.getType(), ls.getTargetsList());
}
iuout.setLinksLocally(links);
copyIU(iu, iuout);
return new UserData<RemotePushIU>(iuout, RemotePushIU.class);
}
else if(iu.getAccessMode() == IU.AccessMode.MESSAGE)
{
RemoteMessageIU iuout = new RemoteMessageIU(iu.getUid());
copyIU(iu,iuout);
return new UserData<RemoteMessageIU>(iuout, RemoteMessageIU.class);
}
else
{
throw new RuntimeException("We can only handle IUs with access mode 'PUSH' for now!");
throw new RuntimeException("Trying to deserialize IU with accesmode: "+iu.getAccessMode()+". " +
"We can only handle IUs with access mode 'PUSH' or 'MESSAGE' for now!");
}
}
private void copyIU(IU iu, AbstractIU iuout)
{
iuout.setCategory(iu.getCategory());
iuout.committed = iu.getCommitted();
iuout.setOwnerName(iu.getOwnerName());
iuout.setRevision(iu.getRevision());
iuout.setReadOnly(iu.getReadOnly());
iuout.payload = new Payload(iuout, iu.getPayloadList());
SetMultimap<String, String> links = HashMultimap.create();
for (LinkSet ls : iu.getLinksList())
{
links.putAll(ls.getType(), ls.getTargetsList());
}
iuout.setLinksLocally(links);
}
}
/*
* 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.
*/
package ipaaca;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
/**
......@@ -32,6 +65,27 @@ public class IUEventHandler
// self._for_categories = (
// None if for_categories is None else
// (for_categories[:] if hasattr(for_categories, '__iter__') else [for_categories]))
public IUEventHandler(HandlerFunctor func)
{
this.handleFunctor = func;
this.categories = new HashSet<String>();
this.eventTypes = EnumSet.allOf(IUEventType.class);
}
public IUEventHandler(HandlerFunctor func, Set<String> categories)
{
this.handleFunctor = func;
this.categories = categories;
this.eventTypes = EnumSet.allOf(IUEventType.class);
}
public IUEventHandler(HandlerFunctor func, EnumSet<IUEventType> eventTypes)
{
this.handleFunctor = func;
this.eventTypes = eventTypes;
this.categories = new HashSet<String>();
}
public IUEventHandler(HandlerFunctor func, EnumSet<IUEventType> eventTypes, Set<String> categories)
{
......@@ -57,7 +111,13 @@ public class IUEventHandler
*/
private boolean conditionMet(IUEventType type, String category)
{
return eventTypes.contains(type) && categories.contains(category);
if (this.categories.isEmpty()) { // match any category
return this.eventTypes.contains(type);
}
else
{
return this.eventTypes.contains(type) && this.categories.contains(category);
}
}
// def call(self, buffer, iu_uid, local, event_type, category):
......
/*
* 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.
*/
package ipaaca;
public enum IUEventType
{
ADDED, COMMITTED, DELETED, RETRACTED, UPDATED, LINKSUPDATED;
ADDED, COMMITTED, DELETED, RETRACTED, UPDATED, LINKSUPDATED, MESSAGE;
}
/*
* 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.
*/
package ipaaca;
/**
......
/*
* 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.
*/
package ipaaca;
/**
......