diff --git a/PrintS/Config/ConfigManager.cpp b/PrintS/Config/ConfigManager.cpp index 60d6c84..671767d 100644 --- a/PrintS/Config/ConfigManager.cpp +++ b/PrintS/Config/ConfigManager.cpp @@ -446,6 +446,20 @@ vector* ConfigManager::GetIOVersions(int machineid) return m_IOVersions[machineid]; } +string ConfigManager::GetIOVersionStrs(int machineid) { + if (m_IOVersions.find(machineid) == m_IOVersions.end()) { + return ""; + } + + string result; + auto start = m_IOVersions[machineid]->begin(); + while (start != m_IOVersions[machineid]->end()) { + result += (*start)->m_VersionCode; + ++start; + } + return result; +} + void ConfigManager::DeleteMachineIO() { char buffer[256]; @@ -491,7 +505,8 @@ void ConfigManager::SendCfgToClients() { m_EleCfg->SendToClients(ELECFGPARAM); } -void ConfigManager::CallFuncs(const ReadData& rd) { +void ConfigManager::CallFuncs(const ReadData& rd, const list& lst, ::stream::ResponseAny** response) { + stream::ComResponce result; ConfigFunc cfunc = (ConfigFunc)ConverType::TryToI(rd.nameKey); switch (cfunc) { @@ -503,6 +518,17 @@ void ConfigManager::CallFuncs(const ReadData& rd) { DeleteMachineIO(); break; case CONTROLRUN: ControlRun(rd.its); break; + case IOVERSIONSTR: + if (lst.front().nameKey == "index") { + result.set_data(GetIOVersionStrs(ConverType::TryToI(lst.front().strValue))); + (*response)->mutable_data()->PackFrom(result); + } + printf("IOVERSIONSTR responded...\n"); + break; + case REDTESTCFGSTART: + RedTestCfgStart(); break; + case REDTESTCFGSTOP: + RedTestCfgStop(); break; default: break; } @@ -537,8 +563,8 @@ void ConfigManager::UpdateCfg(const ReadData& rd) { case POWDERESTIMATECFG: m_PowderEstimateCfg.Update(rd,POWDERESTIMATECFGPARAM); break; case COMMUNICATIONCFG: - UpdateCommunicationCfg(rd); - break; + UpdateCommunicationCfg(rd); break; + default: break; } @@ -585,4 +611,30 @@ void ConfigManager::ControlRun(const list& its) { } } -} \ No newline at end of file +} + + +void ConfigManager::RedTestCfgStart() { + vector* laserCfg = ConfigManager::GetInstance()->GetMatchScannerControlCfg(); + for (size_t cIndex = 0; cIndex < laserCfg->size(); cIndex++) { + ScannerControlCfg* lcfg = (*laserCfg)[cIndex]; + if (lcfg->m_LaserEnable && lcfg->m_LaserEnable->IsActive()) { + lcfg->m_LaserEnable->SetActive(false); + } + + if (lcfg->m_LaserRed && !lcfg->m_LaserRed->IsActive()) { + lcfg->m_LaserRed->SetActive(true); + } + } +} + +void ConfigManager::RedTestCfgStop() { + vector* laserCfg = ConfigManager::GetInstance()->GetMatchScannerControlCfg(); + for (size_t lrIndex = 0; lrIndex < laserCfg->size(); lrIndex++) { + ScannerControlCfg* lcfg = (*laserCfg)[lrIndex]; + if (lcfg->m_LaserRed && lcfg->m_LaserRed->IsActive()) { + lcfg->m_LaserRed->SetActive(false); + } + } +} + diff --git a/PrintS/Config/ConfigManager.h b/PrintS/Config/ConfigManager.h index 48ce958..4836f99 100644 --- a/PrintS/Config/ConfigManager.h +++ b/PrintS/Config/ConfigManager.h @@ -43,6 +43,10 @@ enum ConfigFunc{ SAVEMACHINECONFIG, DELETEMACHINEIO, CONTROLRUN, + IOVERSIONSTR, + + REDTESTCFGSTART, //红光测试配置开始 + REDTESTCFGSTOP, //红光测试配置结束 }; @@ -77,7 +81,7 @@ public: UIShowCfg* GetUIShowCfg() { return &m_UIShowCfg; } //已传 IOCfgWrapper* GetIoCfgWrapper() { return m_IOCfgWrapper; } //已传 void DeleteMachineIO(); //已传 - vector* GetIOVersions(int machineid); //返回一个string, req-rsp模式 + vector* GetIOVersions(int machineid); //已传 改为函数 GetIOVersionStrs PowderEstimateCfg* GetPowderEstimateCfg() { return &m_PowderEstimateCfg; } //已传 map* GetCommunicationCfg() { return m_pCommunicationCfgDao->GetCommunicationCfg(); } //已传 @@ -101,7 +105,7 @@ public: //vector* GetLaserCfgs() { return &m_pLaserCfgDao->m_LaserCfgs; } map* GetScannerControlCfg() { return &m_ScannerControlCfgDao->m_ScannerControlCfgMap; } //传 vector* GetScannerControlCfgs() { return &m_ScannerControlCfgDao->m_ScannerControlCfgs; } //不传 - vector* GetMatchScannerControlCfg() { return &m_ScannerControlCfgDao->m_MatchCfg; } //添加一个函数,不用传 + vector* GetMatchScannerControlCfg() { return &m_ScannerControlCfgDao->m_MatchCfg; } //添加2个函数 已传 ScannerControlCfgDao* GetScannerControlCfgDao() { return m_ScannerControlCfgDao; } //不用 //vector *GetMatchLaser() { return &m_pLaserCfgDao->m_MatchLaser; } @@ -116,7 +120,7 @@ public: } void AddComRefCfg(CommunicationCfg* cfg, IConnect* ic) { m_ComRefCfg[cfg] = ic; } //不传 - map* GetComRefCfg() { return &m_ComRefCfg; } //传一个参数的函数功能 + map* GetComRefCfg() { return &m_ComRefCfg; } //已传 ControlRun // map* GetMitsubishiCfg() { return &m_MitsubishiCfgMap; } // map* GetSanyoCfg() { return &m_SanyoCfgMap; } @@ -129,7 +133,7 @@ public: void SendCfgToClients(); void UpdateCfg(const ReadData& rd); - void CallFuncs(const ReadData& rd); + void CallFuncs(const ReadData& rd, const list& lst = list(), ::stream::ResponseAny** response = nullptr); private: ConfigManager(const ConfigManager&) {}; ConfigManager& operator=(const ConfigManager&) {}; @@ -142,6 +146,9 @@ private: void ControlRun(const list& its); //控制模块启停 void UpdateCommunicationCfg(const ReadData& rd); //更新参数 + string GetIOVersionStrs(int machineid); //io版本 字符串返回 + void RedTestCfgStart(); + void RedTestCfgStop(); private: SQLite::Database* m_pDB; HbdLanguageDao* m_pHbdLanguageDao; diff --git a/PrintS/Config/bean/CommunicationCfg.cpp b/PrintS/Config/bean/CommunicationCfg.cpp index 6aadfef..21a2f3c 100644 --- a/PrintS/Config/bean/CommunicationCfg.cpp +++ b/PrintS/Config/bean/CommunicationCfg.cpp @@ -1,4 +1,5 @@ #include "CommunicationCfg.h" +#include "../utils/StringHelper.h" CommunicationCfg::CommunicationCfg() : m_MachineId(new IntData("MachineId", u8"", 0)) @@ -24,7 +25,7 @@ CommunicationCfg::CommunicationCfg() CommunicationCfg::CommunicationCfg(int mid, string cc, string name, const string& sContent, int type) : m_MachineId(new IntData("MachineId",u8"",mid)) - , m_ClientCode(new StrData("ClientCode",u8"",cc)) + , m_ClientCode(new StrData("ClientCode",u8"编码",cc)) , m_Name(new StrData("Name",u8"",name)) , m_Type(new IntData("Type",u8"",type)) , m_IP(new StrData("IP", u8"IP", "0.0.0.0")) diff --git a/PrintS/Config/dao/CommunicationCfgDao.cpp b/PrintS/Config/dao/CommunicationCfgDao.cpp index e298a12..e734449 100644 --- a/PrintS/Config/dao/CommunicationCfgDao.cpp +++ b/PrintS/Config/dao/CommunicationCfgDao.cpp @@ -39,7 +39,7 @@ void CommunicationCfgDao::InitBeforeFind(int mid) { CommunicationCfg* remote = new CommunicationCfg(mid, "REMOTE", u8"远控", _(u8"远控"), CommunicationCfg::TCP); remote->m_IP->SetValue("192.168.3.88"); - remote->m_Port ->SetValue( 12019); + remote->m_Port->SetValue(12019); remote->m_Interval->SetValue(500); remote->m_AlarmTimeoutTimes->SetValue(3); m_CommunicationCfgMap[remote->m_ClientCode->GetValueStr()] = remote; diff --git a/PrintS/DataManage/DataHandle.cpp b/PrintS/DataManage/DataHandle.cpp index 4a7ae90..586da9c 100644 --- a/PrintS/DataManage/DataHandle.cpp +++ b/PrintS/DataManage/DataHandle.cpp @@ -8,7 +8,7 @@ void DataHandle::DataCallBackProc(void* pthis, const ReadData& msg, const std::l p->DataCallBackHandle(msg,its); } -void DataHandle::LayersDataCallBackProc(void* pthis,const ReadData& msg, ::stream::ResponseAny** response) { +void DataHandle::LayersDataCallBackProc(void* pthis,const ReadData& msg, const list& lst, ::stream::ResponseAny** response) { DataHandle* p = (DataHandle*)pthis; int index = atoi(msg.strValue.data()); @@ -23,6 +23,9 @@ void DataHandle::LayersDataCallBackProc(void* pthis,const ReadData& msg, ::strea else if ((READTYPE)msg.dataType == CAMERAFUNC) { p->m_controller->m_Camera->CallFunc(msg, response); } + else if ((READTYPE)msg.dataType == CONFIGFUNC) { + p->m_config->CallFuncs(msg, lst, response); + } } @@ -36,9 +39,6 @@ DataHandle::DataHandle() DataHandle::~DataHandle() { Stop(); - //m_testFlag = true; - //if (m_testTd.joinable()) m_testTd.join(); - DELP(m_streamServer); DELP(m_controller); } @@ -47,16 +47,6 @@ void DataHandle::Init() { m_config = ConfigManager::GetInstance(); m_config->Init(); - ////测试线程 - //m_testTd = std::thread ([this] { - // static float i = 10.12540f; - // while (!m_testFlag) { - // ClientWrapper::Instance()->PushAllClient(WriteData(TEST, { {string("hello"),std::to_string(i),iFLOAT}})); - // std::this_thread::sleep_for(std::chrono::seconds(1)); - // } - //}); - //m_testTd.detach(); - m_streamServer = new StreamServer(m_config->GetMachine()); m_streamServer->SetCallBackFunc(this, &DataHandle::DataCallBackProc, &DataHandle::LayersDataCallBackProc); m_streamServer->Init(); diff --git a/PrintS/DataManage/DataHandle.h b/PrintS/DataManage/DataHandle.h index 7dbf081..e1a5377 100644 --- a/PrintS/DataManage/DataHandle.h +++ b/PrintS/DataManage/DataHandle.h @@ -7,7 +7,7 @@ class DataHandle{ typedef void (*DataCallBack)(void* pthis, const ReadData& msg); - typedef void (*LayersDataCallBack)(void* pthis, const ReadData& msg, ::stream::ResponseAny** response); + typedef void (*LayersDataCallBack)(void* pthis, const ReadData& msg, const list& lst, ::stream::ResponseAny** response); public: DataHandle(); ~DataHandle(); @@ -17,7 +17,7 @@ public: void Stop(); static void DataCallBackProc(void* pthis, const ReadData& msg,const std::list& its); - static void LayersDataCallBackProc(void* pthis, const ReadData& msg,::stream::ResponseAny** response); + static void LayersDataCallBackProc(void* pthis, const ReadData& msg, const list& lst, ::stream::ResponseAny** response); private: //DataCallBack m_dataCallBack; //std::thread m_testTd; diff --git a/PrintS/DataManage/StreamServer.cpp b/PrintS/DataManage/StreamServer.cpp index 57a70cd..b13c70b 100644 --- a/PrintS/DataManage/StreamServer.cpp +++ b/PrintS/DataManage/StreamServer.cpp @@ -25,8 +25,15 @@ StreamServer::~StreamServer() { readData.nameKey = request->namekey(); readData.strValue = request->strvalue(); readData.valueType = (DATATYPE)request->valuetype(); + + + std::list paramLst; //函数参数 + for (const ::stream::ParamInfo it : request->item()) { + paramLst.emplace_back(Item{ it.namekey(),it.strvalue() ,(DATATYPE)it.valuetype() }); //直接加到readData.its上面,后续的请求无法收到,不知道为啥 + } + if (m_layerDataCallBack) - m_layerDataCallBack(m_handlePtr, readData, &response); + m_layerDataCallBack(m_handlePtr, readData, paramLst, &response); return Status::OK; } diff --git a/PrintS/DataManage/StreamServer.h b/PrintS/DataManage/StreamServer.h index 8091432..ba572c5 100644 --- a/PrintS/DataManage/StreamServer.h +++ b/PrintS/DataManage/StreamServer.h @@ -19,7 +19,7 @@ using stream::ResponseInfo; class StreamServer final : public Stream::Service { typedef void (*DataCallBack)(void* pthis,const ReadData& msg, const std::list& its); - typedef void (*LayerDataCallBack)(void* pthis, const ReadData& msg, ::stream::ResponseAny** response); + typedef void (*LayerDataCallBack)(void* pthis, const ReadData& msg,const list& lst, ::stream::ResponseAny** response); public: diff --git a/PrintS/output/Release/config.hbd b/PrintS/output/Release/config.hbd index a3a9fb5..cf44242 100644 Binary files a/PrintS/output/Release/config.hbd and b/PrintS/output/Release/config.hbd differ diff --git a/PrintS/output/Release/log/2024.hbd b/PrintS/output/Release/log/2024.hbd index 1ea6579..81d5a66 100644 Binary files a/PrintS/output/Release/log/2024.hbd and b/PrintS/output/Release/log/2024.hbd differ diff --git a/PrintS/protobuf/stream.pb.cc b/PrintS/protobuf/stream.pb.cc index 2a0b078..327a184 100644 --- a/PrintS/protobuf/stream.pb.cc +++ b/PrintS/protobuf/stream.pb.cc @@ -235,8 +235,27 @@ struct ImgInfoResponceDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ImgInfoResponceDefaultTypeInternal _ImgInfoResponce_default_instance_; + template +PROTOBUF_CONSTEXPR ComResponce::ComResponce(::_pbi::ConstantInitialized) + : _impl_{ + /*decltype(_impl_.data_)*/ { + &::_pbi::fixed_address_empty_string, + ::_pbi::ConstantInitialized{}, + }, + /*decltype(_impl_._cached_size_)*/ {}, + } {} +struct ComResponceDefaultTypeInternal { + PROTOBUF_CONSTEXPR ComResponceDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~ComResponceDefaultTypeInternal() {} + union { + ComResponce _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ComResponceDefaultTypeInternal _ComResponce_default_instance_; } // namespace stream -static ::_pb::Metadata file_level_metadata_stream_2eproto[11]; +static ::_pb::Metadata file_level_metadata_stream_2eproto[12]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_stream_2eproto[2]; static constexpr const ::_pb::ServiceDescriptor** file_level_service_descriptors_stream_2eproto = nullptr; @@ -367,6 +386,15 @@ const ::uint32_t TableStruct_stream_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE PROTOBUF_FIELD_OFFSET(::stream::ImgInfoResponce, _impl_.levelimage_), PROTOBUF_FIELD_OFFSET(::stream::ImgInfoResponce, _impl_.width_), PROTOBUF_FIELD_OFFSET(::stream::ImgInfoResponce, _impl_.height_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::stream::ComResponce, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::stream::ComResponce, _impl_.data_), }; static const ::_pbi::MigrationSchema @@ -382,6 +410,7 @@ static const ::_pbi::MigrationSchema {95, -1, -1, sizeof(::stream::Point)}, {105, -1, -1, sizeof(::stream::RegResponce)}, {114, -1, -1, sizeof(::stream::ImgInfoResponce)}, + {125, -1, -1, sizeof(::stream::ComResponce)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -396,6 +425,7 @@ static const ::_pb::Message* const file_default_instances[] = { &::stream::_Point_default_instance_._instance, &::stream::_RegResponce_default_instance_._instance, &::stream::_ImgInfoResponce_default_instance_._instance, + &::stream::_ComResponce_default_instance_._instance, }; const char descriptor_table_protodef_stream_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { "\n\014stream.proto\022\006stream\032\031google/protobuf/" @@ -424,19 +454,20 @@ const char descriptor_table_protodef_stream_2eproto[] PROTOBUF_SECTION_VARIABLE( "\n\004xPos\030\001 \001(\002\022\014\n\004yPos\030\002 \001(\002\"\033\n\013RegResponc" "e\022\014\n\004data\030\001 \001(\005\"D\n\017ImgInfoResponce\022\022\n\nle" "velImage\030\001 \001(\r\022\r\n\005width\030\002 \001(\005\022\016\n\006height\030" - "\003 \001(\005*\223\001\n\004TYPE\022\t\n\005iBOOL\020\000\022\n\n\006iSHORT\020\001\022\013\n" - "\007iUSHORT\020\002\022\010\n\004iINT\020\003\022\t\n\005iUINT\020\004\022\n\n\006iFLOA" - "T\020\005\022\013\n\007iSTRING\020\006\022\t\n\005iCHAR\020\007\022\n\n\006iUCHAR\020\010\022" - "\t\n\005iWORD\020\t\022\013\n\007iDOUBLE\020\n\022\n\n\006iTIMET\020\013**\n\nD" - "ATAHANDLE\022\n\n\006UPDATE\020\000\022\007\n\003ADD\020\001\022\007\n\003DEL\020\0022" - "\372\001\n\006Stream\0224\n\006Simple\022\023.stream.RequestInf" - "o\032\023.stream.ResponseAny\"\000\022=\n\014ServerStream" - "\022\023.stream.RequestInfo\032\024.stream.ResponseI" - "nfo\"\0000\001\022=\n\014ClientStream\022\023.stream.Request" - "Info\032\024.stream.ResponseInfo\"\000(\001\022<\n\tAllStr" - "eam\022\023.stream.RequestInfo\032\024.stream.Respon" - "seInfo\"\000(\0010\001B-\n\027io.grpc.examples.streamB" - "\013StreamProtoP\001\242\002\002STb\006proto3" + "\003 \001(\005\"\033\n\013ComResponce\022\014\n\004data\030\001 \001(\014*\223\001\n\004T" + "YPE\022\t\n\005iBOOL\020\000\022\n\n\006iSHORT\020\001\022\013\n\007iUSHORT\020\002\022" + "\010\n\004iINT\020\003\022\t\n\005iUINT\020\004\022\n\n\006iFLOAT\020\005\022\013\n\007iSTR" + "ING\020\006\022\t\n\005iCHAR\020\007\022\n\n\006iUCHAR\020\010\022\t\n\005iWORD\020\t\022" + "\013\n\007iDOUBLE\020\n\022\n\n\006iTIMET\020\013**\n\nDATAHANDLE\022\n" + "\n\006UPDATE\020\000\022\007\n\003ADD\020\001\022\007\n\003DEL\020\0022\372\001\n\006Stream\022" + "4\n\006Simple\022\023.stream.RequestInfo\032\023.stream." + "ResponseAny\"\000\022=\n\014ServerStream\022\023.stream.R" + "equestInfo\032\024.stream.ResponseInfo\"\0000\001\022=\n\014" + "ClientStream\022\023.stream.RequestInfo\032\024.stre" + "am.ResponseInfo\"\000(\001\022<\n\tAllStream\022\023.strea" + "m.RequestInfo\032\024.stream.ResponseInfo\"\000(\0010" + "\001B-\n\027io.grpc.examples.streamB\013StreamProt" + "oP\001\242\002\002STb\006proto3" }; static const ::_pbi::DescriptorTable* const descriptor_table_stream_2eproto_deps[1] = { @@ -446,13 +477,13 @@ static ::absl::once_flag descriptor_table_stream_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_stream_2eproto = { false, false, - 1547, + 1576, descriptor_table_protodef_stream_2eproto, "stream.proto", &descriptor_table_stream_2eproto_once, descriptor_table_stream_2eproto_deps, 1, - 11, + 12, schemas, file_default_instances, TableStruct_stream_2eproto::offsets, @@ -3278,6 +3309,192 @@ void ImgInfoResponce::InternalSwap(ImgInfoResponce* other) { &descriptor_table_stream_2eproto_getter, &descriptor_table_stream_2eproto_once, file_level_metadata_stream_2eproto[10]); } +// =================================================================== + +class ComResponce::_Internal { + public: +}; + +ComResponce::ComResponce(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:stream.ComResponce) +} +ComResponce::ComResponce(const ComResponce& from) : ::google::protobuf::Message() { + ComResponce* const _this = this; + (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.data_){}, + /*decltype(_impl_._cached_size_)*/ {}, + }; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + _impl_.data_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_data().empty()) { + _this->_impl_.data_.Set(from._internal_data(), _this->GetArenaForAllocation()); + } + + // @@protoc_insertion_point(copy_constructor:stream.ComResponce) +} +inline void ComResponce::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.data_){}, + /*decltype(_impl_._cached_size_)*/ {}, + }; + _impl_.data_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} +ComResponce::~ComResponce() { + // @@protoc_insertion_point(destructor:stream.ComResponce) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void ComResponce::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.data_.Destroy(); +} +void ComResponce::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +PROTOBUF_NOINLINE void ComResponce::Clear() { +// @@protoc_insertion_point(message_clear_start:stream.ComResponce) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.data_.ClearToEmpty(); + _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>(); +} + +const char* ComResponce::_InternalParse( + const char* ptr, ::_pbi::ParseContext* ctx) { + ptr = ::_pbi::TcParser::ParseLoop(this, ptr, ctx, &_table_.header); + return ptr; +} + + +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 +const ::_pbi::TcParseTable<0, 1, 0, 0, 2> ComResponce::_table_ = { + { + 0, // no _has_bits_ + 0, // no _extensions_ + 1, 0, // max_field_number, fast_idx_mask + offsetof(decltype(_table_), field_lookup_table), + 4294967294, // skipmap + offsetof(decltype(_table_), field_entries), + 1, // num_field_entries + 0, // num_aux_entries + offsetof(decltype(_table_), field_names), // no aux_entries + &_ComResponce_default_instance_._instance, + ::_pbi::TcParser::GenericFallback, // fallback + }, {{ + // bytes data = 1; + {::_pbi::TcParser::FastBS1, + {10, 63, 0, PROTOBUF_FIELD_OFFSET(ComResponce, _impl_.data_)}}, + }}, {{ + 65535, 65535 + }}, {{ + // bytes data = 1; + {PROTOBUF_FIELD_OFFSET(ComResponce, _impl_.data_), 0, 0, + (0 | ::_fl::kFcSingular | ::_fl::kBytes | ::_fl::kRepAString)}, + }}, + // no aux_entries + {{ + }}, +}; + +::uint8_t* ComResponce::_InternalSerialize( + ::uint8_t* target, + ::google::protobuf::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:stream.ComResponce) + ::uint32_t cached_has_bits = 0; + (void)cached_has_bits; + + // bytes data = 1; + if (!this->_internal_data().empty()) { + const std::string& _s = this->_internal_data(); + target = stream->WriteBytesMaybeAliased(1, _s, target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = + ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:stream.ComResponce) + return target; +} + +::size_t ComResponce::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:stream.ComResponce) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // bytes data = 1; + if (!this->_internal_data().empty()) { + total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( + this->_internal_data()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::google::protobuf::Message::ClassData ComResponce::_class_data_ = { + ::google::protobuf::Message::CopyWithSourceCheck, + ComResponce::MergeImpl +}; +const ::google::protobuf::Message::ClassData*ComResponce::GetClassData() const { return &_class_data_; } + + +void ComResponce::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:stream.ComResponce) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_data().empty()) { + _this->_internal_set_data(from._internal_data()); + } + _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_); +} + +void ComResponce::CopyFrom(const ComResponce& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:stream.ComResponce) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +PROTOBUF_NOINLINE bool ComResponce::IsInitialized() const { + return true; +} + +void ComResponce::InternalSwap(ComResponce* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.data_, lhs_arena, + &other->_impl_.data_, rhs_arena); +} + +::google::protobuf::Metadata ComResponce::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_stream_2eproto_getter, &descriptor_table_stream_2eproto_once, + file_level_metadata_stream_2eproto[11]); +} // @@protoc_insertion_point(namespace_scope) } // namespace stream namespace google { diff --git a/PrintS/protobuf/stream.pb.h b/PrintS/protobuf/stream.pb.h index 692b4e4..e627cb2 100644 --- a/PrintS/protobuf/stream.pb.h +++ b/PrintS/protobuf/stream.pb.h @@ -59,6 +59,9 @@ namespace stream { class ChainDataBlock; struct ChainDataBlockDefaultTypeInternal; extern ChainDataBlockDefaultTypeInternal _ChainDataBlock_default_instance_; +class ComResponce; +struct ComResponceDefaultTypeInternal; +extern ComResponceDefaultTypeInternal _ComResponce_default_instance_; class ImgInfoResponce; struct ImgInfoResponceDefaultTypeInternal; extern ImgInfoResponceDefaultTypeInternal _ImgInfoResponce_default_instance_; @@ -2291,6 +2294,170 @@ class ImgInfoResponce final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_stream_2eproto; +};// ------------------------------------------------------------------- + +class ComResponce final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:stream.ComResponce) */ { + public: + inline ComResponce() : ComResponce(nullptr) {} + ~ComResponce() override; + template + explicit PROTOBUF_CONSTEXPR ComResponce(::google::protobuf::internal::ConstantInitialized); + + ComResponce(const ComResponce& from); + ComResponce(ComResponce&& from) noexcept + : ComResponce() { + *this = ::std::move(from); + } + + inline ComResponce& operator=(const ComResponce& from) { + CopyFrom(from); + return *this; + } + inline ComResponce& operator=(ComResponce&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const ComResponce& default_instance() { + return *internal_default_instance(); + } + static inline const ComResponce* internal_default_instance() { + return reinterpret_cast( + &_ComResponce_default_instance_); + } + static constexpr int kIndexInFileMessages = + 11; + + friend void swap(ComResponce& a, ComResponce& b) { + a.Swap(&b); + } + inline void Swap(ComResponce* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ComResponce* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ComResponce* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::google::protobuf::Message::CopyFrom; + void CopyFrom(const ComResponce& from); + using ::google::protobuf::Message::MergeFrom; + void MergeFrom( const ComResponce& from) { + ComResponce::MergeImpl(*this, from); + } + private: + static void MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::google::protobuf::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ComResponce* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "stream.ComResponce"; + } + protected: + explicit ComResponce(::google::protobuf::Arena* arena); + public: + + static const ClassData _class_data_; + const ::google::protobuf::Message::ClassData*GetClassData() const final; + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kDataFieldNumber = 1, + }; + // bytes data = 1; + void clear_data() ; + const std::string& data() const; + template + void set_data(Arg_&& arg, Args_... args); + std::string* mutable_data(); + PROTOBUF_NODISCARD std::string* release_data(); + void set_allocated_data(std::string* ptr); + + private: + const std::string& _internal_data() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_data( + const std::string& value); + std::string* _internal_mutable_data(); + + public: + // @@protoc_insertion_point(class_scope:stream.ComResponce) + private: + class _Internal; + + friend class ::google::protobuf::internal::TcParser; + static const ::google::protobuf::internal::TcParseTable<0, 1, 0, 0, 2> _table_; + template friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::google::protobuf::internal::ArenaStringPtr data_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_stream_2eproto; }; // =================================================================== @@ -3471,6 +3638,61 @@ inline void ImgInfoResponce::_internal_set_height(::int32_t value) { _impl_.height_ = value; } +// ------------------------------------------------------------------- + +// ComResponce + +// bytes data = 1; +inline void ComResponce::clear_data() { + _impl_.data_.ClearToEmpty(); +} +inline const std::string& ComResponce::data() const { + // @@protoc_insertion_point(field_get:stream.ComResponce.data) + return _internal_data(); +} +template +inline PROTOBUF_ALWAYS_INLINE void ComResponce::set_data(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.data_.SetBytes(static_cast(arg), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:stream.ComResponce.data) +} +inline std::string* ComResponce::mutable_data() { + std::string* _s = _internal_mutable_data(); + // @@protoc_insertion_point(field_mutable:stream.ComResponce.data) + return _s; +} +inline const std::string& ComResponce::_internal_data() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.data_.Get(); +} +inline void ComResponce::_internal_set_data(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.data_.Set(value, GetArenaForAllocation()); +} +inline std::string* ComResponce::_internal_mutable_data() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.data_.Mutable( GetArenaForAllocation()); +} +inline std::string* ComResponce::release_data() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:stream.ComResponce.data) + return _impl_.data_.Release(); +} +inline void ComResponce::set_allocated_data(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.data_.SetAllocated(value, GetArenaForAllocation()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.data_.IsDefault()) { + _impl_.data_.Set("", GetArenaForAllocation()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:stream.ComResponce.data) +} + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ diff --git a/PrintS/protobuf/stream.proto b/PrintS/protobuf/stream.proto index 67eadfa..270abb1 100644 --- a/PrintS/protobuf/stream.proto +++ b/PrintS/protobuf/stream.proto @@ -122,6 +122,11 @@ message ImgInfoResponce{ int32 height = 3; } +//注册功能返回信息 IOVersionStr接口返回值 +message ComResponce{ + bytes data = 1; +} + service Stream { rpc Simple(RequestInfo) returns (ResponseAny) {} // 简单模式 rpc ServerStream (RequestInfo) returns (stream ResponseInfo) {} // 服务端数据流模式 diff --git a/TestClient/DataManage/DataHandle.cpp b/TestClient/DataManage/DataHandle.cpp index 045954f..4148da0 100644 --- a/TestClient/DataManage/DataHandle.cpp +++ b/TestClient/DataManage/DataHandle.cpp @@ -83,7 +83,7 @@ void DataHandle::PrintValue(const ReadData& msg){ it->nameKey; string valueType = m_dataTypeMp[(*it).valueType]; printf("接收:dataType:%d,nameKey:%*s, strvalue:%*s, valueType:%s\n", - msg.dataType, 33, it->nameKey.data(), 13, StringHelper::AsciiToUtf8(it->strValue).data(), valueType.data()); + msg.dataType, 33, it->nameKey.data(), 13, it->strValue.data(), valueType.data()); ++it; } printf("共有参数%zd个...\n", msg.its.size()); @@ -450,5 +450,21 @@ void DataHandle::ConfigTest() { wd.items.emplace_back(Item{ "code", "usp" ,iSTRING }); PushMsg(wd); printf("controlrun is called...\n"); + + ::stream::ResponseAny resp; + stream::ComResponce result; + WriteData wdata{ CONFIGFUNC ,to_string(IOVERSIONSTR) }; + wdata.items.emplace_back(Item{"index","1",iINT}); + m_streamClient->Request(wdata, &resp); + if (resp.data().Is()) { + resp.data().UnpackTo(&result); + printf("IOVERSIONSTR resp:%s\n", result.data().data()); + } + + PushMsg(CONFIGFUNC, to_string(REDTESTCFGSTART)); + printf("redtestcfgstart is called...\n"); + + PushMsg(CONFIGFUNC, to_string(REDTESTCFGSTOP)); + printf("redtestcfgstop is called...\n"); } diff --git a/TestClient/DataManage/FunC.h b/TestClient/DataManage/FunC.h index f0e7de8..3f7af49 100644 --- a/TestClient/DataManage/FunC.h +++ b/TestClient/DataManage/FunC.h @@ -88,4 +88,8 @@ enum ConfigFunc { SAVEMACHINECONFIG, DELETEMACHINEIO, CONTROLRUN, + IOVERSIONSTR, + + REDTESTCFGSTART, //红光测试配置开始 + REDTESTCFGSTOP, //红光测试配置结束 }; \ No newline at end of file diff --git a/TestClient/DataManage/StreamClient.cpp b/TestClient/DataManage/StreamClient.cpp index 665e965..7f2df7e 100644 --- a/TestClient/DataManage/StreamClient.cpp +++ b/TestClient/DataManage/StreamClient.cpp @@ -149,6 +149,14 @@ int StreamClient::Request(const WriteData& writeData , ::stream::ResponseAny* re request.set_namekey(writeData.nameKey); request.set_strvalue(writeData.strValue); request.set_valuetype((stream::TYPE)writeData.valueType); + + for (auto wd = writeData.items.begin(); wd != writeData.items.end(); ++wd) { + ::stream::ParamInfo* paramInfo = request.add_item(); + paramInfo->set_namekey((*wd).nameKey); + paramInfo->set_strvalue((*wd).strValue); + paramInfo->set_valuetype((stream::TYPE)(*wd).valueType); + } + Status status = _stub->Simple(&context, request, response); return status.ok(); diff --git a/TestClient/PrintC.vcxproj.filters b/TestClient/PrintC.vcxproj.filters index 858e3be..2cfa783 100644 --- a/TestClient/PrintC.vcxproj.filters +++ b/TestClient/PrintC.vcxproj.filters @@ -512,15 +512,15 @@ UI + + utils + protobuf protobuf - - utils - diff --git a/TestClient/protobuf/stream.pb.cc b/TestClient/protobuf/stream.pb.cc index 2a0b078..327a184 100644 --- a/TestClient/protobuf/stream.pb.cc +++ b/TestClient/protobuf/stream.pb.cc @@ -235,8 +235,27 @@ struct ImgInfoResponceDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ImgInfoResponceDefaultTypeInternal _ImgInfoResponce_default_instance_; + template +PROTOBUF_CONSTEXPR ComResponce::ComResponce(::_pbi::ConstantInitialized) + : _impl_{ + /*decltype(_impl_.data_)*/ { + &::_pbi::fixed_address_empty_string, + ::_pbi::ConstantInitialized{}, + }, + /*decltype(_impl_._cached_size_)*/ {}, + } {} +struct ComResponceDefaultTypeInternal { + PROTOBUF_CONSTEXPR ComResponceDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~ComResponceDefaultTypeInternal() {} + union { + ComResponce _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ComResponceDefaultTypeInternal _ComResponce_default_instance_; } // namespace stream -static ::_pb::Metadata file_level_metadata_stream_2eproto[11]; +static ::_pb::Metadata file_level_metadata_stream_2eproto[12]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_stream_2eproto[2]; static constexpr const ::_pb::ServiceDescriptor** file_level_service_descriptors_stream_2eproto = nullptr; @@ -367,6 +386,15 @@ const ::uint32_t TableStruct_stream_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE PROTOBUF_FIELD_OFFSET(::stream::ImgInfoResponce, _impl_.levelimage_), PROTOBUF_FIELD_OFFSET(::stream::ImgInfoResponce, _impl_.width_), PROTOBUF_FIELD_OFFSET(::stream::ImgInfoResponce, _impl_.height_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::stream::ComResponce, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::stream::ComResponce, _impl_.data_), }; static const ::_pbi::MigrationSchema @@ -382,6 +410,7 @@ static const ::_pbi::MigrationSchema {95, -1, -1, sizeof(::stream::Point)}, {105, -1, -1, sizeof(::stream::RegResponce)}, {114, -1, -1, sizeof(::stream::ImgInfoResponce)}, + {125, -1, -1, sizeof(::stream::ComResponce)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -396,6 +425,7 @@ static const ::_pb::Message* const file_default_instances[] = { &::stream::_Point_default_instance_._instance, &::stream::_RegResponce_default_instance_._instance, &::stream::_ImgInfoResponce_default_instance_._instance, + &::stream::_ComResponce_default_instance_._instance, }; const char descriptor_table_protodef_stream_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { "\n\014stream.proto\022\006stream\032\031google/protobuf/" @@ -424,19 +454,20 @@ const char descriptor_table_protodef_stream_2eproto[] PROTOBUF_SECTION_VARIABLE( "\n\004xPos\030\001 \001(\002\022\014\n\004yPos\030\002 \001(\002\"\033\n\013RegResponc" "e\022\014\n\004data\030\001 \001(\005\"D\n\017ImgInfoResponce\022\022\n\nle" "velImage\030\001 \001(\r\022\r\n\005width\030\002 \001(\005\022\016\n\006height\030" - "\003 \001(\005*\223\001\n\004TYPE\022\t\n\005iBOOL\020\000\022\n\n\006iSHORT\020\001\022\013\n" - "\007iUSHORT\020\002\022\010\n\004iINT\020\003\022\t\n\005iUINT\020\004\022\n\n\006iFLOA" - "T\020\005\022\013\n\007iSTRING\020\006\022\t\n\005iCHAR\020\007\022\n\n\006iUCHAR\020\010\022" - "\t\n\005iWORD\020\t\022\013\n\007iDOUBLE\020\n\022\n\n\006iTIMET\020\013**\n\nD" - "ATAHANDLE\022\n\n\006UPDATE\020\000\022\007\n\003ADD\020\001\022\007\n\003DEL\020\0022" - "\372\001\n\006Stream\0224\n\006Simple\022\023.stream.RequestInf" - "o\032\023.stream.ResponseAny\"\000\022=\n\014ServerStream" - "\022\023.stream.RequestInfo\032\024.stream.ResponseI" - "nfo\"\0000\001\022=\n\014ClientStream\022\023.stream.Request" - "Info\032\024.stream.ResponseInfo\"\000(\001\022<\n\tAllStr" - "eam\022\023.stream.RequestInfo\032\024.stream.Respon" - "seInfo\"\000(\0010\001B-\n\027io.grpc.examples.streamB" - "\013StreamProtoP\001\242\002\002STb\006proto3" + "\003 \001(\005\"\033\n\013ComResponce\022\014\n\004data\030\001 \001(\014*\223\001\n\004T" + "YPE\022\t\n\005iBOOL\020\000\022\n\n\006iSHORT\020\001\022\013\n\007iUSHORT\020\002\022" + "\010\n\004iINT\020\003\022\t\n\005iUINT\020\004\022\n\n\006iFLOAT\020\005\022\013\n\007iSTR" + "ING\020\006\022\t\n\005iCHAR\020\007\022\n\n\006iUCHAR\020\010\022\t\n\005iWORD\020\t\022" + "\013\n\007iDOUBLE\020\n\022\n\n\006iTIMET\020\013**\n\nDATAHANDLE\022\n" + "\n\006UPDATE\020\000\022\007\n\003ADD\020\001\022\007\n\003DEL\020\0022\372\001\n\006Stream\022" + "4\n\006Simple\022\023.stream.RequestInfo\032\023.stream." + "ResponseAny\"\000\022=\n\014ServerStream\022\023.stream.R" + "equestInfo\032\024.stream.ResponseInfo\"\0000\001\022=\n\014" + "ClientStream\022\023.stream.RequestInfo\032\024.stre" + "am.ResponseInfo\"\000(\001\022<\n\tAllStream\022\023.strea" + "m.RequestInfo\032\024.stream.ResponseInfo\"\000(\0010" + "\001B-\n\027io.grpc.examples.streamB\013StreamProt" + "oP\001\242\002\002STb\006proto3" }; static const ::_pbi::DescriptorTable* const descriptor_table_stream_2eproto_deps[1] = { @@ -446,13 +477,13 @@ static ::absl::once_flag descriptor_table_stream_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_stream_2eproto = { false, false, - 1547, + 1576, descriptor_table_protodef_stream_2eproto, "stream.proto", &descriptor_table_stream_2eproto_once, descriptor_table_stream_2eproto_deps, 1, - 11, + 12, schemas, file_default_instances, TableStruct_stream_2eproto::offsets, @@ -3278,6 +3309,192 @@ void ImgInfoResponce::InternalSwap(ImgInfoResponce* other) { &descriptor_table_stream_2eproto_getter, &descriptor_table_stream_2eproto_once, file_level_metadata_stream_2eproto[10]); } +// =================================================================== + +class ComResponce::_Internal { + public: +}; + +ComResponce::ComResponce(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:stream.ComResponce) +} +ComResponce::ComResponce(const ComResponce& from) : ::google::protobuf::Message() { + ComResponce* const _this = this; + (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.data_){}, + /*decltype(_impl_._cached_size_)*/ {}, + }; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + _impl_.data_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_data().empty()) { + _this->_impl_.data_.Set(from._internal_data(), _this->GetArenaForAllocation()); + } + + // @@protoc_insertion_point(copy_constructor:stream.ComResponce) +} +inline void ComResponce::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.data_){}, + /*decltype(_impl_._cached_size_)*/ {}, + }; + _impl_.data_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} +ComResponce::~ComResponce() { + // @@protoc_insertion_point(destructor:stream.ComResponce) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void ComResponce::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.data_.Destroy(); +} +void ComResponce::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +PROTOBUF_NOINLINE void ComResponce::Clear() { +// @@protoc_insertion_point(message_clear_start:stream.ComResponce) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.data_.ClearToEmpty(); + _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>(); +} + +const char* ComResponce::_InternalParse( + const char* ptr, ::_pbi::ParseContext* ctx) { + ptr = ::_pbi::TcParser::ParseLoop(this, ptr, ctx, &_table_.header); + return ptr; +} + + +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 +const ::_pbi::TcParseTable<0, 1, 0, 0, 2> ComResponce::_table_ = { + { + 0, // no _has_bits_ + 0, // no _extensions_ + 1, 0, // max_field_number, fast_idx_mask + offsetof(decltype(_table_), field_lookup_table), + 4294967294, // skipmap + offsetof(decltype(_table_), field_entries), + 1, // num_field_entries + 0, // num_aux_entries + offsetof(decltype(_table_), field_names), // no aux_entries + &_ComResponce_default_instance_._instance, + ::_pbi::TcParser::GenericFallback, // fallback + }, {{ + // bytes data = 1; + {::_pbi::TcParser::FastBS1, + {10, 63, 0, PROTOBUF_FIELD_OFFSET(ComResponce, _impl_.data_)}}, + }}, {{ + 65535, 65535 + }}, {{ + // bytes data = 1; + {PROTOBUF_FIELD_OFFSET(ComResponce, _impl_.data_), 0, 0, + (0 | ::_fl::kFcSingular | ::_fl::kBytes | ::_fl::kRepAString)}, + }}, + // no aux_entries + {{ + }}, +}; + +::uint8_t* ComResponce::_InternalSerialize( + ::uint8_t* target, + ::google::protobuf::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:stream.ComResponce) + ::uint32_t cached_has_bits = 0; + (void)cached_has_bits; + + // bytes data = 1; + if (!this->_internal_data().empty()) { + const std::string& _s = this->_internal_data(); + target = stream->WriteBytesMaybeAliased(1, _s, target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = + ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:stream.ComResponce) + return target; +} + +::size_t ComResponce::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:stream.ComResponce) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // bytes data = 1; + if (!this->_internal_data().empty()) { + total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( + this->_internal_data()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::google::protobuf::Message::ClassData ComResponce::_class_data_ = { + ::google::protobuf::Message::CopyWithSourceCheck, + ComResponce::MergeImpl +}; +const ::google::protobuf::Message::ClassData*ComResponce::GetClassData() const { return &_class_data_; } + + +void ComResponce::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:stream.ComResponce) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_data().empty()) { + _this->_internal_set_data(from._internal_data()); + } + _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_); +} + +void ComResponce::CopyFrom(const ComResponce& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:stream.ComResponce) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +PROTOBUF_NOINLINE bool ComResponce::IsInitialized() const { + return true; +} + +void ComResponce::InternalSwap(ComResponce* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.data_, lhs_arena, + &other->_impl_.data_, rhs_arena); +} + +::google::protobuf::Metadata ComResponce::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_stream_2eproto_getter, &descriptor_table_stream_2eproto_once, + file_level_metadata_stream_2eproto[11]); +} // @@protoc_insertion_point(namespace_scope) } // namespace stream namespace google { diff --git a/TestClient/protobuf/stream.pb.h b/TestClient/protobuf/stream.pb.h index 692b4e4..e627cb2 100644 --- a/TestClient/protobuf/stream.pb.h +++ b/TestClient/protobuf/stream.pb.h @@ -59,6 +59,9 @@ namespace stream { class ChainDataBlock; struct ChainDataBlockDefaultTypeInternal; extern ChainDataBlockDefaultTypeInternal _ChainDataBlock_default_instance_; +class ComResponce; +struct ComResponceDefaultTypeInternal; +extern ComResponceDefaultTypeInternal _ComResponce_default_instance_; class ImgInfoResponce; struct ImgInfoResponceDefaultTypeInternal; extern ImgInfoResponceDefaultTypeInternal _ImgInfoResponce_default_instance_; @@ -2291,6 +2294,170 @@ class ImgInfoResponce final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_stream_2eproto; +};// ------------------------------------------------------------------- + +class ComResponce final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:stream.ComResponce) */ { + public: + inline ComResponce() : ComResponce(nullptr) {} + ~ComResponce() override; + template + explicit PROTOBUF_CONSTEXPR ComResponce(::google::protobuf::internal::ConstantInitialized); + + ComResponce(const ComResponce& from); + ComResponce(ComResponce&& from) noexcept + : ComResponce() { + *this = ::std::move(from); + } + + inline ComResponce& operator=(const ComResponce& from) { + CopyFrom(from); + return *this; + } + inline ComResponce& operator=(ComResponce&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const ComResponce& default_instance() { + return *internal_default_instance(); + } + static inline const ComResponce* internal_default_instance() { + return reinterpret_cast( + &_ComResponce_default_instance_); + } + static constexpr int kIndexInFileMessages = + 11; + + friend void swap(ComResponce& a, ComResponce& b) { + a.Swap(&b); + } + inline void Swap(ComResponce* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ComResponce* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ComResponce* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::google::protobuf::Message::CopyFrom; + void CopyFrom(const ComResponce& from); + using ::google::protobuf::Message::MergeFrom; + void MergeFrom( const ComResponce& from) { + ComResponce::MergeImpl(*this, from); + } + private: + static void MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::google::protobuf::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ComResponce* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "stream.ComResponce"; + } + protected: + explicit ComResponce(::google::protobuf::Arena* arena); + public: + + static const ClassData _class_data_; + const ::google::protobuf::Message::ClassData*GetClassData() const final; + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kDataFieldNumber = 1, + }; + // bytes data = 1; + void clear_data() ; + const std::string& data() const; + template + void set_data(Arg_&& arg, Args_... args); + std::string* mutable_data(); + PROTOBUF_NODISCARD std::string* release_data(); + void set_allocated_data(std::string* ptr); + + private: + const std::string& _internal_data() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_data( + const std::string& value); + std::string* _internal_mutable_data(); + + public: + // @@protoc_insertion_point(class_scope:stream.ComResponce) + private: + class _Internal; + + friend class ::google::protobuf::internal::TcParser; + static const ::google::protobuf::internal::TcParseTable<0, 1, 0, 0, 2> _table_; + template friend class ::google::protobuf::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::google::protobuf::internal::ArenaStringPtr data_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_stream_2eproto; }; // =================================================================== @@ -3471,6 +3638,61 @@ inline void ImgInfoResponce::_internal_set_height(::int32_t value) { _impl_.height_ = value; } +// ------------------------------------------------------------------- + +// ComResponce + +// bytes data = 1; +inline void ComResponce::clear_data() { + _impl_.data_.ClearToEmpty(); +} +inline const std::string& ComResponce::data() const { + // @@protoc_insertion_point(field_get:stream.ComResponce.data) + return _internal_data(); +} +template +inline PROTOBUF_ALWAYS_INLINE void ComResponce::set_data(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.data_.SetBytes(static_cast(arg), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:stream.ComResponce.data) +} +inline std::string* ComResponce::mutable_data() { + std::string* _s = _internal_mutable_data(); + // @@protoc_insertion_point(field_mutable:stream.ComResponce.data) + return _s; +} +inline const std::string& ComResponce::_internal_data() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.data_.Get(); +} +inline void ComResponce::_internal_set_data(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.data_.Set(value, GetArenaForAllocation()); +} +inline std::string* ComResponce::_internal_mutable_data() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.data_.Mutable( GetArenaForAllocation()); +} +inline std::string* ComResponce::release_data() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:stream.ComResponce.data) + return _impl_.data_.Release(); +} +inline void ComResponce::set_allocated_data(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.data_.SetAllocated(value, GetArenaForAllocation()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.data_.IsDefault()) { + _impl_.data_.Set("", GetArenaForAllocation()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:stream.ComResponce.data) +} + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ diff --git a/TestClient/protobuf/stream.proto b/TestClient/protobuf/stream.proto index bec3f9b..270abb1 100644 --- a/TestClient/protobuf/stream.proto +++ b/TestClient/protobuf/stream.proto @@ -42,7 +42,7 @@ message ParamInfo{ TYPE valueType = 3; //数据类型 } -message RequestInfo { +message RequestInfo { //读 uint32 dataType = 1; //信息类型 bytes nameKey = 2; //参数key bytes strValue = 3; //value值 @@ -51,7 +51,7 @@ message RequestInfo { repeated ParamInfo item = 6; //参数值列表(函数参数使用) } -message ResponseInfo { +message ResponseInfo { //写 uint32 dataType = 1; //信息类型 bool result = 2; //执行成功与否 repeated ParamInfo item = 3; //参数值 @@ -122,6 +122,11 @@ message ImgInfoResponce{ int32 height = 3; } +//注册功能返回信息 IOVersionStr接口返回值 +message ComResponce{ + bytes data = 1; +} + service Stream { rpc Simple(RequestInfo) returns (ResponseAny) {} // 简单模式 rpc ServerStream (RequestInfo) returns (stream ResponseInfo) {} // 服务端数据流模式 diff --git a/TestClient/问题记录.txt b/TestClient/问题记录.txt index 0f85655..359243a 100644 --- a/TestClient/问题记录.txt +++ b/TestClient/问题记录.txt @@ -4,4 +4,16 @@ m_alarmCfgMp SignalService::GetInstance().SetAlarm(m_AlarmCfgWrapper->m_PurifierInternalAlarm, true); 注释掉了 -客户端参数要用带后缀的 \ No newline at end of file +客户端参数要用带后缀的 + +//点击时只执行一次代码 +static bool isenter = false; +if(点击tab){ + if(!isenter){ + func(); + isenter = true; + } +} +else { + isenter = false; +}