From 57f3cb8bf667b15e83b3e6d5e7981d1dcc69b12d Mon Sep 17 00:00:00 2001 From: Yuelong Yu Date: Thu, 17 Feb 2022 18:22:00 +0100 Subject: [PATCH 1/5] WIP adding support for CXP cameras - added property CameraInterface for tango server - added PhxWrapperCXP - added EoSensCXP class to support CXP cameras --- EoSensCL/CameraRegisterAddrMap.h | 117 ++++++++ EoSensCL/EoSensCXP.cpp | 458 +++++++++++++++++++++++++++++++ EoSensCL/EoSensCXP.h | 80 ++++++ EoSensCL/PHXWrapper.cpp | 50 +--- EoSensCL/PHXWrapper.h | 8 +- EoSensCL/PHXWrapperCXP.cpp | 191 +++++++++++++ EoSensCL/PHXWrapperCXP.h | 29 ++ FireBird.cpp | 73 +++-- FireBird.h | 4 + FireBird.xmi | 5 + FireBirdClass.cpp | 14 + Makefile | 14 +- doc_html/FullDocument.html | 8 + doc_html/Properties.html | 8 + 14 files changed, 985 insertions(+), 74 deletions(-) create mode 100644 EoSensCL/CameraRegisterAddrMap.h create mode 100644 EoSensCL/EoSensCXP.cpp create mode 100644 EoSensCL/EoSensCXP.h create mode 100644 EoSensCL/PHXWrapperCXP.cpp create mode 100644 EoSensCL/PHXWrapperCXP.h diff --git a/EoSensCL/CameraRegisterAddrMap.h b/EoSensCL/CameraRegisterAddrMap.h new file mode 100644 index 0000000..9ce0df8 --- /dev/null +++ b/EoSensCL/CameraRegisterAddrMap.h @@ -0,0 +1,117 @@ +/** + * Address map are taken from XML file. + * + * The XML file is an ASCII file which is to be found on the USB storage device + * delivered with the camera. + * + * It is possible to read it from camera , but this is not done yet! + */ +#pragma once + +#include +#include +#include + +namespace EoSensCXP_ns +{ + using namespace std; + + const uint32_t AcquisitionModeReg = 0x8200; + const uint32_t AcquisitionStartReg = 0x8204; + const uint32_t AcquisitionStopReg = 0x8208; + const uint32_t AcquisitionBurstFrameCountReg = 0x8914; + const uint32_t TriggerSelectorReg = 0x8900; + const uint32_t TriggerModeReg = 0x8904; + const uint32_t TriggerSourceReg = 0x8908; + const uint32_t TriggerActivationReg = 0x890C; + const uint32_t TriggerCountReg = 0x891C; + const uint32_t TriggerDebouncerReg = 0x8918; + const uint32_t TriggerSoftwareReg = 0x8910; + const uint32_t ExposureModeReg = 0x8944; + const uint32_t ExposureTimeReg = 0x8840; + const uint32_t AcquisitionFrameRateReg = 0x8814; + const uint32_t AcquisitionFrameRateMaxReg = 0x881C; + const uint32_t UserSetSelectorReg = 0x00008820; + const uint32_t UserSetLoadReg = 0x00008824; + const uint32_t UserSetSaveReg = 0x00008828; + const uint32_t UserSetDefaultSelectorReg = 0x0000882C; + const uint32_t WidthAddressReg = 0x3000; + const uint32_t HeightAddressReg = 0x3004; + const uint32_t AcquisitionModeAddressReg = 0x3008; + const uint32_t AcquistionStartAddressReg = 0x300C; + const uint32_t AcquistionStopAddressReg = 0x3010; + const uint32_t PixelFormatAddressReg = 0x3014; + const uint32_t DeviceTapGeometryAddressReg = 0x3018; + const uint32_t Image1StreamIDAddressReg = 0x301C; + const uint32_t ControlPacketSizeMaxReg = 0x400c; + + const uint32_t DeviceConnectionIDReg = 0x4004; + const uint32_t Iidc2AddressReg = 0x1c; + const uint32_t ConnectionConfigReg = 0x4014; + const uint32_t ConnectionConfigDefaultReg = 0x4018; + const uint32_t ConnectionResetReg = 0x4000; + const uint32_t MasterHostConnectionIDReg = 0x4008; + const uint32_t RevisionReg = 0x4; + const uint32_t StandardReg = 0x0; + const uint32_t StreamPacketSizeMaxReg = 0x4010; + const uint32_t TestErrorCountSelectorReg = 0x4020; + const uint32_t TestErrorCountReg = 0x4024; + const uint32_t TestPacketCountTxReg = 0x4028; + const uint32_t TestPacketCountRxReg = 0x4030; + const uint32_t TestModeReg = 0x401c; + const uint32_t XmlManifestSelectorReg = 0xc; + const uint32_t XmlManifestSizeReg = 0x8; + const uint32_t XmlSchemeVersionReg = 0x14; + const uint32_t XmlUrlAddressReg = 0x18; + const uint32_t XmlVersionReg = 0x10; + const uint32_t DeviceSerialNumberReg = 0x20b0; + const uint32_t DeviceManufacturerInfoReg = 0x2040; + const uint32_t DeviceModelNameReg = 0x2020; + const uint32_t DeviceUserIDReg = 0x20c0; + const uint32_t DeviceVendorNameReg = 0x2000; + const uint32_t DeviceVersionReg = 0x2070; + + const uint32_t DeviceResetReg = 0x8300; + + const uint32_t HeightReg = 0x811c; + const uint32_t OffsetXReg = 0x8800; + const uint32_t Image1StreamIDReg = 0x8164; + const uint32_t PixelFormatReg = 0x8144; + const uint32_t TapGeometryReg = 0x8160; + const uint32_t SensorHeightReg = 0x880c; + const uint32_t SensorWidthReg = 0x8808; + const uint32_t RegionDestinationReg = 0x8188; + const uint32_t WidthReg = 0x8118; + const uint32_t OffsetYReg = 0x8804; + const uint32_t AnalogGainReg = 0x8850; + const uint32_t BlackLevelReg = 0x8854; + const uint32_t LineSelectorReg = 0x8A24; + const uint32_t LineSourceReg = 0x8A28; + const uint32_t LineInverterReg = 0x8A20; + const uint32_t UserOutputSelectorReg = 0x8A4C; + const uint32_t UserOutputValueReg = 0x8A50; + const uint32_t GammaReg = 0x8858; + const uint32_t DigitalGainReg = 0x886C; + const uint32_t TxLogicalConnectionResetReg = 0x9010; + const uint32_t DeviceInformationReg = 0x8A04; + const uint32_t DeviceInformationSelectorReg = 0x8A00; + const uint32_t AnalogRegisterSetSelectorReg = 0x20000; + const uint32_t AnalogRegisterSelectorReg = 0x20004; + const uint32_t AnalogValueReg = 0x20008; + const uint32_t InfoFieldFrameCounterEnableReg = 0x9310; + const uint32_t InfoFieldTimeStampEnableReg = 0x9314; + const uint32_t InfoFieldRoiEnableReg = 0x9318; + const uint32_t FixedPatternNoiseReductionReg = 0x8A10; + + + const uint32_t PixelTypeFReg = 0x51004; + const uint32_t DIN1ConnectorType = 0x8A30; + const uint32_t IsImplementedMultiROI = 0x50004; + const uint32_t CameraTypeHexReg = 0x00051000; + const uint32_t CameraStatusReg = 0x10002200; + const uint32_t IsStopped = 0x10002204; + const uint32_t FileCountReg = 0x08100028; + const uint32_t Has2ConnectionModi = 0x00050014; + const uint32_t ExposureTimeMinReg = 0x8848; + const uint32_t ExposureTimeMaxReg = 0x8818; +} \ No newline at end of file diff --git a/EoSensCL/EoSensCXP.cpp b/EoSensCL/EoSensCXP.cpp new file mode 100644 index 0000000..53e97d5 --- /dev/null +++ b/EoSensCL/EoSensCXP.cpp @@ -0,0 +1,458 @@ +#include "EoSensCXP.h" + +namespace EoSensCXP_ns +{ + + EoSensCXP::EoSensCXP(uint16_t board_nr, uint16_t channel_nr,string config_file,uint16_t mode,CamComm_ns::log_handler fl) + :m_fl(fl), + m_xstart(0), + m_ystart(0), + m_x(0), + m_y(0), + m_max_x(0), + m_max_y(0), + m_mine(0), + m_maxe(9999), + m_minf(0), + m_maxf(9999), + m_hw_buf_len(20), + m_imgs_per_interrupt(1), + m_current_frame(0), + m_loss(0), + m_acquired(0), + m_available(0), + m_start(false), + m_frame_counter(false) + { + m_phx = uptr_phx(new PHX_ns::PHXWrapperCXP(fl)); + if(!(m_phx->OpenCamera(board_nr,channel_nr,config_file))) + { + m_phx.reset(); + throw std::runtime_error("EoSensCXP::cannot open camera"); + } + + if(!GetSensorMaxSize()) + { + m_phx.reset(); + throw std::runtime_error("EoSensCXP::cannot get sensor max size"); + } + + if(!UpdateImageSize()) + { + m_phx.reset(); + throw std::runtime_error("EoSensCXP::cannot update image size"); + } + } + + EoSensCXP::~EoSensCXP() + { + m_phx.reset(); + } + + bool EoSensCXP::ResetCamera() + { + m_fl("EoSensCXP::ResetCamera", EDEBUG); + return ""; + } + + string EoSensCXP::GetCameraErr() + { + m_fl("EoSensCXP::GetCameraErr", EDEBUG); + return ""; + } + + string EoSensCXP::GetCameraSN() + { + m_fl("EoSensCXP::GetCameraSN", EDEBUG); + return ""; + } + + string EoSensCXP::GetCameraID() + { + m_fl("EoSensCXP::GetCameraID", EDEBUG); + return ""; + } + + int16_t EoSensCXP::GetTemerature() + { + m_fl("EoSensCXP::GetTemerature", EDEBUG); + return 0; + } + + bool EoSensCXP::SetBlackLevel(uint16_t b) + { + m_fl("EoSensCXP::SetBlackLevel", EDEBUG); + + return m_phx->Write(BlackLevelReg, static_cast(b)); + } + + bool EoSensCXP::GetBlackLevel(uint16_t& b) + { + m_fl("EoSensCXP::GetBlackLevel", EDEBUG); + uint32_t tmp; + if(!(m_phx->Read(BlackLevelReg, tmp))) + return false; + + b = static_cast(tmp); + return true; + } + + bool EoSensCXP::SetTriggerMode(uint16_t t) + { + m_fl("EoSensCXP::SetTriggerMode", EDEBUG); + return true; + } + + bool EoSensCXP::GetTriggerMode(uint16_t& t) + { + m_fl("EoSensCXP::GetTriggerMode", EDEBUG); + t=0; + return true; + } + + bool EoSensCXP::SetGain(uint16_t g) + { + m_fl("EoSensCXP::SetGain", EDEBUG); + + return m_phx->Write(AnalogGainReg, static_cast(g)); + } + + bool EoSensCXP::GetGain(uint16_t& g) + { + m_fl("EoSensCXP::GetGain", EDEBUG); + uint32_t tmp; + if(!(m_phx->Read(AnalogGainReg, tmp))) + return false; + + g = static_cast(tmp); + + return false; + } + + bool EoSensCXP::SetFrameRate(uint32_t f) + { + m_fl("EoSensCXP::SetFrameRate", EDEBUG); + if(f < m_minf || f > m_maxf) + { + m_fl("frame rate out of range, it should be between " + to_string(m_minf) + " and " + to_string(m_maxf), EERROR); + return false; + } + + return m_phx->Write(AcquisitionFrameRateReg, f); + } + + bool EoSensCXP::GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin) + { + m_fl("EoSensCXP::GetFrameRate", EDEBUG); + if(!(m_phx->Read(AcquisitionFrameRateReg, f))) + return false; + m_minf = 10; // according to document, minimum frame rate + if(!(m_phx->Read(AcquisitionFrameRateMaxReg, m_maxf))) + return false; + return true; + } + + bool EoSensCXP::SetExposureTime(uint32_t e) //unit μs + { + m_fl("EoSensCXP::SetExposureTime", EDEBUG); + if(e < m_mine || e > m_maxe) + { + m_fl("shutter time out of range, it should be between " + to_string(m_mine) + " and " + to_string(m_maxe), EERROR); + return false; + } + + return m_phx->Write(ExposureTimeReg, e); + } + + bool EoSensCXP::GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin) + { + m_fl("EoSensCXP::GetExposureTime", EDEBUG); + + if(!(m_phx->Read(ExposureTimeReg, e))) + return false; + if(!(m_phx->Read(ExposureTimeMinReg, m_mine))) + return false; + if(!(m_phx->Read(ExposureTimeMaxReg, m_maxe))) + return false; + return true; + } + + bool EoSensCXP::SetROI(vector r) + { + m_fl("EoSensCXP::SetROI", EDEBUG); + + if(r.size() != 4) + { + m_fl("ROI size error, should be 4 \ + (xstart,ystart,xwidth,ywidth) \ + instead of" +to_string(r.size()), EERROR); + return false; + } + + uint32_t offset_x = static_cast(r[0]); + uint32_t offset_y = static_cast(r[1]); + uint32_t x = static_cast(r[2]); + uint32_t y = static_cast(r[3]); + if(!(m_phx->Write(OffsetXReg, offset_x)) || + !(m_phx->Write(OffsetYReg, offset_y)) || + !(m_phx->Write(WidthReg, x)) || + !(m_phx->Write(HeightReg, y))) + return false; + return true; + } + + bool EoSensCXP::GetROI(vector& r) + { + m_fl("EoSensCXP::GetROI", EDEBUG); + + uint32_t offset_x, offset_y, x, y; + if(!(m_phx->Read(OffsetXReg, offset_x)) || + !(m_phx->Read(OffsetYReg, offset_y)) || + !(m_phx->Read(WidthReg, x)) || + !(m_phx->Read(HeightReg, y))) + return false; + + r[0] = static_cast(offset_x); + r[1] = static_cast(offset_y); + r[2] = static_cast(x); + r[3] = static_cast(y); + + return true; + } + + bool EoSensCXP::SetPixelClock(uint16_t c) + { + m_fl("EoSensCXP::SetPixelClock", EDEBUG); + return false; + } + bool EoSensCXP::GetPixelClock(uint16_t& c) + { + m_fl("EoSensCXP::GetPixelClock", EDEBUG); + return false; + } + + bool EoSensCXP::SetFrameCounter(bool f) + { + m_fl("EoSensCXP::SetFrameCounter", EDEBUG); + uint32_t val = f ? 1 : 0; + return m_phx->Write(InfoFieldFrameCounterEnableReg, val); + } + + bool EoSensCXP::GetFrameCounter(bool& f) + { + m_fl("EoSensCXP::GetFrameCounter", EDEBUG); + + uint32_t tmp; + if(!(m_phx->Read(InfoFieldFrameCounterEnableReg, tmp))) + return false; + f = (tmp == 1); + return true; + } + + bool EoSensCXP::SetRunMode(uint16_t m) + { + m_fl("EoSensCXP::SetRunMode", EDEBUG); + return false; + } + + bool EoSensCXP::GetRunMode(uint16_t& m) + { + m_fl("EoSensCXP::GetRunMode", EDEBUG); + return false; + } + + bool EoSensCXP::SetCameraMode(uint16_t m) + { + m_fl("EoSensCXP::SetCameraMode", EDEBUG); + return false; + } + + bool EoSensCXP::GetCameraMode(uint16_t& m) + { + m_fl("EoSensCXP::GetCameraMode", EDEBUG); + return false; + } + + bool EoSensCXP::SetFPNCorrection(bool f) + { + m_fl("EoSensCXP::SetFPNCorrection", EDEBUG); + + uint32_t val = f ? 1 : 0; + return m_phx->Write(FixedPatternNoiseReductionReg, val); + } + + bool EoSensCXP::GetFPNCorrection(bool & f) + { + m_fl("EoSensCXP::GetFPNCorrection", EDEBUG); + uint32_t tmp; + if(!(m_phx->Read(FixedPatternNoiseReductionReg, tmp))) + return false; + f = (tmp == 1); + return true; + } + + bool EoSensCXP::StartAcq(int32_t requested_count, int32_t hw_buf_len, int32_t imgs_per_interrupt) + { + m_fl("EoSensCXP::StartAcq", EDEBUG); + m_loss = 0; + m_acquired = 0; + m_available = 0; + m_imgs_per_interrupt = imgs_per_interrupt; + m_hw_buf_len = hw_buf_len; + + // update image size + if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) + m_img.resize(m_x*m_y*m_imgs_per_interrupt); + + // update frame grabber + if(!(m_phx->UpdateImageSize(m_xstart,m_ystart,m_x,m_y, m_hw_buf_len, m_imgs_per_interrupt))) + return false; + + m_start = true; + GetFrameCounter(m_frame_counter); + return m_phx->StartAcq(requested_count); + } + + bool EoSensCXP::StopAcq() + { + m_fl("EoSensCXP::StopAcq", EDEBUG); + + auto ret = m_phx->StopAcq(); + m_loss = 0; + m_acquired = 0; + m_available = 0; + m_start = true; + m_fl("EoSensCXP::StopAcq, loss frames:" + to_string(m_loss), EINFO); + return ret; + } + + uint32_t EoSensCXP::GetFrameLoss() + { + m_fl("EoSensCXP::GetFrameLoss", EDEBUG); + return m_loss; + } + + bool EoSensCXP::GetImageSize(uint32_t& x, uint32_t& y) + { + m_fl("EoSensCXP::GetImageSize", EDEBUG); + vector r; + if(GetROI(r)) + { + x = r[2]; + y = r[3]; + return true; + } + return false; + } + + bool EoSensCXP::GetImage(vector& img, uint32_t& f) + { + m_fl("EoSensCXP::GetImage", EDEBUG); + // there is no available image + // check frame grabber queue, it there is image + if(m_available < m_imgs_per_interrupt) + { + auto current_count = (m_phx->GetImagesInQueue()); + if(current_count == 0) + return false; + m_fl("EoSensCXP::buffer in count" + to_string(current_count), EDEBUG); + m_available = current_count - m_acquired; + } + + if(m_available < m_imgs_per_interrupt) + { + m_fl("EoSensCXP::no new image", EDEBUG); + return false; + } + + if(m_phx->GetImage(m_img)) + { + img = m_img; + // string s = "EoSensCXP::GetImage:first 4 bytes:"; + // for(uint32_t i=0; i<4; i++) + // s += (to_string(static_cast(img[i])) + " "); + // m_fl(s, EDEBUG); + if(m_frame_counter) + CheckFrameNumber(m_img); + m_acquired += m_imgs_per_interrupt; + m_available -= m_imgs_per_interrupt; + f = m_acquired; + return true; + } + else + return false; + } + + bool EoSensCXP::GetSensorMaxSize() + { + m_fl("EoSensCXP::GetSensorMaxSize", EDEBUG); + + if(!(m_phx->Read(SensorWidthReg, m_max_x)) || !(m_phx->Read(SensorHeightReg, m_max_y))) + return false; + + return true; + } + + bool EoSensCXP::UpdateImageSize() + { + vector r; + if(!GetROI(r)) + return false; + + m_fl("EoSensCXP::UpdateImageSize", EDEBUG); + m_xstart = r[0]; + m_ystart = r[1]; + m_x = r[2]; + m_y = r[3]; + // update image size + if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) + m_img.resize(m_x*m_y*m_imgs_per_interrupt); + + // update frame grabber + if(!(m_phx->UpdateImageSize(m_xstart, m_ystart,m_x,m_y,m_hw_buf_len, m_imgs_per_interrupt))) + return false; + + + return true; + + } + + void EoSensCXP::CheckFrameNumber(vector& d) + { + uint32_t frame_nr = static_cast((((uint8_t)d[3])<<24) + +(((uint8_t)d[2])<<16) + +(((uint8_t)d[1])<<8) + +((uint8_t)d[0])); + + if(frame_nr % 10000 == 0) + { + m_fl("EoSensCXP::frame_nr:" + to_string(frame_nr) + + " - current:" + to_string(m_current_frame) + + " - imgs per interrupt" + to_string(m_imgs_per_interrupt) + + " - loss:"+ to_string(m_loss) + + " - avaiable in buffer:" + to_string(m_available), EINFO); + } + + if(m_start) + { + m_current_frame = frame_nr; + m_start = false; + } + else + { + if(frame_nr - m_current_frame != m_imgs_per_interrupt) + { + m_fl("EoSensCXP::frame nr does not match, current:" + + to_string(frame_nr) + + " - previous:" + + to_string(m_current_frame), EDEBUG); + m_loss += (frame_nr - m_current_frame + 1); + m_current_frame = frame_nr; + } + else + { + m_current_frame += m_imgs_per_interrupt; + } + } + } +} \ No newline at end of file diff --git a/EoSensCL/EoSensCXP.h b/EoSensCL/EoSensCXP.h new file mode 100644 index 0000000..edfcf5c --- /dev/null +++ b/EoSensCL/EoSensCXP.h @@ -0,0 +1,80 @@ +#pragma once +#include "CameraCommon.h" +#include "CameraRegisterAddrMap.h" +#include "PHXWrapper.h" +#include "PHXWrapperCXP.h" + +namespace EoSensCXP_ns +{ + using namespace CamComm_ns; + + typedef unique_ptr uptr_phx; + + class EoSensCXP + { + public: + EoSensCXP(uint16_t board_nr, uint16_t channel_nr, string config_file, uint16_t mode = 0, CamComm_ns::log_handler fl=CamComm_ns::default_log); + ~EoSensCXP(); + + bool ResetCamera(); + string GetCameraErr(); + + string GetCameraSN(); + string GetCameraID(); + int16_t GetTemerature(); + + bool SetBlackLevel(uint16_t b); + bool GetBlackLevel(uint16_t& b); + + bool SetTriggerMode(uint16_t t); + bool GetTriggerMode(uint16_t& t); + + bool SetGain(uint16_t g); + bool GetGain(uint16_t& g); + + bool SetFrameRate(uint32_t f); + bool GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin); + + bool SetExposureTime(uint32_t e); + bool GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin); + + bool SetROI(vector r); + bool GetROI(vector& r); + + bool SetPixelClock(uint16_t c); + bool GetPixelClock(uint16_t& c); + + bool SetFrameCounter(bool f); + bool GetFrameCounter(bool& f); + + bool SetRunMode(uint16_t m); + bool GetRunMode(uint16_t& m); + + bool SetCameraMode(uint16_t m); + bool GetCameraMode(uint16_t& m); + + bool SetFPNCorrection(bool f); + bool GetFPNCorrection(bool & f); + + bool StartAcq(int32_t requested_count = -1, int32_t hw_buf_len = 20, int32_t imgs_per_interrupt = 1); + bool StopAcq(); + uint32_t GetFrameLoss(); + bool GetImageSize(uint32_t& x, uint32_t& y); + bool GetImage(vector& img, uint32_t& f); + + private: + bool GetSensorMaxSize(); + bool CheckReply(vector& reply); + bool UpdateImageSize(); + void CheckFrameNumber(vector& d); + uptr_phx m_phx; + CamComm_ns::log_handler m_fl; + vector m_img; + uint32_t m_xstart, m_ystart, m_x,m_y,m_max_x, m_max_y, + m_mine, m_maxe,m_minf,m_maxf, + m_hw_buf_len,m_imgs_per_interrupt, + m_current_frame,m_loss, m_acquired, m_available; + bool m_start, m_frame_counter; + + }; +} \ No newline at end of file diff --git a/EoSensCL/PHXWrapper.cpp b/EoSensCL/PHXWrapper.cpp index 27061d4..91ae9e1 100644 --- a/EoSensCL/PHXWrapper.cpp +++ b/EoSensCL/PHXWrapper.cpp @@ -137,17 +137,6 @@ namespace PHX_ns m_fl("CXP board doesn't support serial communication", EERROR); CloseCamera(); return false; - // if(PhxCommonGetCxpDiscoveryStatus(10, &m_is_discovered) != PHX_OK) - // { - // CloseCamera(); - // return false; - // } - - // if(!m_is_discovered) - // { - // CloseCamera(); - // return false; - // } } else m_fl("this is not a CXP camera", EINFO); @@ -210,7 +199,6 @@ namespace PHX_ns } } - return true; } @@ -338,12 +326,6 @@ namespace PHX_ns if(!GetImageSize(x,y)) return false; - // if(x!=m_x || y!=m_y) - // { - // if(!UpdateImageSize(m_x,m_y)) - // return false; - // } - // start frame grabber if (PHX_StreamRead(m_cam, PHX_START, @@ -516,9 +498,6 @@ namespace PHX_ns return false; } - // auto current_count = m_cb_context.buffer_count; - // if((current_count - m_acquired)>= m_imgs_per_interrupt) - // { m_fl("PHXWrapper::GetImage", EDEBUG); stImageBuff buf; if(PHX_StreamRead(m_cam, PHX_BUFFER_GET,&buf) != PHX_OK) @@ -527,12 +506,7 @@ namespace PHX_ns return false; } m_fl("PHXWrapper::GetImage:read " + to_string(m_imgs_per_interrupt) + "image", EDEBUG); - uint8_t* data = reinterpret_cast(buf.pvAddress); - // string s = "raw first 4 bytes:"; - // for(uint32_t i=0; i<4; i++) - // s += (to_string(static_cast(data[i])) + " "); - // m_fl(s, EDEBUG); - + uint8_t* data = reinterpret_cast(buf.pvAddress); std::copy(data, data + img.size(), &img[0]); m_fl("PHXWrapper::GetImage:copy " +to_string(m_imgs_per_interrupt)+ "image", EDEBUG); @@ -547,14 +521,8 @@ namespace PHX_ns return false; } m_fl("PHXWrapper::GetImage:get "+ to_string(m_imgs_per_interrupt) + " image and released it's buffer in frame grabber", EDEBUG); - //m_cb_context.buffer_count -= (m_imgs_per_interrupt); + m_acquired += (m_imgs_per_interrupt); - // } - // else - // { - // m_fl("PHXWrapper::GetImage:no image in frame grabber yet", EDEBUG); - // return false; - // } return true; } @@ -659,20 +627,6 @@ namespace PHX_ns cb_context->total_count += (cb_context->imgs_per_interrupt); cb_context->fl("PHXWrapper::InterruptCallback new image comes:" + to_string(cb_context->buffer_count), EDEBUG); - - // if(cb_context->buffer_count >= 0.5*(cb_context->max_buffer) && (cb_context->buffer_count != (cb_context->max_buffer))) - // cb_context->fl("PHXWrapper::InterruptCallback buffer reaches 50% max buffer:" + to_string(cb_context->buffer_count), EINFO); - - // if(cb_context->buffer_count == cb_context->max_buffer) - // cb_context->fl("PHXWrapper::InterruptCallback buffer reaches max buffer:" + to_string(cb_context->buffer_count), EERROR); - - - // if((cb_context->total_count >= cb_context->requested_count) - // && (cb_context->requested_count != -1)) - // { - // cb_context->fl("PHXWrapper::InterruptCallback get enough images, stop...", EINFO); - // cb_context->phx->StopAcq(); - // } } /* A FIFO overflow occurred, diff --git a/EoSensCL/PHXWrapper.h b/EoSensCL/PHXWrapper.h index b704d06..8543b60 100644 --- a/EoSensCL/PHXWrapper.h +++ b/EoSensCL/PHXWrapper.h @@ -33,10 +33,12 @@ namespace PHX_ns { public: PHXWrapper(CamComm_ns::log_handler fl); - ~PHXWrapper(); - bool OpenCamera(uint16_t board, uint16_t channel, string config); + virtual ~PHXWrapper(); + virtual bool OpenCamera(uint16_t board, uint16_t channel, string config); void CloseCamera(); bool RunCMD(const vector& cmd, vector& reply); + virtual bool Write(uint32_t, uint32_t){ return false; }; + virtual bool Read(uint32_t, uint32_t&){ return false; }; bool StartAcq(int32_t requested_count = -1); bool StopAcq(); bool GetImageSize(uint32_t &x, uint32_t &y); @@ -44,7 +46,7 @@ namespace PHX_ns uint32_t GetImagesInQueue(); bool GetImage(vector& img); - private: + protected: etStat PhxCommonIsCxp(tFlag *is_cxp); etStat PhxCommonGetCxpDiscoveryStatus(ui32 time_out, tFlag* is_discovered); static void InterruptCallback(tHandle cam, ui32 interrupt_mask,void *context); diff --git a/EoSensCL/PHXWrapperCXP.cpp b/EoSensCL/PHXWrapperCXP.cpp new file mode 100644 index 0000000..3de60dd --- /dev/null +++ b/EoSensCL/PHXWrapperCXP.cpp @@ -0,0 +1,191 @@ +#include "PHXWrapperCXP.h" + +namespace PHX_ns +{ + PHXWrapperCXP::PHXWrapperCXP(CamComm_ns::log_handler fl) + :PHXWrapper(fl) + { + } + + bool PHXWrapperCXP::OpenCamera(uint16_t board_nr, uint16_t channel_nr, string config_file) + { + m_fl("PHXWrapperCXP::OpenCamera, board:" + + to_string(board_nr) + + "- channel:" + to_string(channel_nr) + + "- config" + config_file, EDEBUG); + // create phoenix handle + if(PHX_Create(&(this->m_cam), PHX_ErrHandlerDefault) != PHX_OK) + { + m_fl("cannot create camera handle", EERROR); + CloseCamera(); + return false; + } + + // set configuration file + char* config = NULL; + if(!config_file.empty()) + { + m_fl("config file not empty",EDEBUG); + config = &config_file[0]; + } + m_fl("set config file :" + config_file, EDEBUG); + if(PHX_ParameterSet(this->m_cam, PHX_CONFIG_FILE, &config) != PHX_OK) + { + m_fl("cannot set PHX_CONFIG_FILE:" + string(config),EERROR); + CloseCamera(); + return false; + } + + //set board number + etParamValue board; + switch(board_nr) + { + case 0: board = PHX_BOARD_NUMBER_AUTO; break; + case 1: board = PHX_BOARD_NUMBER_1; break; + case 2: board = PHX_BOARD_NUMBER_2; break; + case 3: board = PHX_BOARD_NUMBER_3; break; + case 4: board = PHX_BOARD_NUMBER_4; break; + case 5: board = PHX_BOARD_NUMBER_5; break; + case 6: board = PHX_BOARD_NUMBER_6; break; + case 7: board = PHX_BOARD_NUMBER_7; break; + default: + m_fl("board number out of range should be 0-8 instead of " + + std::to_string(board_nr),EERROR); + return false; + } + + m_fl("set board number", EDEBUG); + if(PHX_ParameterSet(this->m_cam, PHX_BOARD_NUMBER, &board) != PHX_OK) + { + m_fl("cannot set PHX_BOARD_NUMBER:" + std::to_string(board_nr), EERROR); + CloseCamera(); + return false; + } + + //set channel number + etParamValue channel; + switch(channel_nr) + { + case 0: channel = PHX_CHANNEL_NUMBER_AUTO; break; + case 1: channel = PHX_CHANNEL_NUMBER_1; break; + case 2: channel = PHX_CHANNEL_NUMBER_2; break; + case 3: channel = PHX_CHANNEL_NUMBER_3; break; + case 4: channel = PHX_CHANNEL_NUMBER_4; break; + case 5: channel = PHX_CHANNEL_NUMBER_5; break; + case 6: channel = PHX_CHANNEL_NUMBER_6; break; + case 7: channel = PHX_CHANNEL_NUMBER_7; break; + case 8: channel = PHX_CHANNEL_NUMBER_8; break; + default: + m_fl("channel number out of range should be 0-8 instead of " + + std::to_string(channel_nr), EERROR); + CloseCamera(); + return false; + } + + m_fl("set channel number", EDEBUG); + if(PHX_ParameterSet(this->m_cam, PHX_CHANNEL_NUMBER, &channel)) + { + m_fl("cannot set PHX_CHANNEL_NUMBER:" + std::to_string(channel_nr), EERROR); + CloseCamera(); + return false; + } + + m_fl("set PHX_CONFIG_MODE", EDEBUG); + // both acquistion engine and com ports + etParamValue config_mode = PHX_CONFIG_NORMAL; + if(PHX_ParameterSet(this->m_cam, PHX_CONFIG_MODE, &config_mode)) + { + m_fl("cannot set PHX_CONFIG_MODE", EERROR); + CloseCamera(); + return false; + } + + m_fl("open camera", EDEBUG); + //open camera + if(PHX_Open(this->m_cam) != PHX_OK) + { + m_fl("cannot open camera", EERROR); + return false; + } + + m_fl("check if it's cxp camera", EDEBUG); + tFlag is_cxp_camera; + if(PhxCommonIsCxp(&is_cxp_camera) != PHX_OK) + { + m_fl("this is a CXP camera", EERROR); + } + else + { + if(is_cxp_camera) + { + tFlag is_discovered; + PhxCommonGetCxpDiscoveryStatus(10,&is_discovered); + if(!is_discovered) + { + m_fl("camera not discovered", EERROR); + CloseCamera(); + return false; + } + else + { + m_fl("camera discovered", EINFO); + return true; + } + } + else + { + m_fl("this is not a CXP camera", EERROR); + CloseCamera(); + return false; + } + } + + return true; + } + + bool PHXWrapperCXP::Write(uint32_t address, uint32_t v) + { + m_fl("PHXWrapperCXP::Write:" + to_string(address) + ":" + to_string(v),EDEBUG); + ui32 v_big_endian = htobe32(v); // convert to big endian + ui32 v_in_bytes = sizeof(v); + + if (PHX_OK != PHX_ControlWrite(this->m_cam, PHX_REGISTER_DEVICE, &address, (ui8 *)&v_big_endian, (ui32 *)&v_in_bytes, 800)) + { + m_fl("Error writing to Camera CXP register", EERROR); + return false; + } + + if (v_in_bytes != sizeof(v)) + { + m_fl("Error writing to Camera CXP register: size written does not match size requested.", EERROR); + return false; + } + + return true; + } + + bool PHXWrapperCXP::Read(uint32_t address, uint32_t& r) + { + m_fl("PHXWrapperCXP::Read:" + to_string(address),EDEBUG); + ui32 r_in_bytes = sizeof(r); + ui32 tmp; + + if (PHX_ControlRead(this->m_cam, PHX_REGISTER_DEVICE, &address, (ui8 *)&tmp, (ui32 *)&r_in_bytes, 800)) + { + m_fl("Error reading Camera CXP register.", EERROR); + + return false; + } + + if (r_in_bytes != sizeof(r)) { + m_fl("Error reading Camera CXP register: size read does not match size requested.", EERROR); + + return false; + } + + r = be32toh(tmp);//convert received data to littel endian + + return true; + } + +} \ No newline at end of file diff --git a/EoSensCL/PHXWrapperCXP.h b/EoSensCL/PHXWrapperCXP.h new file mode 100644 index 0000000..5af7265 --- /dev/null +++ b/EoSensCL/PHXWrapperCXP.h @@ -0,0 +1,29 @@ +/* +The following code is taken from examples of ActiveSDK from vendor +*/ +#pragma once + +#include "PHXWrapper.h" +#include + +namespace PHX_ns +{ + using namespace std; + using namespace CamComm_ns; + + /** + * \brief PHXWrapperCXP + * camera with CoaXPress interface + * + */ + class PHXWrapperCXP : public PHXWrapper + { + public: + PHXWrapperCXP(CamComm_ns::log_handler fl); + ~PHXWrapperCXP() = default; + bool OpenCamera(uint16_t board, uint16_t channel, string config) override; + bool Write(uint32_t address, uint32_t v) override; + bool Read(uint32_t address, uint32_t& r) override; + + }; +} \ No newline at end of file diff --git a/FireBird.cpp b/FireBird.cpp index 07487cc..f386875 100644 --- a/FireBird.cpp +++ b/FireBird.cpp @@ -342,6 +342,7 @@ void FireBird::get_device_property() dev_prop.push_back(Tango::DbDatum("CameraMode")); dev_prop.push_back(Tango::DbDatum("FrameGrabberBuffer")); dev_prop.push_back(Tango::DbDatum("BufferLength")); + dev_prop.push_back(Tango::DbDatum("CameraInterface")); // is there at least one property to be read ? if (dev_prop.size()>0) @@ -466,6 +467,17 @@ void FireBird::get_device_property() // And try to extract BufferLength value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> bufferLength; + // Try to initialize CameraInterface from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> cameraInterface; + else { + // Try to initialize CameraInterface from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> cameraInterface; + } + // And try to extract CameraInterface value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> cameraInterface; + } /*----- PROTECTED REGION ID(FireBird::get_device_property_after) ENABLED START -----*/ @@ -1999,24 +2011,49 @@ bool FireBird::OpenCamera() { try { - m_cam - = sptr_cam(new EoSensCL_ns::EoSensCL( - boardNumber, channelNumber, configFile, cameraMode, - [=](string msg,CamComm_ns::LogLevel l) - { - switch(l) - { - case CamComm_ns::EDEBUG: - DEBUG_STREAM<<"EoSensCL:"< 10000 + + + + 0 + diff --git a/FireBirdClass.cpp b/FireBirdClass.cpp index 0cd1330..e0987fc 100644 --- a/FireBirdClass.cpp +++ b/FireBirdClass.cpp @@ -410,6 +410,20 @@ void FireBirdClass::set_default_property() } else add_wiz_dev_prop(prop_name, prop_desc); + prop_name = "CameraInterface"; + prop_desc = "camera interface:\n0: CL\n1: CXP"; + prop_def = "0"; + vect_data.clear(); + vect_data.push_back("0"); + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); } //-------------------------------------------------------- diff --git a/Makefile b/Makefile index b34749a..97973e4 100644 --- a/Makefile +++ b/Makefile @@ -120,18 +120,22 @@ SVC_INCL = $(PACKAGE_NAME).h $(PACKAGE_NAME)Class.h \ FireBirdData.h \ $(EoSensCL_PATH)/CameraCommon.h \ $(EoSensCL_PATH)/CameraCommands.h \ + $(EoSensCL_PATH)/CameraRegisterAddrMap.h \ $(EoSensCL_PATH)/EoSensCL.h \ - $(EoSensCL_PATH)/PHXWrapper.h - + $(EoSensCL_PATH)/EoSensCXP.h \ + $(EoSensCL_PATH)/PHXWrapper.h \ + $(EoSensCL_PATH)/PHXWrapperCXP.h SVC_OBJS = \ $(LIB_OBJS) \ $(OBJDIR)/ClassFactory.o \ $(OBJDIR)/main.o \ $(OBJDIR)/FireBirdData.o \ - $(OBJDIR)/$(EoSensCL_PATH)//EoSensCL.o \ - $(OBJDIR)/$(EoSensCL_PATH)//PHXWrapper.o \ - $(OBJDIR)/$(EoSensCL_PATH)//CameraCommon.o + $(OBJDIR)/$(EoSensCL_PATH)/EoSensCL.o \ + $(OBJDIR)/$(EoSensCL_PATH)/EoSensCXP.o \ + $(OBJDIR)/$(EoSensCL_PATH)/PHXWrapper.o \ + $(OBJDIR)/$(EoSensCL_PATH)/PHXWrapperCXP.o \ + $(OBJDIR)/$(EoSensCL_PATH)/CameraCommon.o LIB_OBJS = \ $(OBJDIR)/$(PACKAGE_NAME).o \ diff --git a/doc_html/FullDocument.html b/doc_html/FullDocument.html index 1f77c60..82a03df 100644 --- a/doc_html/FullDocument.html +++ b/doc_html/FullDocument.html @@ -206,6 +206,14 @@ int 10000
+ + CameraInterface + camera interface:
+ 0: CL
+ 1: CXP + short + 0
+


