cpp_api.rst 3.88 KB
Newer Older
1 2 3
C++ API
=======

Samuel Debionne's avatar
Samuel Debionne committed
4 5 6 7 8 9
Unfortunately very limited documentation is available from the source but that should improve over time.

User API
--------

In this section we cover the classes that defines the user interface.
10

11
Hello, Lima!
Samuel Debionne's avatar
Samuel Debionne committed
12
^^^^^^^^^^^^
13

Samuel Debionne's avatar
Samuel Debionne committed
14
Let's get started with a simple example of an image acquisition function using the simulator camera.
15 16 17

.. code-block:: c++

Samuel Debionne's avatar
Samuel Debionne committed
18
  // A camera instance and its hardware interface
19 20
  Simulator::Camera simu;
  Simulator::Interface hw(simu);
Samuel Debionne's avatar
Samuel Debionne committed
21 22

  // The control object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  CtControl ct = CtControl(&hw);

  // Get the saving control and set some properties
  CtSaving *save = ct.saving();
  save->setDirectory("./data");
  save->setPrefix("test_");
  save->setSuffix(".edf");
  save->setNextNumber(100);
  save->setFormat(CtSaving::EDF);
  save->setSavingMode(CtSaving::AutoFrame);
  save->setFramesPerFile(100);

  // Set the binning or any other processing
  Bin bin(2, 2);
  CtImage *image = ct.image();
  image->setBin(bin);

Samuel Debionne's avatar
Samuel Debionne committed
40
  // Get the acquisition control and set some properties
41 42 43 44 45
  CtAcquisition *acq = ct.acquisition();
  acq->setAcqMode(Single);
  acq->setAcqExpoTime(expo);
  acq->setAcqNbFrames(nframe);

Samuel Debionne's avatar
Samuel Debionne committed
46
  // Prepare acquisition (transfer properties to the camera)
47 48
  ct.prepareAcq();

Samuel Debionne's avatar
Samuel Debionne committed
49
  // Start acquisition
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
  ct.startAcq();
  std::cout << "SIMUTEST: acq started" << std::endl;

  //
  long frame = -1;
  while (frame < (nframe - 1))
  {
  	using namespace std::chrono;

  	high_resolution_clock::time_point begin = high_resolution_clock::now();

  	usleep(100000);

  	CtControl::ImageStatus img_status;
  	ct.getImageStatus(img_status);

  	high_resolution_clock::time_point end = high_resolution_clock::now();

  	auto duration = duration_cast<microseconds>(end - begin).count();

  	std::cout << "SIMUTEST: acq frame nr " << img_status.LastImageAcquired
  		<< " - saving frame nr " << img_status.LastImageSaved << std::endl;

  	if (frame != img_status.LastImageAcquired) {
  		unsigned int nb_frames = img_status.LastImageAcquired - frame;

  		std::cout << "  " << duration << " usec for " << nb_frames << " frames\n";
  		std::cout << "  " << 1e6 * nb_frames / duration << " fps" << std::endl;

  		frame = img_status.LastImageAcquired;
  	}
  }
  std::cout << "SIMUTEST: acq finished" << std::endl;

  // Stop acquisition ( not really necessary since all frames where acquired)
  ct.stopAcq();

  std::cout << "SIMUTEST: acq stopped" << std::endl;

Samuel Debionne's avatar
Samuel Debionne committed
89 90
Control Interfaces
^^^^^^^^^^^^^^^^^^
91

Samuel Debionne's avatar
Samuel Debionne committed
92
The control interface is the high level interface that controls an acquisition.
93 94 95 96

.. doxygenclass:: lima::CtControl
  :project: control
  :members:
Samuel Debionne's avatar
Samuel Debionne committed
97 98 99
  
Acquisition Interface
"""""""""""""""""""""
100 101 102 103 104

.. doxygenclass:: lima::CtAcquisition
  :project: control
  :members:

Samuel Debionne's avatar
Samuel Debionne committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
Saving Interface
""""""""""""""""

.. doxygenclass:: lima::CtSaving
  :project: control
  :members:
  
Image Interface
"""""""""""""""

.. doxygenclass:: lima::CtImage
  :project: control
  :members:
  
Shutter Interface
"""""""""""""""""

.. doxygenclass:: lima::CtShutter
  :project: control
124 125
  :members:

Samuel Debionne's avatar
Samuel Debionne committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
Buffer Interface
""""""""""""""""

.. doxygenclass:: lima::CtBuffer
  :project: control
  :members:
  
Statuses
^^^^^^^^

.. doxygenenum:: lima::AcqStatus
      :project: common

.. doxygenenum:: lima::DetStatus
    :project: common

Camera Plugin API
-----------------

Hardware Interface
^^^^^^^^^^^^^^^^^^

148 149 150
The Hardware Interface is the low level interface that must be implemented by detector plugins.

.. doxygenclass:: lima::HwInterface
151 152 153 154
  :project: hardware
  :members:

Capabilities interfaces
Samuel Debionne's avatar
Samuel Debionne committed
155
^^^^^^^^^^^^^^^^^^^^^^^
156 157 158 159 160 161 162 163 164 165 166 167 168

.. doxygenclass:: lima::HwDetInfoCtrlObj
  :project: hardware
  :members:

.. doxygenclass:: lima::HwBufferCtrlObj
  :project: hardware
  :members:

.. doxygenclass:: lima::HwSyncCtrlObj
  :project: hardware
  :members:

Samuel Debionne's avatar
Samuel Debionne committed
169 170 171 172 173 174 175
Callbacks
^^^^^^^^^

.. doxygenclass:: lima::HwFrameCallback
  :project: hardware
  :members:

176
Implementations Helpers
Samuel Debionne's avatar
Samuel Debionne committed
177
^^^^^^^^^^^^^^^^^^^^^^^
178 179 180 181

.. doxygenclass:: lima::SoftBufferCtrlObj
  :project: hardware
  :members: