This commit is contained in:
codeboss 2025-05-31 12:18:43 +08:00
parent 1f04de258a
commit 30739ba3c3
7 changed files with 69 additions and 56 deletions

View File

@ -2,44 +2,36 @@
// ͨ¹ý ProcList ¼Ì³Ð // ͨ¹ý ProcList ¼Ì³Ð
std::shared_ptr<Box3DDesc> Visible3DPlugin::execute(std::shared_ptr<const Get3DBox> in) {
auto ins = std::make_shared<Box3DDesc>();
ins->setPosition(_self_lla);
ins->setPosture(_self_posture);
ins->setTarget(_bind_entity, in->sourceEntity());
ins->setVolume(_self_d3);
return ins;
}
void Visible3DPlugin::recoveryFrom(const QJsonObject& obj) { void Visible3DPlugin::recoveryFrom(const QJsonObject& obj) {
this->_bind_entity = obj["_bind_entity"].toVariant().toULongLong(); this->_bind_entity = obj["_bind_entity"].toVariant().toULongLong();
DBL_PEAK(_self_d3._length_m); DOUOBLE_PEAK(_self_d3._length_m);
DBL_PEAK(_self_d3._width_m); DOUOBLE_PEAK(_self_d3._width_m);
DBL_PEAK(_self_d3._height_m); DOUOBLE_PEAK(_self_d3._height_m);
DBL_PEAK(_self_lla._lon_deg); DOUOBLE_PEAK(_self_lla._lon_deg);
DBL_PEAK(_self_lla._lat_deg); DOUOBLE_PEAK(_self_lla._lat_deg);
DBL_PEAK(_self_lla._alt_m); DOUOBLE_PEAK(_self_lla._alt_m);
DBL_PEAK(_self_posture._azimuth_deg); DOUOBLE_PEAK(_self_posture._azimuth_deg);
DBL_PEAK(_self_posture._pitch_deg); DOUOBLE_PEAK(_self_posture._pitch_deg);
DBL_PEAK(_self_posture._roll_deg); DOUOBLE_PEAK(_self_posture._roll_deg);
} }
void Visible3DPlugin::saveTo(QJsonObject& obj) const { void Visible3DPlugin::saveTo(QJsonObject& obj) const {
obj["_bind_entity"] = QJsonValue::fromVariant(QVariant::fromValue(this->_bind_entity)); obj["_bind_entity"] = QJsonValue::fromVariant(QVariant::fromValue(this->_bind_entity));
DBL_SAVE(_self_d3._length_m); DOUBLE_SAVE(_self_d3._length_m);
DBL_SAVE(_self_d3._width_m); DOUBLE_SAVE(_self_d3._width_m);
DBL_SAVE(_self_d3._height_m); DOUBLE_SAVE(_self_d3._height_m);
DBL_SAVE(_self_lla._lon_deg); DOUBLE_SAVE(_self_lla._lon_deg);
DBL_SAVE(_self_lla._lat_deg); DOUBLE_SAVE(_self_lla._lat_deg);
DBL_SAVE(_self_lla._alt_m); DOUBLE_SAVE(_self_lla._alt_m);
DBL_SAVE(_self_posture._azimuth_deg); DOUBLE_SAVE(_self_posture._azimuth_deg);
DBL_SAVE(_self_posture._pitch_deg); DOUBLE_SAVE(_self_posture._pitch_deg);
DBL_SAVE(_self_posture._roll_deg); DOUBLE_SAVE(_self_posture._roll_deg);
} }
std::shared_ptr<WsComponent> Visible3DPlugin::defaultNew() const { std::shared_ptr<WsComponent> Visible3DPlugin::defaultNew() const {
@ -58,3 +50,13 @@ void Visible3DPlugin::bindEntity(uint64_t entity_id) {
QString Visible3DPlugin::name() const { QString Visible3DPlugin::name() const {
return NAME(Visible3DPlugin); return NAME(Visible3DPlugin);
} }
void Visible3DPlugin::execute(std::shared_ptr<const Get3DBox> in, std::shared_ptr<Box3DDesc>& out)
{
auto ins = std::make_shared<Box3DDesc>();
ins->setPosition(_self_lla);
ins->setPosture(_self_posture);
ins->setTarget(_bind_entity, in->sourceEntity());
ins->setVolume(_self_d3);
out = ins;
}

View File

@ -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;
std::shared_ptr<Box3DDesc> execute(std::shared_ptr<const Get3DBox> in) override; void execute(std::shared_ptr<const Get3DBox> in, 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;

View File

@ -27,15 +27,17 @@ public:
/// 子类中实际处理函数 /// 子类中实际处理函数
/// </summary> /// </summary>
/// <param name="in"></param> /// <param name="in"></param>
/// <returns></returns> /// <param name="out"></param>
virtual std::shared_ptr<MsgB> execute(std::shared_ptr<const MsgA> in) = 0; virtual void execute(std::shared_ptr<const MsgA> in, 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<const WsMessage> in) -> std::shared_ptr<WsMessage> { WsRespondEntry ins = [=](std::shared_ptr<const WsMessage> in, std::shared_ptr<WsMessage>& out) {
return this->execute(std::static_pointer_cast<const MsgA>(in)); std::shared_ptr<MsgB> o_ptr;
this->execute(std::static_pointer_cast<const MsgA>(in), o_ptr);
out = o_ptr;
}; };
map[SelfType::signature()] = ins; map[SelfType::signature()] = ins;
} }
@ -71,12 +73,14 @@ struct ProcList : public _ProcRoute_<Procs...>, public WsComponent
} }
return list; return list;
} }
WsRespondEntry getEntryWithSignature(const WsRespondSignatureType& t) const override QList<WsRespondEntry> getEntryWithSignature(const WsRespondSignatureType& t) const override
{ {
QList<WsRespondEntry> list;
for (auto key : _ProcRoute_<>::_execute_map.keys()) { for (auto key : _ProcRoute_<>::_execute_map.keys()) {
if (key == t) if (key == t)
return _ProcRoute_<>::_execute_map[key]; list.append(_ProcRoute_<>::_execute_map[key]);
} }
return list;
} }
QList<WsRespondEntry> getEntrysWithInType(const QString& msg_type) const override QList<WsRespondEntry> getEntrysWithInType(const QString& msg_type) const override
{ {

View File

@ -184,34 +184,34 @@ LLAPos Box3DDesc::position() const { return this->_lla_pos; }
void Box3DDesc::recoveryFrom(const QJsonObject& obj) void Box3DDesc::recoveryFrom(const QJsonObject& obj)
{ {
from_to_recovery(_from_id, _to_id, obj); from_to_recovery(_from_id, _to_id, obj);
DBL_PEAK(this->_d3_data._height_m); DOUOBLE_PEAK(this->_d3_data._height_m);
DBL_PEAK(this->_d3_data._length_m); DOUOBLE_PEAK(this->_d3_data._length_m);
DBL_PEAK(this->_d3_data._width_m); DOUOBLE_PEAK(this->_d3_data._width_m);
DBL_PEAK(this->_lla_pos._lon_deg); DOUOBLE_PEAK(this->_lla_pos._lon_deg);
DBL_PEAK(this->_lla_pos._lat_deg); DOUOBLE_PEAK(this->_lla_pos._lat_deg);
DBL_PEAK(this->_lla_pos._alt_m); DOUOBLE_PEAK(this->_lla_pos._alt_m);
DBL_PEAK(this->_posture_d3._azimuth_deg); DOUOBLE_PEAK(this->_posture_d3._azimuth_deg);
DBL_PEAK(this->_posture_d3._pitch_deg); DOUOBLE_PEAK(this->_posture_d3._pitch_deg);
DBL_PEAK(this->_posture_d3._roll_deg); DOUOBLE_PEAK(this->_posture_d3._roll_deg);
} }
void Box3DDesc::saveTo(QJsonObject& obj) const void Box3DDesc::saveTo(QJsonObject& obj) const
{ {
from_to_save(_from_id, _to_id, obj); from_to_save(_from_id, _to_id, obj);
DBL_SAVE(this->_d3_data._height_m); DOUBLE_SAVE(this->_d3_data._height_m);
DBL_SAVE(this->_d3_data._length_m); DOUBLE_SAVE(this->_d3_data._length_m);
DBL_SAVE(this->_d3_data._width_m); DOUBLE_SAVE(this->_d3_data._width_m);
DBL_SAVE(this->_lla_pos._lon_deg); DOUBLE_SAVE(this->_lla_pos._lon_deg);
DBL_SAVE(this->_lla_pos._lat_deg); DOUBLE_SAVE(this->_lla_pos._lat_deg);
DBL_SAVE(this->_lla_pos._alt_m); DOUBLE_SAVE(this->_lla_pos._alt_m);
DBL_SAVE(this->_posture_d3._azimuth_deg); DOUBLE_SAVE(this->_posture_d3._azimuth_deg);
DBL_SAVE(this->_posture_d3._pitch_deg); DOUBLE_SAVE(this->_posture_d3._pitch_deg);
DBL_SAVE(this->_posture_d3._roll_deg); DOUBLE_SAVE(this->_posture_d3._roll_deg);
} }
QString Box3DDesc::topicString() const QString Box3DDesc::topicString() const

View File

@ -4,8 +4,8 @@
#include "simsbasic.h" #include "simsbasic.h"
#define NAME(v) #v #define NAME(v) #v
#define DBL_SAVE(u) obj[NAME(u)] = u #define DOUBLE_SAVE(u) obj[NAME(u)] = u
#define DBL_PEAK(u) u = obj[NAME(u)].toDouble() #define DOUOBLE_PEAK(u) u = obj[NAME(u)].toDouble()
/// <summary> /// <summary>
/// ÍÆÑÝÇëÇó /// ÍÆÑÝÇëÇó

View File

@ -63,7 +63,7 @@ public:
/// <summary> /// <summary>
/// 所有消息处理单元通用接口 /// 所有消息处理单元通用接口
/// </summary> /// </summary>
using WsRespondEntry = std::function<std::shared_ptr<WsMessage>(std::shared_ptr<const WsMessage>)>; using WsRespondEntry = std::function<void(std::shared_ptr<const WsMessage>, std::shared_ptr<WsMessage>&)>;
/// <summary> /// <summary>
/// Respond签名类型 /// Respond签名类型
/// </summary> /// </summary>
@ -103,7 +103,7 @@ public:
/// </summary> /// </summary>
/// <param name="t">处理签名</param> /// <param name="t">处理签名</param>
/// <returns>处理接口</returns> /// <returns>处理接口</returns>
virtual WsRespondEntry getEntryWithSignature(const WsRespondSignatureType& t) const = 0; virtual QList<WsRespondEntry> getEntryWithSignature(const WsRespondSignatureType& t) const = 0;
/// <summary> /// <summary>
/// 通过输入消息类型获取处理入口 /// 通过输入消息类型获取处理入口
/// </summary> /// </summary>

View File

@ -1,15 +1,22 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.13.35825.156 d17.13 VisualStudioVersion = 17.13.35825.156
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimsWorld", "SimsWorld\SimsWorld.vcxproj", "{46E3FBA5-6775-4638-AE2E-935675D3B9CE}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimsWorld", "SimsWorld\SimsWorld.vcxproj", "{46E3FBA5-6775-4638-AE2E-935675D3B9CE}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimsBasic", "SimsBasic\SimsBasic.vcxproj", "{DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimsBasic", "SimsBasic\SimsBasic.vcxproj", "{DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ComponentBasic", "ComponentBasic\ComponentBasic.vcxproj", "{20CFC220-4F5B-4D39-97FA-74C70768F1A7}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ComponentBasic", "ComponentBasic\ComponentBasic.vcxproj", "{20CFC220-4F5B-4D39-97FA-74C70768F1A7}"
ProjectSection(ProjectDependencies) = postProject
{DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0} = {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}
{E1104048-F35B-40B7-995C-0320E689BF09} = {E1104048-F35B-40B7-995C-0320E689BF09}
EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MessageBasic", "MessageBasic\MessageBasic.vcxproj", "{E1104048-F35B-40B7-995C-0320E689BF09}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MessageBasic", "MessageBasic\MessageBasic.vcxproj", "{E1104048-F35B-40B7-995C-0320E689BF09}"
ProjectSection(ProjectDependencies) = postProject
{DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0} = {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}
EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution