11 auto InstrParams = DynExp::dynamic_Params_cast<PVCam>(Instance.
ParamsGetter());
14 Instance.
LockObject(InstrParams->HardwareAdapter, InstrData->HardwareAdapter);
16 auto ColorMode = InstrData->HardwareAdapter->GetColorMode();
17 if (ColorMode != DynExpHardware::PVCamSyms::PL_COLOR_MODES::COLOR_NONE)
20 "Only monochrome PVCam cameras with an image format of 2 bytes per pixel are supported.");
22 InstrData->SetImageWidth(InstrData->HardwareAdapter->GetImageWidth());
23 InstrData->SetImageHeight(InstrData->HardwareAdapter->GetImageHeight());
24 InstrData->SetCameraModes(InstrData->HardwareAdapter->GetCameraModes());
39 if (!InstrData->HardwareAdapter->IsSharedUsageEnabled() || InstrData->HardwareAdapter->GetUseCount() == 1)
40 InstrData->HardwareAdapter->StopCapturing();
58 unsigned int BitDepth = 16;
62 bool UpdateError =
false;
66 InstrData->SetMinExposureTime(InstrData->HardwareAdapter->GetMinExposureTime());
67 InstrData->SetMaxExposureTime(InstrData->HardwareAdapter->GetMaxExposureTime());
68 InstrData->SetExposureTime(InstrData->HardwareAdapter->GetExposureTime());
69 InstrData->SetCurrentFPS(InstrData->HardwareAdapter->GetFPS());
70 InstrData->SetCapturingState(InstrData->HardwareAdapter->GetCameraState());
72 BitDepth = InstrData->HardwareAdapter->GetBitDepth();
73 ImageWidth = InstrData->GetImageWidth();
74 ImageHeight = InstrData->GetImageHeight();
75 ImageTransformation = InstrData->GetImageTransformation();
76 ImageBlob = InstrData->HardwareAdapter->GetCurrentImage();
83 if (InstrData->NumFailedStatusUpdateAttempts++ >= 3)
88 InstrData->NumFailedStatusUpdateAttempts = 0;
92 auto ImageBlobPtr = ImageBlob.
GetPtr();
93 for (
auto i = 0; i < ImageBlob.
Size(); i += 2)
96 DynExpHardware::PVCamSyms::uns16 Pixel = (*(ImageBlobPtr) | (*(ImageBlobPtr + 1) << 8)) * std::exp2(16) / std::exp2(BitDepth);
103 *(ImageBlobPtr) = Pixel & 0xff;
104 *(ImageBlobPtr + 1) = (Pixel & 0xff00) >> 8;
133 InstrData->HardwareAdapter->SetCameraMode(ID);
142 InstrData->HardwareAdapter->SetExposureTime(ExposureTime);
151 InstrData->HardwareAdapter->CaptureSingle();
160 InstrData->HardwareAdapter->StartCapturing();
169 InstrData->HardwareAdapter->StopCapturing();
177 NumFailedStatusUpdateAttempts = 0;
183 :
Camera(OwnerThreadID, std::move(Params))
Implementation of an instrument to control Teledyne Photometrics PVCam cameras.
constexpr static auto BytesPerPixel() noexcept
unsigned int ImageDimensionType
Type describing image dimensions such as width and height.
bool IsEnabled
Determines whether the image transformation is to be applied (enabled).
Meta instrument for an image capturing (camera) device.
void ResetImpl(dispatch_tag< CameraData >) 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...
void ExitFuncImpl(dispatch_tag< CameraTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
void InitFuncImpl(dispatch_tag< CameraTasks::InitTask >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
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...
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 QImage ObtainImage(DynExp::InstrumentInstance &Instance) override
Retrieves the current image from the underlying hardware device, applies image transformations (e....
void ResetImpl(dispatch_tag< Camera >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
PVCam(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Refer to DynExp::ParamsBase::dispatch_tag.
Refer to DynExp::ParamsBase::dispatch_tag.
Refer to ParamsBase::dispatch_tag.
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.
const Object::ParamsGetterType ParamsGetter
Invoke to obtain the parameters (derived from ParamsBase) of Owner.
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
void LockObject(const ParamsBase::Param< ObjectLink< ObjectT >> &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault)
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< O...
const auto & GetOwner() const noexcept
Returns Owner.
Defines the return type of task functions.
Data type which manages a binary large object. The reserved memory is freed upon destruction.
auto Size() const noexcept
Returns the size of the stored data in bytes.
auto GetPtr() noexcept
Returns a pointer to the stored buffer.
Thrown when a requested feature is either under development and thus not implemented yet or when a sp...
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
T TransformPixel(T Pixel, const CameraData::ImageTransformationType &ImageTransformation)
Applies an image transformation to a single pixel.
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
QImage QImageFromBlobData(BlobDataType &&BlobData, int Width, int Height, int BytesPerLine, QImage::Format Format)
Converts raw pixel data stored in a Util::BlobDataType object to a QImage transfering the ownership o...
Accumulates include statements to provide a precompiled header.