layer3/platform/qt/qtdntimekeeperimpl.cpp \
layer3/platform/qt/qtdnthreadimpl.cpp \
layer3/platform/qt/qtdnserialportimpl.cpp \
- layer3/DNCellInterfaceable.cpp
+ layer3/DNCellInterfaceable.cpp \
+ layer3/dnplugininputcell.cpp \
+ layer3/dnpluginoutputcell.cpp \
+ layer3/platform/qt/qtdnpluginmanager.cpp \
+ layer3/platform/qt/qtdnplugin.cpp
HEADERS += \
layer1/TKLockImpl.h \
layer3/platform/qt/qtdntimekeeperimpl.h \
layer1/DNStorageImpl.h \
layer3/DNCellInterfaceable.h \
- versioninfo.h
+ versioninfo.h \
+ layer3/dnplugininputcell.h \
+ layer3/dnpluginoutputcell.h \
+ layer3/dnpluginmanager.h \
+ layer3/dnplugin.h \
+ layer3/platform/qt/qtdnpluginmanager.h \
+ layer3/platform/qt/qtdnplugin.h \
+ plugins/dennco_plugin.h
FORMS += layer3/QtDennco/mainwindow.ui
FORMS += layer3/QtDennco/portinfodialog.ui
macx {
QMAKE_POST_LINK = "mkdir -p ../bin/QtDennco.app/Contents/Frameworks;cp ../Thirdparty/qt/qserialdevice-qserialdevice/src/libSerialPort.1.dylib ../bin/QtDennco.app/Contents/Frameworks;install_name_tool -change libSerialPort.1.dylib @executable_path/../Frameworks/libSerialPort.1.dylib ../bin/QtDennco.app/Contents/MacOS/QtDennco"
} else {
- win32:QMAKE_POST_LINK = "copy ..\\Thirdparty\\qt\\qserialdevice-qserialdevice\\src\\debug\\SerialPort.dll ..\\bin"
+ win32:QMAKE_POST_LINK = $$quote(copy ..\\Thirdparty\\qt\\qserialdevice-qserialdevice\\src\\debug\\SerialPort.dll ..\\bin $$escape_expand(\\n\\t))
unix:QMAKE_POST_LINK = "cp ../Thirdparty/qt/qserialdevice-qserialdevice/src/libSerialPort.so ../bin"
}
} else {
macx {
QMAKE_POST_LINK = "mkdir -p ../bin/QtDennco.app/Contents/Frameworks;cp ../Thirdparty/qt/qserialdevice-qserialdevice/src/libSerialPort.1.dylib ../bin/QtDennco.app/Contents/Frameworks;install_name_tool -change libSerialPort.1.dylib @executable_path/../Frameworks/libSerialPort.1.dylib ../bin/QtDennco.app/Contents/MacOS/QtDennco"
} else {
- win32:QMAKE_POST_LINK = "copy ..\\Thirdparty\\qt\\qserialdevice-qserialdevice\\src\\release\\SerialPort.dll ..\\bin"
+ win32:QMAKE_POST_LINK = $$quote(copy ..\\Thirdparty\\qt\\qserialdevice-qserialdevice\\src\\release\\SerialPort.dll ..\\bin $$escape_expand(\\n\\t))
unix:QMAKE_POST_LINK = "cp ../Thirdparty/qt/qserialdevice-qserialdevice/src/libSerialPort.so ../bin"
}
}
-OTHER_FILES +=
+macx {
+} else {
+ win32 {
+ COPY_PLUGINS_SRC_DEST = $$PWD\\plugins\\build\\plugins $$DESTDIR\\plugins
+ QMAKE_POST_LINK += $$quote(xcopy /S /I /Y $$replace(COPY_PLUGINS_SRC_DEST, "/", "\\"))
+ } else {
+ }
+}
-RESOURCES += \
- dennco.qrc
RC_FILE = dn.rc
#include "TKCellCode.h"
#include "DNStorage.h"
#include "DNUtils.h"
+#include "dnpluginmanager.h"
#include <string>
const std::string TKContainer::CELLTYPE_OUT = "O";
const std::string TKContainer::CELLTYPE_IN = "I";
const std::string TKContainer::CELLTYPE_BASICSTORAGE = "BS";
+const std::string TKContainer::CELLTYPE_PLUGIN_IN = "PI";
+const std::string TKContainer::CELLTYPE_PLUGIN_OUT = "PO";
const std::string TKContainer::CELLCODENAME_EMPTY = "_DNEMPTY";
TKContainer::TKContainer() : mStorage(NULL), mEmptyCellClass(NULL)
{
+ DNPluginManager::construct();
}
void TKContainer::init()
{
doDestroy();
releaseDataStore();
+ DNPluginManager::destroy();
}
bool TKContainer::doInit()
{
cell = cellFactory(theLocation, theName, type, false, false);
}
+ else if (type == CELLTYPE_PLUGIN_IN)
+ {
+ cell = cellFactory(theLocation, theName, type, true, false);
+ noScript = true;
+ }
+ else if (type == CELLTYPE_PLUGIN_OUT)
+ {
+ cell = cellFactory(theLocation, theName, type, false, true);
+ noScript = true;
+ }
else
{
std::string message = std::string("Failed to construct cell '").append(theLocation).append("#").append(theName);
static const std::string CELLTYPE_OUT;
static const std::string CELLTYPE_IN;
static const std::string CELLTYPE_BASICSTORAGE;
+ static const std::string CELLTYPE_PLUGIN_IN;
+ static const std::string CELLTYPE_PLUGIN_OUT;
static const std::string CELLCODENAME_EMPTY;
if (lineNumber <= list.length())
{
int i = lineNumber < 2 ? 0 : lineNumber - 2;
- int j = i + 2 <= list.length() ? i + 2 : list.length() - 1;
+ int j = i + 2 < list.length() ? i + 2 : list.length() - 1;
while (i <= j)
{
errorStatement += list.at(i);
#include "dnqsinputcell.h"
#include "dnqsoutputcell.h"
#include "dnqsbasicstoragecell.h"
+#include "dnplugininputcell.h"
+#include "dnpluginoutputcell.h"
#include "dnqscellcode.h"
#include "DNGlobal.h"
cell = new DNQSBasicStorageCell(this, location, name, canInterfaceIn, canInterfaceOut);
cell->init();
}
+ else if (type == CELLTYPE_PLUGIN_IN)
+ {
+ cell = new DNPluginInputCell(this, location, name);
+ cell->init();
+
+ }
+ else if (type == CELLTYPE_PLUGIN_OUT)
+ {
+ cell = new DNPluginOutputCell(this, location, name);
+ cell->init();
+ }
return cell;
}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#ifndef DNPLUGIN_H
+#define DNPLUGIN_H
+
+class DNPlugin
+{
+protected:
+ typedef bool (*InitFunction)();
+ typedef bool (*UnloadFunction)();
+ typedef float (*QueryPluginValueFunction)(const char*);
+ typedef void (*SetValueToPluginFunction)(const char*, float);
+
+ bool d_isValid;
+ InitFunction d_initFunction;
+ UnloadFunction d_unloadFunction;
+ QueryPluginValueFunction d_queryPluginValueFunction;
+ SetValueToPluginFunction d_setValueToPluginFunction;
+
+ DNPlugin() :
+ d_isValid(false), d_initFunction(0), d_unloadFunction(0), d_queryPluginValueFunction(0), d_setValueToPluginFunction(0)
+ {}
+
+public:
+ virtual ~DNPlugin(){}
+ inline bool getIsValid() const { return d_isValid; }
+ inline bool init() { return d_initFunction ? d_initFunction() : false; }
+ inline bool unload() { return d_unloadFunction ? d_unloadFunction() : true; }
+ inline float queryPluginValue(const char* name) { return d_isValid ? d_queryPluginValueFunction(name) : 0.0f; }
+ inline void setValueToPlugin(const char* name, float value) { if (d_isValid) d_setValueToPluginFunction(name, value); }
+};
+
+#endif // DNPLUGIN_H
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#include "dnplugininputcell.h"
+
+#include "TKContainer.h"
+#include "TKAxon.h"
+
+#include "dnplugin.h"
+#include "dnpluginmanager.h"
+#include "DNUtils.h"
+
+#include <limits>
+
+DNPluginInputCell::DNPluginInputCell(TKContainer *container, std::string location, std::string name):
+ DNCellInterfaceable(container,location,name, true, false),
+ d_plugin(NULL), d_inputValue(std::numeric_limits<float>::quiet_NaN())
+{
+ bool parsed = false;
+ unsigned int idx = name.find("?");
+ if (idx != std::string::npos && idx + 1 < name.length())
+ {
+ std::string pluginInfo = name.substr(idx+1);
+ unsigned int idx2 = pluginInfo.find(":");
+ if (idx != std::string::npos && idx2 > 0 && idx2 + 1 < pluginInfo.length())
+ {
+ parsed = true;
+ std::string pluginName = pluginInfo.substr(0,idx2);
+ d_valueName = pluginInfo.substr(idx2+1);
+ d_plugin = DNPluginManager::instance()->getPlugin(pluginName);
+ if (!d_plugin)
+ {
+ std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
+ message.append("'\nLoading the specified plugin : '").append(pluginName).append("' failed");
+ dnNotifyError("Initialization failed", message);
+ }
+ }
+ }
+ if (!parsed)
+ {
+ std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
+ message.append("'\nThis is a plugin input cell. The name of the cell should be described by following form:\n'cellName'?'pluginName':'pluginValueName'");
+ dnNotifyError("Initialization failed", message);
+ }
+}
+
+DNPluginInputCell::~DNPluginInputCell()
+{
+}
+
+bool DNPluginInputCell::doTick(float time)
+{
+ (void)time;
+ return true;
+}
+
+bool DNPluginInputCell::doInit()
+{
+ return true;
+}
+
+bool DNPluginInputCell::doDestroy()
+{
+ return true;
+}
+
+void DNPluginInputCell::updateReceptorValue()
+{
+ if (d_plugin && d_plugin->getIsValid())
+ {
+ float v = d_plugin->queryPluginValue(d_valueName.c_str());
+ if (v != d_inputValue)
+ {
+ d_inputValue = v;
+ mAxon->setValue(v);
+ mReceptorValueUpdated = true;
+ }
+ }
+}
+
+void DNPluginInputCell::setValue(float value)
+{
+ (void)value;
+}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#ifndef DNPLUGININPUTCELL_H
+#define DNPLUGININPUTCELL_H
+
+#include "DNCellInterfaceable.h"
+
+class DNPlugin;
+
+class DNPluginInputCell : public DNCellInterfaceable
+{
+ DNPlugin *d_plugin;
+ std::string d_valueName;
+ float d_inputValue;
+
+public:
+ DNPluginInputCell(TKContainer *container, std::string location, std::string name);
+ virtual ~DNPluginInputCell();
+
+ virtual bool doTick(float time);
+ virtual bool doInit();
+ virtual bool doDestroy();
+
+ virtual void updateReceptorValue();
+ virtual void setValue(float value);
+};
+
+#endif // DNPLUGININPUTCELL_H
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#ifndef DNPLUGINMANAGER_H
+#define DNPLUGINMANAGER_H
+
+class DNPlugin;
+
+#include <string>
+
+class DNPluginManager
+{
+
+public:
+ static DNPluginManager* instance();
+ static void construct();
+ static void destroy();
+ virtual ~DNPluginManager(){}
+
+ virtual DNPlugin* getPlugin(std::string name) = 0;
+
+protected:
+ DNPluginManager(){}
+
+};
+
+#endif // DNPLUGINMANAGER_H
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#include "dnpluginoutputcell.h"
+
+#include "dnplugin.h"
+#include "dnpluginmanager.h"
+#include "TKReceptor.h"
+#include "TKAxon.h"
+#include "DNUtils.h"
+
+#include <limits>
+
+DNPluginOutputCell::DNPluginOutputCell(TKContainer *container, std::string location, std::string name)
+ : DNCellInterfaceable(container, location, name, false, true),
+ d_plugin(NULL), d_outputValue(std::numeric_limits<float>::quiet_NaN())
+{
+ bool parsed = false;
+ unsigned int idx = name.find("?");
+ if (idx != std::string::npos && idx + 1 < name.length())
+ {
+ std::string pluginInfo = name.substr(idx+1);
+ unsigned int idx2 = pluginInfo.find(":");
+ if (idx != std::string::npos && idx2 > 0 && idx2 + 1 < pluginInfo.length())
+ {
+ parsed = true;
+ std::string pluginName = pluginInfo.substr(0,idx2);
+ d_valueName = pluginInfo.substr(idx2+1);
+ d_plugin = DNPluginManager::instance()->getPlugin(pluginName);
+ if (!d_plugin)
+ {
+ std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
+ message.append("'\nLoading the specified plugin : '").append(pluginName).append("' failed");
+ dnNotifyError("Initialization failed", message);
+ }
+ }
+ }
+ if (!parsed)
+ {
+ std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
+ message.append("'\nThis is a plugin output cell. The name of the cell should be described by following form:\n'cellName'?'pluginName':'pluginValueName'");
+ dnNotifyError("Initialization failed", message);
+ }
+}
+
+DNPluginOutputCell::~DNPluginOutputCell()
+{
+}
+
+bool DNPluginOutputCell::doTick(float time)
+{
+ (void)time;
+
+ float value = 0.0;
+
+ for ( TKReceptorMap::iterator it = mReceptors.begin(); it != mReceptors.end(); ++it ) {
+ value += it->second->getValue();
+ }
+
+ mAxon->setValue(value);
+ if (d_plugin && d_plugin->getIsValid() && d_outputValue != value)
+ {
+ d_outputValue = value;
+ d_plugin->setValueToPlugin(d_valueName.c_str(), value);
+ }
+
+ return true;
+}
+
+bool DNPluginOutputCell::doInit()
+{
+ return true;
+}
+
+bool DNPluginOutputCell::doDestroy()
+{
+ return true;
+}
+
+void DNPluginOutputCell::setValue(float value)
+{
+ (void)value;
+}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#ifndef DNPLUGINOUTPUTCELL_H
+#define DNPLUGINOUTPUTCELL_H
+
+#include "DNCellInterfaceable.h"
+
+class DNPlugin;
+
+class DNPluginOutputCell : public DNCellInterfaceable
+{
+ DNPlugin *d_plugin;
+ std::string d_valueName;
+ float d_outputValue;
+
+public:
+ DNPluginOutputCell(TKContainer *container, std::string location, std::string name);
+ virtual ~DNPluginOutputCell();
+
+ virtual bool doTick(float time);
+ virtual bool doInit();
+ virtual bool doDestroy();
+
+ virtual void setValue(float value);
+};
+
+#endif // DNPLUGINOUTPUTCELL_H
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#include "qtdnplugin.h"
+
+#include "DNUtils.h"
+
+#include <QApplication>
+
+QtDNPlugin::QtDNPlugin(QString name) : DNPlugin()
+{
+#if defined(Q_WS_WIN)
+ QString libPath = QApplication::applicationDirPath() + "/plugins/win32/" + name + ".dll";
+#elif defined(Q_WS_MAC)
+ QString libPath = QApplication::applicationDirPath() + "/plugins/osx/" + name;
+#else
+ QString libPath = QApplication::applicationDirPath() + "/plugins/linux/" + name;
+#endif
+
+ d_library = new QLibrary(libPath);
+
+ if (d_library->load())
+ {
+ d_initFunction = (DNPlugin::InitFunction)d_library->resolve("init");
+ d_unloadFunction = (DNPlugin::UnloadFunction) d_library->resolve("unload");
+ d_queryPluginValueFunction = (DNPlugin::QueryPluginValueFunction)d_library->resolve("queryPluginValue");
+ d_setValueToPluginFunction = (DNPlugin::SetValueToPluginFunction)d_library->resolve("setValueToPlugin");
+
+ if (d_initFunction && d_unloadFunction && d_queryPluginValueFunction && d_setValueToPluginFunction)
+ {
+ d_isValid = init();
+ }
+ }
+ else
+ {
+ std::string message = std::string("Failed to load plugin file '").append(libPath.toStdString()).append("'\n");
+ message.append("Reason:").append(d_library->errorString().toStdString());
+ dnNotifyError("Initialization failed", message);
+ }
+}
+
+QtDNPlugin::~QtDNPlugin()
+{
+ if (d_library)
+ {
+ unload();
+ delete d_library;
+ }
+}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#ifndef QTDNPLUGIN_H
+#define QTDNPLUGIN_H
+
+#include "dnplugin.h"
+
+#include <QLibrary>
+
+class QtDNPlugin : public DNPlugin
+{
+ QLibrary *d_library;
+
+public:
+ QtDNPlugin(QString name);
+ virtual ~QtDNPlugin();
+
+};
+
+#endif // QTDNPLUGIN_H
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#include "qtdnpluginmanager.h"
+
+#include "qtdnplugin.h"
+#include <QLibrary>
+#include <QMessageBox>
+
+static QtDNPluginManager *s_manager = NULL;
+
+//static
+DNPluginManager* DNPluginManager::instance()
+{
+ return s_manager;
+}
+
+//static
+void DNPluginManager::construct()
+{
+ if (!s_manager)
+ s_manager = new QtDNPluginManager;
+}
+
+//static
+void DNPluginManager::destroy()
+{
+ if (s_manager)
+ delete s_manager;
+
+ s_manager = NULL;
+}
+
+QtDNPluginManager::QtDNPluginManager()
+{
+}
+
+QtDNPluginManager::~QtDNPluginManager()
+{
+ while (!m_plugins.isEmpty())
+ {
+ QMap<QString, DNPlugin*>::iterator i = m_plugins.begin();
+ delete i.value();
+ m_plugins.take(i.key());
+ }
+}
+
+DNPlugin* QtDNPluginManager::getPlugin(std::string name)
+{
+ QString qname = QString::fromStdString(name);
+ QMap<QString, DNPlugin*>::const_iterator it = m_plugins.find(qname);
+ if (it != m_plugins.end())
+ {
+ return it.value();
+ }
+
+ DNPlugin *plugin = new QtDNPlugin(qname);
+ m_plugins.insert(qname, plugin);
+
+ return plugin;
+}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/17/2013.
+//
+#ifndef QTDNPLUGINMANAGER_H
+#define QTDNPLUGINMANAGER_H
+
+#include "dnpluginmanager.h"
+
+#include <QMap>
+
+class QtDNPluginManager : public DNPluginManager
+{
+ QMap<QString, DNPlugin*> m_plugins;
+
+public:
+ QtDNPluginManager();
+ virtual ~QtDNPluginManager();
+ virtual DNPlugin* getPlugin(std::string name);
+
+};
+
+#endif // QTDNPLUGINMANAGER_H
--- /dev/null
+#-------------------------------------------------
+#
+# Project created by QtCreator 2013-01-19T22:49:15
+#
+#-------------------------------------------------
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = SamplePlugin1
+TEMPLATE = lib
+
+INCLUDEPATH += $$PWD/../../
+
+SOURCES +=\
+ plugin.cpp
+
+HEADERS +=
+
+FORMS += \
+ dialog.ui
+
+macx {
+ DLLDESTDIR = $$PWD/../../build/plugins/osx
+} else {
+ win32 {
+ DLLDESTDIR = $$PWD/../../build/plugins/win32
+ } else {
+ DLLDESTDIR = $$PWD/../../plugins/unix
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>162</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="1">
+ <widget class="QSlider" name="PluginToDennco1">
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Plugin -> Dennco 1</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Dennco -> Plugin 1</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSlider" name="DenncoToPlugin1">
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSlider" name="PluginToDennco2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSlider" name="DenncoToPlugin2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Plugin -> Dennco 2</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Dennco -> Plugin 2</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+
+
+#include "dennco_plugin.h"
+#include "ui_dialog.h"
+
+#include <QDialog>
+#include <QDebug>
+
+
+class PluginDialog;
+
+static PluginDialog *s_dialog = NULL;
+
+class PluginDialog : public QDialog
+{
+ Ui::Dialog *d_ui;
+
+public:
+
+ static void construct()
+ {
+ if (!s_dialog)
+ {
+ s_dialog = new PluginDialog;
+ }
+ }
+
+ static PluginDialog* instance()
+ {
+ return s_dialog;
+ }
+
+ static void destruct()
+ {
+ if (s_dialog)
+ {
+ s_dialog->close();
+ s_dialog->deleteLater();
+ s_dialog = NULL;
+ }
+ }
+
+ PluginDialog()
+ {
+ d_ui = new Ui::Dialog;
+ d_ui->setupUi(this);
+ }
+
+ virtual ~PluginDialog()
+ {
+ }
+
+ void setValue1(float v)
+ {
+ d_ui->DenncoToPlugin1->setValue(v*100);
+ }
+
+ void setValue2(float v)
+ {
+ d_ui->DenncoToPlugin2->setValue(v*100);
+ }
+
+ float getValue1() const
+ {
+ return d_ui->PluginToDennco1->value() / 100.0f;
+ }
+
+ float getValue2() const
+ {
+ return d_ui->PluginToDennco2->value() / 100.0f;
+ }
+
+};
+
+PLUGINAPI bool init()
+{
+ PluginDialog::construct();
+ PluginDialog::instance()->show();
+
+ return true;
+}
+
+PLUGINAPI bool unload()
+{
+ PluginDialog::destruct();
+
+ return true;
+}
+
+PLUGINAPI float queryPluginValue(const char* name)
+{
+ if (strcmp("input1", name) == 0)
+ {
+ return PluginDialog::instance()->getValue1();
+ }
+ else if (strcmp("input2", name) == 0)
+ {
+ return PluginDialog::instance()->getValue2();
+ }
+ else
+ {
+ QString msg;
+ msg.sprintf("SamplePlugin1: queryPluginValue: %s not found!\n", name);
+ qDebug() << msg;
+ }
+ return 0.0f;
+}
+
+PLUGINAPI void setValueToPlugin(const char* name, float value)
+{
+ if (strcmp("output1", name) == 0)
+ {
+ PluginDialog::instance()->setValue1(value);
+ }
+ else if (strcmp("output2", name) == 0)
+ {
+ PluginDialog::instance()->setValue2(value);
+ }
+ else
+ {
+ QString msg;
+ msg.sprintf("SamplePlugin1: setValueToPlugin: %s not found!\n", name);
+ qDebug() << msg;
+ }
+}
--- /dev/null
+// Copyright (c) 2013 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Jan-14/2013.
+//
+//
+#ifndef DENNCO_PLUGIN_H
+#define DENNCO_PLUGIN_H
+
+#ifndef PLUGINAPI
+#define PLUGINAPI extern "C" __declspec(dllexport)
+#endif
+
+PLUGINAPI bool init();
+PLUGINAPI bool unload();
+
+PLUGINAPI float queryPluginValue(const char* name);
+PLUGINAPI void setValueToPlugin(const char* name, float value);
+
+#endif //DENNCO_PLUGIN_H
#ifndef VERSIONINFO_H
#define VERSIONINFO_H
-#define CONTAINER_VERSION "alpha 2.0"
-#define ENGINE_VERSION "alpha 2.0"
+#define CONTAINER_VERSION "alpha 2.1d"
+#define ENGINE_VERSION "alpha 2.1d"
#endif // VERSIONINFO_H
TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS+= serialport Source
+SUBDIRS+= serialport Source/plugins/SamplePlugin1/SamplePlugin1 Source
serialport.file = Thirdparty/qt/qserialdevice-qserialdevice/serialport.pro