diff --git a/src/IrisCamera.cpp b/src/IrisCamera.cpp index 465c71235eed018748d8ef790ea6b3151cd1787d..4b658643893a8955eae703b844e135666e39c3c8 100644 --- a/src/IrisCamera.cpp +++ b/src/IrisCamera.cpp @@ -700,33 +700,8 @@ void Camera::setBin(const Bin &_bin) { DEB_MEMBER_FUNCT(); CameraContext* ctx = contexts[cSingleCamIndex]; - // TODO: might also be run on init and save values to some class member variable - NVPC binsSer, binsPar; - - if (!ReadEnumeration(ctx->hcam, &binsSer, PARAM_BINNING_SER, "PARAM_BINNING_SER")) { - _printError("Cannot get available bin serial factors"); - } - - if (!ReadEnumeration(ctx->hcam, &binsPar, PARAM_BINNING_PAR, "PARAM_BINNING_PAR")) { - _printError("Cannot get available bin parallel factors error"); - } - - const uns32 binCount = (uns32)std::min(binsSer.size(), binsPar.size()); - - // check if provided bining values are available - // NVP containers for serial and parallel bining factors should be the same. - uns32 n; - for (n=0; n= binCount) { - _printError("Provided binning not available"); - } else { - ctx->region.sbin = _bin.getX(); - ctx->region.pbin = _bin.getY(); - } + ctx->region.sbin = _bin.getX(); + ctx->region.pbin = _bin.getY(); } void Camera::getBin(Bin &_bin) const { @@ -737,75 +712,66 @@ void Camera::getBin(Bin &_bin) const { DEB_RETURN() << DEB_VAR1(_bin); } + void Camera::checkBin(Bin &aBin) { DEB_MEMBER_FUNCT(); - - // TODO: check if bin set is not exceeding the max bin possible to set in the cam. Partiely done int setBin() + CameraContext* ctx = contexts[cSingleCamIndex]; + int x = aBin.getX(); int y = aBin.getY(); - aBin = Bin(x,y); -} + NVPC binsSer, binsPar; -// void Camera::checkBin(Bin &aBin) { -// DEB_MEMBER_FUNCT(); -// CameraContext* ctx = contexts[cSingleCamIndex]; - -// int x = aBin.getX(); -// int y = aBin.getY(); - -// NVPC binsSer, binsPar; - -// if (!ReadEnumeration(ctx->hcam, &binsSer, PARAM_BINNING_SER, "PARAM_BINNING_SER")) { -// THROW_HW_ERROR(Error) << "Cannot get available bin serial factors"; -// } else { -// uns32 serBinCount = binsSer.size(); -// // check if provided bining values are available -// // NVP containers for serial and parallel bining factors should be the same. -// uns32 n; -// for (n=0; n= serBinCount) { -// // set to maximum possible value if provided value is not available; -// if (PV_OK != pl_get_param(ctx->hcam, PARAM_BINNING_SER, ATTR_MAX, (void*)&serBin)) -// THROW_HW_ERROR(Error) << "Cannot get max value of ser binning"; -// } else { -// serBin = binsSer[n].value; -// } - -// x = serBin; -// } - -// if (!ReadEnumeration(ctx->hcam, &binsPar, PARAM_BINNING_PAR, "PARAM_BINNING_PAR")) { -// THROW_HW_ERROR(Error) << "Cannot get available bin parallel factors error"; -// } else { -// uns32 parBinCount = binsPar.size(); -// // check if provided bining values are available -// // NVP containers for serial and parallel bining factors should be the same. -// uns32 n; -// for (n=0; n= parBinCount) { -// // set to maximum possible value if provided value is not available; -// if (PV_OK != pl_get_param(ctx->hcam, PARAM_BINNING_PAR, ATTR_MAX, (void*)&parBin)) -// THROW_HW_ERROR(Error) << "Cannot get max value of par binning"; -// } else { -// parBin = binsPar[n].value; -// } - -// y = parBin; -// } - -// aBin = Bin(x,y); -// } + if (!ReadEnumeration(ctx->hcam, &binsSer, PARAM_BINNING_SER, "PARAM_BINNING_SER")) { + _printError("Cannot get available ser serial factors"); + } else { + uns32 serBinCount = binsSer.size(); + // check if provided bining values are available + // NVP containers for serial and parallel bining factors should be the same. + uns32 n; + for (n=0; n= serBinCount) { + // set to maximum possible value if provided value is not available; + if (PV_OK != pl_get_param(ctx->hcam, PARAM_BINNING_SER, ATTR_MAX, (void*)&serBin)) + _printError("Cannot get max value of ser binning"); + } else { + serBin = binsSer[n].value; + } + + x = serBin; + } + + if (!ReadEnumeration(ctx->hcam, &binsPar, PARAM_BINNING_PAR, "PARAM_BINNING_PAR")) { + _printError("Cannot get available bin parallel factors error"); + } else { + uns32 parBinCount = binsPar.size(); + // check if provided bining values are available + // NVP containers for serial and parallel bining factors should be the same. + uns32 n; + for (n=0; n= parBinCount) { + // set to maximum possible value if provided value is not available; + if (PV_OK != pl_get_param(ctx->hcam, PARAM_BINNING_PAR, ATTR_MAX, (void*)&parBin)) + _printError("Cannot get max value of par binning"); + } else { + parBin = binsPar[n].value; + } + + y = parBin; + } + + aBin = Bin(x,y); +} void Camera::getFrameRate(double& frame_rate) const { DEB_MEMBER_FUNCT(); diff --git a/test/test_api.py b/test/test_api.py new file mode 100644 index 0000000000000000000000000000000000000000..0ec0aa6657c5021c84d7fdca8559f25795f0eda4 --- /dev/null +++ b/test/test_api.py @@ -0,0 +1,83 @@ +""" +This file can be used with `pytest`. + +The following way to execute the whole tests. +``` +pytest test/test.py +``` + +Or the following way to execute a single test. +``` +pytest test/test.py::test_internal_trigger +``` + +""" + +import time +import logging +from Lima import Core, Iris + + +_logger = logging.getLogger(__name__) + + +class AcquisitionStatusFromImageStatusCallback(Core.CtControl.ImageStatusCallback): + def __init__(self): + super().__init__() + self.last_base_image_ready = -1 + self.last_image_acquired = -1 + self.last_image_ready = -1 + self.last_image_saved = -1 + self.last_counter_ready = -1 + + def imageStatusChanged(self, image_status): + self.last_base_image_ready = image_status.LastBaseImageReady + self.last_image_acquired = image_status.LastImageAcquired + self.last_image_ready = image_status.LastImageReady + self.last_image_saved = image_status.LastImageSaved + self.last_counter_ready = image_status.LastCounterReady + + +def test_internal_trigger(): + # cam = Iris.Camera() + # hw = Iris.Interface(cam) + # ct = Core.CtControl(hw) + +# acq_status = AcquisitionStatusFromImageStatusCallback() +# ct.registerImageStatusCallback(acq_status) + +# ct.prepareAcq() +# ct.startAcq() + +# while ct.getStatus().AcquisitionStatus != Core.AcqReady: +# time.sleep(0.1) + +# assert acq_status.last_image_ready == 0 + assert True + + +#def test_internal_trigger_multi(): +# cam = Iris.Camera() +# hw = Iris.Interface(cam) +# ct = Core.CtControl(hw) + +# acq_status = AcquisitionStatusFromImageStatusCallback() +# ct.registerImageStatusCallback(acq_status) + +# acq = ct.acquisition() +# acq.setTriggerMode(Core.IntTrigMult) +# acq.setAcqNbFrames(3) +# acq.setAcqExpoTime(0.01) + +# ct.prepareAcq() +# for _ in range(3): +# time.sleep(0.1) +# ct.startAcq() +# # Make sure the detector is ready for next image +# while hw.getStatus().acq != Core.AcqReady: +# time.sleep(0.1) + +# while ct.getStatus().AcquisitionStatus != Core.AcqReady: +# time.sleep(0.1) + +# assert acq_status.last_image_ready == 2 diff --git a/test/test_api.py~Stashed changes b/test/test_api.py~Stashed changes new file mode 100644 index 0000000000000000000000000000000000000000..0ec0aa6657c5021c84d7fdca8559f25795f0eda4 --- /dev/null +++ b/test/test_api.py~Stashed changes @@ -0,0 +1,83 @@ +""" +This file can be used with `pytest`. + +The following way to execute the whole tests. +``` +pytest test/test.py +``` + +Or the following way to execute a single test. +``` +pytest test/test.py::test_internal_trigger +``` + +""" + +import time +import logging +from Lima import Core, Iris + + +_logger = logging.getLogger(__name__) + + +class AcquisitionStatusFromImageStatusCallback(Core.CtControl.ImageStatusCallback): + def __init__(self): + super().__init__() + self.last_base_image_ready = -1 + self.last_image_acquired = -1 + self.last_image_ready = -1 + self.last_image_saved = -1 + self.last_counter_ready = -1 + + def imageStatusChanged(self, image_status): + self.last_base_image_ready = image_status.LastBaseImageReady + self.last_image_acquired = image_status.LastImageAcquired + self.last_image_ready = image_status.LastImageReady + self.last_image_saved = image_status.LastImageSaved + self.last_counter_ready = image_status.LastCounterReady + + +def test_internal_trigger(): + # cam = Iris.Camera() + # hw = Iris.Interface(cam) + # ct = Core.CtControl(hw) + +# acq_status = AcquisitionStatusFromImageStatusCallback() +# ct.registerImageStatusCallback(acq_status) + +# ct.prepareAcq() +# ct.startAcq() + +# while ct.getStatus().AcquisitionStatus != Core.AcqReady: +# time.sleep(0.1) + +# assert acq_status.last_image_ready == 0 + assert True + + +#def test_internal_trigger_multi(): +# cam = Iris.Camera() +# hw = Iris.Interface(cam) +# ct = Core.CtControl(hw) + +# acq_status = AcquisitionStatusFromImageStatusCallback() +# ct.registerImageStatusCallback(acq_status) + +# acq = ct.acquisition() +# acq.setTriggerMode(Core.IntTrigMult) +# acq.setAcqNbFrames(3) +# acq.setAcqExpoTime(0.01) + +# ct.prepareAcq() +# for _ in range(3): +# time.sleep(0.1) +# ct.startAcq() +# # Make sure the detector is ready for next image +# while hw.getStatus().acq != Core.AcqReady: +# time.sleep(0.1) + +# while ct.getStatus().AcquisitionStatus != Core.AcqReady: +# time.sleep(0.1) + +# assert acq_status.last_image_ready == 2