11 return std::strong_ordering::equal;
13 return std::strong_ordering::greater;
15 return std::strong_ordering::less;
20 stream <<
"CellIDString = " << CellID.
IDString <<
"\n";
21 stream <<
"CellIDX = " << CellID.
X_id <<
"\n";
22 stream <<
"CellIDY = " << CellID.
Y_id <<
"\n";
23 stream <<
"CellIDValid = " << (CellID.
Valid ?
"yes" :
"no") <<
"\n";
35 ExitFuncImpl(dispatch_tag<ExitTask>(), Instance);
40 UpdateFuncImpl(dispatch_tag<UpdateTask>(), Instance);
44 : ImageWidth(Util::NumToT<google::protobuf::uint32>(Image.width())), ImageHeight(Util::NumToT<google::protobuf::uint32>(Image.height())),
45 ImageFormat(Image.format())
47 ImageData.resize(Image.sizeInBytes());
50 std::memcpy(ImageData.data(), Image.bits(), ImageData.size());
55 DynExpProto::WidefieldLocalization::ImageMessage ImageMsg;
57 ImageMsg.set_width(ImageWidth);
58 ImageMsg.set_height(ImageHeight);
62 case QImage::Format::Format_Grayscale8: ImageMsg.set_imageformat(DynExpProto::WidefieldLocalization::ImageFormatType::Mono8);
break;
63 case QImage::Format::Format_Grayscale16: ImageMsg.set_imageformat(DynExpProto::WidefieldLocalization::ImageFormatType::Mono16);
break;
67 ImageMsg.set_image(std::move(ImageData));
79 grpc::ClientContext Context;
80 DynExpProto::WidefieldLocalization::ImageMessage ImageMsg = MakeImageMessage();
81 DynExpProto::WidefieldLocalization::CellIDMessage CellIDMsg;
85 auto InstrData = DynExp::dynamic_InstrumentData_cast<WidefieldLocalization>(Instance.
InstrumentDataGetter());
86 StubPtr = InstrData->GetStub<0>();
89 auto Result = StubPtr->ReadCellID(&Context, ImageMsg, &CellIDMsg);
92 if (CellIDMsg.resultmsg().result() != DynExpProto::WidefieldLocalization::ResultType::OK &&
93 CellIDMsg.resultmsg().result() != DynExpProto::WidefieldLocalization::ResultType::LocalizationFailed)
97 auto InstrData = DynExp::dynamic_InstrumentData_cast<WidefieldLocalization>(Instance.
InstrumentDataGetter());
99 if (CellIDMsg.resultmsg().result() == DynExpProto::WidefieldLocalization::ResultType::OK)
102 InstrData->CellID.IDString = CellIDMsg.idstring();
103 InstrData->CellID.X_id = CellIDMsg.id().x();
104 InstrData->CellID.Y_id = CellIDMsg.id().y();
105 InstrData->CellID.Valid =
true;
106 InstrData->CellID.CellShift_px_x = CellIDMsg.has_cellshift_px() ? CellIDMsg.cellshift_px().x() : 0;
107 InstrData->CellID.CellShift_px_y = CellIDMsg.has_cellshift_px() ? CellIDMsg.cellshift_px().y() : 0;
113 InstrData->CellID = {};
127 grpc::ClientContext Context;
128 DynExpProto::WidefieldLocalization::ImageMessage ImageMsg = MakeImageMessage();
129 DynExpProto::WidefieldLocalization::PositionsMessage PositionsMsg;
133 auto InstrData = DynExp::dynamic_InstrumentData_cast<WidefieldLocalization>(Instance.
InstrumentDataGetter());
134 StubPtr = InstrData->GetStub<0>();
137 auto Result = StubPtr->AnalyzeWidefield(&Context, ImageMsg, &PositionsMsg);
142 auto InstrData = DynExp::dynamic_InstrumentData_cast<WidefieldLocalization>(Instance.
InstrumentDataGetter());
143 InstrData->SetLocalizedPositions(PositionsMsg);
156 grpc::ClientContext Context;
157 DynExpProto::WidefieldLocalization::ImageMessage ImageMsg = MakeImageMessage();
158 DynExpProto::WidefieldLocalization::VoidMessage VoidMsg;
162 auto InstrData = DynExp::dynamic_InstrumentData_cast<WidefieldLocalization>(Instance.
InstrumentDataGetter());
163 StubPtr = InstrData->GetStub<0>();
166 auto Result = StubPtr->AnalyzeTipTilt(&Context, ImageMsg, &VoidMsg);
174 std::string_view MeasureSavePath,
CallbackType CallbackFunc) noexcept
181 grpc::ClientContext Context;
182 DynExpProto::WidefieldLocalization::RecallPositionsMessage RecallPositionsMsg;
183 DynExpProto::WidefieldLocalization::PositionsMessage PositionsMsg;
185 auto ImageMsg = std::make_unique<DynExpProto::WidefieldLocalization::ImageMessage>(MakeImageMessage());
186 RecallPositionsMsg.set_allocated_image(ImageMsg.release());
188 auto CellIDResultsMsg = std::make_unique<DynExpProto::WidefieldLocalization::ResultMessage>();
190 auto IDPointMsg = std::make_unique<DynExpProto::WidefieldLocalization::PointMessage>();
191 IDPointMsg->set_x(CellID.X_id);
192 IDPointMsg->set_y(CellID.Y_id);
193 auto CellIDMsg = std::make_unique<DynExpProto::WidefieldLocalization::CellIDMessage>();
194 CellIDMsg->set_allocated_resultmsg(CellIDResultsMsg.release());
195 CellIDMsg->set_idstring(CellID.IDString);
196 CellIDMsg->set_allocated_id(IDPointMsg.release());
197 RecallPositionsMsg.set_allocated_cellid(CellIDMsg.release());
199 RecallPositionsMsg.set_measuresavepath(MeasureSavePath);
203 auto InstrData = DynExp::dynamic_InstrumentData_cast<WidefieldLocalization>(Instance.
InstrumentDataGetter());
204 StubPtr = InstrData->GetStub<0>();
207 auto Result = StubPtr->RecallPositions(&Context, RecallPositionsMsg, &PositionsMsg);
212 auto InstrData = DynExp::dynamic_InstrumentData_cast<WidefieldLocalization>(Instance.
InstrumentDataGetter());
213 InstrData->SetLocalizedPositions(PositionsMsg);
222 LocalizedPositions.clear();
224 ResetImpl(dispatch_tag<WidefieldLocalizationData>());
229 if (PositionsMsg.resultmsg().result() != DynExpProto::WidefieldLocalization::ResultType::OK)
232 const auto NumPositions = PositionsMsg.entries_size();
233 LocalizedPositions.clear();
234 for (std::remove_const_t<decltype(NumPositions)> i = 0; i < NumPositions; ++i)
236 QPoint Position{ Util::NumToT<int>(PositionsMsg.entries(i).pos_px().x()), Util::NumToT<int>(PositionsMsg.entries(i).pos_px().y()) };
237 LocalizedPositions.emplace(PositionsMsg.entries(i).id(), Position);
Implementation of a gRPC client instrument to access a remote service for image processing (localizat...
Defines an exception caused by an operation involving the gRPC library and communication over a TCP s...
void SetLocalizedPositions(const DynExpProto::WidefieldLocalization::PositionsMessage &PositionsMsg)
void ResetImpl(dispatch_tag< gRPCInstrumentData >) override final
AnalyzeDistortionTask(const QImage &Image, CallbackType CallbackFunc) noexcept
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
AnalyzeWidefieldTask(const QImage &Image, CallbackType CallbackFunc) noexcept
void ExitFuncImpl(dispatch_tag< gRPCInstrumentTasks::ExitTask< DynExp::InstrumentBase, 0, DynExpProto::WidefieldLocalization::WidefieldLocalization >>, DynExp::InstrumentInstance &Instance) override final
ImageProcessingTaskBase(const QImage &Image) noexcept
DynExpProto::WidefieldLocalization::ImageMessage MakeImageMessage()
void InitFuncImpl(dispatch_tag< gRPCInstrumentTasks::InitTask< DynExp::InstrumentBase, 0, DynExpProto::WidefieldLocalization::WidefieldLocalization >>, DynExp::InstrumentInstance &Instance) override final
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
ReadCellIDTask(const QImage &Image, CallbackType CallbackFunc) noexcept
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
RecallPositionsTask(const QImage &Image, const WidefieldLocalizationCellIDType &CellID, std::string_view MeasureSavePath, CallbackType CallbackFunc) noexcept
void UpdateFuncImpl(dispatch_tag< gRPCInstrumentTasks::UpdateTask< DynExp::InstrumentBase, 0, DynExpProto::WidefieldLocalization::WidefieldLocalization >>, DynExp::InstrumentInstance &Instance) override final
void ResetImpl(dispatch_tag< gRPCInstrument >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
WidefieldLocalization(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Meta instrument template for transforming meta instruments into network instruments,...
Defines data for a thread belonging to a InstrumentBase instance. Refer to RunnableInstance.
const InstrumentBase::InstrumentDataGetterType InstrumentDataGetter
Getter for instrument's data. Refer to InstrumentBase::InstrumentDataGetterType.
Refer to ParamsBase::dispatch_tag.
std::function< void(const TaskBase &, ExceptionContainer &)> CallbackType
Type of a callback function which is invoked when a task has finished, failed or has been aborted....
Defines the return type of task functions.
Thrown when a requested feature is either under development and thus not implemented yet or when a sp...
Denotes that e.g. a remote gRPC service failed.
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
std::strong_ordering operator<=>(const WidefieldLocalizationCellIDType &lhs, const WidefieldLocalizationCellIDType &rhs)
std::shared_ptr< typename gRPCStub::Stub > StubPtrType
Alias for a pointer to a gRPC stub.
std::ostream & operator<<(std::ostream &stream, const WidefieldLocalizationCellIDType &CellID)
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
Accumulates include statements to provide a precompiled header.