diff --git a/doc_html/Properties.html b/doc_html/Properties.html index 52a2833..c2cf7ae 100644 --- a/doc_html/Properties.html +++ b/doc_html/Properties.html @@ -88,6 +88,14 @@ int 10000
+ + CameraInterface + camera interface:
+ 0: CL
+ 1: CXP + short + 0
+ -- GitLab From f1cf0be625e7598da08a7a4bac98ee0900030802 Mon Sep 17 00:00:00 2001 From: Yuelong Yu Date: Fri, 18 Feb 2022 10:27:49 +0100 Subject: [PATCH 2/5] WIP code refactoring - added interface class - put CL CXP cameras into different namespaces - removed property CameraInterface --- EoSensCL/CameraCommands.h | 235 ------- EoSensCL/CameraRegisterAddrMap.h | 117 ---- EoSensCL/EoSensCL.cpp | 681 --------------------- EoSensCL/EoSensCL.h | 79 --- EoSensCL/EoSensCXP.cpp | 458 -------------- EoSensCL/EoSensCXP.h | 80 --- EoSensCams/CameraCommands.h | 238 +++++++ {EoSensCL => EoSensCams}/CameraCommon.cpp | 0 {EoSensCL => EoSensCams}/CameraCommon.h | 0 EoSensCams/CameraRegisterAddrMap.h | 120 ++++ EoSensCams/EoSensCL.cpp | 673 ++++++++++++++++++++ EoSensCams/EoSensCL.h | 83 +++ EoSensCams/EoSensCXP.cpp | 460 ++++++++++++++ EoSensCams/EoSensCXP.h | 82 +++ EoSensCams/EoSensCamInterface.cpp | 34 + EoSensCams/EoSensCamInterface.h | 68 ++ {EoSensCL => EoSensCams}/PHXWrapper.cpp | 0 {EoSensCL => EoSensCams}/PHXWrapper.h | 0 {EoSensCL => EoSensCams}/PHXWrapperCXP.cpp | 0 {EoSensCL => EoSensCams}/PHXWrapperCXP.h | 0 FireBird.cpp | 111 ++-- FireBird.h | 13 +- FireBird.xmi | 5 - FireBirdClass.cpp | 14 - FireBirdData.h | 2 +- Makefile | 28 +- doc_html/FullDocument.html | 8 - doc_html/Properties.html | 8 - 28 files changed, 1817 insertions(+), 1780 deletions(-) delete mode 100644 EoSensCL/CameraCommands.h delete mode 100644 EoSensCL/CameraRegisterAddrMap.h delete mode 100644 EoSensCL/EoSensCL.cpp delete mode 100644 EoSensCL/EoSensCL.h delete mode 100644 EoSensCL/EoSensCXP.cpp delete mode 100644 EoSensCL/EoSensCXP.h create mode 100644 EoSensCams/CameraCommands.h rename {EoSensCL => EoSensCams}/CameraCommon.cpp (100%) rename {EoSensCL => EoSensCams}/CameraCommon.h (100%) create mode 100644 EoSensCams/CameraRegisterAddrMap.h create mode 100644 EoSensCams/EoSensCL.cpp create mode 100644 EoSensCams/EoSensCL.h create mode 100644 EoSensCams/EoSensCXP.cpp create mode 100644 EoSensCams/EoSensCXP.h create mode 100644 EoSensCams/EoSensCamInterface.cpp create mode 100644 EoSensCams/EoSensCamInterface.h rename {EoSensCL => EoSensCams}/PHXWrapper.cpp (100%) rename {EoSensCL => EoSensCams}/PHXWrapper.h (100%) rename {EoSensCL => EoSensCams}/PHXWrapperCXP.cpp (100%) rename {EoSensCL => EoSensCams}/PHXWrapperCXP.h (100%) diff --git a/EoSensCL/CameraCommands.h b/EoSensCL/CameraCommands.h deleted file mode 100644 index ee65ba3..0000000 --- a/EoSensCL/CameraCommands.h +++ /dev/null @@ -1,235 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace EoSensCL_ns -{ - using namespace std; - - const char CMD_PREFIX = ':'; - const char CMD_GET_SUFFIX = '?'; - const char CMD_END = '\r'; //carriage return 0xd - - /** - * @brief acknowledge status - * get :A? - * set: :A = y/n - * - * In order to check your input, set the acknowledg - * flag with the command :A. If the acknowledge flag is set, each - * write command will either be acknowledged with ACK (0x06) if it was - * successful or with NAK (0x15), if it was not successful. NAK will also - * be returned, if the command or its parameters are incorrect - * @return - */ - const char CAMERA_ACK = 'A'; - - /** - * @brief baudrate setting - * get:b? - * set:b =0...4 - * - * select baudrate - * 0 = 9600 (default) - * 1 = 19200 - * 2 = 38400 - * 3 = 57600 - * 4 = 115200 - */ - const char CAMERA_BAUDRATE = 'b'; - - /** - * @brief last error max 45 chars - */ - const char CAMERA_ERROR = 'B'; - - /** - * @brief reset camera and load up power up profile - */ - const char CAMERA_RESET = 'c'; - - /** - * @brief set ROI start- and end position (data area) - * get :d? - * set ::d - * = x-start 0...4F8 hex - * = y-start 0...3FE hex - * = x-width 2...500 hex - * = y-height 1...400 hex - */ - const char CAMERA_ROI = 'd'; - - /** - * @brief set gain - * get :D? - * set :D - * = 0, 400...1000h - * digital gain - * 400 = gain 1x, - * 1000 = gain 4x, - * 0 = gain correction off - */ - const char CAMERA_GAIN = 'D'; - - /** - * @brief load factory profile - * get :f? - * set :f - * = 0...7 for FULL = 0...3 for BASE - */ - const char CAEMRA_LOAD_FACTORY_PROFILE = 'f'; - - /** - * @brief load user profile in bank bank 'c' = PowerUpProfile - * get :g? - * set :g - * = 0...7 for FULL = 0...3 for BASE - */ - const char CAEMRA_LOAD_USER_PROFILE = 'g'; - - /** - * @brief camera trigger - * get :h? - * set: h =0...2 - * 0 = free run - * 1 = PWC - * 2 = timer - * - */ - const char CAMERA_TRIGGER = 'h'; - - /** - * @brief trigger pulse - * get :H? - * set :H = 0,1 - * set shutter pulse polarity - * 0 = positive edge - * 1 = negative edge - */ - const char CAMERA_EXT_PULSE = 'H'; - - /** - * @brief dynamic range adjustment - * get :i? - * set :i / i - * details in document - */ - const char CAMERA_DYNAMIC_RANGE_ADJUSTMENT = 'i'; - - /** - * @brief line scan mode - * get :j? - * set j = 0, 1 - * linescan mode - * 1 = enable - * 0 = disable - */ - const char CAMERA_LINE_SCAN = 'j'; - - /** - * @brief set blacklevel - * get :k? - * set :k = 32...C8 hex - * set blacklevel - * value 80h is default - * increase or decrease value - * slightly to adjust blacklevel - */ - const char CAMERA_BLACK_LEVEL = 'k'; - - /** - * @brief camera link output mode - * The output modes can be changed: the CameraLink mode and the - * pixel clock value used with it. In addition, you can set the camera into - * a mode where it behaves like a line scan camera. - * In order to read the actual value replace the parameter by a question - * mark. - */ - const char CAMERA_CL_OUTPUT_MODE = 'M'; - - - /** - * @brief camera simulation mode - * In order to test camera logic and video data transmission, sensor - * data can be replaced by an internal gray scale pattern with pixel values - * from 0 to 255. With x = 0, the camera sends a gray scale that - * is slowly rolling from right to left. This mode can also be used to save - * power consumption because the image sensor will go in standby mode. - * get :n? - * set :n = 0...1 - * 0 = Power down + testimage - * 1 = normal operation - */ - const char CAMERA_SIMULATION = 'n'; - - /** - * @brief fpn correction - * The column FPN (fixed pattern noise) correction can be activated or - * deactivated. At the beginning of each frame, before visible lines are - * read out, a fixed voltage is applied to the columns. If FPN correction is - * enabled, this voltage value will be subtracted from each pixel. As a - * result the picture will be more homogeneous but has a reduced dynamic. - * FPN correction offers a column correction only. A pixel correction of - * the full frame has to be executed by the frame grabber or the imaging - * processing software. - */ - const char CAMERA_FPN_CORRECTION = 'N'; - - /** - * @brief frame rate - * get :q? ' ''-' - * set :q = 1...13880 hex - * set framerate - * get actual framerate, and - * possible framerate range - * for actual ROI - */ - const char CAMERA_FRAME_RATE = 'q'; - - /** - * @brief decimation mode - * get :Q? - * set :Q = 0...1 - * decimation (subsampling)mode on/off - */ - const char CAMERA_DECIMATION_MODE = 'Q'; - - /** - * @brief pixel clock - * get :R? - * set :R =28,2d,32,37,3c,41,46,4b,50 hex - * reduce pixel clock from - * 80 MHz to 40, 45, 55, 60, - * 65, 70 or 75 MHz - */ - const char CAMERA_PIXEL_CLOCK = 'R'; - - /** - * @brief shutter time - * get :t? - * set :t = 2...F4240 hex - * - * set shutter time in μs - */ - const char CAMERA_SHUTTER_TIME = 't'; - - /** - * @brief get temperature - */ - const char CAMERA_TEMPERATURE = 'T'; - - /** - * @brief set camera frame counter - * get :u? - * set :u = 0,1 - * Framecounter: - * 0 = off - * 1 = on - */ - const char CAMERA_FRAME_COUNTER = 'u'; - - const char CAMERA_SN_FW = 'v'; - const char CAMERA_ID = 'V'; -} \ No newline at end of file diff --git a/EoSensCL/CameraRegisterAddrMap.h b/EoSensCL/CameraRegisterAddrMap.h deleted file mode 100644 index 9ce0df8..0000000 --- a/EoSensCL/CameraRegisterAddrMap.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Address map are taken from XML file. - * - * The XML file is an ASCII file which is to be found on the USB storage device - * delivered with the camera. - * - * It is possible to read it from camera , but this is not done yet! - */ -#pragma once - -#include -#include -#include - -namespace EoSensCXP_ns -{ - using namespace std; - - const uint32_t AcquisitionModeReg = 0x8200; - const uint32_t AcquisitionStartReg = 0x8204; - const uint32_t AcquisitionStopReg = 0x8208; - const uint32_t AcquisitionBurstFrameCountReg = 0x8914; - const uint32_t TriggerSelectorReg = 0x8900; - const uint32_t TriggerModeReg = 0x8904; - const uint32_t TriggerSourceReg = 0x8908; - const uint32_t TriggerActivationReg = 0x890C; - const uint32_t TriggerCountReg = 0x891C; - const uint32_t TriggerDebouncerReg = 0x8918; - const uint32_t TriggerSoftwareReg = 0x8910; - const uint32_t ExposureModeReg = 0x8944; - const uint32_t ExposureTimeReg = 0x8840; - const uint32_t AcquisitionFrameRateReg = 0x8814; - const uint32_t AcquisitionFrameRateMaxReg = 0x881C; - const uint32_t UserSetSelectorReg = 0x00008820; - const uint32_t UserSetLoadReg = 0x00008824; - const uint32_t UserSetSaveReg = 0x00008828; - const uint32_t UserSetDefaultSelectorReg = 0x0000882C; - const uint32_t WidthAddressReg = 0x3000; - const uint32_t HeightAddressReg = 0x3004; - const uint32_t AcquisitionModeAddressReg = 0x3008; - const uint32_t AcquistionStartAddressReg = 0x300C; - const uint32_t AcquistionStopAddressReg = 0x3010; - const uint32_t PixelFormatAddressReg = 0x3014; - const uint32_t DeviceTapGeometryAddressReg = 0x3018; - const uint32_t Image1StreamIDAddressReg = 0x301C; - const uint32_t ControlPacketSizeMaxReg = 0x400c; - - const uint32_t DeviceConnectionIDReg = 0x4004; - const uint32_t Iidc2AddressReg = 0x1c; - const uint32_t ConnectionConfigReg = 0x4014; - const uint32_t ConnectionConfigDefaultReg = 0x4018; - const uint32_t ConnectionResetReg = 0x4000; - const uint32_t MasterHostConnectionIDReg = 0x4008; - const uint32_t RevisionReg = 0x4; - const uint32_t StandardReg = 0x0; - const uint32_t StreamPacketSizeMaxReg = 0x4010; - const uint32_t TestErrorCountSelectorReg = 0x4020; - const uint32_t TestErrorCountReg = 0x4024; - const uint32_t TestPacketCountTxReg = 0x4028; - const uint32_t TestPacketCountRxReg = 0x4030; - const uint32_t TestModeReg = 0x401c; - const uint32_t XmlManifestSelectorReg = 0xc; - const uint32_t XmlManifestSizeReg = 0x8; - const uint32_t XmlSchemeVersionReg = 0x14; - const uint32_t XmlUrlAddressReg = 0x18; - const uint32_t XmlVersionReg = 0x10; - const uint32_t DeviceSerialNumberReg = 0x20b0; - const uint32_t DeviceManufacturerInfoReg = 0x2040; - const uint32_t DeviceModelNameReg = 0x2020; - const uint32_t DeviceUserIDReg = 0x20c0; - const uint32_t DeviceVendorNameReg = 0x2000; - const uint32_t DeviceVersionReg = 0x2070; - - const uint32_t DeviceResetReg = 0x8300; - - const uint32_t HeightReg = 0x811c; - const uint32_t OffsetXReg = 0x8800; - const uint32_t Image1StreamIDReg = 0x8164; - const uint32_t PixelFormatReg = 0x8144; - const uint32_t TapGeometryReg = 0x8160; - const uint32_t SensorHeightReg = 0x880c; - const uint32_t SensorWidthReg = 0x8808; - const uint32_t RegionDestinationReg = 0x8188; - const uint32_t WidthReg = 0x8118; - const uint32_t OffsetYReg = 0x8804; - const uint32_t AnalogGainReg = 0x8850; - const uint32_t BlackLevelReg = 0x8854; - const uint32_t LineSelectorReg = 0x8A24; - const uint32_t LineSourceReg = 0x8A28; - const uint32_t LineInverterReg = 0x8A20; - const uint32_t UserOutputSelectorReg = 0x8A4C; - const uint32_t UserOutputValueReg = 0x8A50; - const uint32_t GammaReg = 0x8858; - const uint32_t DigitalGainReg = 0x886C; - const uint32_t TxLogicalConnectionResetReg = 0x9010; - const uint32_t DeviceInformationReg = 0x8A04; - const uint32_t DeviceInformationSelectorReg = 0x8A00; - const uint32_t AnalogRegisterSetSelectorReg = 0x20000; - const uint32_t AnalogRegisterSelectorReg = 0x20004; - const uint32_t AnalogValueReg = 0x20008; - const uint32_t InfoFieldFrameCounterEnableReg = 0x9310; - const uint32_t InfoFieldTimeStampEnableReg = 0x9314; - const uint32_t InfoFieldRoiEnableReg = 0x9318; - const uint32_t FixedPatternNoiseReductionReg = 0x8A10; - - - const uint32_t PixelTypeFReg = 0x51004; - const uint32_t DIN1ConnectorType = 0x8A30; - const uint32_t IsImplementedMultiROI = 0x50004; - const uint32_t CameraTypeHexReg = 0x00051000; - const uint32_t CameraStatusReg = 0x10002200; - const uint32_t IsStopped = 0x10002204; - const uint32_t FileCountReg = 0x08100028; - const uint32_t Has2ConnectionModi = 0x00050014; - const uint32_t ExposureTimeMinReg = 0x8848; - const uint32_t ExposureTimeMaxReg = 0x8818; -} \ No newline at end of file diff --git a/EoSensCL/EoSensCL.cpp b/EoSensCL/EoSensCL.cpp deleted file mode 100644 index 156d465..0000000 --- a/EoSensCL/EoSensCL.cpp +++ /dev/null @@ -1,681 +0,0 @@ -#include "EoSensCL.h" - -namespace EoSensCL_ns -{ - - EoSensCL::EoSensCL(uint16_t board_nr, uint16_t channel_nr,string config_file,uint16_t mode,CamComm_ns::log_handler fl) - :m_fl(fl), - m_xstart(0), - m_ystart(0), - m_x(0), - m_y(0), - m_mine(0), - m_maxe(9999), - m_minf(0), - m_maxf(9999), - m_hw_buf_len(20), - m_imgs_per_interrupt(1), - m_current_frame(0), - m_loss(0), - m_acquired(0), - m_available(0), - m_start(false), - m_frame_counter(false) - { - m_phx = uptr_phx(new PHX_ns::PHXWrapper(fl)); - if(!(m_phx->OpenCamera(board_nr,channel_nr,config_file))) - { - m_phx.reset(); - throw std::runtime_error("EoSensCL::cannot open camera"); - } - - if(!EnableACK()) - m_fl("EoSensCL:: command ack is not enabled", EERROR); - - - if(!UpdateImageSize()) - { - m_phx.reset(); - throw std::runtime_error("EoSensCL::cannot open camera, cannot update image size"); - } - - uint16_t m = 0; - if(!GetCameraMode(m)) - throw std::runtime_error("EoSensCL::cannot open camera, cannot get camera mode"); - - if(m != mode) - { - if(!SetCameraMode(mode)) - { - m_phx.reset(); - throw std::runtime_error("EoSensCL::cannot open camera, cannot set camera mode"); - } - } - } - - EoSensCL::~EoSensCL() - { - m_phx.reset(); - } - - bool EoSensCL::ResetCamera() - { - m_fl("EoSensCL::ResetCamera", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_RESET, CMD_END}; - return m_phx->RunCMD(cmd, reply); - } - - string EoSensCL::GetCameraErr() - { - m_fl("EoSensCL::GetCameraErr", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_ERROR, CMD_END}; - m_phx->RunCMD(cmd, reply); - return string(reply.begin(), reply.end()); - } - - string EoSensCL::GetCameraSN() - { - m_fl("EoSensCL::GetCameraSN", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_SN_FW, CMD_END}; - m_phx->RunCMD(cmd, reply); - return string(reply.begin(), reply.end()); - } - - string EoSensCL::GetCameraID() - { - m_fl("EoSensCL::GetCameraID", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_ID, CMD_END}; - m_phx->RunCMD(cmd, reply); - return string(reply.begin(), reply.end()); - } - - int16_t EoSensCL::GetTemerature() - { - m_fl("EoSensCL::GetTemerature", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_TEMPERATURE, CMD_END}; - m_phx->RunCMD(cmd, reply); - return stoi(string(reply.begin(), reply.end())); - } - - bool EoSensCL::SetBlackLevel(uint16_t b) - { - m_fl("EoSensCL::SetBlackLevel", EDEBUG); - if(b<50 || b>200) - { - m_fl("black level should be 50-200 instead of" + to_string(b), EERROR); - return false; - } - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_BLACK_LEVEL}; - auto str = Uint16ToHexStr(b); - for(auto &s : str) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - - bool EoSensCL::GetBlackLevel(uint16_t& b) - { - m_fl("EoSensCL::GetBlackLevel", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_BLACK_LEVEL, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - b = HexStrToUint16(string(reply.begin(), reply.end())); - return true; - } - return false; - } - - bool EoSensCL::SetTriggerMode(uint16_t t) - { - m_fl("EoSensCL::SetTriggerMode", EDEBUG); - return true; - } - - bool EoSensCL::GetTriggerMode(uint16_t& t) - { - m_fl("EoSensCL::GetTriggerMode", EDEBUG); - t=0; - return true; - } - - bool EoSensCL::SetGain(uint16_t g) - { - m_fl("EoSensCL::SetGain", EDEBUG); - string gain; - if(g==0) - gain = "0000"; - else if(g==1) - gain = "0400"; - else if(g==4) - gain = "1000"; - else - { - gain = "0000"; - m_fl("EoSensCL::SetGain, gain is not supported" + to_string(g) + "it should be one of 0,1,4", EERROR); - return false; - } - - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_GAIN}; - //auto str = Uint16ToHexStr(gain,4); - for(auto &s : gain) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - - bool EoSensCL::GetGain(uint16_t& g) - { - m_fl("EoSensCL::GetGain", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_GAIN, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - string gain = string(reply.begin(), reply.end()-1); - if(gain == string("0400")) - g = 1; - else if(gain == string("1000")) - g = 4; - else if(gain == string("0000")) - g = 0; - else - { - m_fl("EoSensCL::GetGain:get gain " + gain, EERROR); - return false; - } - return true; - } - return false; - } - - bool EoSensCL::SetFrameRate(uint32_t f) - { - m_fl("EoSensCL::SetFrameRate", EDEBUG); - if(f < m_minf || f > m_maxf) - { - m_fl("frame rate out of range, it should be between " + to_string(m_minf) + " and " + to_string(m_maxf), EERROR); - return false; - } - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_FRAME_RATE}; - auto str = Uint32ToHexStr(f,6); - for(auto &s : str) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - - bool EoSensCL::GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin) - { - m_fl("EoSensCL::GetFrameRate", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_FRAME_RATE, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - f = HexStrToUint32(string(reply.begin() , reply.begin() + 6)); - m_minf = HexStrToUint32(string(reply.begin() + 7, reply.begin() + 9)); - m_maxf = HexStrToUint32(string(reply.begin() + 10, reply.end())); - fmin = m_minf; - fmax = m_maxf; - m_fl("frame rate:" + to_string(f) + "max:" + to_string(m_maxf) + " min:"+ to_string(m_minf), EINFO); - return true; - } - return false; - } - - bool EoSensCL::SetExposureTime(uint32_t e) - { - m_fl("EoSensCL::SetExposureTime", EDEBUG); - if(e < m_mine || e > m_maxe) - { - m_fl("shutter time out of range, it should be between " + to_string(m_mine) + " and " + to_string(m_maxe), EERROR); - return false; - } - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_SHUTTER_TIME}; - auto str = Uint32ToHexStr(e,6); - for(auto &s : str) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - - return true; - } - - bool EoSensCL::GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin) - { - m_fl("EoSensCL::GetExposureTime", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_SHUTTER_TIME, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - e = HexStrToUint32(string(reply.begin() , reply.begin() + 6)); - m_mine = HexStrToUint32(string(reply.begin() + 7, reply.begin() + 9)); - m_maxe = HexStrToUint32(string(reply.begin() + 10, reply.end())); - emin = m_mine; - emax = m_maxe; - m_fl("exposure time:" + to_string(e) + "max:" + to_string(m_maxe) + " min:"+ to_string(m_mine), EINFO); - return true; - } - return false; - } - - bool EoSensCL::SetROI(vector r) - { - m_fl("EoSensCL::SetROI", EDEBUG); - - if(r.size() != 4) - { - m_fl("ROI size error, should be 4 \ - (xstart,ystart,xwidth,ywidth) \ - instead of" +to_string(r.size()), EERROR); - return false; - } - - // if(r[0]>1272 || r[1]>1022 || r[2]<2 - // || r[2]>1280 || r[3]< 2 || r[3]>1024 ) - // { - // m_fl("ROI out of range, should be in: \ - // xstart : 0-1272, \ - // ystart : 0-1022, \ - // xwidth : 2-1280, \ - // ywidth : 2-1024",EERROR); - // return false; - // } - - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_ROI}; - for (auto &v : r) - { - auto str = Uint16ToHexStr(v,3); - for(auto &s : str) - cmd.push_back(s); - } - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - - if(!UpdateImageSize()) - { - m_fl("cannot update image size", EERROR); - return false; - } - - return true; - } - - bool EoSensCL::GetROI(vector& r) - { - m_fl("EoSensCL::GetROI", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_ROI, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - for(int i=0; i<4; i++) - r.push_back( - HexStrToUint16( - string(reply.begin() + i*4 , reply.begin() + (i+1)*4))); - - return true; - } - return false; - } - - bool EoSensCL::SetPixelClock(uint16_t c) - { - m_fl("EoSensCL::SetPixelClock", EDEBUG); - - if(c!=40 && c!=45 && c!=55 && c!=60 && c!=65 && c!=70 && c!=75 && c!=80) - { - m_fl("not supported pixel clock" + to_string(c), EERROR); - return false; - } - - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_PIXEL_CLOCK}; - auto str = Uint16ToHexStr(c); - m_fl("c:"+to_string(c)+" - hex str:" + str, EDEBUG); - for(auto &s : str) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - bool EoSensCL::GetPixelClock(uint16_t& c) - { - m_fl("EoSensCL::GetPixelClock", EDEBUG); - - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_PIXEL_CLOCK, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - c = HexStrToUint16(string(reply.begin(), reply.end())); - - return true; - } - //sn = string(reply.begin(), reply.end()); - return false; - } - - bool EoSensCL::SetFrameCounter(bool f) - { - m_fl("EoSensCL::SetFrameCounter", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_FRAME_COUNTER}; - uint16_t val = f ? 1 : 0; - for(auto &s : to_string(val)) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - - bool EoSensCL::GetFrameCounter(bool& f) - { - m_fl("EoSensCL::GetFrameCounter", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_FRAME_COUNTER, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - auto v = stoi(string(reply.begin(), reply.end())); - f = (v==1?true:false); - return true; - } - return false; - } - - bool EoSensCL::SetRunMode(uint16_t m) - { - m_fl("EoSensCL::SetRunMode", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_SIMULATION}; - for(auto &s : to_string(m)) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - - bool EoSensCL::GetRunMode(uint16_t& m) - { - m_fl("EoSensCL::GetRunMode", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_SIMULATION, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - auto str = string(reply.begin(), reply.end()); - m = stoi(str); - return true; - } - return false; - } - - bool EoSensCL::SetCameraMode(uint16_t m) - { - m_fl("EoSensCL::SetCameraMode", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_CL_OUTPUT_MODE}; - for(auto &s : to_string(m)) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - - bool EoSensCL::GetCameraMode(uint16_t& m) - { - m_fl("EoSensCL::GetCameraMode", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_CL_OUTPUT_MODE, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - auto str = string(reply.begin(), reply.end()); - m = stoi(str); - return true; - } - return false; - } - - bool EoSensCL::SetFPNCorrection(bool f) - { - m_fl("EoSensCL::SetFPNCorrection", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_FPN_CORRECTION}; - uint16_t val = f ? 1 : 0; - for(auto &s : to_string(val)) - cmd.push_back(s); - cmd.push_back(CMD_END); - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - - bool EoSensCL::GetFPNCorrection(bool & f) - { - m_fl("EoSensCL::GetFPNCorrection", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_FPN_CORRECTION, CMD_GET_SUFFIX, CMD_END}; - if(m_phx->RunCMD(cmd, reply)) - { - auto v = stoi(string(reply.begin(), reply.end())); - f = (v==1?true:false); - return true; - } - return false; - } - - bool EoSensCL::StartAcq(int32_t requested_count, int32_t hw_buf_len, int32_t imgs_per_interrupt) - { - m_fl("EoSensCL::StartAcq", EDEBUG); - m_loss = 0; - m_acquired = 0; - m_available = 0; - m_imgs_per_interrupt = imgs_per_interrupt; - m_hw_buf_len = hw_buf_len; - - // update image size - if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) - m_img.resize(m_x*m_y*m_imgs_per_interrupt); - - // update frame grabber - if(!(m_phx->UpdateImageSize(m_xstart,m_ystart,m_x,m_y, m_hw_buf_len, m_imgs_per_interrupt))) - return false; - - m_start = true; - GetFrameCounter(m_frame_counter); - return m_phx->StartAcq(requested_count); - } - - bool EoSensCL::StopAcq() - { - m_fl("EoSensCL::StopAcq", EDEBUG); - - auto ret = m_phx->StopAcq(); - m_loss = 0; - m_acquired = 0; - m_available = 0; - m_start = true; - m_fl("EoSensCL::StopAcq, loss frames:" + to_string(m_loss), EINFO); - return ret; - } - - uint32_t EoSensCL::GetFrameLoss() - { - m_fl("EoSensCL::GetFrameLoss", EDEBUG); - return m_loss; - } - - bool EoSensCL::GetImageSize(uint32_t& x, uint32_t& y) - { - m_fl("EoSensCL::GetImageSize", EDEBUG); - vector r; - if(GetROI(r)) - { - x = r[2]; - y = r[3]; - return true; - } - return false; - } - - bool EoSensCL::GetImage(vector& img, uint32_t& f) - { - m_fl("EoSensCL::GetImage", EDEBUG); - // there is no available image - // check frame grabber queue, it there is image - if(m_available < m_imgs_per_interrupt) - { - auto current_count = (m_phx->GetImagesInQueue()); - if(current_count == 0) - return false; - m_fl("EoSensCL::buffer in count" + to_string(current_count), EDEBUG); - m_available = current_count - m_acquired; - } - - if(m_available < m_imgs_per_interrupt) - { - m_fl("EoSensCL::no new image", EDEBUG); - return false; - } - - if(m_phx->GetImage(m_img)) - { - img = m_img; - // string s = "EoSensCL::GetImage:first 4 bytes:"; - // for(uint32_t i=0; i<4; i++) - // s += (to_string(static_cast(img[i])) + " "); - // m_fl(s, EDEBUG); - if(m_frame_counter) - CheckFrameNumber(m_img); - m_acquired += m_imgs_per_interrupt; - m_available -= m_imgs_per_interrupt; - f = m_acquired; - return true; - } - else - return false; - } - - bool EoSensCL::EnableACK() - { - m_fl("EoSensCL::EnableACK", EDEBUG); - vector reply; - vector cmd = {CMD_PREFIX, CAMERA_ACK,'y'}; - if(!(m_phx->RunCMD(cmd, reply))) - return false; - if(!CheckReply(reply)) - return false; - return true; - } - - bool EoSensCL::CheckReply(vector& reply) - { - if(!reply.empty()) - { - if(reply[0] == 0x06) //ACK - return true; - } - return false; - } - - bool EoSensCL::UpdateImageSize() - { - vector r; - if(!GetROI(r)) - return false; - - m_fl("EoSensCL::UpdateImageSize", EDEBUG); - m_xstart = r[0]; - m_ystart = r[1]; - m_x = r[2]; - m_y = r[3]; - // update image size - if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) - m_img.resize(m_x*m_y*m_imgs_per_interrupt); - - // update frame grabber - if(!(m_phx->UpdateImageSize(m_xstart, m_ystart,m_x,m_y,m_hw_buf_len, m_imgs_per_interrupt))) - return false; - - - return true; - - } - - void EoSensCL::CheckFrameNumber(vector& d) - { - uint32_t frame_nr = static_cast((((uint8_t)d[3])<<24) - +(((uint8_t)d[2])<<16) - +(((uint8_t)d[1])<<8) - +((uint8_t)d[0])); - - if(frame_nr % 10000 == 0) - { - m_fl("EoSensCL::frame_nr:" + to_string(frame_nr) - + " - current:" + to_string(m_current_frame) - + " - imgs per interrupt" + to_string(m_imgs_per_interrupt) - + " - loss:"+ to_string(m_loss) - + " - avaiable in buffer:" + to_string(m_available), EINFO); - } - - if(m_start) - { - m_current_frame = frame_nr; - m_start = false; - } - else - { - if(frame_nr - m_current_frame != m_imgs_per_interrupt) - { - m_fl("EoSensCL::frame nr does not match, current:" - + to_string(frame_nr) - + " - previous:" - + to_string(m_current_frame), EDEBUG); - m_loss += (frame_nr - m_current_frame + 1); - m_current_frame = frame_nr; - } - else - { - m_current_frame += m_imgs_per_interrupt; - } - } - } -} \ No newline at end of file diff --git a/EoSensCL/EoSensCL.h b/EoSensCL/EoSensCL.h deleted file mode 100644 index 28268f2..0000000 --- a/EoSensCL/EoSensCL.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once -#include "CameraCommon.h" -#include "CameraCommands.h" -#include "PHXWrapper.h" - -namespace EoSensCL_ns -{ - using namespace CamComm_ns; - - typedef unique_ptr uptr_phx; - - class EoSensCL - { - public: - EoSensCL(uint16_t board_nr, uint16_t channel_nr, string config_file, uint16_t mode = 0, CamComm_ns::log_handler fl=CamComm_ns::default_log); - ~EoSensCL(); - - bool ResetCamera(); - string GetCameraErr(); - - string GetCameraSN(); - string GetCameraID(); - int16_t GetTemerature(); - - bool SetBlackLevel(uint16_t b); - bool GetBlackLevel(uint16_t& b); - - bool SetTriggerMode(uint16_t t); - bool GetTriggerMode(uint16_t& t); - - bool SetGain(uint16_t g); - bool GetGain(uint16_t& g); - - bool SetFrameRate(uint32_t f); - bool GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin); - - bool SetExposureTime(uint32_t e); - bool GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin); - - bool SetROI(vector r); - bool GetROI(vector& r); - - bool SetPixelClock(uint16_t c); - bool GetPixelClock(uint16_t& c); - - bool SetFrameCounter(bool f); - bool GetFrameCounter(bool& f); - - bool SetRunMode(uint16_t m); - bool GetRunMode(uint16_t& m); - - bool SetCameraMode(uint16_t m); - bool GetCameraMode(uint16_t& m); - - bool SetFPNCorrection(bool f); - bool GetFPNCorrection(bool & f); - - bool StartAcq(int32_t requested_count = -1, int32_t hw_buf_len = 20, int32_t imgs_per_interrupt = 1); - bool StopAcq(); - uint32_t GetFrameLoss(); - bool GetImageSize(uint32_t& x, uint32_t& y); - bool GetImage(vector& img, uint32_t& f); - - private: - bool EnableACK(); - bool CheckReply(vector& reply); - bool UpdateImageSize(); - void CheckFrameNumber(vector& d); - uptr_phx m_phx; - CamComm_ns::log_handler m_fl; - vector m_img; - uint32_t m_xstart, m_ystart, m_x,m_y, - m_mine, m_maxe,m_minf,m_maxf, - m_hw_buf_len,m_imgs_per_interrupt, - m_current_frame,m_loss, m_acquired, m_available; - bool m_start, m_frame_counter; - - }; -} \ No newline at end of file diff --git a/EoSensCL/EoSensCXP.cpp b/EoSensCL/EoSensCXP.cpp deleted file mode 100644 index 53e97d5..0000000 --- a/EoSensCL/EoSensCXP.cpp +++ /dev/null @@ -1,458 +0,0 @@ -#include "EoSensCXP.h" - -namespace EoSensCXP_ns -{ - - EoSensCXP::EoSensCXP(uint16_t board_nr, uint16_t channel_nr,string config_file,uint16_t mode,CamComm_ns::log_handler fl) - :m_fl(fl), - m_xstart(0), - m_ystart(0), - m_x(0), - m_y(0), - m_max_x(0), - m_max_y(0), - m_mine(0), - m_maxe(9999), - m_minf(0), - m_maxf(9999), - m_hw_buf_len(20), - m_imgs_per_interrupt(1), - m_current_frame(0), - m_loss(0), - m_acquired(0), - m_available(0), - m_start(false), - m_frame_counter(false) - { - m_phx = uptr_phx(new PHX_ns::PHXWrapperCXP(fl)); - if(!(m_phx->OpenCamera(board_nr,channel_nr,config_file))) - { - m_phx.reset(); - throw std::runtime_error("EoSensCXP::cannot open camera"); - } - - if(!GetSensorMaxSize()) - { - m_phx.reset(); - throw std::runtime_error("EoSensCXP::cannot get sensor max size"); - } - - if(!UpdateImageSize()) - { - m_phx.reset(); - throw std::runtime_error("EoSensCXP::cannot update image size"); - } - } - - EoSensCXP::~EoSensCXP() - { - m_phx.reset(); - } - - bool EoSensCXP::ResetCamera() - { - m_fl("EoSensCXP::ResetCamera", EDEBUG); - return ""; - } - - string EoSensCXP::GetCameraErr() - { - m_fl("EoSensCXP::GetCameraErr", EDEBUG); - return ""; - } - - string EoSensCXP::GetCameraSN() - { - m_fl("EoSensCXP::GetCameraSN", EDEBUG); - return ""; - } - - string EoSensCXP::GetCameraID() - { - m_fl("EoSensCXP::GetCameraID", EDEBUG); - return ""; - } - - int16_t EoSensCXP::GetTemerature() - { - m_fl("EoSensCXP::GetTemerature", EDEBUG); - return 0; - } - - bool EoSensCXP::SetBlackLevel(uint16_t b) - { - m_fl("EoSensCXP::SetBlackLevel", EDEBUG); - - return m_phx->Write(BlackLevelReg, static_cast(b)); - } - - bool EoSensCXP::GetBlackLevel(uint16_t& b) - { - m_fl("EoSensCXP::GetBlackLevel", EDEBUG); - uint32_t tmp; - if(!(m_phx->Read(BlackLevelReg, tmp))) - return false; - - b = static_cast(tmp); - return true; - } - - bool EoSensCXP::SetTriggerMode(uint16_t t) - { - m_fl("EoSensCXP::SetTriggerMode", EDEBUG); - return true; - } - - bool EoSensCXP::GetTriggerMode(uint16_t& t) - { - m_fl("EoSensCXP::GetTriggerMode", EDEBUG); - t=0; - return true; - } - - bool EoSensCXP::SetGain(uint16_t g) - { - m_fl("EoSensCXP::SetGain", EDEBUG); - - return m_phx->Write(AnalogGainReg, static_cast(g)); - } - - bool EoSensCXP::GetGain(uint16_t& g) - { - m_fl("EoSensCXP::GetGain", EDEBUG); - uint32_t tmp; - if(!(m_phx->Read(AnalogGainReg, tmp))) - return false; - - g = static_cast(tmp); - - return false; - } - - bool EoSensCXP::SetFrameRate(uint32_t f) - { - m_fl("EoSensCXP::SetFrameRate", EDEBUG); - if(f < m_minf || f > m_maxf) - { - m_fl("frame rate out of range, it should be between " + to_string(m_minf) + " and " + to_string(m_maxf), EERROR); - return false; - } - - return m_phx->Write(AcquisitionFrameRateReg, f); - } - - bool EoSensCXP::GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin) - { - m_fl("EoSensCXP::GetFrameRate", EDEBUG); - if(!(m_phx->Read(AcquisitionFrameRateReg, f))) - return false; - m_minf = 10; // according to document, minimum frame rate - if(!(m_phx->Read(AcquisitionFrameRateMaxReg, m_maxf))) - return false; - return true; - } - - bool EoSensCXP::SetExposureTime(uint32_t e) //unit μs - { - m_fl("EoSensCXP::SetExposureTime", EDEBUG); - if(e < m_mine || e > m_maxe) - { - m_fl("shutter time out of range, it should be between " + to_string(m_mine) + " and " + to_string(m_maxe), EERROR); - return false; - } - - return m_phx->Write(ExposureTimeReg, e); - } - - bool EoSensCXP::GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin) - { - m_fl("EoSensCXP::GetExposureTime", EDEBUG); - - if(!(m_phx->Read(ExposureTimeReg, e))) - return false; - if(!(m_phx->Read(ExposureTimeMinReg, m_mine))) - return false; - if(!(m_phx->Read(ExposureTimeMaxReg, m_maxe))) - return false; - return true; - } - - bool EoSensCXP::SetROI(vector r) - { - m_fl("EoSensCXP::SetROI", EDEBUG); - - if(r.size() != 4) - { - m_fl("ROI size error, should be 4 \ - (xstart,ystart,xwidth,ywidth) \ - instead of" +to_string(r.size()), EERROR); - return false; - } - - uint32_t offset_x = static_cast(r[0]); - uint32_t offset_y = static_cast(r[1]); - uint32_t x = static_cast(r[2]); - uint32_t y = static_cast(r[3]); - if(!(m_phx->Write(OffsetXReg, offset_x)) || - !(m_phx->Write(OffsetYReg, offset_y)) || - !(m_phx->Write(WidthReg, x)) || - !(m_phx->Write(HeightReg, y))) - return false; - return true; - } - - bool EoSensCXP::GetROI(vector& r) - { - m_fl("EoSensCXP::GetROI", EDEBUG); - - uint32_t offset_x, offset_y, x, y; - if(!(m_phx->Read(OffsetXReg, offset_x)) || - !(m_phx->Read(OffsetYReg, offset_y)) || - !(m_phx->Read(WidthReg, x)) || - !(m_phx->Read(HeightReg, y))) - return false; - - r[0] = static_cast(offset_x); - r[1] = static_cast(offset_y); - r[2] = static_cast(x); - r[3] = static_cast(y); - - return true; - } - - bool EoSensCXP::SetPixelClock(uint16_t c) - { - m_fl("EoSensCXP::SetPixelClock", EDEBUG); - return false; - } - bool EoSensCXP::GetPixelClock(uint16_t& c) - { - m_fl("EoSensCXP::GetPixelClock", EDEBUG); - return false; - } - - bool EoSensCXP::SetFrameCounter(bool f) - { - m_fl("EoSensCXP::SetFrameCounter", EDEBUG); - uint32_t val = f ? 1 : 0; - return m_phx->Write(InfoFieldFrameCounterEnableReg, val); - } - - bool EoSensCXP::GetFrameCounter(bool& f) - { - m_fl("EoSensCXP::GetFrameCounter", EDEBUG); - - uint32_t tmp; - if(!(m_phx->Read(InfoFieldFrameCounterEnableReg, tmp))) - return false; - f = (tmp == 1); - return true; - } - - bool EoSensCXP::SetRunMode(uint16_t m) - { - m_fl("EoSensCXP::SetRunMode", EDEBUG); - return false; - } - - bool EoSensCXP::GetRunMode(uint16_t& m) - { - m_fl("EoSensCXP::GetRunMode", EDEBUG); - return false; - } - - bool EoSensCXP::SetCameraMode(uint16_t m) - { - m_fl("EoSensCXP::SetCameraMode", EDEBUG); - return false; - } - - bool EoSensCXP::GetCameraMode(uint16_t& m) - { - m_fl("EoSensCXP::GetCameraMode", EDEBUG); - return false; - } - - bool EoSensCXP::SetFPNCorrection(bool f) - { - m_fl("EoSensCXP::SetFPNCorrection", EDEBUG); - - uint32_t val = f ? 1 : 0; - return m_phx->Write(FixedPatternNoiseReductionReg, val); - } - - bool EoSensCXP::GetFPNCorrection(bool & f) - { - m_fl("EoSensCXP::GetFPNCorrection", EDEBUG); - uint32_t tmp; - if(!(m_phx->Read(FixedPatternNoiseReductionReg, tmp))) - return false; - f = (tmp == 1); - return true; - } - - bool EoSensCXP::StartAcq(int32_t requested_count, int32_t hw_buf_len, int32_t imgs_per_interrupt) - { - m_fl("EoSensCXP::StartAcq", EDEBUG); - m_loss = 0; - m_acquired = 0; - m_available = 0; - m_imgs_per_interrupt = imgs_per_interrupt; - m_hw_buf_len = hw_buf_len; - - // update image size - if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) - m_img.resize(m_x*m_y*m_imgs_per_interrupt); - - // update frame grabber - if(!(m_phx->UpdateImageSize(m_xstart,m_ystart,m_x,m_y, m_hw_buf_len, m_imgs_per_interrupt))) - return false; - - m_start = true; - GetFrameCounter(m_frame_counter); - return m_phx->StartAcq(requested_count); - } - - bool EoSensCXP::StopAcq() - { - m_fl("EoSensCXP::StopAcq", EDEBUG); - - auto ret = m_phx->StopAcq(); - m_loss = 0; - m_acquired = 0; - m_available = 0; - m_start = true; - m_fl("EoSensCXP::StopAcq, loss frames:" + to_string(m_loss), EINFO); - return ret; - } - - uint32_t EoSensCXP::GetFrameLoss() - { - m_fl("EoSensCXP::GetFrameLoss", EDEBUG); - return m_loss; - } - - bool EoSensCXP::GetImageSize(uint32_t& x, uint32_t& y) - { - m_fl("EoSensCXP::GetImageSize", EDEBUG); - vector r; - if(GetROI(r)) - { - x = r[2]; - y = r[3]; - return true; - } - return false; - } - - bool EoSensCXP::GetImage(vector& img, uint32_t& f) - { - m_fl("EoSensCXP::GetImage", EDEBUG); - // there is no available image - // check frame grabber queue, it there is image - if(m_available < m_imgs_per_interrupt) - { - auto current_count = (m_phx->GetImagesInQueue()); - if(current_count == 0) - return false; - m_fl("EoSensCXP::buffer in count" + to_string(current_count), EDEBUG); - m_available = current_count - m_acquired; - } - - if(m_available < m_imgs_per_interrupt) - { - m_fl("EoSensCXP::no new image", EDEBUG); - return false; - } - - if(m_phx->GetImage(m_img)) - { - img = m_img; - // string s = "EoSensCXP::GetImage:first 4 bytes:"; - // for(uint32_t i=0; i<4; i++) - // s += (to_string(static_cast(img[i])) + " "); - // m_fl(s, EDEBUG); - if(m_frame_counter) - CheckFrameNumber(m_img); - m_acquired += m_imgs_per_interrupt; - m_available -= m_imgs_per_interrupt; - f = m_acquired; - return true; - } - else - return false; - } - - bool EoSensCXP::GetSensorMaxSize() - { - m_fl("EoSensCXP::GetSensorMaxSize", EDEBUG); - - if(!(m_phx->Read(SensorWidthReg, m_max_x)) || !(m_phx->Read(SensorHeightReg, m_max_y))) - return false; - - return true; - } - - bool EoSensCXP::UpdateImageSize() - { - vector r; - if(!GetROI(r)) - return false; - - m_fl("EoSensCXP::UpdateImageSize", EDEBUG); - m_xstart = r[0]; - m_ystart = r[1]; - m_x = r[2]; - m_y = r[3]; - // update image size - if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) - m_img.resize(m_x*m_y*m_imgs_per_interrupt); - - // update frame grabber - if(!(m_phx->UpdateImageSize(m_xstart, m_ystart,m_x,m_y,m_hw_buf_len, m_imgs_per_interrupt))) - return false; - - - return true; - - } - - void EoSensCXP::CheckFrameNumber(vector& d) - { - uint32_t frame_nr = static_cast((((uint8_t)d[3])<<24) - +(((uint8_t)d[2])<<16) - +(((uint8_t)d[1])<<8) - +((uint8_t)d[0])); - - if(frame_nr % 10000 == 0) - { - m_fl("EoSensCXP::frame_nr:" + to_string(frame_nr) - + " - current:" + to_string(m_current_frame) - + " - imgs per interrupt" + to_string(m_imgs_per_interrupt) - + " - loss:"+ to_string(m_loss) - + " - avaiable in buffer:" + to_string(m_available), EINFO); - } - - if(m_start) - { - m_current_frame = frame_nr; - m_start = false; - } - else - { - if(frame_nr - m_current_frame != m_imgs_per_interrupt) - { - m_fl("EoSensCXP::frame nr does not match, current:" - + to_string(frame_nr) - + " - previous:" - + to_string(m_current_frame), EDEBUG); - m_loss += (frame_nr - m_current_frame + 1); - m_current_frame = frame_nr; - } - else - { - m_current_frame += m_imgs_per_interrupt; - } - } - } -} \ No newline at end of file diff --git a/EoSensCL/EoSensCXP.h b/EoSensCL/EoSensCXP.h deleted file mode 100644 index edfcf5c..0000000 --- a/EoSensCL/EoSensCXP.h +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once -#include "CameraCommon.h" -#include "CameraRegisterAddrMap.h" -#include "PHXWrapper.h" -#include "PHXWrapperCXP.h" - -namespace EoSensCXP_ns -{ - using namespace CamComm_ns; - - typedef unique_ptr uptr_phx; - - class EoSensCXP - { - public: - EoSensCXP(uint16_t board_nr, uint16_t channel_nr, string config_file, uint16_t mode = 0, CamComm_ns::log_handler fl=CamComm_ns::default_log); - ~EoSensCXP(); - - bool ResetCamera(); - string GetCameraErr(); - - string GetCameraSN(); - string GetCameraID(); - int16_t GetTemerature(); - - bool SetBlackLevel(uint16_t b); - bool GetBlackLevel(uint16_t& b); - - bool SetTriggerMode(uint16_t t); - bool GetTriggerMode(uint16_t& t); - - bool SetGain(uint16_t g); - bool GetGain(uint16_t& g); - - bool SetFrameRate(uint32_t f); - bool GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin); - - bool SetExposureTime(uint32_t e); - bool GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin); - - bool SetROI(vector r); - bool GetROI(vector& r); - - bool SetPixelClock(uint16_t c); - bool GetPixelClock(uint16_t& c); - - bool SetFrameCounter(bool f); - bool GetFrameCounter(bool& f); - - bool SetRunMode(uint16_t m); - bool GetRunMode(uint16_t& m); - - bool SetCameraMode(uint16_t m); - bool GetCameraMode(uint16_t& m); - - bool SetFPNCorrection(bool f); - bool GetFPNCorrection(bool & f); - - bool StartAcq(int32_t requested_count = -1, int32_t hw_buf_len = 20, int32_t imgs_per_interrupt = 1); - bool StopAcq(); - uint32_t GetFrameLoss(); - bool GetImageSize(uint32_t& x, uint32_t& y); - bool GetImage(vector& img, uint32_t& f); - - private: - bool GetSensorMaxSize(); - bool CheckReply(vector& reply); - bool UpdateImageSize(); - void CheckFrameNumber(vector& d); - uptr_phx m_phx; - CamComm_ns::log_handler m_fl; - vector m_img; - uint32_t m_xstart, m_ystart, m_x,m_y,m_max_x, m_max_y, - m_mine, m_maxe,m_minf,m_maxf, - m_hw_buf_len,m_imgs_per_interrupt, - m_current_frame,m_loss, m_acquired, m_available; - bool m_start, m_frame_counter; - - }; -} \ No newline at end of file diff --git a/EoSensCams/CameraCommands.h b/EoSensCams/CameraCommands.h new file mode 100644 index 0000000..c5109a9 --- /dev/null +++ b/EoSensCams/CameraCommands.h @@ -0,0 +1,238 @@ +#pragma once + +#include +#include +#include + +namespace EoSensCam_ns +{ + namespace EoSensCL_ns + { + using namespace std; + + const char CMD_PREFIX = ':'; + const char CMD_GET_SUFFIX = '?'; + const char CMD_END = '\r'; //carriage return 0xd + + /** + * @brief acknowledge status + * get :A? + * set: :A = y/n + * + * In order to check your input, set the acknowledg + * flag with the command :A. If the acknowledge flag is set, each + * write command will either be acknowledged with ACK (0x06) if it was + * successful or with NAK (0x15), if it was not successful. NAK will also + * be returned, if the command or its parameters are incorrect + * @return + */ + const char CAMERA_ACK = 'A'; + + /** + * @brief baudrate setting + * get:b? + * set:b =0...4 + * + * select baudrate + * 0 = 9600 (default) + * 1 = 19200 + * 2 = 38400 + * 3 = 57600 + * 4 = 115200 + */ + const char CAMERA_BAUDRATE = 'b'; + + /** + * @brief last error max 45 chars + */ + const char CAMERA_ERROR = 'B'; + + /** + * @brief reset camera and load up power up profile + */ + const char CAMERA_RESET = 'c'; + + /** + * @brief set ROI start- and end position (data area) + * get :d? + * set ::d + * = x-start 0...4F8 hex + * = y-start 0...3FE hex + * = x-width 2...500 hex + * = y-height 1...400 hex + */ + const char CAMERA_ROI = 'd'; + + /** + * @brief set gain + * get :D? + * set :D + * = 0, 400...1000h + * digital gain + * 400 = gain 1x, + * 1000 = gain 4x, + * 0 = gain correction off + */ + const char CAMERA_GAIN = 'D'; + + /** + * @brief load factory profile + * get :f? + * set :f + * = 0...7 for FULL = 0...3 for BASE + */ + const char CAEMRA_LOAD_FACTORY_PROFILE = 'f'; + + /** + * @brief load user profile in bank bank 'c' = PowerUpProfile + * get :g? + * set :g + * = 0...7 for FULL = 0...3 for BASE + */ + const char CAEMRA_LOAD_USER_PROFILE = 'g'; + + /** + * @brief camera trigger + * get :h? + * set: h =0...2 + * 0 = free run + * 1 = PWC + * 2 = timer + * + */ + const char CAMERA_TRIGGER = 'h'; + + /** + * @brief trigger pulse + * get :H? + * set :H = 0,1 + * set shutter pulse polarity + * 0 = positive edge + * 1 = negative edge + */ + const char CAMERA_EXT_PULSE = 'H'; + + /** + * @brief dynamic range adjustment + * get :i? + * set :i / i + * details in document + */ + const char CAMERA_DYNAMIC_RANGE_ADJUSTMENT = 'i'; + + /** + * @brief line scan mode + * get :j? + * set j = 0, 1 + * linescan mode + * 1 = enable + * 0 = disable + */ + const char CAMERA_LINE_SCAN = 'j'; + + /** + * @brief set blacklevel + * get :k? + * set :k = 32...C8 hex + * set blacklevel + * value 80h is default + * increase or decrease value + * slightly to adjust blacklevel + */ + const char CAMERA_BLACK_LEVEL = 'k'; + + /** + * @brief camera link output mode + * The output modes can be changed: the CameraLink mode and the + * pixel clock value used with it. In addition, you can set the camera into + * a mode where it behaves like a line scan camera. + * In order to read the actual value replace the parameter by a question + * mark. + */ + const char CAMERA_CL_OUTPUT_MODE = 'M'; + + + /** + * @brief camera simulation mode + * In order to test camera logic and video data transmission, sensor + * data can be replaced by an internal gray scale pattern with pixel values + * from 0 to 255. With x = 0, the camera sends a gray scale that + * is slowly rolling from right to left. This mode can also be used to save + * power consumption because the image sensor will go in standby mode. + * get :n? + * set :n = 0...1 + * 0 = Power down + testimage + * 1 = normal operation + */ + const char CAMERA_SIMULATION = 'n'; + + /** + * @brief fpn correction + * The column FPN (fixed pattern noise) correction can be activated or + * deactivated. At the beginning of each frame, before visible lines are + * read out, a fixed voltage is applied to the columns. If FPN correction is + * enabled, this voltage value will be subtracted from each pixel. As a + * result the picture will be more homogeneous but has a reduced dynamic. + * FPN correction offers a column correction only. A pixel correction of + * the full frame has to be executed by the frame grabber or the imaging + * processing software. + */ + const char CAMERA_FPN_CORRECTION = 'N'; + + /** + * @brief frame rate + * get :q? ' ''-' + * set :q = 1...13880 hex + * set framerate + * get actual framerate, and + * possible framerate range + * for actual ROI + */ + const char CAMERA_FRAME_RATE = 'q'; + + /** + * @brief decimation mode + * get :Q? + * set :Q = 0...1 + * decimation (subsampling)mode on/off + */ + const char CAMERA_DECIMATION_MODE = 'Q'; + + /** + * @brief pixel clock + * get :R? + * set :R =28,2d,32,37,3c,41,46,4b,50 hex + * reduce pixel clock from + * 80 MHz to 40, 45, 55, 60, + * 65, 70 or 75 MHz + */ + const char CAMERA_PIXEL_CLOCK = 'R'; + + /** + * @brief shutter time + * get :t? + * set :t = 2...F4240 hex + * + * set shutter time in μs + */ + const char CAMERA_SHUTTER_TIME = 't'; + + /** + * @brief get temperature + */ + const char CAMERA_TEMPERATURE = 'T'; + + /** + * @brief set camera frame counter + * get :u? + * set :u = 0,1 + * Framecounter: + * 0 = off + * 1 = on + */ + const char CAMERA_FRAME_COUNTER = 'u'; + + const char CAMERA_SN_FW = 'v'; + const char CAMERA_ID = 'V'; + } +} \ No newline at end of file diff --git a/EoSensCL/CameraCommon.cpp b/EoSensCams/CameraCommon.cpp similarity index 100% rename from EoSensCL/CameraCommon.cpp rename to EoSensCams/CameraCommon.cpp diff --git a/EoSensCL/CameraCommon.h b/EoSensCams/CameraCommon.h similarity index 100% rename from EoSensCL/CameraCommon.h rename to EoSensCams/CameraCommon.h diff --git a/EoSensCams/CameraRegisterAddrMap.h b/EoSensCams/CameraRegisterAddrMap.h new file mode 100644 index 0000000..cd3790f --- /dev/null +++ b/EoSensCams/CameraRegisterAddrMap.h @@ -0,0 +1,120 @@ +/** + * Address map are taken from XML file. + * + * The XML file is an ASCII file which is to be found on the USB storage device + * delivered with the camera. + * + * It is possible to read it from camera , but this is not done yet! + */ +#pragma once + +#include +#include +#include + +namespace EoSensCam_ns +{ + namespace EoSensCXP_ns + { + using namespace std; + + const uint32_t AcquisitionModeReg = 0x8200; + const uint32_t AcquisitionStartReg = 0x8204; + const uint32_t AcquisitionStopReg = 0x8208; + const uint32_t AcquisitionBurstFrameCountReg = 0x8914; + const uint32_t TriggerSelectorReg = 0x8900; + const uint32_t TriggerModeReg = 0x8904; + const uint32_t TriggerSourceReg = 0x8908; + const uint32_t TriggerActivationReg = 0x890C; + const uint32_t TriggerCountReg = 0x891C; + const uint32_t TriggerDebouncerReg = 0x8918; + const uint32_t TriggerSoftwareReg = 0x8910; + const uint32_t ExposureModeReg = 0x8944; + const uint32_t ExposureTimeReg = 0x8840; + const uint32_t AcquisitionFrameRateReg = 0x8814; + const uint32_t AcquisitionFrameRateMaxReg = 0x881C; + const uint32_t UserSetSelectorReg = 0x00008820; + const uint32_t UserSetLoadReg = 0x00008824; + const uint32_t UserSetSaveReg = 0x00008828; + const uint32_t UserSetDefaultSelectorReg = 0x0000882C; + const uint32_t WidthAddressReg = 0x3000; + const uint32_t HeightAddressReg = 0x3004; + const uint32_t AcquisitionModeAddressReg = 0x3008; + const uint32_t AcquistionStartAddressReg = 0x300C; + const uint32_t AcquistionStopAddressReg = 0x3010; + const uint32_t PixelFormatAddressReg = 0x3014; + const uint32_t DeviceTapGeometryAddressReg = 0x3018; + const uint32_t Image1StreamIDAddressReg = 0x301C; + const uint32_t ControlPacketSizeMaxReg = 0x400c; + + const uint32_t DeviceConnectionIDReg = 0x4004; + const uint32_t Iidc2AddressReg = 0x1c; + const uint32_t ConnectionConfigReg = 0x4014; + const uint32_t ConnectionConfigDefaultReg = 0x4018; + const uint32_t ConnectionResetReg = 0x4000; + const uint32_t MasterHostConnectionIDReg = 0x4008; + const uint32_t RevisionReg = 0x4; + const uint32_t StandardReg = 0x0; + const uint32_t StreamPacketSizeMaxReg = 0x4010; + const uint32_t TestErrorCountSelectorReg = 0x4020; + const uint32_t TestErrorCountReg = 0x4024; + const uint32_t TestPacketCountTxReg = 0x4028; + const uint32_t TestPacketCountRxReg = 0x4030; + const uint32_t TestModeReg = 0x401c; + const uint32_t XmlManifestSelectorReg = 0xc; + const uint32_t XmlManifestSizeReg = 0x8; + const uint32_t XmlSchemeVersionReg = 0x14; + const uint32_t XmlUrlAddressReg = 0x18; + const uint32_t XmlVersionReg = 0x10; + const uint32_t DeviceSerialNumberReg = 0x20b0; + const uint32_t DeviceManufacturerInfoReg = 0x2040; + const uint32_t DeviceModelNameReg = 0x2020; + const uint32_t DeviceUserIDReg = 0x20c0; + const uint32_t DeviceVendorNameReg = 0x2000; + const uint32_t DeviceVersionReg = 0x2070; + + const uint32_t DeviceResetReg = 0x8300; + + const uint32_t HeightReg = 0x811c; + const uint32_t OffsetXReg = 0x8800; + const uint32_t Image1StreamIDReg = 0x8164; + const uint32_t PixelFormatReg = 0x8144; + const uint32_t TapGeometryReg = 0x8160; + const uint32_t SensorHeightReg = 0x880c; + const uint32_t SensorWidthReg = 0x8808; + const uint32_t RegionDestinationReg = 0x8188; + const uint32_t WidthReg = 0x8118; + const uint32_t OffsetYReg = 0x8804; + const uint32_t AnalogGainReg = 0x8850; + const uint32_t BlackLevelReg = 0x8854; + const uint32_t LineSelectorReg = 0x8A24; + const uint32_t LineSourceReg = 0x8A28; + const uint32_t LineInverterReg = 0x8A20; + const uint32_t UserOutputSelectorReg = 0x8A4C; + const uint32_t UserOutputValueReg = 0x8A50; + const uint32_t GammaReg = 0x8858; + const uint32_t DigitalGainReg = 0x886C; + const uint32_t TxLogicalConnectionResetReg = 0x9010; + const uint32_t DeviceInformationReg = 0x8A04; + const uint32_t DeviceInformationSelectorReg = 0x8A00; + const uint32_t AnalogRegisterSetSelectorReg = 0x20000; + const uint32_t AnalogRegisterSelectorReg = 0x20004; + const uint32_t AnalogValueReg = 0x20008; + const uint32_t InfoFieldFrameCounterEnableReg = 0x9310; + const uint32_t InfoFieldTimeStampEnableReg = 0x9314; + const uint32_t InfoFieldRoiEnableReg = 0x9318; + const uint32_t FixedPatternNoiseReductionReg = 0x8A10; + + + const uint32_t PixelTypeFReg = 0x51004; + const uint32_t DIN1ConnectorType = 0x8A30; + const uint32_t IsImplementedMultiROI = 0x50004; + const uint32_t CameraTypeHexReg = 0x00051000; + const uint32_t CameraStatusReg = 0x10002200; + const uint32_t IsStopped = 0x10002204; + const uint32_t FileCountReg = 0x08100028; + const uint32_t Has2ConnectionModi = 0x00050014; + const uint32_t ExposureTimeMinReg = 0x8848; + const uint32_t ExposureTimeMaxReg = 0x8818; + } +} \ No newline at end of file diff --git a/EoSensCams/EoSensCL.cpp b/EoSensCams/EoSensCL.cpp new file mode 100644 index 0000000..8238645 --- /dev/null +++ b/EoSensCams/EoSensCL.cpp @@ -0,0 +1,673 @@ +#include "EoSensCL.h" + +namespace EoSensCam_ns +{ + namespace EoSensCL_ns + { + + EoSensCL::EoSensCL(uint16_t board_nr, uint16_t channel_nr,string config_file,uint16_t mode,CamComm_ns::log_handler fl) + :m_fl(fl), + m_xstart(0), + m_ystart(0), + m_x(0), + m_y(0), + m_mine(0), + m_maxe(9999), + m_minf(0), + m_maxf(9999), + m_hw_buf_len(20), + m_imgs_per_interrupt(1), + m_current_frame(0), + m_loss(0), + m_acquired(0), + m_available(0), + m_start(false), + m_frame_counter(false) + { + m_phx = uptr_phx(new PHX_ns::PHXWrapper(fl)); + if(!(m_phx->OpenCamera(board_nr,channel_nr,config_file))) + { + m_phx.reset(); + throw std::runtime_error("EoSensCL::cannot open camera"); + } + + if(!EnableACK()) + m_fl("EoSensCL:: command ack is not enabled", EERROR); + + + if(!UpdateImageSize()) + { + m_phx.reset(); + throw std::runtime_error("EoSensCL::cannot open camera, cannot update image size"); + } + + uint16_t m = 0; + if(!GetCameraMode(m)) + throw std::runtime_error("EoSensCL::cannot open camera, cannot get camera mode"); + + if(m != mode) + { + if(!SetCameraMode(mode)) + { + m_phx.reset(); + throw std::runtime_error("EoSensCL::cannot open camera, cannot set camera mode"); + } + } + } + + EoSensCL::~EoSensCL() + { + m_phx.reset(); + } + + bool EoSensCL::ResetCamera() + { + m_fl("EoSensCL::ResetCamera", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_RESET, CMD_END}; + return m_phx->RunCMD(cmd, reply); + } + + string EoSensCL::GetCameraErr() + { + m_fl("EoSensCL::GetCameraErr", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_ERROR, CMD_END}; + m_phx->RunCMD(cmd, reply); + return string(reply.begin(), reply.end()); + } + + string EoSensCL::GetCameraSN() + { + m_fl("EoSensCL::GetCameraSN", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_SN_FW, CMD_END}; + m_phx->RunCMD(cmd, reply); + return string(reply.begin(), reply.end()); + } + + string EoSensCL::GetCameraID() + { + m_fl("EoSensCL::GetCameraID", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_ID, CMD_END}; + m_phx->RunCMD(cmd, reply); + return string(reply.begin(), reply.end()); + } + + int16_t EoSensCL::GetTemerature() + { + m_fl("EoSensCL::GetTemerature", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_TEMPERATURE, CMD_END}; + m_phx->RunCMD(cmd, reply); + return stoi(string(reply.begin(), reply.end())); + } + + bool EoSensCL::SetBlackLevel(uint16_t b) + { + m_fl("EoSensCL::SetBlackLevel", EDEBUG); + if(b<50 || b>200) + { + m_fl("black level should be 50-200 instead of" + to_string(b), EERROR); + return false; + } + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_BLACK_LEVEL}; + auto str = Uint16ToHexStr(b); + for(auto &s : str) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + + bool EoSensCL::GetBlackLevel(uint16_t& b) + { + m_fl("EoSensCL::GetBlackLevel", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_BLACK_LEVEL, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + b = HexStrToUint16(string(reply.begin(), reply.end())); + return true; + } + return false; + } + + bool EoSensCL::SetTriggerMode(uint16_t t) + { + m_fl("EoSensCL::SetTriggerMode", EDEBUG); + return true; + } + + bool EoSensCL::GetTriggerMode(uint16_t& t) + { + m_fl("EoSensCL::GetTriggerMode", EDEBUG); + t=0; + return true; + } + + bool EoSensCL::SetGain(uint16_t g) + { + m_fl("EoSensCL::SetGain", EDEBUG); + string gain; + if(g==0) + gain = "0000"; + else if(g==1) + gain = "0400"; + else if(g==4) + gain = "1000"; + else + { + gain = "0000"; + m_fl("EoSensCL::SetGain, gain is not supported" + to_string(g) + "it should be one of 0,1,4", EERROR); + return false; + } + + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_GAIN}; + //auto str = Uint16ToHexStr(gain,4); + for(auto &s : gain) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + + bool EoSensCL::GetGain(uint16_t& g) + { + m_fl("EoSensCL::GetGain", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_GAIN, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + string gain = string(reply.begin(), reply.end()-1); + if(gain == string("0400")) + g = 1; + else if(gain == string("1000")) + g = 4; + else if(gain == string("0000")) + g = 0; + else + { + m_fl("EoSensCL::GetGain:get gain " + gain, EERROR); + return false; + } + return true; + } + return false; + } + + bool EoSensCL::SetFrameRate(uint32_t f) + { + m_fl("EoSensCL::SetFrameRate", EDEBUG); + if(f < m_minf || f > m_maxf) + { + m_fl("frame rate out of range, it should be between " + to_string(m_minf) + " and " + to_string(m_maxf), EERROR); + return false; + } + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_FRAME_RATE}; + auto str = Uint32ToHexStr(f,6); + for(auto &s : str) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + + bool EoSensCL::GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin) + { + m_fl("EoSensCL::GetFrameRate", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_FRAME_RATE, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + f = HexStrToUint32(string(reply.begin() , reply.begin() + 6)); + m_minf = HexStrToUint32(string(reply.begin() + 7, reply.begin() + 9)); + m_maxf = HexStrToUint32(string(reply.begin() + 10, reply.end())); + fmin = m_minf; + fmax = m_maxf; + m_fl("frame rate:" + to_string(f) + "max:" + to_string(m_maxf) + " min:"+ to_string(m_minf), EINFO); + return true; + } + return false; + } + + bool EoSensCL::SetExposureTime(uint32_t e) + { + m_fl("EoSensCL::SetExposureTime", EDEBUG); + if(e < m_mine || e > m_maxe) + { + m_fl("shutter time out of range, it should be between " + to_string(m_mine) + " and " + to_string(m_maxe), EERROR); + return false; + } + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_SHUTTER_TIME}; + auto str = Uint32ToHexStr(e,6); + for(auto &s : str) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + + return true; + } + + bool EoSensCL::GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin) + { + m_fl("EoSensCL::GetExposureTime", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_SHUTTER_TIME, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + e = HexStrToUint32(string(reply.begin() , reply.begin() + 6)); + m_mine = HexStrToUint32(string(reply.begin() + 7, reply.begin() + 9)); + m_maxe = HexStrToUint32(string(reply.begin() + 10, reply.end())); + emin = m_mine; + emax = m_maxe; + m_fl("exposure time:" + to_string(e) + "max:" + to_string(m_maxe) + " min:"+ to_string(m_mine), EINFO); + return true; + } + return false; + } + + bool EoSensCL::SetROI(vector r) + { + m_fl("EoSensCL::SetROI", EDEBUG); + + if(r.size() != 4) + { + m_fl("ROI size error, should be 4 \ + (xstart,ystart,xwidth,ywidth) \ + instead of" +to_string(r.size()), EERROR); + return false; + } + + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_ROI}; + for (auto &v : r) + { + auto str = Uint16ToHexStr(v,3); + for(auto &s : str) + cmd.push_back(s); + } + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + + if(!UpdateImageSize()) + { + m_fl("cannot update image size", EERROR); + return false; + } + + return true; + } + + bool EoSensCL::GetROI(vector& r) + { + m_fl("EoSensCL::GetROI", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_ROI, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + for(int i=0; i<4; i++) + r.push_back( + HexStrToUint16( + string(reply.begin() + i*4 , reply.begin() + (i+1)*4))); + + return true; + } + return false; + } + + bool EoSensCL::SetPixelClock(uint16_t c) + { + m_fl("EoSensCL::SetPixelClock", EDEBUG); + + if(c!=40 && c!=45 && c!=55 && c!=60 && c!=65 && c!=70 && c!=75 && c!=80) + { + m_fl("not supported pixel clock" + to_string(c), EERROR); + return false; + } + + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_PIXEL_CLOCK}; + auto str = Uint16ToHexStr(c); + m_fl("c:"+to_string(c)+" - hex str:" + str, EDEBUG); + for(auto &s : str) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + bool EoSensCL::GetPixelClock(uint16_t& c) + { + m_fl("EoSensCL::GetPixelClock", EDEBUG); + + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_PIXEL_CLOCK, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + c = HexStrToUint16(string(reply.begin(), reply.end())); + + return true; + } + //sn = string(reply.begin(), reply.end()); + return false; + } + + bool EoSensCL::SetFrameCounter(bool f) + { + m_fl("EoSensCL::SetFrameCounter", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_FRAME_COUNTER}; + uint16_t val = f ? 1 : 0; + for(auto &s : to_string(val)) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + + bool EoSensCL::GetFrameCounter(bool& f) + { + m_fl("EoSensCL::GetFrameCounter", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_FRAME_COUNTER, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + auto v = stoi(string(reply.begin(), reply.end())); + f = (v==1?true:false); + return true; + } + return false; + } + + bool EoSensCL::SetRunMode(uint16_t m) + { + m_fl("EoSensCL::SetRunMode", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_SIMULATION}; + for(auto &s : to_string(m)) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + + bool EoSensCL::GetRunMode(uint16_t& m) + { + m_fl("EoSensCL::GetRunMode", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_SIMULATION, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + auto str = string(reply.begin(), reply.end()); + m = stoi(str); + return true; + } + return false; + } + + bool EoSensCL::SetCameraMode(uint16_t m) + { + m_fl("EoSensCL::SetCameraMode", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_CL_OUTPUT_MODE}; + for(auto &s : to_string(m)) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + + bool EoSensCL::GetCameraMode(uint16_t& m) + { + m_fl("EoSensCL::GetCameraMode", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_CL_OUTPUT_MODE, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + auto str = string(reply.begin(), reply.end()); + m = stoi(str); + return true; + } + return false; + } + + bool EoSensCL::SetFPNCorrection(bool f) + { + m_fl("EoSensCL::SetFPNCorrection", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_FPN_CORRECTION}; + uint16_t val = f ? 1 : 0; + for(auto &s : to_string(val)) + cmd.push_back(s); + cmd.push_back(CMD_END); + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + + bool EoSensCL::GetFPNCorrection(bool & f) + { + m_fl("EoSensCL::GetFPNCorrection", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_FPN_CORRECTION, CMD_GET_SUFFIX, CMD_END}; + if(m_phx->RunCMD(cmd, reply)) + { + auto v = stoi(string(reply.begin(), reply.end())); + f = (v==1?true:false); + return true; + } + return false; + } + + bool EoSensCL::StartAcq(int32_t requested_count, int32_t hw_buf_len, int32_t imgs_per_interrupt) + { + m_fl("EoSensCL::StartAcq", EDEBUG); + m_loss = 0; + m_acquired = 0; + m_available = 0; + m_imgs_per_interrupt = imgs_per_interrupt; + m_hw_buf_len = hw_buf_len; + + // update image size + if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) + m_img.resize(m_x*m_y*m_imgs_per_interrupt); + + // update frame grabber + if(!(m_phx->UpdateImageSize(m_xstart,m_ystart,m_x,m_y, m_hw_buf_len, m_imgs_per_interrupt))) + return false; + + m_start = true; + GetFrameCounter(m_frame_counter); + return m_phx->StartAcq(requested_count); + } + + bool EoSensCL::StopAcq() + { + m_fl("EoSensCL::StopAcq", EDEBUG); + + auto ret = m_phx->StopAcq(); + m_loss = 0; + m_acquired = 0; + m_available = 0; + m_start = true; + m_fl("EoSensCL::StopAcq, loss frames:" + to_string(m_loss), EINFO); + return ret; + } + + uint32_t EoSensCL::GetFrameLoss() + { + m_fl("EoSensCL::GetFrameLoss", EDEBUG); + return m_loss; + } + + bool EoSensCL::GetImageSize(uint32_t& x, uint32_t& y) + { + m_fl("EoSensCL::GetImageSize", EDEBUG); + vector r; + if(GetROI(r)) + { + x = r[2]; + y = r[3]; + return true; + } + return false; + } + + bool EoSensCL::GetImage(vector& img, uint32_t& f) + { + m_fl("EoSensCL::GetImage", EDEBUG); + // there is no available image + // check frame grabber queue, it there is image + if(m_available < m_imgs_per_interrupt) + { + auto current_count = (m_phx->GetImagesInQueue()); + if(current_count == 0) + return false; + m_fl("EoSensCL::buffer in count" + to_string(current_count), EDEBUG); + m_available = current_count - m_acquired; + } + + if(m_available < m_imgs_per_interrupt) + { + m_fl("EoSensCL::no new image", EDEBUG); + return false; + } + + if(m_phx->GetImage(m_img)) + { + img = m_img; + // string s = "EoSensCL::GetImage:first 4 bytes:"; + // for(uint32_t i=0; i<4; i++) + // s += (to_string(static_cast(img[i])) + " "); + // m_fl(s, EDEBUG); + if(m_frame_counter) + CheckFrameNumber(m_img); + m_acquired += m_imgs_per_interrupt; + m_available -= m_imgs_per_interrupt; + f = m_acquired; + return true; + } + else + return false; + } + + bool EoSensCL::EnableACK() + { + m_fl("EoSensCL::EnableACK", EDEBUG); + vector reply; + vector cmd = {CMD_PREFIX, CAMERA_ACK,'y'}; + if(!(m_phx->RunCMD(cmd, reply))) + return false; + if(!CheckReply(reply)) + return false; + return true; + } + + bool EoSensCL::CheckReply(vector& reply) + { + if(!reply.empty()) + { + if(reply[0] == 0x06) //ACK + return true; + } + return false; + } + + bool EoSensCL::UpdateImageSize() + { + vector r; + if(!GetROI(r)) + return false; + + m_fl("EoSensCL::UpdateImageSize", EDEBUG); + m_xstart = r[0]; + m_ystart = r[1]; + m_x = r[2]; + m_y = r[3]; + // update image size + if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) + m_img.resize(m_x*m_y*m_imgs_per_interrupt); + + // update frame grabber + if(!(m_phx->UpdateImageSize(m_xstart, m_ystart,m_x,m_y,m_hw_buf_len, m_imgs_per_interrupt))) + return false; + + + return true; + + } + + void EoSensCL::CheckFrameNumber(vector& d) + { + uint32_t frame_nr = static_cast((((uint8_t)d[3])<<24) + +(((uint8_t)d[2])<<16) + +(((uint8_t)d[1])<<8) + +((uint8_t)d[0])); + + if(frame_nr % 10000 == 0) + { + m_fl("EoSensCL::frame_nr:" + to_string(frame_nr) + + " - current:" + to_string(m_current_frame) + + " - imgs per interrupt" + to_string(m_imgs_per_interrupt) + + " - loss:"+ to_string(m_loss) + + " - avaiable in buffer:" + to_string(m_available), EINFO); + } + + if(m_start) + { + m_current_frame = frame_nr; + m_start = false; + } + else + { + if(frame_nr - m_current_frame != m_imgs_per_interrupt) + { + m_fl("EoSensCL::frame nr does not match, current:" + + to_string(frame_nr) + + " - previous:" + + to_string(m_current_frame), EDEBUG); + m_loss += (frame_nr - m_current_frame + 1); + m_current_frame = frame_nr; + } + else + { + m_current_frame += m_imgs_per_interrupt; + } + } + } + } +} \ No newline at end of file diff --git a/EoSensCams/EoSensCL.h b/EoSensCams/EoSensCL.h new file mode 100644 index 0000000..0331762 --- /dev/null +++ b/EoSensCams/EoSensCL.h @@ -0,0 +1,83 @@ +#pragma once +#include "EoSensCamInterface.h" +#include "CameraCommands.h" +#include "PHXWrapper.h" + +namespace EoSensCam_ns +{ + namespace EoSensCL_ns + { + using namespace CamComm_ns; + + typedef unique_ptr uptr_phx; + + class EoSensCL : public EoSensCam + { + public: + EoSensCL(uint16_t board_nr, uint16_t channel_nr, string config_file, uint16_t mode = 0, CamComm_ns::log_handler fl=CamComm_ns::default_log); + ~EoSensCL(); + + bool ResetCamera() override; + string GetCameraErr() override; + + string GetCameraSN() override; + string GetCameraID() override; + int16_t GetTemerature(); + + bool SetBlackLevel(uint16_t b) override; + bool GetBlackLevel(uint16_t& b) override; + + bool SetTriggerMode(uint16_t t) override; + bool GetTriggerMode(uint16_t& t) override; + + bool SetGain(uint16_t g) override; + bool GetGain(uint16_t& g) override; + + bool SetFrameRate(uint32_t f) override; + bool GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin) override; + + bool SetExposureTime(uint32_t e) override; + bool GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin) override; + + bool SetROI(vector r) override; + bool GetROI(vector& r) override; + + bool SetPixelClock(uint16_t c) override; + bool GetPixelClock(uint16_t& c) override; + + bool SetFrameCounter(bool f) override; + bool GetFrameCounter(bool& f) override; + + bool SetRunMode(uint16_t m) override; + bool GetRunMode(uint16_t& m) override; + + bool SetCameraMode(uint16_t m) override; + bool GetCameraMode(uint16_t& m) override; + + bool SetFPNCorrection(bool f) override; + bool GetFPNCorrection(bool & f) override; + + //bool StartAcq(int32_t requested_count = -1, int32_t hw_buf_len = 20, int32_t imgs_per_interrupt = 1); + bool StartAcq(int32_t requested_count, int32_t hw_buf_len, int32_t imgs_per_interrupt) override; + bool StopAcq() override; + uint32_t GetFrameLoss() override; + bool GetImageSize(uint32_t& x, uint32_t& y) override; + bool GetImage(vector& img, uint32_t& f) override; + + private: + bool EnableACK(); + bool CheckReply(vector& reply); + bool UpdateImageSize(); + void CheckFrameNumber(vector& d); + uptr_phx m_phx; + CamComm_ns::log_handler m_fl; + vector m_img; + uint32_t m_xstart, m_ystart, m_x,m_y, + m_mine, m_maxe,m_minf,m_maxf, + m_hw_buf_len,m_imgs_per_interrupt, + m_current_frame,m_loss, m_acquired, m_available; + bool m_start, m_frame_counter; + + }; + } +} \ No newline at end of file diff --git a/EoSensCams/EoSensCXP.cpp b/EoSensCams/EoSensCXP.cpp new file mode 100644 index 0000000..228d45b --- /dev/null +++ b/EoSensCams/EoSensCXP.cpp @@ -0,0 +1,460 @@ +#include "EoSensCXP.h" + +namespace EoSensCam_ns +{ + namespace EoSensCXP_ns + { + EoSensCXP::EoSensCXP(uint16_t board_nr, uint16_t channel_nr,string config_file,uint16_t mode,CamComm_ns::log_handler fl) + :m_fl(fl), + m_xstart(0), + m_ystart(0), + m_x(0), + m_y(0), + m_max_x(0), + m_max_y(0), + m_mine(0), + m_maxe(9999), + m_minf(0), + m_maxf(9999), + m_hw_buf_len(20), + m_imgs_per_interrupt(1), + m_current_frame(0), + m_loss(0), + m_acquired(0), + m_available(0), + m_start(false), + m_frame_counter(false) + { + m_phx = uptr_phx(new PHX_ns::PHXWrapperCXP(fl)); + if(!(m_phx->OpenCamera(board_nr,channel_nr,config_file))) + { + m_phx.reset(); + throw std::runtime_error("EoSensCXP::cannot open camera"); + } + + if(!GetSensorMaxSize()) + { + m_phx.reset(); + throw std::runtime_error("EoSensCXP::cannot get sensor max size"); + } + + if(!UpdateImageSize()) + { + m_phx.reset(); + throw std::runtime_error("EoSensCXP::cannot update image size"); + } + } + + EoSensCXP::~EoSensCXP() + { + m_phx.reset(); + } + + bool EoSensCXP::ResetCamera() + { + m_fl("EoSensCXP::ResetCamera", EDEBUG); + return ""; + } + + string EoSensCXP::GetCameraErr() + { + m_fl("EoSensCXP::GetCameraErr", EDEBUG); + return ""; + } + + string EoSensCXP::GetCameraSN() + { + m_fl("EoSensCXP::GetCameraSN", EDEBUG); + return ""; + } + + string EoSensCXP::GetCameraID() + { + m_fl("EoSensCXP::GetCameraID", EDEBUG); + return ""; + } + + int16_t EoSensCXP::GetTemerature() + { + m_fl("EoSensCXP::GetTemerature", EDEBUG); + return 0; + } + + bool EoSensCXP::SetBlackLevel(uint16_t b) + { + m_fl("EoSensCXP::SetBlackLevel", EDEBUG); + + return m_phx->Write(BlackLevelReg, static_cast(b)); + } + + bool EoSensCXP::GetBlackLevel(uint16_t& b) + { + m_fl("EoSensCXP::GetBlackLevel", EDEBUG); + uint32_t tmp; + if(!(m_phx->Read(BlackLevelReg, tmp))) + return false; + + b = static_cast(tmp); + return true; + } + + bool EoSensCXP::SetTriggerMode(uint16_t t) + { + m_fl("EoSensCXP::SetTriggerMode", EDEBUG); + return true; + } + + bool EoSensCXP::GetTriggerMode(uint16_t& t) + { + m_fl("EoSensCXP::GetTriggerMode", EDEBUG); + t=0; + return true; + } + + bool EoSensCXP::SetGain(uint16_t g) + { + m_fl("EoSensCXP::SetGain", EDEBUG); + + return m_phx->Write(AnalogGainReg, static_cast(g)); + } + + bool EoSensCXP::GetGain(uint16_t& g) + { + m_fl("EoSensCXP::GetGain", EDEBUG); + uint32_t tmp; + if(!(m_phx->Read(AnalogGainReg, tmp))) + return false; + + g = static_cast(tmp); + + return false; + } + + bool EoSensCXP::SetFrameRate(uint32_t f) + { + m_fl("EoSensCXP::SetFrameRate", EDEBUG); + if(f < m_minf || f > m_maxf) + { + m_fl("frame rate out of range, it should be between " + to_string(m_minf) + " and " + to_string(m_maxf), EERROR); + return false; + } + + return m_phx->Write(AcquisitionFrameRateReg, f); + } + + bool EoSensCXP::GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin) + { + m_fl("EoSensCXP::GetFrameRate", EDEBUG); + if(!(m_phx->Read(AcquisitionFrameRateReg, f))) + return false; + m_minf = 10; // according to document, minimum frame rate + if(!(m_phx->Read(AcquisitionFrameRateMaxReg, m_maxf))) + return false; + return true; + } + + bool EoSensCXP::SetExposureTime(uint32_t e) //unit μs + { + m_fl("EoSensCXP::SetExposureTime", EDEBUG); + if(e < m_mine || e > m_maxe) + { + m_fl("shutter time out of range, it should be between " + to_string(m_mine) + " and " + to_string(m_maxe), EERROR); + return false; + } + + return m_phx->Write(ExposureTimeReg, e); + } + + bool EoSensCXP::GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin) + { + m_fl("EoSensCXP::GetExposureTime", EDEBUG); + + if(!(m_phx->Read(ExposureTimeReg, e))) + return false; + if(!(m_phx->Read(ExposureTimeMinReg, m_mine))) + return false; + if(!(m_phx->Read(ExposureTimeMaxReg, m_maxe))) + return false; + return true; + } + + bool EoSensCXP::SetROI(vector r) + { + m_fl("EoSensCXP::SetROI", EDEBUG); + + if(r.size() != 4) + { + m_fl("ROI size error, should be 4 \ + (xstart,ystart,xwidth,ywidth) \ + instead of" +to_string(r.size()), EERROR); + return false; + } + + uint32_t offset_x = static_cast(r[0]); + uint32_t offset_y = static_cast(r[1]); + uint32_t x = static_cast(r[2]); + uint32_t y = static_cast(r[3]); + if(!(m_phx->Write(OffsetXReg, offset_x)) || + !(m_phx->Write(OffsetYReg, offset_y)) || + !(m_phx->Write(WidthReg, x)) || + !(m_phx->Write(HeightReg, y))) + return false; + return true; + } + + bool EoSensCXP::GetROI(vector& r) + { + m_fl("EoSensCXP::GetROI", EDEBUG); + + uint32_t offset_x, offset_y, x, y; + if(!(m_phx->Read(OffsetXReg, offset_x)) || + !(m_phx->Read(OffsetYReg, offset_y)) || + !(m_phx->Read(WidthReg, x)) || + !(m_phx->Read(HeightReg, y))) + return false; + + r[0] = static_cast(offset_x); + r[1] = static_cast(offset_y); + r[2] = static_cast(x); + r[3] = static_cast(y); + + return true; + } + + bool EoSensCXP::SetPixelClock(uint16_t c) + { + m_fl("EoSensCXP::SetPixelClock", EDEBUG); + return false; + } + bool EoSensCXP::GetPixelClock(uint16_t& c) + { + m_fl("EoSensCXP::GetPixelClock", EDEBUG); + return false; + } + + bool EoSensCXP::SetFrameCounter(bool f) + { + m_fl("EoSensCXP::SetFrameCounter", EDEBUG); + uint32_t val = f ? 1 : 0; + return m_phx->Write(InfoFieldFrameCounterEnableReg, val); + } + + bool EoSensCXP::GetFrameCounter(bool& f) + { + m_fl("EoSensCXP::GetFrameCounter", EDEBUG); + + uint32_t tmp; + if(!(m_phx->Read(InfoFieldFrameCounterEnableReg, tmp))) + return false; + f = (tmp == 1); + return true; + } + + bool EoSensCXP::SetRunMode(uint16_t m) + { + m_fl("EoSensCXP::SetRunMode", EDEBUG); + return false; + } + + bool EoSensCXP::GetRunMode(uint16_t& m) + { + m_fl("EoSensCXP::GetRunMode", EDEBUG); + return false; + } + + bool EoSensCXP::SetCameraMode(uint16_t m) + { + m_fl("EoSensCXP::SetCameraMode", EDEBUG); + return false; + } + + bool EoSensCXP::GetCameraMode(uint16_t& m) + { + m_fl("EoSensCXP::GetCameraMode", EDEBUG); + return false; + } + + bool EoSensCXP::SetFPNCorrection(bool f) + { + m_fl("EoSensCXP::SetFPNCorrection", EDEBUG); + + uint32_t val = f ? 1 : 0; + return m_phx->Write(FixedPatternNoiseReductionReg, val); + } + + bool EoSensCXP::GetFPNCorrection(bool & f) + { + m_fl("EoSensCXP::GetFPNCorrection", EDEBUG); + uint32_t tmp; + if(!(m_phx->Read(FixedPatternNoiseReductionReg, tmp))) + return false; + f = (tmp == 1); + return true; + } + + bool EoSensCXP::StartAcq(int32_t requested_count, int32_t hw_buf_len, int32_t imgs_per_interrupt) + { + m_fl("EoSensCXP::StartAcq", EDEBUG); + m_loss = 0; + m_acquired = 0; + m_available = 0; + m_imgs_per_interrupt = imgs_per_interrupt; + m_hw_buf_len = hw_buf_len; + + // update image size + if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) + m_img.resize(m_x*m_y*m_imgs_per_interrupt); + + // update frame grabber + if(!(m_phx->UpdateImageSize(m_xstart,m_ystart,m_x,m_y, m_hw_buf_len, m_imgs_per_interrupt))) + return false; + + m_start = true; + GetFrameCounter(m_frame_counter); + return m_phx->StartAcq(requested_count); + } + + bool EoSensCXP::StopAcq() + { + m_fl("EoSensCXP::StopAcq", EDEBUG); + + auto ret = m_phx->StopAcq(); + m_loss = 0; + m_acquired = 0; + m_available = 0; + m_start = true; + m_fl("EoSensCXP::StopAcq, loss frames:" + to_string(m_loss), EINFO); + return ret; + } + + uint32_t EoSensCXP::GetFrameLoss() + { + m_fl("EoSensCXP::GetFrameLoss", EDEBUG); + return m_loss; + } + + bool EoSensCXP::GetImageSize(uint32_t& x, uint32_t& y) + { + m_fl("EoSensCXP::GetImageSize", EDEBUG); + vector r; + if(GetROI(r)) + { + x = r[2]; + y = r[3]; + return true; + } + return false; + } + + bool EoSensCXP::GetImage(vector& img, uint32_t& f) + { + m_fl("EoSensCXP::GetImage", EDEBUG); + // there is no available image + // check frame grabber queue, it there is image + if(m_available < m_imgs_per_interrupt) + { + auto current_count = (m_phx->GetImagesInQueue()); + if(current_count == 0) + return false; + m_fl("EoSensCXP::buffer in count" + to_string(current_count), EDEBUG); + m_available = current_count - m_acquired; + } + + if(m_available < m_imgs_per_interrupt) + { + m_fl("EoSensCXP::no new image", EDEBUG); + return false; + } + + if(m_phx->GetImage(m_img)) + { + img = m_img; + // string s = "EoSensCXP::GetImage:first 4 bytes:"; + // for(uint32_t i=0; i<4; i++) + // s += (to_string(static_cast(img[i])) + " "); + // m_fl(s, EDEBUG); + if(m_frame_counter) + CheckFrameNumber(m_img); + m_acquired += m_imgs_per_interrupt; + m_available -= m_imgs_per_interrupt; + f = m_acquired; + return true; + } + else + return false; + } + + bool EoSensCXP::GetSensorMaxSize() + { + m_fl("EoSensCXP::GetSensorMaxSize", EDEBUG); + + if(!(m_phx->Read(SensorWidthReg, m_max_x)) || !(m_phx->Read(SensorHeightReg, m_max_y))) + return false; + + return true; + } + + bool EoSensCXP::UpdateImageSize() + { + vector r; + if(!GetROI(r)) + return false; + + m_fl("EoSensCXP::UpdateImageSize", EDEBUG); + m_xstart = r[0]; + m_ystart = r[1]; + m_x = r[2]; + m_y = r[3]; + // update image size + if(m_img.size() != m_x*m_y*m_imgs_per_interrupt) + m_img.resize(m_x*m_y*m_imgs_per_interrupt); + + // update frame grabber + if(!(m_phx->UpdateImageSize(m_xstart, m_ystart,m_x,m_y,m_hw_buf_len, m_imgs_per_interrupt))) + return false; + + + return true; + + } + + void EoSensCXP::CheckFrameNumber(vector& d) + { + uint32_t frame_nr = static_cast((((uint8_t)d[3])<<24) + +(((uint8_t)d[2])<<16) + +(((uint8_t)d[1])<<8) + +((uint8_t)d[0])); + + if(frame_nr % 10000 == 0) + { + m_fl("EoSensCXP::frame_nr:" + to_string(frame_nr) + + " - current:" + to_string(m_current_frame) + + " - imgs per interrupt" + to_string(m_imgs_per_interrupt) + + " - loss:"+ to_string(m_loss) + + " - avaiable in buffer:" + to_string(m_available), EINFO); + } + + if(m_start) + { + m_current_frame = frame_nr; + m_start = false; + } + else + { + if(frame_nr - m_current_frame != m_imgs_per_interrupt) + { + m_fl("EoSensCXP::frame nr does not match, current:" + + to_string(frame_nr) + + " - previous:" + + to_string(m_current_frame), EDEBUG); + m_loss += (frame_nr - m_current_frame + 1); + m_current_frame = frame_nr; + } + else + { + m_current_frame += m_imgs_per_interrupt; + } + } + } + } +} \ No newline at end of file diff --git a/EoSensCams/EoSensCXP.h b/EoSensCams/EoSensCXP.h new file mode 100644 index 0000000..e647867 --- /dev/null +++ b/EoSensCams/EoSensCXP.h @@ -0,0 +1,82 @@ +#pragma once +#include "EoSensCamInterface.h" +#include "CameraRegisterAddrMap.h" +#include "PHXWrapper.h" +#include "PHXWrapperCXP.h" + +namespace EoSensCam_ns +{ + namespace EoSensCXP_ns + { + using namespace CamComm_ns; + + typedef unique_ptr uptr_phx; + + class EoSensCXP : public EoSensCam + { + public: + EoSensCXP(uint16_t board_nr, uint16_t channel_nr, string config_file, uint16_t mode = 0, CamComm_ns::log_handler fl=CamComm_ns::default_log); + ~EoSensCXP(); + + bool ResetCamera() override; + string GetCameraErr() override; + + string GetCameraSN() override; + string GetCameraID() override; + int16_t GetTemerature() override; + + bool SetBlackLevel(uint16_t b) override; + bool GetBlackLevel(uint16_t& b) override; + + bool SetTriggerMode(uint16_t t) override; + bool GetTriggerMode(uint16_t& t) override; + + bool SetGain(uint16_t g) override; + bool GetGain(uint16_t& g) override; + + bool SetFrameRate(uint32_t f); + bool GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin) override; + + bool SetExposureTime(uint32_t e) override; + bool GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin) override; + + bool SetROI(vector r) override; + bool GetROI(vector& r) override; + + bool SetPixelClock(uint16_t c) override; + bool GetPixelClock(uint16_t& c) override; + + bool SetFrameCounter(bool f) override; + bool GetFrameCounter(bool& f) override; + + bool SetRunMode(uint16_t m) override; + bool GetRunMode(uint16_t& m) override; + + bool SetCameraMode(uint16_t m) override; + bool GetCameraMode(uint16_t& m) override; + + bool SetFPNCorrection(bool f) override; + bool GetFPNCorrection(bool & f) override; + + bool StartAcq(int32_t requested_count, int32_t hw_buf_len, int32_t imgs_per_interrupt) override; + bool StopAcq() override; + uint32_t GetFrameLoss() override; + bool GetImageSize(uint32_t& x, uint32_t& y) override; + bool GetImage(vector& img, uint32_t& f) override; + + private: + bool GetSensorMaxSize(); + bool UpdateImageSize(); + void CheckFrameNumber(vector& d); + uptr_phx m_phx; + CamComm_ns::log_handler m_fl; + vector m_img; + uint32_t m_xstart, m_ystart, m_x,m_y,m_max_x, m_max_y, + m_mine, m_maxe,m_minf,m_maxf, + m_hw_buf_len,m_imgs_per_interrupt, + m_current_frame,m_loss, m_acquired, m_available; + bool m_start, m_frame_counter; + + }; + } +} \ No newline at end of file diff --git a/EoSensCams/EoSensCamInterface.cpp b/EoSensCams/EoSensCamInterface.cpp new file mode 100644 index 0000000..e2b2cf5 --- /dev/null +++ b/EoSensCams/EoSensCamInterface.cpp @@ -0,0 +1,34 @@ +#include "EoSensCamInterface.h" +#include "EoSensCL.h" +#include "EoSensCXP.h" + +namespace EoSensCam_ns +{ + std::unique_ptr CamInstance(uint16_t board_nr, uint16_t channel_nr, string config_file, uint16_t mode, CamComm_ns::log_handler fl) + { + + try + { + fl("try to open camera link camera...", EINFO); + auto ptr = unique_ptr(new EoSensCL_ns::EoSensCL(board_nr, channel_nr, config_file, mode,fl)); + return std::move(ptr); + } + catch(const std::runtime_error& e) + { + fl("open camera link camera failed." + string(e.what()), EERROR); + } + + try + { + fl("try to open CXP camera...", EINFO); + auto ptr = unique_ptr(new EoSensCXP_ns::EoSensCXP(board_nr, channel_nr, config_file, mode,fl)); + return std::move(ptr); + } + catch(const std::runtime_error& e) + { + fl("open CXP camera failed." + string(e.what()), EERROR); + } + fl("no camera found!", EERROR); + return nullptr; + } +} \ No newline at end of file diff --git a/EoSensCams/EoSensCamInterface.h b/EoSensCams/EoSensCamInterface.h new file mode 100644 index 0000000..58f0b34 --- /dev/null +++ b/EoSensCams/EoSensCamInterface.h @@ -0,0 +1,68 @@ +#pragma once +#include "CameraCommon.h" +#include +#include +#include +#include + +namespace EoSensCam_ns +{ + using namespace CamComm_ns; + using namespace std; + + class EoSensCam + { + public: + virtual ~EoSensCam() = default; + + virtual bool ResetCamera() = 0; + virtual string GetCameraErr() = 0; + + virtual string GetCameraSN() = 0; + virtual string GetCameraID() = 0; + virtual int16_t GetTemerature() = 0; + + virtual bool SetBlackLevel(uint16_t b) = 0; + virtual bool GetBlackLevel(uint16_t& b) = 0; + + virtual bool SetTriggerMode(uint16_t t) = 0; + virtual bool GetTriggerMode(uint16_t& t) = 0; + + virtual bool SetGain(uint16_t g) = 0; + virtual bool GetGain(uint16_t& g) = 0; + + virtual bool SetFrameRate(uint32_t f) = 0; + virtual bool GetFrameRate(uint32_t& f, uint32_t& fmax, uint32_t& fmin) = 0; + + virtual bool SetExposureTime(uint32_t e) = 0; + virtual bool GetExposureTime(uint32_t& e, uint32_t& emax, uint32_t& emin) = 0; + + virtual bool SetROI(vector r) = 0; + virtual bool GetROI(vector& r) = 0; + + virtual bool SetPixelClock(uint16_t c) = 0; + virtual bool GetPixelClock(uint16_t& c) = 0; + + virtual bool SetFrameCounter(bool f) = 0; + virtual bool GetFrameCounter(bool& f) = 0; + + virtual bool SetRunMode(uint16_t m) = 0; + virtual bool GetRunMode(uint16_t& m) = 0; + + virtual bool SetCameraMode(uint16_t m) = 0; + virtual bool GetCameraMode(uint16_t& m) = 0; + + virtual bool SetFPNCorrection(bool f) = 0; + virtual bool GetFPNCorrection(bool & f) = 0; + + virtual bool StartAcq(int32_t requested_count, int32_t hw_buf_len, int32_t imgs_per_interrupt) = 0; + virtual bool StopAcq() = 0; + virtual uint32_t GetFrameLoss() = 0; + virtual bool GetImageSize(uint32_t& x, uint32_t& y) = 0; + virtual bool GetImage(vector& img, uint32_t& f) = 0; + protected: + EoSensCam() = default; + }; + + std::unique_ptr CamInstance(uint16_t board_nr, uint16_t channel_nr, string config_file, uint16_t mode = 0, CamComm_ns::log_handler fl=CamComm_ns::default_log); +} \ No newline at end of file diff --git a/EoSensCL/PHXWrapper.cpp b/EoSensCams/PHXWrapper.cpp similarity index 100% rename from EoSensCL/PHXWrapper.cpp rename to EoSensCams/PHXWrapper.cpp diff --git a/EoSensCL/PHXWrapper.h b/EoSensCams/PHXWrapper.h similarity index 100% rename from EoSensCL/PHXWrapper.h rename to EoSensCams/PHXWrapper.h diff --git a/EoSensCL/PHXWrapperCXP.cpp b/EoSensCams/PHXWrapperCXP.cpp similarity index 100% rename from EoSensCL/PHXWrapperCXP.cpp rename to EoSensCams/PHXWrapperCXP.cpp diff --git a/EoSensCL/PHXWrapperCXP.h b/EoSensCams/PHXWrapperCXP.h similarity index 100% rename from EoSensCL/PHXWrapperCXP.h rename to EoSensCams/PHXWrapperCXP.h diff --git a/FireBird.cpp b/FireBird.cpp index f386875..e262a5d 100644 --- a/FireBird.cpp +++ b/FireBird.cpp @@ -342,7 +342,6 @@ void FireBird::get_device_property() dev_prop.push_back(Tango::DbDatum("CameraMode")); dev_prop.push_back(Tango::DbDatum("FrameGrabberBuffer")); dev_prop.push_back(Tango::DbDatum("BufferLength")); - dev_prop.push_back(Tango::DbDatum("CameraInterface")); // is there at least one property to be read ? if (dev_prop.size()>0) @@ -467,17 +466,6 @@ void FireBird::get_device_property() // And try to extract BufferLength value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> bufferLength; - // Try to initialize CameraInterface from class property - cl_prop = ds_class->get_class_property(dev_prop[++i].name); - if (cl_prop.is_empty()==false) cl_prop >> cameraInterface; - else { - // Try to initialize CameraInterface from default device value - def_prop = ds_class->get_default_device_property(dev_prop[i].name); - if (def_prop.is_empty()==false) def_prop >> cameraInterface; - } - // And try to extract CameraInterface value from database - if (dev_prop[i].is_empty()==false) dev_prop[i] >> cameraInterface; - } /*----- PROTECTED REGION ID(FireBird::get_device_property_after) ENABLED START -----*/ @@ -608,7 +596,8 @@ void FireBird::read_CameraSimulation(Tango::Attribute &attr) DEBUG_STREAM << "FireBird::read_CameraSimulation(Tango::Attribute &attr) entering... " << endl; /*----- PROTECTED REGION ID(FireBird::read_CameraSimulation) ENABLED START -----*/ // Set the attribute value - attr.set_value(attr_CameraSimulation_read); + if(m_run_mode_support) + attr.set_value(attr_CameraSimulation_read); /*----- PROTECTED REGION END -----*/ // FireBird::read_CameraSimulation } @@ -629,7 +618,9 @@ void FireBird::write_CameraSimulation(Tango::WAttribute &attr) Tango::DevBoolean w_val; attr.get_write_value(w_val); /*----- PROTECTED REGION ID(FireBird::write_CameraSimulation) ENABLED START -----*/ - + if(!m_run_mode_support) + ThrowException("this feature is not supported"); + uint16_t i = (w_val?0:1); if(m_cam->SetRunMode(i)) *attr_CameraSimulation_read = w_val; @@ -1329,7 +1320,8 @@ void FireBird::read_Linkoutputmode(Tango::Attribute &attr) DEBUG_STREAM << "FireBird::read_Linkoutputmode(Tango::Attribute &attr) entering... " << endl; /*----- PROTECTED REGION ID(FireBird::read_Linkoutputmode) ENABLED START -----*/ // Set the attribute value - attr.set_value(attr_Linkoutputmode_read); + if(m_camera_mode_support) + attr.set_value(attr_Linkoutputmode_read); /*----- PROTECTED REGION END -----*/ // FireBird::read_Linkoutputmode } @@ -1523,7 +1515,8 @@ void FireBird::read_PixelClock(Tango::Attribute &attr) DEBUG_STREAM << "FireBird::read_PixelClock(Tango::Attribute &attr) entering... " << endl; /*----- PROTECTED REGION ID(FireBird::read_PixelClock) ENABLED START -----*/ // Set the attribute value - attr.set_value(attr_PixelClock_read); + if(m_pixelclock_support) + attr.set_value(attr_PixelClock_read); /*----- PROTECTED REGION END -----*/ // FireBird::read_PixelClock } @@ -2009,61 +2002,28 @@ void FireBird::add_dynamic_commands() // Additional Methods bool FireBird::OpenCamera() { - try - { - switch(cameraInterface) - { - case 0: // CL camera - m_cam - = sptr_cam(new EoSensCL_ns::EoSensCL( - boardNumber, channelNumber, configFile, cameraMode, - [=](string msg,CamComm_ns::LogLevel l) - { - switch(l) - { - case CamComm_ns::EDEBUG: - DEBUG_STREAM<<"EoSensCL:"< #include #include @@ -64,7 +64,7 @@ namespace FireBird_ns // Additional Class Declarations using namespace FSDaqNS; -typedef shared_ptr sptr_cam; +typedef shared_ptr sptr_cam; /*----- PROTECTED REGION END -----*/ // FireBird::Additional Class Declarations @@ -77,7 +77,10 @@ class FireBird : public TANGO_BASE_CLASS shared_ptr m_fb_data; shared_ptr m_writer; std::atomic m_thread_status; - bool m_gain_support; + bool m_gain_support, + m_camera_mode_support, + m_run_mode_support, + m_pixelclock_support; //stringstream m_ssinfo; public: string m_save_filename; @@ -118,10 +121,6 @@ public: // BufferLength: how much system RAM is reserved as image buffer // measured by number of images Tango::DevLong bufferLength; - // CameraInterface: camera interface: - // 0: CL - // 1: CXP - Tango::DevUShort cameraInterface; // Attribute data members public: diff --git a/FireBird.xmi b/FireBird.xmi index cc9350d..9fcc736 100644 --- a/FireBird.xmi +++ b/FireBird.xmi @@ -54,11 +54,6 @@ 10000 - - - - 0 - diff --git a/FireBirdClass.cpp b/FireBirdClass.cpp index e0987fc..0cd1330 100644 --- a/FireBirdClass.cpp +++ b/FireBirdClass.cpp @@ -410,20 +410,6 @@ void FireBirdClass::set_default_property() } else add_wiz_dev_prop(prop_name, prop_desc); - prop_name = "CameraInterface"; - prop_desc = "camera interface:\n0: CL\n1: CXP"; - prop_def = "0"; - vect_data.clear(); - vect_data.push_back("0"); - if (prop_def.length()>0) - { - Tango::DbDatum data(prop_name); - data << vect_data ; - dev_def_prop.push_back(data); - add_wiz_dev_prop(prop_name, prop_desc, prop_def); - } - else - add_wiz_dev_prop(prop_name, prop_desc); } //-------------------------------------------------------- diff --git a/FireBirdData.h b/FireBirdData.h index 64a4467..0ef8be4 100644 --- a/FireBirdData.h +++ b/FireBirdData.h @@ -6,7 +6,7 @@ namespace FSDaqNS { typedef FireBird_ns::FireBird* sptr_fb; - typedef shared_ptr sptr_cam; + typedef shared_ptr sptr_cam; class FireBirdData : public Data { public: diff --git a/Makefile b/Makefile index 97973e4..cd2cfda 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ MAJOR_VERS = 2 MINOR_VERS = 3 RELEASE = Release_$(MAJOR_VERS)_$(MINOR_VERS) -EoSensCL_PATH=./EoSensCL +EoSensCam_PATH=./EoSensCams # #============================================================================= # # RELEASE_TYPE @@ -118,24 +118,26 @@ include $(MAKE_ENV)/tango.opt # SVC_INCL = $(PACKAGE_NAME).h $(PACKAGE_NAME)Class.h \ FireBirdData.h \ - $(EoSensCL_PATH)/CameraCommon.h \ - $(EoSensCL_PATH)/CameraCommands.h \ - $(EoSensCL_PATH)/CameraRegisterAddrMap.h \ - $(EoSensCL_PATH)/EoSensCL.h \ - $(EoSensCL_PATH)/EoSensCXP.h \ - $(EoSensCL_PATH)/PHXWrapper.h \ - $(EoSensCL_PATH)/PHXWrapperCXP.h + $(EoSensCam_PATH)/CameraCommon.h \ + $(EoSensCam_PATH)/CameraCommands.h \ + $(EoSensCam_PATH)/CameraRegisterAddrMap.h \ + $(EoSensCam_PATH)/EoSensCamInterface.h \ + $(EoSensCam_PATH)/EoSensCL.h \ + $(EoSensCam_PATH)/EoSensCXP.h \ + $(EoSensCam_PATH)/PHXWrapper.h \ + $(EoSensCam_PATH)/PHXWrapperCXP.h SVC_OBJS = \ $(LIB_OBJS) \ $(OBJDIR)/ClassFactory.o \ $(OBJDIR)/main.o \ $(OBJDIR)/FireBirdData.o \ - $(OBJDIR)/$(EoSensCL_PATH)/EoSensCL.o \ - $(OBJDIR)/$(EoSensCL_PATH)/EoSensCXP.o \ - $(OBJDIR)/$(EoSensCL_PATH)/PHXWrapper.o \ - $(OBJDIR)/$(EoSensCL_PATH)/PHXWrapperCXP.o \ - $(OBJDIR)/$(EoSensCL_PATH)/CameraCommon.o + $(OBJDIR)/$(EoSensCam_PATH)/EoSensCamInterface.o \ + $(OBJDIR)/$(EoSensCam_PATH)/EoSensCL.o \ + $(OBJDIR)/$(EoSensCam_PATH)/EoSensCXP.o \ + $(OBJDIR)/$(EoSensCam_PATH)/PHXWrapper.o \ + $(OBJDIR)/$(EoSensCam_PATH)/PHXWrapperCXP.o \ + $(OBJDIR)/$(EoSensCam_PATH)/CameraCommon.o LIB_OBJS = \ $(OBJDIR)/$(PACKAGE_NAME).o \ diff --git a/doc_html/FullDocument.html b/doc_html/FullDocument.html index 82a03df..1f77c60 100644 --- a/doc_html/FullDocument.html +++ b/doc_html/FullDocument.html @@ -206,14 +206,6 @@ int 10000
- - CameraInterface - camera interface:
- 0: CL
- 1: CXP - short - 0
-


diff --git a/doc_html/Properties.html b/doc_html/Properties.html index c2cf7ae..52a2833 100644 --- a/doc_html/Properties.html +++ b/doc_html/Properties.html @@ -88,14 +88,6 @@ int 10000
- - CameraInterface - camera interface:
- 0: CL
- 1: CXP - short - 0
- -- GitLab From bc7806de1415120be0f882c51df5c8842459f5f3 Mon Sep 17 00:00:00 2001 From: Yuelong Yu Date: Fri, 18 Feb 2022 18:17:31 +0100 Subject: [PATCH 3/5] WIP test - fixed error in frame rate max/min - fixed error in exposure time max/min - fixed seg fault when reading ROIs - added start/stop command --- EoSensCams/EoSensCXP.cpp | 26 +++++++++++++++++++------- EoSensCams/PHXWrapper.cpp | 5 ++++- EoSensCams/PHXWrapperCXP.cpp | 4 ++-- FireBird.cpp | 6 +++--- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/EoSensCams/EoSensCXP.cpp b/EoSensCams/EoSensCXP.cpp index 228d45b..91fe21c 100644 --- a/EoSensCams/EoSensCXP.cpp +++ b/EoSensCams/EoSensCXP.cpp @@ -150,6 +150,9 @@ namespace EoSensCam_ns m_minf = 10; // according to document, minimum frame rate if(!(m_phx->Read(AcquisitionFrameRateMaxReg, m_maxf))) return false; + + fmin = m_minf; + fmax = m_maxf; return true; } @@ -175,6 +178,8 @@ namespace EoSensCam_ns return false; if(!(m_phx->Read(ExposureTimeMaxReg, m_maxe))) return false; + emin = m_mine; + emax = m_maxe; return true; } @@ -213,10 +218,10 @@ namespace EoSensCam_ns !(m_phx->Read(HeightReg, y))) return false; - r[0] = static_cast(offset_x); - r[1] = static_cast(offset_y); - r[2] = static_cast(x); - r[3] = static_cast(y); + r.push_back(static_cast(offset_x)); + r.push_back(static_cast(offset_y)); + r.push_back(static_cast(x)); + r.push_back(static_cast(y)); return true; } @@ -311,14 +316,21 @@ namespace EoSensCam_ns m_start = true; GetFrameCounter(m_frame_counter); - return m_phx->StartAcq(requested_count); + + if(!(m_phx->StartAcq(requested_count))) + return false; + uint32_t value = 0; + if(!(m_phx->Write(AcquisitionStartReg, value))) + return false; + return true; } bool EoSensCXP::StopAcq() { m_fl("EoSensCXP::StopAcq", EDEBUG); - - auto ret = m_phx->StopAcq(); + uint32_t value = 0; + auto ret = m_phx->Write(AcquisitionStopReg,value); + ret = m_phx->StopAcq(); m_loss = 0; m_acquired = 0; m_available = 0; diff --git a/EoSensCams/PHXWrapper.cpp b/EoSensCams/PHXWrapper.cpp index 91ae9e1..8d000cc 100644 --- a/EoSensCams/PHXWrapper.cpp +++ b/EoSensCams/PHXWrapper.cpp @@ -507,7 +507,10 @@ namespace PHX_ns } m_fl("PHXWrapper::GetImage:read " + to_string(m_imgs_per_interrupt) + "image", EDEBUG); uint8_t* data = reinterpret_cast(buf.pvAddress); - + string s = "vector first 4 bytes:" + to_string(img.size()) + ":"; + for(uint32_t i=0; i<4; i++) + s += (to_string(static_cast(data[i])) + " "); + m_fl(s, EINFO); std::copy(data, data + img.size(), &img[0]); m_fl("PHXWrapper::GetImage:copy " +to_string(m_imgs_per_interrupt)+ "image", EDEBUG); // s = "vector first 4 bytes:"; diff --git a/EoSensCams/PHXWrapperCXP.cpp b/EoSensCams/PHXWrapperCXP.cpp index 3de60dd..924cd03 100644 --- a/EoSensCams/PHXWrapperCXP.cpp +++ b/EoSensCams/PHXWrapperCXP.cpp @@ -160,7 +160,7 @@ namespace PHX_ns m_fl("Error writing to Camera CXP register: size written does not match size requested.", EERROR); return false; } - + m_fl("PHXWrapperCXP::Write:" + to_string(address) + ":" + to_string(v),EINFO); return true; } @@ -184,7 +184,7 @@ namespace PHX_ns } r = be32toh(tmp);//convert received data to littel endian - + m_fl("PHXWrapperCXP::Read:" + to_string(address) + ":" + to_string(r),EINFO); return true; } diff --git a/FireBird.cpp b/FireBird.cpp index e262a5d..fddbf69 100644 --- a/FireBird.cpp +++ b/FireBird.cpp @@ -2010,13 +2010,13 @@ bool FireBird::OpenCamera() switch(l) { case CamComm_ns::EDEBUG: - DEBUG_STREAM<<"EoSensCL:"< Date: Fri, 18 Feb 2022 18:58:51 +0100 Subject: [PATCH 4/5] WIP added image update when seting ROIs --- EoSensCams/EoSensCXP.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/EoSensCams/EoSensCXP.cpp b/EoSensCams/EoSensCXP.cpp index 91fe21c..d67b95e 100644 --- a/EoSensCams/EoSensCXP.cpp +++ b/EoSensCams/EoSensCXP.cpp @@ -204,6 +204,13 @@ namespace EoSensCam_ns !(m_phx->Write(WidthReg, x)) || !(m_phx->Write(HeightReg, y))) return false; + + if(!UpdateImageSize()) + { + m_fl("cannot update image size", EERROR); + return false; + } + return true; } -- GitLab From 546748e91573fb670ade96cf662d2fe0629571db Mon Sep 17 00:00:00 2001 From: Yuelong Yu Date: Mon, 21 Feb 2022 10:56:54 +0100 Subject: [PATCH 5/5] fix warnings --- EoSensCams/EoSensCL.cpp | 4 +++- EoSensCams/EoSensCXP.cpp | 22 +++++++++++++++++----- EoSensCams/PHXWrapper.cpp | 12 ++++++------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/EoSensCams/EoSensCL.cpp b/EoSensCams/EoSensCL.cpp index 8238645..6b64833 100644 --- a/EoSensCams/EoSensCL.cpp +++ b/EoSensCams/EoSensCL.cpp @@ -138,15 +138,17 @@ namespace EoSensCam_ns return false; } - bool EoSensCL::SetTriggerMode(uint16_t t) + bool EoSensCL::SetTriggerMode(uint16_t /*t*/) { m_fl("EoSensCL::SetTriggerMode", EDEBUG); + m_fl("EoSensCXP::SetTriggerMode not implemented", EERROR); return true; } bool EoSensCL::GetTriggerMode(uint16_t& t) { m_fl("EoSensCL::GetTriggerMode", EDEBUG); + m_fl("EoSensCXP::GetTriggerMode not implemented", EERROR); t=0; return true; } diff --git a/EoSensCams/EoSensCXP.cpp b/EoSensCams/EoSensCXP.cpp index d67b95e..5e400e7 100644 --- a/EoSensCams/EoSensCXP.cpp +++ b/EoSensCams/EoSensCXP.cpp @@ -4,7 +4,7 @@ namespace EoSensCam_ns { namespace EoSensCXP_ns { - EoSensCXP::EoSensCXP(uint16_t board_nr, uint16_t channel_nr,string config_file,uint16_t mode,CamComm_ns::log_handler fl) + EoSensCXP::EoSensCXP(uint16_t board_nr, uint16_t channel_nr,string config_file,uint16_t /*mode*/,CamComm_ns::log_handler fl) :m_fl(fl), m_xstart(0), m_ystart(0), @@ -98,15 +98,18 @@ namespace EoSensCam_ns return true; } - bool EoSensCXP::SetTriggerMode(uint16_t t) + bool EoSensCXP::SetTriggerMode(uint16_t /*t*/) { m_fl("EoSensCXP::SetTriggerMode", EDEBUG); + m_fl("EoSensCXP::SetTriggerMode not implemented", EERROR); + return true; } bool EoSensCXP::GetTriggerMode(uint16_t& t) { m_fl("EoSensCXP::GetTriggerMode", EDEBUG); + m_fl("EoSensCXP::GetTriggerMode not implemented", EERROR); t=0; return true; } @@ -233,14 +236,17 @@ namespace EoSensCam_ns return true; } - bool EoSensCXP::SetPixelClock(uint16_t c) + bool EoSensCXP::SetPixelClock(uint16_t /*c*/) { m_fl("EoSensCXP::SetPixelClock", EDEBUG); + m_fl("EoSensCXP::SetPixelClock not supported", EERROR); return false; } bool EoSensCXP::GetPixelClock(uint16_t& c) { m_fl("EoSensCXP::GetPixelClock", EDEBUG); + m_fl("EoSensCXP::GetPixelClock not supported", EERROR); + c=0; return false; } @@ -262,27 +268,33 @@ namespace EoSensCam_ns return true; } - bool EoSensCXP::SetRunMode(uint16_t m) + bool EoSensCXP::SetRunMode(uint16_t /*m*/) { m_fl("EoSensCXP::SetRunMode", EDEBUG); + m_fl("EoSensCXP::SetRunMode not supported", EERROR); return false; } bool EoSensCXP::GetRunMode(uint16_t& m) { m_fl("EoSensCXP::GetRunMode", EDEBUG); + m_fl("EoSensCXP::GetRunMode not supported", EERROR); + m = 0; return false; } - bool EoSensCXP::SetCameraMode(uint16_t m) + bool EoSensCXP::SetCameraMode(uint16_t /*m*/) { m_fl("EoSensCXP::SetCameraMode", EDEBUG); + m_fl("EoSensCXP::SetCameraMode not supported", EERROR); return false; } bool EoSensCXP::GetCameraMode(uint16_t& m) { m_fl("EoSensCXP::GetCameraMode", EDEBUG); + m_fl("EoSensCXP::GetCameraMode not supported", EERROR); + m=0; return false; } diff --git a/EoSensCams/PHXWrapper.cpp b/EoSensCams/PHXWrapper.cpp index 8d000cc..0e87657 100644 --- a/EoSensCams/PHXWrapper.cpp +++ b/EoSensCams/PHXWrapper.cpp @@ -381,10 +381,10 @@ namespace PHX_ns return true; } - bool PHXWrapper::UpdateImageSize(uint32_t xstart, uint32_t ystart, uint32_t x, uint32_t y, uint32_t buf_len, uint32_t imgs_per_interrupt) + bool PHXWrapper::UpdateImageSize(uint32_t /*xstart*/, uint32_t /*ystart*/, uint32_t x, uint32_t y, uint32_t buf_len, uint32_t imgs_per_interrupt) { m_fl("PHXWrapper::UpdateImageSize", EDEBUG); - uint32_t xstart1, ystart1, x1,y1; + uint32_t x1,y1; if(PHX_ParameterGet(m_cam, PHX_BUF_DST_XLENGTH, &x1) != PHX_OK) { @@ -508,9 +508,9 @@ namespace PHX_ns m_fl("PHXWrapper::GetImage:read " + to_string(m_imgs_per_interrupt) + "image", EDEBUG); uint8_t* data = reinterpret_cast(buf.pvAddress); string s = "vector first 4 bytes:" + to_string(img.size()) + ":"; - for(uint32_t i=0; i<4; i++) - s += (to_string(static_cast(data[i])) + " "); - m_fl(s, EINFO); + // for(uint32_t i=0; i<4; i++) + // s += (to_string(static_cast(data[i])) + " "); + // m_fl(s, EDEBUG); std::copy(data, data + img.size(), &img[0]); m_fl("PHXWrapper::GetImage:copy " +to_string(m_imgs_per_interrupt)+ "image", EDEBUG); // s = "vector first 4 bytes:"; @@ -616,7 +616,7 @@ namespace PHX_ns return eStat; } - void PHXWrapper::InterruptCallback(tHandle cam, ui32 interrupt_mask,void *context) + void PHXWrapper::InterruptCallback(tHandle /*cam*/, ui32 interrupt_mask,void *context) { /* A hardware event occurred, deal with it */ if (context) -- GitLab