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_valueIterator = mReceptors.end();
34 d_forceUpdateIterator = mReceptors.end();
36 d_plugin = DNPluginManager::instance()->getPlugin(pluginName);
39 std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
40 message.append("'\nLoading the specified plugin : '").append(pluginName).append("' failed");
41 dnNotifyError("Initialization failed", message);
45 DNPluginOutputCell::~DNPluginOutputCell()
49 bool DNPluginOutputCell::doTick(float time)
54 if (d_valueIterator != mReceptors.end())
56 value = d_valueIterator->second->getValue();
60 d_valueIterator = mReceptors.find("value");
63 bool forceUpdate = false;
64 if (d_forceUpdateIterator != mReceptors.end())
66 forceUpdate = d_forceUpdateIterator->second->getValue() > 0;
70 d_forceUpdateIterator = mReceptors.find("forceUpdate");
73 mAxon->setValue(value);
74 if (d_plugin && d_plugin->getIsValid())
76 bool isReady = d_plugin->getIsReady();
77 if (isReady && (value != d_outputValue || forceUpdate))
79 d_outputValue = value;
80 d_plugin->setValueToPlugin(d_valueName.c_str(), value);
87 bool DNPluginOutputCell::doInit()
92 bool DNPluginOutputCell::doDestroy()
97 void DNPluginOutputCell::setValue(float value)