Commit f5a8f74d authored by Samuel Debionne's avatar Samuel Debionne

Fix IntTrigMult trigger mode. Fix compilation on Windows. Rename Prepare...

Fix IntTrigMult trigger mode. Fix compilation on Windows. Rename Prepare status to Prepared. Fix doc. Add test for IntTrigMult.
parent 2d8c939b
......@@ -45,6 +45,7 @@ target_include_directories(lima${NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inclu
target_link_libraries(lima${NAME} limacore)
if(WIN32)
target_compile_definitions(lima${NAME} PUBLIC NOMINMAX)
target_compile_definitions(lima${NAME} PRIVATE LIBSIMULATOR_EXPORTS)
endif()
......
......@@ -47,7 +47,7 @@ The camera will be initialized within the :cpp:class:`Camera` object. The :cpp:f
This simulator plugin architecture is based on the :cpp:class:`FrameGetter` interface that have multiple implementations.
.. image:: https://yuml.me/diagram/scruffy/class/edit/Simulator%20Class%20Diagram,%20[FrameGetter%7CgetNextFrame()],%20[FrameGetter]%5E-[FrameBuilder],%20[FrameGetter]%5E-[FrameLoader]
.. image:: https://yuml.me/diagram/scruffy/class/Simulator%20Class%20Diagram,%20[FrameGetter%7CgetNextFrame()],%20[FrameGetter]%5E-[FrameBuilder],%20[FrameGetter]%5E-[FrameLoader]
The :cpp:class:`SimulatorCamera` class provides a specific member function :cpp:func:`SimulatorCamera::getFrameGetter()` that returns the :cpp:class:`FrameGetter` instance.
......@@ -113,7 +113,7 @@ For a quick test one can use the python binding, here is a short code example:
.. code-block:: python
from Lima import Simulator
from lima import Core
from Lima import Core
import time
def test_mode_generator(cam, nb_frames_prefetched = 0):
......
......@@ -113,7 +113,7 @@ class LIBSIMULATOR_API Camera
public:
enum { // Status
Ready = MaxThreadStatus,
Prepare,
Prepared,
Exposure,
Readout,
Latency,
......
......@@ -40,7 +40,7 @@ public:
MODE_LOADER_PREFETCH
};
Camera(const Mode& mode);
Camera(const Mode& mode = Simulator::Camera::Mode::MODE_GENERATOR);
~Camera();
HwBufferCtrlObj* getBufferCtrlObj();
......
......@@ -84,10 +84,11 @@ void Camera::SimuThread::execPrepareAcq()
DEB_MEMBER_FUNCT();
m_acq_frame_nb = 0;
setStatus(Prepare);
// Delegate to the frame getter that may need some preparation
m_simu->m_frame_getter->prepareAcq();
setStatus(Prepared);
}
void Camera::SimuThread::execStartAcq()
......@@ -304,7 +305,7 @@ HwInterface::StatusType::Basic Camera::getStatus()
int thread_status = m_thread.getStatus();
switch (thread_status) {
case SimuThread::Ready:
case SimuThread::Prepare:
case SimuThread::Prepared:
return HwInterface::StatusType::Ready;
case SimuThread::Exposure:
return HwInterface::StatusType::Exposure;
......@@ -321,25 +322,27 @@ void Camera::prepareAcq()
{
DEB_MEMBER_FUNCT();
if (m_thread.getStatus() == SimuThread::Prepare)
if (m_thread.getStatus() == SimuThread::Prepared)
return;
if (m_thread.getStatus() != SimuThread::Ready)
THROW_HW_ERROR(Error) << "Camera not Ready";
m_thread.sendCmd(SimuThread::PrepareAcq);
m_thread.waitStatus(SimuThread::Prepare);
m_thread.waitStatus(SimuThread::Prepared);
}
void Camera::startAcq()
{
DEB_MEMBER_FUNCT();
if (m_thread.getStatus() != SimuThread::Prepare)
THROW_HW_ERROR(Error) << "Camera not Prepared";
int status = m_thread.getStatus();
if (status != SimuThread::Prepared && status != SimuThread::Ready)
THROW_HW_ERROR(Error) << "Camera not Prepared and not Ready neither";
m_buffer_ctrl_obj.getBuffer().setStartTimestamp(Timestamp::now());
m_thread.sendCmd(SimuThread::StartAcq);
m_thread.waitNotStatus(SimuThread::Prepare);
m_thread.waitStatus(SimuThread::Exposure);
}
void Camera::stopAcq()
......
......@@ -76,8 +76,8 @@ void simulator_test(double expo, long nframe)
Simulator::Camera simu;
//config_loader(simu);
config_loader_prefetched(simu);
//config_generator(simu);
//config_loader_prefetched(simu);
config_generator(simu);
//config_generator_prefetched(simu);
Simulator::Interface hw(simu);
......@@ -138,7 +138,7 @@ void simulator_test(double expo, long nframe)
std::cout << " " << duration << " usec for " << nb_frames << " frames\n";
std::cout << " " << 1e6 * nb_frames / duration << " fps" << std::endl;
frame = img_status.LastImageAcquired;
frame = img_status.LastImageAcquired;
}
}
std::cout << "SIMUTEST: acq finished" << std::endl;
......@@ -154,6 +154,58 @@ void simulator_test(double expo, long nframe)
std::cout << "SIMUTEST: acq stopped" << std::endl;
}
void simulator_test_int_trig_mult(double expo, long nframe)
{
Simulator::Camera simu;
Simulator::Interface hw(simu);
CtControl ct = CtControl(&hw);
std::cout << "SIMUTEST: " << expo << " sec / " << nframe << " frames" << std::endl;
CtAcquisition *acq = ct.acquisition();
acq->setAcqMode(Single);
acq->setAcqExpoTime(expo);
acq->setAcqNbFrames(nframe);
acq->setTriggerMode(IntTrigMult);
ct.prepareAcq();
ct.startAcq();
std::cout << "SIMUTEST: acq started" << std::endl;
long frame = -1;
while (frame < (nframe - 1))
{
usleep(100000);
CtControl::ImageStatus img_status;
ct.getImageStatus(img_status);
CtControl::Status status;
ct.getStatus(status);
std::cout << "SIMUTEST: status " << status.AcquisitionStatus << std::endl;
if (frame != img_status.LastImageAcquired) {
if (frame < (nframe - 2))
ct.startAcq();
std::cout << "SIMUTEST: acq frame nr " << img_status.LastImageAcquired << std::endl;
frame = img_status.LastImageAcquired;
}
}
std::cout << "SIMUTEST: acq finished" << std::endl;
CtControl::Status status;
ct.getStatus(status);
std::cout << "SIMUTEST: status " << status << std::endl;
}
int main(int argc, char *argv[])
{
double expo;
......@@ -170,6 +222,7 @@ int main(int argc, char *argv[])
try {
simulator_test(expo, nframe);
simulator_test_int_trig_mult(expo, nframe);
}
catch (Exception e) {
std::cerr << "LIMA Exception:" << e.getErrMsg() << std::endl;
......
......@@ -30,6 +30,7 @@ extern "C"
int lima_import_array()
{
import_array();
return 0;
}
#else
void lima_import_array()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment