parent
8ff26d2257
commit
ed6371a19f
|
@ -37,7 +37,7 @@
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||||
<QtInstall>5.12.11_msvc2017_64</QtInstall>
|
<QtInstall>5.12.11_msvc2017_64</QtInstall>
|
||||||
<QtModules>core;gui</QtModules>
|
<QtModules>core;gui;concurrent</QtModules>
|
||||||
<QtBuildConfig>debug</QtBuildConfig>
|
<QtBuildConfig>debug</QtBuildConfig>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>MessageBasic.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>MessageBasic.lib;SimsBasic.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
@ -101,12 +101,12 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="EntitiesManager.cpp" />
|
<ClCompile Include="EntityDocks.cpp" />
|
||||||
<ClCompile Include="MapRoute.cpp" />
|
<ClCompile Include="MapRoute.cpp" />
|
||||||
<ClCompile Include="VisibleBox.cpp" />
|
<ClCompile Include="VisibleBox.cpp" />
|
||||||
<ClInclude Include="componentbasic_global.h" />
|
<ClInclude Include="componentbasic_global.h" />
|
||||||
<ClInclude Include="componentbasic.h" />
|
<ClInclude Include="componentbasic.h" />
|
||||||
<ClInclude Include="EntityDocks.h" />
|
<QtMoc Include="EntityDocks.h" />
|
||||||
<ClInclude Include="MapRoute.h" />
|
<ClInclude Include="MapRoute.h" />
|
||||||
<ClInclude Include="VisibleBox.h" />
|
<ClInclude Include="VisibleBox.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -35,9 +35,6 @@
|
||||||
<ClInclude Include="MapRoute.h">
|
<ClInclude Include="MapRoute.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="EntityDocks.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="VisibleBox.cpp">
|
<ClCompile Include="VisibleBox.cpp">
|
||||||
|
@ -46,8 +43,13 @@
|
||||||
<ClCompile Include="MapRoute.cpp">
|
<ClCompile Include="MapRoute.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="EntitiesManager.cpp">
|
<ClCompile Include="EntityDocks.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<QtMoc Include="EntityDocks.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1 +0,0 @@
|
||||||
#include "EntityDocks.h"
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
#include "EntityDocks.h"
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
QList<std::shared_ptr<WsMessage>> deduct_each(std::shared_ptr<WsEntity> item)
|
||||||
|
{
|
||||||
|
QList<std::shared_ptr<WsMessage>> rets;
|
||||||
|
auto immediate = std::make_shared<ImmediateCore>(item);
|
||||||
|
|
||||||
|
for (auto msg : DeduceFramework::_accept_stack) {
|
||||||
|
if (msg->targetEntity() == item->entityID()) {
|
||||||
|
auto enters = item->getEntryWithInType(msg->topicString());
|
||||||
|
for (auto e : enters)
|
||||||
|
e(immediate, msg, rets);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rets;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<std::shared_ptr<WsMessage>> DeduceFramework::_accept_stack;
|
||||||
|
void DeduceFramework::accept(const QList<std::shared_ptr<WsMessage>>& set)
|
||||||
|
{
|
||||||
|
_accept_stack.append(set);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
void DeduceFramework::deduceBegin(std::shared_ptr<const DeduceRequest> ins)
|
||||||
|
{
|
||||||
|
auto dt = QTime::currentTime();
|
||||||
|
|
||||||
|
auto ret_list_set = QtConcurrent::blockingMapped(
|
||||||
|
_entity_map.values(), deduct_each
|
||||||
|
);
|
||||||
|
|
||||||
|
_accept_stack.clear();
|
||||||
|
for (auto vlist : ret_list_set)
|
||||||
|
emit this->reply(vlist);
|
||||||
|
|
||||||
|
auto fmsg = std::make_shared<RespondDefault>();
|
||||||
|
fmsg->reset(ins->targetEntity(), ins->sourceEntity());
|
||||||
|
fmsg->_time_consume = dt.msecsTo(QTime::currentTime());
|
||||||
|
emit this->complete(fmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <simsbasic.h>
|
||||||
|
DeduceFramework::DeduceFramework() {
|
||||||
|
auto mgr_e = std::make_shared<EntitiesManager>();
|
||||||
|
mgr_e->append(this->shared_from_this());
|
||||||
|
this->_entity_map[mgr_e->entityID()] = mgr_e;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<WsComponent> DeduceFramework::defaultNew() const
|
||||||
|
{
|
||||||
|
throw std::logic_error("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeduceFramework::bindEntity(uint64_t entity_id)
|
||||||
|
{
|
||||||
|
this->_bind_entity = entity_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DeduceFramework::name() const
|
||||||
|
{
|
||||||
|
return NAME(DeduceFramework);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeduceFramework::recoveryFrom(const QJsonObject& obj)
|
||||||
|
{
|
||||||
|
throw std::logic_error("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeduceFramework::saveTo(QJsonObject& obj) const
|
||||||
|
{
|
||||||
|
throw std::logic_error("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeduceFramework::execute(std::shared_ptr<ImmediateMap> map,
|
||||||
|
std::shared_ptr<const EntityAllocte> in, QList<std::shared_ptr<RespondDefault>>& out)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void DeduceFramework::execute(std::shared_ptr<ImmediateMap> map,
|
||||||
|
std::shared_ptr<const EntityTotalGet> in, QList<std::shared_ptr<EntityTotalList>>& out)
|
||||||
|
{
|
||||||
|
auto rst = std::make_shared<EntityTotalList>();
|
||||||
|
rst->reset(in->targetEntity(), in->sourceEntity());
|
||||||
|
rst->_entities_list = _entity_map.keys();
|
||||||
|
out << rst;
|
||||||
|
}
|
|
@ -1,2 +1,56 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <simsbasic.h>
|
#include <simsbasic.h>
|
||||||
|
#include <messagebasic.h>
|
||||||
|
#include "componentbasic.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
|
class COMPONENTBASIC_EXPORT DeduceFramework : public QObject,
|
||||||
|
public ProcList<
|
||||||
|
WsRespond<EntityAllocte, RespondDefault>,
|
||||||
|
WsRespond<EntityTotalGet, EntityTotalList>>
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
uint64_t _bind_entity = 0;
|
||||||
|
|
||||||
|
QHash<uint64_t, std::shared_ptr<WsEntity>> _entity_map;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/// <summary>
|
||||||
|
/// 推演过程中的回复信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="msg_set">消息列表</param>
|
||||||
|
void reply(const QList<std::shared_ptr<WsMessage>> &msg_set);
|
||||||
|
/// <summary>
|
||||||
|
/// 推演完成
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ins">回复消息</param>
|
||||||
|
void complete(std::shared_ptr<RespondDefault> ins);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/// <summary>
|
||||||
|
/// 接收消息列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="set">传入的消息队列</param>
|
||||||
|
void accept(const QList<std::shared_ptr<WsMessage>> &set);
|
||||||
|
/// <summary>
|
||||||
|
/// 推演入口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ins">消息</param>
|
||||||
|
void deduceBegin(std::shared_ptr<const DeduceRequest> ins);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static QList<std::shared_ptr<WsMessage>> _accept_stack;
|
||||||
|
DeduceFramework();
|
||||||
|
|
||||||
|
std::shared_ptr<WsComponent> defaultNew() const override;
|
||||||
|
void bindEntity(uint64_t entity_id) override;
|
||||||
|
QString name() const override;
|
||||||
|
void recoveryFrom(const QJsonObject& obj) override;
|
||||||
|
void saveTo(QJsonObject& obj) const override;
|
||||||
|
|
||||||
|
|
||||||
|
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const EntityAllocte> in, QList<std::shared_ptr<RespondDefault>>& out) override;
|
||||||
|
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const EntityTotalGet> in, QList<std::shared_ptr<EntityTotalList>>& out) override;
|
||||||
|
};
|
|
@ -51,12 +51,12 @@ QString Visible3DPlugin::name() const {
|
||||||
return NAME(Visible3DPlugin);
|
return NAME(Visible3DPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visible3DPlugin::execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const Get3DBox> in, std::shared_ptr<Box3DDesc>& out)
|
void Visible3DPlugin::execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const Get3DBox> in, QList<std::shared_ptr<Box3DDesc>>& out)
|
||||||
{
|
{
|
||||||
auto ins = std::make_shared<Box3DDesc>();
|
auto ins = std::make_shared<Box3DDesc>();
|
||||||
ins->_lla_pos = _self_lla;
|
ins->_lla_pos = _self_lla;
|
||||||
ins->_posture_d3 = _self_posture;
|
ins->_posture_d3 = _self_posture;
|
||||||
ins->_d3_data = _self_d3;
|
ins->_d3_data = _self_d3;
|
||||||
ins->reset(_bind_entity, in->sourceEntity());
|
ins->reset(_bind_entity, in->sourceEntity());
|
||||||
out = ins;
|
out << ins;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
void bindEntity(uint64_t entity_id) override;
|
void bindEntity(uint64_t entity_id) override;
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
|
|
||||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const Get3DBox> in, std::shared_ptr<Box3DDesc>& out) override;
|
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const Get3DBox> in, QList<std::shared_ptr<Box3DDesc>>& out) override;
|
||||||
|
|
||||||
std::shared_ptr<WsComponent> defaultNew() const override;
|
std::shared_ptr<WsComponent> defaultNew() const override;
|
||||||
void recoveryFrom(const QJsonObject& obj) override;
|
void recoveryFrom(const QJsonObject& obj) override;
|
||||||
|
|
|
@ -28,16 +28,17 @@ public:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="in"></param>
|
/// <param name="in"></param>
|
||||||
/// <param name="out"></param>
|
/// <param name="out"></param>
|
||||||
virtual void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const MsgA> in, std::shared_ptr<MsgB>& out) = 0;
|
virtual void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const MsgA> in, QList<std::shared_ptr<MsgB>>& out) = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WsRespond构造函数
|
/// WsRespond构造函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="map">注册函数</param>
|
/// <param name="map">注册函数</param>
|
||||||
explicit WsRespond(QHash<WsRespondSignatureType, WsRespondEntry>& map) {
|
explicit WsRespond(QHash<WsRespondSignatureType, WsRespondEntry>& map) {
|
||||||
WsRespondEntry ins = [=](std::shared_ptr<ImmediateMap> map, std::shared_ptr<const WsMessage> in, std::shared_ptr<WsMessage>& out) {
|
WsRespondEntry ins = [=](std::shared_ptr<ImmediateMap> map, std::shared_ptr<const WsMessage> in, QList<std::shared_ptr<WsMessage>>& out) {
|
||||||
std::shared_ptr<MsgB> o_ptr;
|
QList<std::shared_ptr<MsgB>> o_ptrs;
|
||||||
this->execute(map, std::static_pointer_cast<const MsgA>(in), o_ptr);
|
this->execute(map, std::static_pointer_cast<const MsgA>(in), o_ptrs);
|
||||||
out = o_ptr;
|
std::transform(o_ptrs.begin(), o_ptrs.end(), std::back_inserter(out),
|
||||||
|
[](std::shared_ptr<MsgB> v) { return std::static_pointer_cast<WsMessage>(v); });
|
||||||
};
|
};
|
||||||
map[SelfType::signature()] = ins;
|
map[SelfType::signature()] = ins;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,10 @@ EntityTotalGet::EntityTotalGet()
|
||||||
:AbstractMessage(NAME(EntityTotalGet)) {
|
:AbstractMessage(NAME(EntityTotalGet)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityTotalList::EntityTotalList()
|
||||||
|
:AbstractMessage(NAME(EntityTotalList)) {
|
||||||
|
}
|
||||||
|
|
||||||
void EntityTotalList::recoveryFrom(const QJsonObject& obj)
|
void EntityTotalList::recoveryFrom(const QJsonObject& obj)
|
||||||
{
|
{
|
||||||
AbstractMessage::recoveryFrom(obj);
|
AbstractMessage::recoveryFrom(obj);
|
||||||
|
|
|
@ -121,13 +121,20 @@ struct MESSAGEBASIC_EXPORT EntityAllocte : public AbstractMessage {
|
||||||
void saveTo(QJsonObject& obj) const override;
|
void saveTo(QJsonObject& obj) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有实体句柄
|
||||||
|
/// </summary>
|
||||||
struct MESSAGEBASIC_EXPORT EntityTotalGet : public AbstractMessage {
|
struct MESSAGEBASIC_EXPORT EntityTotalGet : public AbstractMessage {
|
||||||
EntityTotalGet();
|
EntityTotalGet();
|
||||||
};
|
};
|
||||||
|
/// <summary>
|
||||||
|
/// 所有实体列表
|
||||||
|
/// </summary>
|
||||||
struct MESSAGEBASIC_EXPORT EntityTotalList : public AbstractMessage {
|
struct MESSAGEBASIC_EXPORT EntityTotalList : public AbstractMessage {
|
||||||
QList<uint64_t> _entities_list;
|
QList<uint64_t> _entities_list;
|
||||||
|
|
||||||
|
EntityTotalList();
|
||||||
|
|
||||||
// ͨ¹ý WsMessage ¼Ì³Ð
|
// ͨ¹ý WsMessage ¼Ì³Ð
|
||||||
void recoveryFrom(const QJsonObject& obj) override;
|
void recoveryFrom(const QJsonObject& obj) override;
|
||||||
void saveTo(QJsonObject& obj) const override;
|
void saveTo(QJsonObject& obj) const override;
|
||||||
|
|
|
@ -203,10 +203,7 @@ QList<std::shared_ptr<WsMessage>> ImmediateCore::execute(const WsRespondSignatur
|
||||||
QList<std::shared_ptr<WsMessage>> rets;
|
QList<std::shared_ptr<WsMessage>> rets;
|
||||||
auto list = this->_bind_entity->getEntryWithSignature(resp_signature);
|
auto list = this->_bind_entity->getEntryWithSignature(resp_signature);
|
||||||
for (auto func : list) {
|
for (auto func : list) {
|
||||||
std::shared_ptr<WsMessage> out;
|
func(shared_from_this(), in, rets);
|
||||||
func(shared_from_this(), in, out);
|
|
||||||
|
|
||||||
if (out) rets << out;
|
|
||||||
}
|
}
|
||||||
return rets;
|
return rets;
|
||||||
}
|
}
|
||||||
|
@ -216,10 +213,7 @@ QList<std::shared_ptr<WsMessage>> ImmediateCore::execute(std::shared_ptr<const W
|
||||||
QList<std::shared_ptr<WsMessage>> rets;
|
QList<std::shared_ptr<WsMessage>> rets;
|
||||||
auto list = this->_bind_entity->getEntryWithInType(in->topicString());
|
auto list = this->_bind_entity->getEntryWithInType(in->topicString());
|
||||||
for (auto func : list) {
|
for (auto func : list) {
|
||||||
std::shared_ptr<WsMessage> out;
|
func(shared_from_this(), in, rets);
|
||||||
func(shared_from_this(), in, out);
|
|
||||||
|
|
||||||
if (out) rets << out;
|
|
||||||
}
|
}
|
||||||
return rets;
|
return rets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所有消息处理单元通用接口
|
/// 所有消息处理单元通用接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
using WsRespondEntry = std::function<void(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const WsMessage>, std::shared_ptr<WsMessage>&)>;
|
using WsRespondEntry = std::function<void(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const WsMessage>, QList<std::shared_ptr<WsMessage>>&)>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 功能插件的基类
|
/// 功能插件的基类
|
||||||
|
|
Loading…
Reference in New Issue