1 // Copyright (c) 2012 Dennco Project
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // Created by tkawata on 1/17/2013.
19 #include "dnpluginoutputcell.h"
22 #include "dnpluginmanager.h"
23 #include "TKReceptor.h"
29 DNPluginOutputCell::DNPluginOutputCell(TKContainer *container, std::string location, std::string name, std::string pluginName, std::string valueName)
30 : DNCellInterfaceable(container, location, name, false, true),
31 d_plugin(NULL), d_valueName(valueName), d_outputValue(std::numeric_limits<float>::quiet_NaN()), d_wasReady(false)
33 d_plugin = DNPluginManager::instance()->getPlugin(pluginName);
36 std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
37 message.append("'\nLoading the specified plugin : '").append(pluginName).append("' failed");
38 dnNotifyError("Initialization failed", message);
42 DNPluginOutputCell::~DNPluginOutputCell()
46 bool DNPluginOutputCell::doTick(float time)
52 for ( TKReceptorMap::iterator it = mReceptors.begin(); it != mReceptors.end(); ++it ) {
53 value += it->second->getValue();
56 mAxon->setValue(value);
57 if (d_plugin && d_plugin->getIsValid())
59 bool isReady = d_plugin->getIsReady();
60 if (isReady && (d_outputValue != value ||!d_wasReady))
62 d_outputValue = value;
63 d_plugin->setValueToPlugin(d_valueName.c_str(), value);
70 bool DNPluginOutputCell::doInit()
75 bool DNPluginOutputCell::doDestroy()
80 void DNPluginOutputCell::setValue(float value)