2025-06-25 14:34:26 +00:00
|
|
|
|
#include "BehaviorPerform.h"
|
|
|
|
|
|
|
|
|
|
|
2025-06-28 17:38:37 +00:00
|
|
|
|
void BehaviorPerformPlugin::mapReset(const QString& path)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorPerformPlugin::execute(std::shared_ptr<const EntityInitialRequest> in, QList<std::shared_ptr<RespondDefault>>& out)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorPerformPlugin::execute(std::shared_ptr<const EntityPreparedRequest> in, QList<std::shared_ptr<RespondDefault>>& out)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorPerformPlugin::execute(std::shared_ptr<const SyncRequest> in, QList<std::shared_ptr<RespondDefault>>& out)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorPerformPlugin::execute(std::shared_ptr<const DeduceRequest> in, QList<std::shared_ptr<RespondDefault>>& out)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 14:34:26 +00:00
|
|
|
|
void BehaviorPerformPlugin::recoveryFrom(const QJsonObject& obj)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorPerformPlugin::saveTo(QJsonObject& obj) const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-28 17:38:37 +00:00
|
|
|
|
std::shared_ptr<Serializable> BehaviorPerformPlugin::newDefault() const
|
2025-06-25 14:34:26 +00:00
|
|
|
|
{
|
2025-06-28 17:38:37 +00:00
|
|
|
|
return std::make_shared<BehaviorPerformPlugin>();
|
2025-06-25 14:34:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorPerformPlugin::bindEntity(std::weak_ptr<WsEntity> host)
|
|
|
|
|
{
|
2025-06-28 17:38:37 +00:00
|
|
|
|
this->_bind_entity = host;
|
2025-06-25 14:34:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BehaviorPerformPlugin::name() const
|
|
|
|
|
{
|
2025-06-28 17:38:37 +00:00
|
|
|
|
return NAME(BehaviorPerformPlugin);
|
2025-06-25 14:34:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-28 17:38:37 +00:00
|
|
|
|
#include <MessageLoader.h>
|
|
|
|
|
MapKernal::MapKernal(std::shared_ptr<MessageLoader> ins)
|
|
|
|
|
: _bind_loader(ins) {
|
|
|
|
|
for (auto key : ins->allType())
|
|
|
|
|
registData(ins->makeDefault(key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QString> MapKernal::compareTypes() const
|
|
|
|
|
{
|
|
|
|
|
return _compare_types.keys();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MapKernal::registCompare(std::shared_ptr<CompareKernel> ins)
|
2025-06-25 14:34:26 +00:00
|
|
|
|
{
|
2025-06-28 17:38:37 +00:00
|
|
|
|
_compare_types[ins->name()] = ins;
|
2025-06-25 14:34:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-28 17:38:37 +00:00
|
|
|
|
std::shared_ptr<CompareKernel> MapKernal::getCompare(const QString& name)
|
2025-06-25 14:34:26 +00:00
|
|
|
|
{
|
2025-06-28 17:38:37 +00:00
|
|
|
|
if (!_compare_types.contains(name))
|
2025-06-25 14:34:26 +00:00
|
|
|
|
return nullptr;
|
2025-06-28 17:38:37 +00:00
|
|
|
|
return _compare_types[name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MapKernal::registConvert(std::shared_ptr<ConvertKernel> ins)
|
|
|
|
|
{
|
|
|
|
|
_convert_types[ins->name()] = ins;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QString> MapKernal::convertTypes() const
|
|
|
|
|
{
|
|
|
|
|
return _convert_types.keys();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ConvertKernel> MapKernal::getConvert(const QString& name)
|
|
|
|
|
{
|
|
|
|
|
if (!_convert_types.contains(name))
|
|
|
|
|
return nullptr;
|
|
|
|
|
return _convert_types[name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<MessageLoader> MapKernal::messageLoader() const
|
|
|
|
|
{
|
|
|
|
|
return this->_bind_loader;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MapKernal::registData(std::shared_ptr<TopicData> init)
|
|
|
|
|
{
|
|
|
|
|
if (_variable_types.contains(init->topicString()))
|
|
|
|
|
throw new UniException(QString("<EFBFBD>ظ<EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{%1}").arg(init->topicString()));
|
|
|
|
|
|
|
|
|
|
_variable_types[init->topicString()] = init;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QString> MapKernal::dataTypes() const
|
|
|
|
|
{
|
|
|
|
|
return _variable_types.keys();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<TopicData> MapKernal::getData(const QString& topic)
|
|
|
|
|
{
|
|
|
|
|
return _variable_types[topic];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Serializable> MapKernal::newDefault() const
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogicalNode::LogicalNode(NodeKind t /*= NodeKind::ACTIONNODE*/)
|
|
|
|
|
:_node_type(t) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LogicalNode::setParent(std::weak_ptr<LogicalNode> pnode)
|
|
|
|
|
{
|
|
|
|
|
this->_parent_bind = pnode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NodeKind LogicalNode::kind() const
|
|
|
|
|
{
|
|
|
|
|
return _node_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<LogicalNode> LogicalNode::bindParentMap() const
|
|
|
|
|
{
|
|
|
|
|
auto node_temp = this->getBackwards().lock();
|
|
|
|
|
if (!node_temp) return nullptr;
|
|
|
|
|
|
|
|
|
|
while (node_temp->kind() != NodeKind::MAPNODE) {
|
|
|
|
|
node_temp = node_temp->getBackwards().lock();
|
|
|
|
|
}
|
|
|
|
|
return node_temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LogicalNode::setID(int unique_id)
|
|
|
|
|
{
|
|
|
|
|
this->_node_id = unique_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LogicalNode::getID() const
|
|
|
|
|
{
|
|
|
|
|
return this->_node_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString LogicalNode::runtimeName() const
|
|
|
|
|
{
|
|
|
|
|
return QString("%1(%2)").arg(this->typeName()).arg(getID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::weak_ptr<LogicalNode> LogicalNode::getBackwards() const
|
|
|
|
|
{
|
|
|
|
|
return this->_parent_bind;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BehaviorMapNode::BehaviorMapNode(std::shared_ptr<MessageLoader> core)
|
|
|
|
|
:LogicalNode(NodeKind::MAPNODE), MapKernal(core) {
|
|
|
|
|
}
|
2025-06-25 14:34:26 +00:00
|
|
|
|
|
2025-06-28 17:38:37 +00:00
|
|
|
|
void BehaviorMapNode::setVariable(const QString& key, IO_TYPE t, std::shared_ptr<TopicData> ins)
|
|
|
|
|
{
|
|
|
|
|
if (_variables.contains(key))
|
|
|
|
|
if (_variables[key].second->topicString() != ins->topicString())
|
|
|
|
|
throw new UniException("<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>");
|
|
|
|
|
_variables[key] = std::make_pair(t, ins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<TopicData> BehaviorMapNode::getVariable(const QString& key) const
|
|
|
|
|
{
|
|
|
|
|
if (!_variables.contains(key))
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
return _variables[key].second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorMapNode::resetName(const QString& val)
|
|
|
|
|
{
|
|
|
|
|
this->_map_name = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Serializable> BehaviorMapNode::newDefault() const
|
|
|
|
|
{
|
|
|
|
|
return std::make_shared<BehaviorMapNode>(this->messageLoader());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorMapNode::recoveryFrom(const QJsonObject& obj)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorMapNode::saveTo(QJsonObject& obj) const
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<LogicalNode>> BehaviorMapNode::getForwards() const
|
|
|
|
|
{
|
|
|
|
|
return children();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BehaviorMapNode::fallback(std::shared_ptr<LogicalNode> node, LogicalResult ste)
|
|
|
|
|
{
|
|
|
|
|
this->_state_value = ste;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorMapNode::reset()
|
|
|
|
|
{
|
|
|
|
|
this->_state_value = LogicalResult::UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BehaviorMapNode::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return _map_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogicalResult BehaviorMapNode::execute()
|
|
|
|
|
{
|
|
|
|
|
return _state_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> BehaviorMapNode::inputList() const
|
|
|
|
|
{
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> list;
|
|
|
|
|
for (auto key : this->_variables.keys()) {
|
|
|
|
|
if (this->_variables[key].first == IO_TYPE::INPUT && key.contains("::"))
|
|
|
|
|
list[key] = _variables[key].second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> BehaviorMapNode::outputList() const
|
|
|
|
|
{
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> list;
|
|
|
|
|
for (auto key : this->_variables.keys()) {
|
|
|
|
|
if (this->_variables[key].first == IO_TYPE::OUTPUT && key.contains("::"))
|
|
|
|
|
list[key] = _variables[key].second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SequenceNode::SequenceNode()
|
|
|
|
|
: LogicalNode(NodeKind::SEQUENCENODE) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<LogicalNode>> SequenceNode::getForwards() const
|
|
|
|
|
{
|
|
|
|
|
for (auto item : children()) {
|
|
|
|
|
// <20>ӽڵ<D3BD>ִ<EFBFBD><D6B4>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
if (_state_map.contains(item->getID())) {
|
|
|
|
|
if (_state_map[item->getID()] != LogicalResult::SUCCESS)
|
|
|
|
|
return QList<std::shared_ptr<LogicalNode>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD>½ڵ<C2BD>
|
|
|
|
|
if (!_state_map.contains(item->getID()))
|
|
|
|
|
return QList<std::shared_ptr<LogicalNode>>() << item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ȫ<><C8AB><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
return QList<std::shared_ptr<LogicalNode>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SequenceNode::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return "˳<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogicalResult SequenceNode::execute() {
|
|
|
|
|
if (children().size() >= _state_map.size())
|
|
|
|
|
return LogicalResult::FAILURE;
|
|
|
|
|
|
|
|
|
|
for (auto ste : this->_state_map) {
|
|
|
|
|
switch (ste) {
|
|
|
|
|
case LogicalResult::SUCCESS:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return LogicalResult::FAILURE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LogicalResult::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> SequenceNode::inputList() const
|
|
|
|
|
{
|
|
|
|
|
return QHash<QString, std::shared_ptr<TopicData>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> SequenceNode::outputList() const
|
|
|
|
|
{
|
|
|
|
|
return QHash<QString, std::shared_ptr<TopicData>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SequenceNode::recoveryFrom(const QJsonObject& obj)
|
|
|
|
|
{
|
|
|
|
|
QStringList state_items;
|
|
|
|
|
STRLIST_PEAK(state_items);
|
|
|
|
|
for (auto kv : state_items) {
|
|
|
|
|
auto kv_pair = kv.split(":");
|
|
|
|
|
_state_map[kv_pair[0].toInt()] = (LogicalResult)kv_pair[1].toInt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SequenceNode::saveTo(QJsonObject& obj) const
|
|
|
|
|
{
|
|
|
|
|
QStringList state_items;
|
|
|
|
|
for (auto inv : _state_map.keys()) {
|
|
|
|
|
state_items << QString("%1:%2").arg(inv).arg((int)_state_map[inv]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
STRLIST_SAVE(state_items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SequenceNode::fallback(std::shared_ptr<LogicalNode> node, LogicalResult ste)
|
|
|
|
|
{
|
|
|
|
|
this->_state_map[node->getID()] = ste;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Serializable> SequenceNode::newDefault() const
|
|
|
|
|
{
|
|
|
|
|
return std::make_shared<SequenceNode>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SequenceNode::reset()
|
|
|
|
|
{
|
|
|
|
|
this->_state_map.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<LogicalNode>> ComposeNode::children() const
|
|
|
|
|
{
|
|
|
|
|
return _child_list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ComposeNode::insert(std::shared_ptr<LogicalNode> node, int index /*= -1*/)
|
|
|
|
|
{
|
|
|
|
|
for (auto it : _child_list)
|
|
|
|
|
if (it->getID() == node->getID())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_child_list.insert(index, node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ComposeNode::remove(std::shared_ptr<LogicalNode> node)
|
|
|
|
|
{
|
|
|
|
|
_child_list.removeAll(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectorNode::SelectorNode()
|
|
|
|
|
: LogicalNode(NodeKind::SEQUENCENODE) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<LogicalNode>> SelectorNode::getForwards() const
|
|
|
|
|
{
|
|
|
|
|
for (auto item : children()) {
|
|
|
|
|
// <20>ӽڵ<D3BD>ִ<EFBFBD><D6B4>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
if (_state_map.contains(item->getID())) {
|
|
|
|
|
if (_state_map[item->getID()] == LogicalResult::SUCCESS)
|
|
|
|
|
return QList<std::shared_ptr<LogicalNode>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD>½ڵ<C2BD>
|
|
|
|
|
if (!_state_map.contains(item->getID()))
|
|
|
|
|
return QList<std::shared_ptr<LogicalNode>>() << item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ȫ<><C8AB><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
return QList<std::shared_ptr<LogicalNode>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SelectorNode::fallback(std::shared_ptr<LogicalNode> node, LogicalResult ste)
|
|
|
|
|
{
|
|
|
|
|
_state_map[node->getID()] = ste;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Serializable> SelectorNode::newDefault() const
|
|
|
|
|
{
|
|
|
|
|
return std::make_shared<SelectorNode>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectorNode::recoveryFrom(const QJsonObject& obj)
|
|
|
|
|
{
|
|
|
|
|
QStringList state_items;
|
|
|
|
|
STRLIST_PEAK(state_items);
|
|
|
|
|
for (auto kv : state_items) {
|
|
|
|
|
auto kv_pair = kv.split(":");
|
|
|
|
|
_state_map[kv_pair[0].toInt()] = (LogicalResult)kv_pair[1].toInt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectorNode::saveTo(QJsonObject& obj) const
|
|
|
|
|
{
|
|
|
|
|
QStringList state_items;
|
|
|
|
|
for (auto inv : _state_map.keys()) {
|
|
|
|
|
state_items << QString("%1:%2").arg(inv).arg((int)_state_map[inv]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
STRLIST_SAVE(state_items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectorNode::reset()
|
|
|
|
|
{
|
|
|
|
|
_state_map.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SelectorNode::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return "ѡ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogicalResult SelectorNode::execute()
|
|
|
|
|
{
|
|
|
|
|
for (auto value : _state_map) {
|
|
|
|
|
if (value == LogicalResult::SUCCESS)
|
|
|
|
|
return LogicalResult::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
return LogicalResult::FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> SelectorNode::inputList() const
|
|
|
|
|
{
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> SelectorNode::outputList() const
|
|
|
|
|
{
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<LogicalNode>> ParallelNode::getForwards() const
|
|
|
|
|
{
|
|
|
|
|
if (this->children().size() == _state_map.size())
|
|
|
|
|
return QList<std::shared_ptr<LogicalNode>>();
|
|
|
|
|
return this->children();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ParallelNode::fallback(std::shared_ptr<LogicalNode> node, LogicalResult ste)
|
|
|
|
|
{
|
|
|
|
|
_state_map[node->getID()] = ste;
|
|
|
|
|
return children().size() == _state_map.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParallelNode::reset()
|
|
|
|
|
{
|
|
|
|
|
_state_map.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ParallelNode::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return "<EFBFBD><EFBFBD><EFBFBD>нڵ<EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogicalResult ParallelNode::execute()
|
|
|
|
|
{
|
|
|
|
|
for (auto ste : this->_state_map)
|
|
|
|
|
if (ste != LogicalResult::SUCCESS)
|
|
|
|
|
return LogicalResult::FAILURE;
|
|
|
|
|
|
|
|
|
|
return LogicalResult::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Serializable> ParallelNode::newDefault() const
|
|
|
|
|
{
|
|
|
|
|
return std::make_shared<ParallelNode>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParallelNode::ParallelNode()
|
|
|
|
|
: LogicalNode(NodeKind::PARALLELNODE) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> ParallelNode::inputList() const
|
|
|
|
|
{
|
|
|
|
|
return QHash<QString, std::shared_ptr<TopicData>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> ParallelNode::outputList() const
|
|
|
|
|
{
|
|
|
|
|
return QHash<QString, std::shared_ptr<TopicData>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParallelNode::recoveryFrom(const QJsonObject& obj)
|
|
|
|
|
{
|
|
|
|
|
QStringList state_items;
|
|
|
|
|
STRLIST_PEAK(state_items);
|
|
|
|
|
for (auto kv : state_items) {
|
|
|
|
|
auto kv_pair = kv.split(":");
|
|
|
|
|
_state_map[kv_pair[0].toInt()] = (LogicalResult)kv_pair[1].toInt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParallelNode::saveTo(QJsonObject& obj) const
|
|
|
|
|
{
|
|
|
|
|
QStringList state_items;
|
|
|
|
|
for (auto inv : _state_map.keys()) {
|
|
|
|
|
state_items << QString("%1:%2").arg(inv).arg((int)_state_map[inv]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
STRLIST_SAVE(state_items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompareNode::reset() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CompareNode::typeName() const
|
|
|
|
|
{
|
|
|
|
|
return QString("%1<%2>").arg("<EFBFBD>ȽϽڵ<EFBFBD>", delegateName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogicalResult CompareNode::execute()
|
|
|
|
|
{
|
|
|
|
|
if (this->_bind_delegate) {
|
|
|
|
|
auto vl = _data_map["<EFBFBD><EFBFBD>ֵ"];
|
|
|
|
|
auto vb = _data_map["<EFBFBD><EFBFBD>ֵ"];
|
|
|
|
|
if (this->_bind_delegate->compare(vl, vb))
|
|
|
|
|
return LogicalResult::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
return LogicalResult::FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Serializable> CompareNode::newDefault() const
|
|
|
|
|
{
|
|
|
|
|
return std::make_shared<CompareNode>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompareNode::CompareNode()
|
|
|
|
|
: LogicalNode(NodeKind::COMPARENODE) {
|
|
|
|
|
_data_map["<EFBFBD><EFBFBD>ֵ"] = std::make_shared<GeneralData>();
|
|
|
|
|
_data_map["<EFBFBD><EFBFBD>ֵ"] = std::make_shared<GeneralData>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CompareNode::delegateName() const
|
|
|
|
|
{
|
|
|
|
|
if (_bind_delegate)
|
|
|
|
|
return _bind_delegate->name();
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompareNode::bindDelegate(std::shared_ptr<CompareKernel> ins)
|
|
|
|
|
{
|
|
|
|
|
this->_bind_delegate = ins;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> CompareNode::inputList() const
|
|
|
|
|
{
|
|
|
|
|
return _data_map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<TopicData>> CompareNode::outputList() const
|
|
|
|
|
{
|
|
|
|
|
return QHash<QString, std::shared_ptr<TopicData>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompareNode::recoveryFrom(const QJsonObject& obj)
|
|
|
|
|
{
|
|
|
|
|
auto vala = obj["ValL"];
|
|
|
|
|
auto valb = obj["ValR"];
|
|
|
|
|
|
|
|
|
|
_data_map["<EFBFBD><EFBFBD>ֵ"]->recoveryFrom(vala.toObject());
|
|
|
|
|
_data_map["<EFBFBD><EFBFBD>ֵ"]->recoveryFrom(valb.toObject());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompareNode::saveTo(QJsonObject& obj) const
|
|
|
|
|
{
|
|
|
|
|
QJsonObject vala, valb;
|
|
|
|
|
_data_map["<EFBFBD><EFBFBD>ֵ"]->saveTo(vala);
|
|
|
|
|
_data_map["<EFBFBD><EFBFBD>ֵ"]->saveTo(valb);
|
|
|
|
|
|
|
|
|
|
obj["ValL"] = vala;
|
|
|
|
|
obj["ValR"] = valb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
QString GeneralData::topicString() const
|
|
|
|
|
{
|
|
|
|
|
return "GeneralData";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Serializable> GeneralData::newDefault() const
|
|
|
|
|
{
|
|
|
|
|
return std::make_shared<GeneralData>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GeneralData::recoveryFrom(const QJsonObject& obj)
|
|
|
|
|
{
|
|
|
|
|
_element_bind = obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GeneralData::saveTo(QJsonObject& obj) const
|
|
|
|
|
{
|
|
|
|
|
obj = _element_bind;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompareKernel::CompareKernel(QJSEngine& bind_engine, const QString& func)
|
|
|
|
|
:_script_engine(bind_engine), _function_name(func) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CompareKernel::name() const
|
|
|
|
|
{
|
|
|
|
|
return _function_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CompareKernel::compare(std::shared_ptr<TopicData> vleft, std::shared_ptr<TopicData> vright)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConvertKernel::ConvertKernel(std::shared_ptr<MapKernal> host, QJSEngine& bind_engine, const QString& func)
|
|
|
|
|
: _host_bind(host), _script_engine(bind_engine), _function_name(func) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ConvertKernel::name() const
|
|
|
|
|
{
|
|
|
|
|
return _function_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::pair<ConvertKernel::DATA_TOPIC_STRING, QString>> ConvertKernel::inputTable() const
|
|
|
|
|
{
|
|
|
|
|
return _input_table;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConvertKernel::inputReset(const QList<std::pair<DATA_TOPIC_STRING, QString>>& table)
|
|
|
|
|
{
|
|
|
|
|
this->_input_table = table;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::pair<ConvertKernel::DATA_TOPIC_STRING, QString> ConvertKernel::outputVariable() const
|
|
|
|
|
{
|
|
|
|
|
return _output_appoint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConvertKernel::outputReset(std::pair<DATA_TOPIC_STRING, QString> appoint)
|
|
|
|
|
{
|
|
|
|
|
this->_output_appoint = appoint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<TopicData> ConvertKernel::convert(const QList<std::shared_ptr<TopicData>>& input_variables)
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
2025-06-25 14:34:26 +00:00
|
|
|
|
}
|