Debian Codegraph @

src/ArvInterface.h

raw
1 /*
2 GigE interface wrapper on aravis
3 Copyright (C) 2016 Hendrik Beijeman ([email protected])
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 #ifndef CPP_ARV_IFACE_H
20 #define CPP_ARV_IFACE_H
21
22 #include <stdint.h>
23 #include <stddef.h>
24
25 namespace arv
26 {
27 typedef enum {
28 ARV_EXPOSURE_UNKNOWN = -1, //!< Unknown status?
29 ARV_EXPOSURE_FINISHED = 0, //!< Exposure has finished, image returned
30 ARV_EXPOSURE_BUSY, //!< Exposure is still ungoing
31 ARV_EXPOSURE_FILLING, //!< Exposure is finished, being transferred on the lower layer
32 ARV_EXPOSURE_FAILED, //!< Exposure has finished, with an error, no image returned.
33
34 } ARV_EXPOSURE_STATUS;
35
36 template <class T>
37 class min_max_property
38 {
39 public:
40 min_max_property() {}
41 min_max_property(T const min, T const max, T const val)
42 {
43 this->_min = min;
44 this->_max = max;
45 this->_val = val;
46 }
47
48 void update(T const min, T const max)
49 {
50 this->_min = min;
51 this->_max = max;
52 }
53
54 void set(T const new_val)
55 {
56 if (new_val > this->_max)
57 this->_val = this->_max;
58 else if (new_val < this->_min)
59 this->_val = this->_min;
60 else
61 this->_val = new_val;
62 }
63 void set_single(T const single_val) { this->_min = this->_max = this->_val = single_val; }
64
65 T val() { return this->_val; }
66 T min() { return this->_min; }
67 T max() { return this->_max; }
68
69 private:
70 T _min, _max, _val;
71 };
72
73 class ArvCamera
74 {
75 public:
76 ArvCamera(void *camera_device) {}
77 virtual bool connect() = 0;
78 virtual bool disconnect() = 0;
79 virtual bool is_connected() = 0;
80 virtual bool is_exposing() = 0;
81
82 /* Get properties */
83 virtual const char *vendor_name() = 0;
84 virtual const char *model_name() = 0;
85 virtual const char *device_id() = 0;
86 virtual int get_frame_byte_size() = 0;
87 virtual min_max_property<int> get_bin_x() = 0;
88 virtual min_max_property<int> get_bin_y() = 0;
89 virtual min_max_property<int> get_x_offset() = 0;
90 virtual min_max_property<int> get_y_offset() = 0;
91 virtual min_max_property<int> get_width() = 0;
92 virtual min_max_property<int> get_height() = 0;
93 virtual min_max_property<int> get_bpp() = 0;
94 virtual min_max_property<double> get_pixel_pitch() = 0;
95 virtual min_max_property<double> get_exposure() = 0;
96 virtual min_max_property<double> get_gain() = 0;
97 virtual min_max_property<double> get_frame_rate() = 0;
98
99 /* Set geometry */
100 virtual void set_bin(int const bin_x, int const bin_y) = 0;
101 virtual void set_geometry(int const x, int const y, int const w, int const h) = 0;
102 virtual void update_geometry(void) = 0;
103
104 /* Set exposure */
105 virtual void set_exposure_time(double const val) = 0;
106 virtual void set_gain(double const val) = 0;
107
108 virtual void exposure_start(void) = 0;
109 virtual void exposure_abort(void) = 0;
110 virtual ARV_EXPOSURE_STATUS exposure_poll(void (*fn_image_callback)(void *const, uint8_t const *const, size_t),
111 void *const) = 0;
112 };
113
114 class ArvFactory
115 {
116 public:
117 static ArvCamera *find_first_available(void);
118
119 //TODO: add iterative support to add all discovered cameras
120 };
121
122 } /* Namepsace */
123
124 #endif