From f85327f951ad96a0fe41f473992d8f16cc2922cf Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 7 Aug 2012 16:12:03 +0200 Subject: First compiling version of dexela implementation. --- cmake/FindDEXELA.cmake | 19 +++++ src/CMakeLists.txt | 14 ++++ src/cameras/uca-dexela-camera.c | 164 ++++++++++++++++++++++++++++++++++++++++ src/cameras/uca-dexela-camera.h | 68 +++++++++++++++++ src/config.h.in | 1 + src/uca-camera.c | 7 ++ 6 files changed, 273 insertions(+) create mode 100644 cmake/FindDEXELA.cmake create mode 100644 src/cameras/uca-dexela-camera.c create mode 100644 src/cameras/uca-dexela-camera.h diff --git a/cmake/FindDEXELA.cmake b/cmake/FindDEXELA.cmake new file mode 100644 index 0000000..b343e14 --- /dev/null +++ b/cmake/FindDEXELA.cmake @@ -0,0 +1,19 @@ +# Try to find libdexela.so +# +# Defines +# +# DEXELA_FOUND - system has libdexela +# DEXELA_INCLUDE_DIRS - libdexela include directory +# DEXELA_LIBRARIES - dexela library + +find_package(PackageHandleStandardArgs) + +find_path(DEXELA_INCLUDE_DIRS dexela_api.h PATHS /root/Dexela/include) +find_library(DEXELA_LIBRARIES dexela PATHS /root/Dexela/dexela-spike) + +find_package_handle_standard_args(DEXELA DEFAULT_MSG DEXELA_LIBRARIES DEXELA_INCLUDE_DIRS) + +mark_as_advanced( + DEXELA_INCLUDE_DIRS + DEXELA_LIBRARIES +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9508c5c..94de82d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,7 @@ find_package(PCO) find_package(PF) find_package(IPE) find_package(Pylon) +find_package(DEXELA) # --- Find frame grabber interfaces find_package(FgLib5) @@ -103,7 +104,20 @@ if (PYLON_FOUND) include_directories(${LIBPYLONCAM_INCLUDEDIR}) link_directories(${LIBPYLONCAM_LIBDIR}) endif() +endif() + +if (DEXELA_FOUND) + option(HAVE_DEXELA_CL "Camera: CameraLink-based dexela detector" ON) + + if (HAVE_DEXELA_CL) + list(APPEND uca_SRCS cameras/uca-dexela-camera.c) + list(APPEND uca_HDRS cameras/uca-dexela-camera.h) + list(APPEND cameras "Ufo") + + set(uca_LIBS ${uca_LIBS} ${DEXELA_LIBRARIES}) + include_directories(${DEXELA_INCLUDE_DIRS}) + endif() endif() if (HAVE_MOCK_CAMERA) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c new file mode 100644 index 0000000..576c769 --- /dev/null +++ b/src/cameras/uca-dexela-camera.c @@ -0,0 +1,164 @@ +/* Copyright (C) 2011, 2012 Mihael Koep + (Softwareschneiderei GmbH) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2.1 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along + with this library; if not, write to the Free Software Foundation, Inc., 51 + Franklin St, Fifth Floor, Boston, MA 02110, USA */ + +#include "uca-camera.h" +#include "uca-dexela-camera.h" +#include "uca-enums.h" + +#define UCA_DEXELA_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraPrivate)) + +G_DEFINE_TYPE(UcaDexelaCamera, uca_dexela_camera, UCA_TYPE_CAMERA) +/** + * UcaDexelaCameraError: + * @UCA_DEXELA_CAMERA_ERROR_LIBPCO_INIT: Initializing libdexela failed + */ +GQuark uca_pco_camera_error_quark() +{ + return g_quark_from_static_string("uca-dexela-camera-error-quark"); +} + +enum { + PROP_SENSOR_EXTENDED = N_BASE_PROPERTIES, + N_PROPERTIES +}; + +static gint base_overrideables[] = { + PROP_NAME, + PROP_SENSOR_WIDTH, + PROP_SENSOR_HEIGHT, + PROP_SENSOR_BITDEPTH, + PROP_SENSOR_HORIZONTAL_BINNING, + PROP_SENSOR_HORIZONTAL_BINNINGS, + PROP_SENSOR_VERTICAL_BINNING, + PROP_SENSOR_VERTICAL_BINNINGS, + PROP_SENSOR_MAX_FRAME_RATE, + PROP_EXPOSURE_TIME, + PROP_TRIGGER_MODE, + PROP_ROI_X, + PROP_ROI_Y, + PROP_ROI_WIDTH, + PROP_ROI_HEIGHT, + PROP_ROI_WIDTH_MULTIPLIER, + PROP_ROI_HEIGHT_MULTIPLIER, + PROP_HAS_STREAMING, + PROP_HAS_CAMRAM_RECORDING, + 0 +}; + +static GParamSpec *dexela_properties[N_PROPERTIES] = { NULL, }; + +struct _UcaDexelaCameraPrivate { +}; + +UcaDexelaCamera *uca_dexela_camera_new(GError **error) +{ + UcaDexelaCamera *camera = g_object_new(UCA_TYPE_DEXELA_CAMERA, NULL); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); + /* + * Here we override property ranges because we didn't know them at property + * installation time. + */ + GObjectClass *camera_class = G_OBJECT_CLASS (UCA_CAMERA_GET_CLASS (camera)); + return camera; +} + +static void uca_dexela_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + + switch (property_id) { + case PROP_EXPOSURE_TIME: + { + // TODO set exposure time + + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + return; + } +} + +static void uca_dexela_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + + switch (property_id) { + case PROP_EXPOSURE_TIME: + { + // TODO read exposure time + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + break; + } +} + +static void uca_dexela_camera_start_recording(UcaCamera *camera, GError **error) +{ +} + +static void uca_dexela_camera_stop_recording(UcaCamera *camera, GError **error) +{ +} + +static void uca_dexela_camera_start_readout(UcaCamera *camera, GError **error) +{ +} + +static void uca_dexela_camera_trigger(UcaCamera *camera, GError **error) +{ +} + +static void uca_dexela_camera_grab(UcaCamera *camera, gpointer *data, GError **error) +{ +} + +static void uca_dexela_camera_finalize(GObject *object) +{ + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + G_OBJECT_CLASS(uca_dexela_camera_parent_class)->finalize(object); +} + +static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + gobject_class->set_property = uca_dexela_camera_set_property; + gobject_class->get_property = uca_dexela_camera_get_property; + gobject_class->finalize = uca_dexela_camera_finalize; + + UcaCameraClass *camera_class = UCA_CAMERA_CLASS(klass); + camera_class->start_recording = uca_dexela_camera_start_recording; + camera_class->stop_recording = uca_dexela_camera_stop_recording; + camera_class->start_readout = uca_dexela_camera_start_readout; + camera_class->trigger = uca_dexela_camera_trigger; + camera_class->grab = uca_dexela_camera_grab; + + for (guint i = 0; base_overrideables[i] != 0; i++) + g_object_class_override_property(gobject_class, base_overrideables[i], uca_camera_props[base_overrideables[i]]); + + for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) { + g_object_class_install_property(gobject_class, id, dexela_properties[id]); + } + g_type_class_add_private(klass, sizeof(UcaDexelaCameraPrivate)); +} + +static void uca_dexela_camera_init(UcaDexelaCamera *self) +{ + self->priv = UCA_DEXELA_CAMERA_GET_PRIVATE(self); +} diff --git a/src/cameras/uca-dexela-camera.h b/src/cameras/uca-dexela-camera.h new file mode 100644 index 0000000..9badf10 --- /dev/null +++ b/src/cameras/uca-dexela-camera.h @@ -0,0 +1,68 @@ +/* Copyright (C) 2011, 2012 Mihael Koep + (Softwareschneiderei GmbH) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2.1 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along + with this library; if not, write to the Free Software Foundation, Inc., 51 + Franklin St, Fifth Floor, Boston, MA 02110, USA */ + +#ifndef __UCA_DEXELA_CAMERA_H +#define __UCA_DEXELA_CAMERA_H + +#include +#include "uca-camera.h" + +#define UCA_TYPE_DEXELA_CAMERA (uca_dexela_camera_get_type()) +#define UCA_DEXELA_CAMERA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCamera)) +#define UCA_IS_DEXELA_CAMERA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UCA_TYPE_DEXELA_CAMERA)) +#define UCA_DEXELA_CAMERA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraClass)) +#define UCA_IS_DEXELA_CAMERA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UCA_TYPE_DEXELA_CAMERA)) +#define UCA_DEXELA_CAMERA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraClass)) + +#define UCA_DEXELA_CAMERA_ERROR uca_dexela_camera_error_quark() +typedef enum { + UCA_DEXELA_CAMERA_ERROR_LIBPCO_INIT, +} UcaDexelaCameraError; + +typedef struct _UcaDexelaCamera UcaDexelaCamera; +typedef struct _UcaDexelaCameraClass UcaDexelaCameraClass; +typedef struct _UcaDexelaCameraPrivate UcaDexelaCameraPrivate; + +/** + * UcaDexelaCamera: + * + * Creates #UcaDexelaCamera instances by loading corresponding shared objects. The + * contents of the #UcaDexelaCamera structure are private and should only be + * accessed via the provided API. + */ +struct _UcaDexelaCamera { + /*< private >*/ + UcaCamera parent; + + UcaDexelaCameraPrivate *priv; +}; + +/** + * UcaDexelaCameraClass: + * + * #UcaDexelaCamera class + */ +struct _UcaDexelaCameraClass { + /*< private >*/ + UcaCameraClass parent; +}; + +UcaDexelaCamera *uca_dexela_camera_new(GError **error); + +GType uca_dexela_camera_get_type(void); + +#endif diff --git a/src/config.h.in b/src/config.h.in index e3911a1..ec1fb62 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -3,6 +3,7 @@ #cmakedefine HAVE_PHOTRON_FASTCAM #cmakedefine HAVE_UFO_CAMERA #cmakedefine HAVE_PYLON_CAMERA +#cmakedefine HAVE_DEXELA_CL #cmakedefine HAVE_MOCK_CAMERA #define CONTROL_GLADE_PATH "${CMAKE_INSTALL_PREFIX}/share/libuca/control.glade" diff --git a/src/uca-camera.c b/src/uca-camera.c index 78adae3..6b4b9f1 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -40,6 +40,10 @@ #include "cameras/uca-pf-camera.h" #endif +#ifdef HAVE_DEXELA_CL +#include "cameras/uca-dexela-camera.h" +#endif + #define UCA_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_CAMERA, UcaCameraPrivate)) G_DEFINE_TYPE(UcaCamera, uca_camera, G_TYPE_OBJECT) @@ -80,6 +84,9 @@ static gchar *uca_camera_types[] = { #endif #ifdef HAVE_PHOTON_FOCUS "pf", +#endif +#ifdef HAVE_DEXELA_CL + "dexela", #endif NULL }; -- cgit v1.2.3 From a741bab1373beb5bef1d7028870af5ae7d493558 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 7 Aug 2012 17:30:39 +0200 Subject: Fix indentation and implement the name property. --- src/cameras/uca-dexela-camera.c | 49 +++++++++++++++++++++++++---------------- src/uca-camera.c | 5 +++++ 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 576c769..ba4aea0 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -18,6 +18,8 @@ #include "uca-camera.h" #include "uca-dexela-camera.h" #include "uca-enums.h" +#include "dexela_api.h" +#include "dexela_lowlevel.h" #define UCA_DEXELA_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraPrivate)) @@ -32,8 +34,7 @@ GQuark uca_pco_camera_error_quark() } enum { - PROP_SENSOR_EXTENDED = N_BASE_PROPERTIES, - N_PROPERTIES + N_PROPERTIES = N_BASE_PROPERTIES, }; static gint base_overrideables[] = { @@ -67,26 +68,29 @@ struct _UcaDexelaCameraPrivate { UcaDexelaCamera *uca_dexela_camera_new(GError **error) { UcaDexelaCamera *camera = g_object_new(UCA_TYPE_DEXELA_CAMERA, NULL); - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); + //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); /* - * Here we override property ranges because we didn't know them at property - * installation time. - */ + * Here we override property ranges because we didn't know them at property + * installation time. + */ GObjectClass *camera_class = G_OBJECT_CLASS (UCA_CAMERA_GET_CLASS (camera)); + // TODO implement error checking + openDetector(); + initSerialConnection(); return camera; } static void uca_dexela_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); switch (property_id) { case PROP_EXPOSURE_TIME: - { - // TODO set exposure time - - } - break; + { + // TODO set exposure time + + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); return; @@ -95,13 +99,20 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c static void uca_dexela_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); switch (property_id) { + case PROP_NAME: + { + gchar* model = getModel(); + g_value_set_string(value, g_strdup_printf("Dexela %s", model)); + g_free(model); + break; + } case PROP_EXPOSURE_TIME: { - // TODO read exposure time - } + // TODO read exposure time + } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); @@ -131,7 +142,7 @@ static void uca_dexela_camera_grab(UcaCamera *camera, gpointer *data, GError **e static void uca_dexela_camera_finalize(GObject *object) { - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); G_OBJECT_CLASS(uca_dexela_camera_parent_class)->finalize(object); } @@ -154,11 +165,11 @@ static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) { g_object_class_install_property(gobject_class, id, dexela_properties[id]); - } - g_type_class_add_private(klass, sizeof(UcaDexelaCameraPrivate)); + } + //g_type_class_add_private(klass, sizeof(UcaDexelaCameraPrivate)); } static void uca_dexela_camera_init(UcaDexelaCamera *self) { - self->priv = UCA_DEXELA_CAMERA_GET_PRIVATE(self); + //self->priv = UCA_DEXELA_CAMERA_GET_PRIVATE(self); } diff --git a/src/uca-camera.c b/src/uca-camera.c index 6b4b9f1..d9d2d6a 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -404,6 +404,11 @@ static UcaCamera *uca_camera_new_from_type(const gchar *type, GError **error) return UCA_CAMERA(uca_pf_camera_new(error)); #endif +#ifdef HAVE_DEXELA_CL + if (!g_strcmp0(type, "dexela")) + return UCA_CAMERA(uca_dexela_camera_new(error)); +#endif + return NULL; } -- cgit v1.2.3 From 4b5340396590f499e3759b1e10e73a334e48a2fd Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 9 Aug 2012 12:04:21 +0200 Subject: Add ignore file. --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..60578cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +CMake* +*~ +*.cmake +Makefile +src/libuca.so* -- cgit v1.2.3 From b8679d1f1aca80f39fbb399151f9b8ac904a0be0 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 28 Aug 2012 17:47:23 +0200 Subject: fix detection of libdexela. --- cmake/FindDEXELA.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/FindDEXELA.cmake b/cmake/FindDEXELA.cmake index b343e14..1fef7af 100644 --- a/cmake/FindDEXELA.cmake +++ b/cmake/FindDEXELA.cmake @@ -8,8 +8,8 @@ find_package(PackageHandleStandardArgs) -find_path(DEXELA_INCLUDE_DIRS dexela_api.h PATHS /root/Dexela/include) -find_library(DEXELA_LIBRARIES dexela PATHS /root/Dexela/dexela-spike) +find_path(DEXELA_INCLUDE_DIRS dexela_api.h PATHS /usr/include) +find_library(DEXELA_LIBRARIES dexela) find_package_handle_standard_args(DEXELA DEFAULT_MSG DEXELA_LIBRARIES DEXELA_INCLUDE_DIRS) -- cgit v1.2.3 From c4f4ad5883e2305b252cfa5bdc585d105b8934e7 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 28 Aug 2012 17:50:52 +0200 Subject: make dexela part compile again. --- src/cameras/uca-dexela-camera.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index ba4aea0..ccba1c3 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -19,7 +19,6 @@ #include "uca-dexela-camera.h" #include "uca-enums.h" #include "dexela_api.h" -#include "dexela_lowlevel.h" #define UCA_DEXELA_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraPrivate)) @@ -75,7 +74,7 @@ UcaDexelaCamera *uca_dexela_camera_new(GError **error) */ GObjectClass *camera_class = G_OBJECT_CLASS (UCA_CAMERA_GET_CLASS (camera)); // TODO implement error checking - openDetector(); + openDetector("/usr/share/dexela/dexela-1207_32.fmt"); initSerialConnection(); return camera; } -- cgit v1.2.3 From 363836b468a296771b77f122740ea8ef0498dbe2 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 4 Sep 2012 11:49:47 +0200 Subject: Minor cleanup to trigger the build for testing our generic commit hook... --- src/cameras/uca-dexela-camera.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index ccba1c3..50bd385 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -87,7 +87,6 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c case PROP_EXPOSURE_TIME: { // TODO set exposure time - } break; default: -- cgit v1.2.3 From 6e5eed16048cc25ec1346c1398516f8d9fe3c028 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 4 Sep 2012 11:54:02 +0200 Subject: Minor reformatting to trigger the build for testing our generic commit hook... --- src/cameras/uca-dexela-camera.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 50bd385..a254989 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -108,13 +108,15 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G break; } case PROP_EXPOSURE_TIME: - { - // TODO read exposure time - } + { + // TODO read exposure time break; + } default: + { G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; + } } } -- cgit v1.2.3 From 26a14d07343ce6285a29c0005c50f056c9986d35 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 4 Sep 2012 14:41:25 +0200 Subject: Ignore some generated files. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 60578cb..8bea720 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ CMake* *.cmake Makefile src/libuca.so* +test/ +libuca.spec +src/config.h -- cgit v1.2.3 From c45a310216bc28a567195ebcc71d9e1cf0f16ba1 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 4 Sep 2012 14:41:45 +0200 Subject: Fix the dexela error quark. --- src/cameras/uca-dexela-camera.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index a254989..b68f40e 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -25,9 +25,9 @@ G_DEFINE_TYPE(UcaDexelaCamera, uca_dexela_camera, UCA_TYPE_CAMERA) /** * UcaDexelaCameraError: - * @UCA_DEXELA_CAMERA_ERROR_LIBPCO_INIT: Initializing libdexela failed + * @UCA_DEXELA_CAMERA_ERROR_LIBDEXELA_INIT: Initializing libdexela failed */ -GQuark uca_pco_camera_error_quark() +GQuark uca_dexela_camera_error_quark() { return g_quark_from_static_string("uca-dexela-camera-error-quark"); } -- cgit v1.2.3 From 2fad826eb9b5ca6a2825193e864545e2d4976966 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 4 Sep 2012 16:07:09 +0200 Subject: Implement 64bit detection for install directory of libuca. --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ade68ad..4f7ef43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket") set(CPACK_GENERATOR "DEB;RPM;") -set(CPACK_PACKAGE_RELEASE 3) +set(CPACK_PACKAGE_RELEASE 4) set(CPACK_DEBIAN_PACKAGE_NAME "libuca") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Matthias Vogelgesang ") set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${UCA_DESCRIPTION}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 94de82d..c318d52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -264,7 +264,12 @@ endif() # --- Install target ---------------------------------------------------------- -set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}") +# check for 64 bit +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(LIB_INSTALL_DIR "lib64") +else() + set(LIB_INSTALL_DIR "lib") +endif() install(TARGETS uca LIBRARY DESTINATION ${LIB_INSTALL_DIR}) -- cgit v1.2.3 From 7122b2c6fd1ae34438d019c72c10ec84776171d6 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 6 Sep 2012 18:02:10 +0200 Subject: Implement exposure time property. --- src/cameras/uca-dexela-camera.c | 44 +++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index b68f40e..14d7899 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -79,22 +79,6 @@ UcaDexelaCamera *uca_dexela_camera_new(GError **error) return camera; } -static void uca_dexela_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); - - switch (property_id) { - case PROP_EXPOSURE_TIME: - { - // TODO set exposure time - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - return; - } -} - static void uca_dexela_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); @@ -109,7 +93,7 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G } case PROP_EXPOSURE_TIME: { - // TODO read exposure time + g_value_set_double(value, getExposureTimeMicros() / 10e6d); break; } default: @@ -120,24 +104,46 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G } } +static void uca_dexela_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + + switch (property_id) { + case PROP_EXPOSURE_TIME: + { + const gdouble exposureTimeInSeconds = g_value_get_double(value); + setExposureTimeMicros(exposureTimeInSeconds * 10e6d); + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + return; + } +} + static void uca_dexela_camera_start_recording(UcaCamera *camera, GError **error) { + g_debug("start recording called"); } static void uca_dexela_camera_stop_recording(UcaCamera *camera, GError **error) { + g_debug("stop recording called"); } static void uca_dexela_camera_start_readout(UcaCamera *camera, GError **error) { + g_debug("start readout called"); } static void uca_dexela_camera_trigger(UcaCamera *camera, GError **error) { + g_debug("trigger called"); } static void uca_dexela_camera_grab(UcaCamera *camera, gpointer *data, GError **error) { + g_debug("grab called"); } static void uca_dexela_camera_finalize(GObject *object) @@ -160,9 +166,9 @@ static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) camera_class->trigger = uca_dexela_camera_trigger; camera_class->grab = uca_dexela_camera_grab; - for (guint i = 0; base_overrideables[i] != 0; i++) + for (guint i = 0; base_overrideables[i] != 0; i++) { g_object_class_override_property(gobject_class, base_overrideables[i], uca_camera_props[base_overrideables[i]]); - + } for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) { g_object_class_install_property(gobject_class, id, dexela_properties[id]); } -- cgit v1.2.3 From 4ee0daf9be362d25a4fde1ff9859197be9ce8c02 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 6 Sep 2012 18:08:32 +0200 Subject: Standardize package naming. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c318d52..ff9108e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -314,7 +314,7 @@ set(CPACK_GENERATOR "DEB;RPM;") set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_IGNORE_FILES ".git" "tags" ".bzr" ".swp") set(CPACK_SOURCE_PACKAGE_FILE_NAME "libuca-${UCA_VERSION_STRING}" CACHE INTERNAL "tarball basename") -set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${UCA_VERSION_STRING}-${CMAKE_SYSTEM_PROCESSOR}") +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${UCA_VERSION_STRING}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../libuca.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/../libuca.spec" @ONLY IMMEDIATE) -- cgit v1.2.3 From 484a45bbebf1a5beebe6619bab8099758d1c0fc5 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Wed, 12 Sep 2012 17:43:00 +0200 Subject: Implement sensor width, height, bit depth and binning properties. --- src/cameras/uca-dexela-camera.c | 113 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 105 insertions(+), 8 deletions(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 14d7899..ca6781b 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -61,13 +61,45 @@ static gint base_overrideables[] = { static GParamSpec *dexela_properties[N_PROPERTIES] = { NULL, }; +static const gdouble MICROS_TO_SECONDS_FACTOR = 10e6d; + struct _UcaDexelaCameraPrivate { + GValueArray *binnings; }; +/** + * Hardcode possible binnings for now + */ +static void fill_binnings(UcaDexelaCameraPrivate *priv) +{ + GValue val = {0}; + g_value_init(&val, G_TYPE_UINT); + + priv->binnings = g_value_array_new(3); + g_value_set_uint(&val, 1); + g_value_array_append(priv->binnings, &val); + g_value_set_uint(&val, 2); + g_value_array_append(priv->binnings, &val); + g_value_set_uint(&val, 4); + g_value_array_append(priv->binnings, &val); +} + +static gboolean is_binning_allowed(UcaDexelaCameraPrivate *priv, guint binning) +{ + for (int i = 0; i < priv->binnings->n_values; i++) { + guint allowedBinning = g_value_get_uint(g_value_array_get_nth(priv->binnings, i)); + if (binning == allowedBinning) { + return TRUE; + } + } + return FALSE; +} + UcaDexelaCamera *uca_dexela_camera_new(GError **error) { UcaDexelaCamera *camera = g_object_new(UCA_TYPE_DEXELA_CAMERA, NULL); - //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); + fill_binnings(priv); /* * Here we override property ranges because we didn't know them at property * installation time. @@ -81,7 +113,7 @@ UcaDexelaCamera *uca_dexela_camera_new(GError **error) static void uca_dexela_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); switch (property_id) { case PROP_NAME: @@ -93,7 +125,52 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G } case PROP_EXPOSURE_TIME: { - g_value_set_double(value, getExposureTimeMicros() / 10e6d); + g_value_set_double(value, getExposureTimeMicros() / MICROS_TO_SECONDS_FACTOR); + break; + } + case PROP_HAS_CAMRAM_RECORDING: + { + g_value_set_boolean(value, FALSE); + break; + } + case PROP_HAS_STREAMING: + { + g_value_set_boolean(value, FALSE); + break; + } + case PROP_SENSOR_BITDEPTH: + { + g_value_set_uint(value, getBitDepth()); + break; + } + case PROP_SENSOR_WIDTH: + { + g_value_set_uint(value, getWidth()); + break; + } + case PROP_SENSOR_HEIGHT: + { + g_value_set_uint(value, getHeight()); + break; + } + case PROP_SENSOR_HORIZONTAL_BINNING: + { + g_value_set_uint(value, getBinningModeHorizontal()); + break; + } + case PROP_SENSOR_HORIZONTAL_BINNINGS: + { + g_value_set_boxed(value, priv->binnings); + break; + } + case PROP_SENSOR_VERTICAL_BINNING: + { + g_value_set_uint(value, getBinningModeVertical()); + break; + } + case PROP_SENSOR_VERTICAL_BINNINGS: + { + g_value_set_boxed(value, priv->binnings); break; } default: @@ -106,15 +183,35 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G static void uca_dexela_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); switch (property_id) { case PROP_EXPOSURE_TIME: { const gdouble exposureTimeInSeconds = g_value_get_double(value); - setExposureTimeMicros(exposureTimeInSeconds * 10e6d); + setExposureTimeMicros(exposureTimeInSeconds * MICROS_TO_SECONDS_FACTOR); + break; + } + case PROP_SENSOR_HORIZONTAL_BINNING: + { + const guint horizontalBinning = g_value_get_uint(value); + if (!is_binning_allowed(priv, horizontalBinning)) { + g_warning("Tried to set illegal horizontal binning: %d", horizontalBinning); + return; + } + setBinningMode(horizontalBinning, getBinningModeVertical()); + break; + } + case PROP_SENSOR_VERTICAL_BINNING: + { + const guint verticalBinning = g_value_get_uint(value); + if (!is_binning_allowed(priv, verticalBinning)) { + g_warning("Tried to set illegal vertical binning: %d", verticalBinning); + return; + } + setBinningMode(getBinningModeHorizontal(), verticalBinning); + break; } - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); return; @@ -172,10 +269,10 @@ static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) { g_object_class_install_property(gobject_class, id, dexela_properties[id]); } - //g_type_class_add_private(klass, sizeof(UcaDexelaCameraPrivate)); + g_type_class_add_private(klass, sizeof(UcaDexelaCameraPrivate)); } static void uca_dexela_camera_init(UcaDexelaCamera *self) { - //self->priv = UCA_DEXELA_CAMERA_GET_PRIVATE(self); + self->priv = UCA_DEXELA_CAMERA_GET_PRIVATE(self); } -- cgit v1.2.3 From 4f04ef64bf8c737b68500ecc8a72f4a374315abc Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Wed, 12 Sep 2012 17:59:05 +0200 Subject: Start implementing gain property. --- src/cameras/uca-dexela-camera.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index ca6781b..436bea6 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -33,7 +33,8 @@ GQuark uca_dexela_camera_error_quark() } enum { - N_PROPERTIES = N_BASE_PROPERTIES, + PROP_GAIN_MODE = N_BASE_PROPERTIES, + N_PROPERTIES }; static gint base_overrideables[] = { @@ -173,6 +174,10 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G g_value_set_boxed(value, priv->binnings); break; } + case PROP_SENSOR_MAX_FRAME_RATE: + // TODO: we do not know how to compute the correct value, so just return 0 for now + g_value_set_float(value, 0.0f); + break; default: { G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); @@ -266,6 +271,11 @@ static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) for (guint i = 0; base_overrideables[i] != 0; i++) { g_object_class_override_property(gobject_class, base_overrideables[i], uca_camera_props[base_overrideables[i]]); } + dexela_properties[PROP_GAIN_MODE] = + g_param_spec_uint("gain-mode", + "High or Low Full Well", + "High (1) or Low (0) Full Well", + 0, 1, 0, G_PARAM_READWRITE); for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) { g_object_class_install_property(gobject_class, id, dexela_properties[id]); } -- cgit v1.2.3 From 12a110995cd7d5aeffe363ca8dfbe5c4f7be0de0 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 13 Sep 2012 12:00:03 +0200 Subject: Implement gain and trigger mode properties. --- src/cameras/uca-dexela-camera.c | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 436bea6..52b8b47 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -85,6 +85,41 @@ static void fill_binnings(UcaDexelaCameraPrivate *priv) g_value_array_append(priv->binnings, &val); } +static void map_dexela_trigger_mode_to_uca(GValue* value, TriggerMode mode) +{ + if (mode == SOFTWARE) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_INTERNAL); + return; + } + if (mode == EDGE) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_EXTERNAL); + return; + } + // XXX: this mapping is only a hack/guess + if (mode == DURATION) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_AUTO); + return; + } + g_warning("Unsupported dexela trigger mode: %d", mode); +} + +static void set_trigger_mode(UcaCameraTrigger mode) +{ + if (mode == UCA_CAMERA_TRIGGER_INTERNAL) { + setTriggerMode(SOFTWARE); + return; + } + if (mode == UCA_CAMERA_TRIGGER_EXTERNAL) { + setTriggerMode(EDGE); + return; + } + if (mode == UCA_CAMERA_TRIGGER_AUTO) { + setTriggerMode(DURATION); + return; + } + g_warning("Unsupported uca trigger mode: %d", mode); +} + static gboolean is_binning_allowed(UcaDexelaCameraPrivate *priv, guint binning) { for (int i = 0; i < priv->binnings->n_values; i++) { @@ -175,9 +210,21 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G break; } case PROP_SENSOR_MAX_FRAME_RATE: + { // TODO: we do not know how to compute the correct value, so just return 0 for now g_value_set_float(value, 0.0f); break; + } + case PROP_GAIN_MODE: + { + g_value_set_uint(value, getGain()); + break; + } + case PROP_TRIGGER_MODE: + { + map_dexela_trigger_mode_to_uca(value, getTriggerMode()); + break; + } default: { G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); @@ -217,6 +264,25 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c setBinningMode(getBinningModeHorizontal(), verticalBinning); break; } + case PROP_GAIN_MODE: + { + const guint gain = g_value_get_uint(value); + if (gain == 0) { + setGain(LOW); + return; + } + if (gain == 1) { + setGain(HIGH); + return; + } + g_warning("Illegal attempt to set gain: %d", gain); + break; + } + case PROP_TRIGGER_MODE: + { + set_trigger_mode(g_value_get_enum(value)); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); return; -- cgit v1.2.3 From 39ac718975bfa7ef4ccf9b9fb2e85aed4f32ea34 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 13 Sep 2012 17:08:42 +0200 Subject: Work on acquisition. --- src/cameras/uca-dexela-camera.c | 42 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 52b8b47..53c59c1 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -66,6 +66,10 @@ static const gdouble MICROS_TO_SECONDS_FACTOR = 10e6d; struct _UcaDexelaCameraPrivate { GValueArray *binnings; + guint width; + guint height; + guint bits; + gsize num_bytes; }; /** @@ -144,6 +148,10 @@ UcaDexelaCamera *uca_dexela_camera_new(GError **error) // TODO implement error checking openDetector("/usr/share/dexela/dexela-1207_32.fmt"); initSerialConnection(); + priv->bits = getBitDepth(); + priv->width = getWidth(); + priv->height = getHeight(); + priv->num_bytes = 2; return camera; } @@ -176,17 +184,17 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G } case PROP_SENSOR_BITDEPTH: { - g_value_set_uint(value, getBitDepth()); + g_value_set_uint(value, priv->bits); break; } case PROP_SENSOR_WIDTH: { - g_value_set_uint(value, getWidth()); + g_value_set_uint(value, priv->width); break; } case PROP_SENSOR_HEIGHT: { - g_value_set_uint(value, getHeight()); + g_value_set_uint(value, priv->height); break; } case PROP_SENSOR_HORIZONTAL_BINNING: @@ -292,31 +300,35 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c static void uca_dexela_camera_start_recording(UcaCamera *camera, GError **error) { g_debug("start recording called"); + dexela_start_acquisition(); } static void uca_dexela_camera_stop_recording(UcaCamera *camera, GError **error) { g_debug("stop recording called"); -} - -static void uca_dexela_camera_start_readout(UcaCamera *camera, GError **error) -{ - g_debug("start readout called"); -} - -static void uca_dexela_camera_trigger(UcaCamera *camera, GError **error) -{ - g_debug("trigger called"); + dexela_stop_acquisition(); } static void uca_dexela_camera_grab(UcaCamera *camera, gpointer *data, GError **error) { g_debug("grab called"); + g_return_if_fail(UCA_IS_DEXELA_CAMERA(camera)); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); + g_debug("Data-pointer: %p, %p", data, *data); + if (*data == NULL) { + g_debug("Allocating buffer"); + *data = g_malloc0(priv->width * priv->height * priv->num_bytes); + } + // TODO: fetch image from libdexela + // TODO: copy to the data buffer + memcpy((gchar *) *data, dexela_grab(), priv->width * priv->height * priv->num_bytes); } static void uca_dexela_camera_finalize(GObject *object) { - //UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + g_value_array_free(priv->binnings); + G_OBJECT_CLASS(uca_dexela_camera_parent_class)->finalize(object); } @@ -330,8 +342,6 @@ static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) UcaCameraClass *camera_class = UCA_CAMERA_CLASS(klass); camera_class->start_recording = uca_dexela_camera_start_recording; camera_class->stop_recording = uca_dexela_camera_stop_recording; - camera_class->start_readout = uca_dexela_camera_start_readout; - camera_class->trigger = uca_dexela_camera_trigger; camera_class->grab = uca_dexela_camera_grab; for (guint i = 0; base_overrideables[i] != 0; i++) { -- cgit v1.2.3 From 77516f3ec1403c7b2beaf8d5a998472faec7d553 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 13 Sep 2012 17:37:36 +0200 Subject: Adapt to new libdexela interface. --- src/cameras/uca-dexela-camera.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 53c59c1..4671168 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -110,15 +110,15 @@ static void map_dexela_trigger_mode_to_uca(GValue* value, TriggerMode mode) static void set_trigger_mode(UcaCameraTrigger mode) { if (mode == UCA_CAMERA_TRIGGER_INTERNAL) { - setTriggerMode(SOFTWARE); + dexela_set_trigger_mode(SOFTWARE); return; } if (mode == UCA_CAMERA_TRIGGER_EXTERNAL) { - setTriggerMode(EDGE); + dexela_set_trigger_mode(EDGE); return; } if (mode == UCA_CAMERA_TRIGGER_AUTO) { - setTriggerMode(DURATION); + dexela_set_trigger_mode(DURATION); return; } g_warning("Unsupported uca trigger mode: %d", mode); @@ -146,11 +146,11 @@ UcaDexelaCamera *uca_dexela_camera_new(GError **error) */ GObjectClass *camera_class = G_OBJECT_CLASS (UCA_CAMERA_GET_CLASS (camera)); // TODO implement error checking - openDetector("/usr/share/dexela/dexela-1207_32.fmt"); - initSerialConnection(); - priv->bits = getBitDepth(); - priv->width = getWidth(); - priv->height = getHeight(); + dexela_open_detector("/usr/share/dexela/dexela-1207_32.fmt"); + dexela_init_serial_connection(); + priv->bits = dexela_get_bit_depth(); + priv->width = dexela_get_width(); + priv->height = dexela_get_height(); priv->num_bytes = 2; return camera; } @@ -162,14 +162,14 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G switch (property_id) { case PROP_NAME: { - gchar* model = getModel(); + gchar* model = dexela_get_model(); g_value_set_string(value, g_strdup_printf("Dexela %s", model)); g_free(model); break; } case PROP_EXPOSURE_TIME: { - g_value_set_double(value, getExposureTimeMicros() / MICROS_TO_SECONDS_FACTOR); + g_value_set_double(value, dexela_get_exposure_time_micros() / MICROS_TO_SECONDS_FACTOR); break; } case PROP_HAS_CAMRAM_RECORDING: @@ -199,7 +199,7 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G } case PROP_SENSOR_HORIZONTAL_BINNING: { - g_value_set_uint(value, getBinningModeHorizontal()); + g_value_set_uint(value, dexela_get_binning_mode_horizontal()); break; } case PROP_SENSOR_HORIZONTAL_BINNINGS: @@ -209,7 +209,7 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G } case PROP_SENSOR_VERTICAL_BINNING: { - g_value_set_uint(value, getBinningModeVertical()); + g_value_set_uint(value, dexela_get_binning_mode_vertical()); break; } case PROP_SENSOR_VERTICAL_BINNINGS: @@ -225,12 +225,12 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G } case PROP_GAIN_MODE: { - g_value_set_uint(value, getGain()); + g_value_set_uint(value, dexela_get_gain()); break; } case PROP_TRIGGER_MODE: { - map_dexela_trigger_mode_to_uca(value, getTriggerMode()); + map_dexela_trigger_mode_to_uca(value, dexela_get_trigger_mode()); break; } default: @@ -249,7 +249,7 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c case PROP_EXPOSURE_TIME: { const gdouble exposureTimeInSeconds = g_value_get_double(value); - setExposureTimeMicros(exposureTimeInSeconds * MICROS_TO_SECONDS_FACTOR); + dexela_set_exposure_time_micros(exposureTimeInSeconds * MICROS_TO_SECONDS_FACTOR); break; } case PROP_SENSOR_HORIZONTAL_BINNING: @@ -259,7 +259,7 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c g_warning("Tried to set illegal horizontal binning: %d", horizontalBinning); return; } - setBinningMode(horizontalBinning, getBinningModeVertical()); + dexela_set_binning_mode(horizontalBinning, dexela_get_binning_mode_vertical()); break; } case PROP_SENSOR_VERTICAL_BINNING: @@ -269,18 +269,18 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c g_warning("Tried to set illegal vertical binning: %d", verticalBinning); return; } - setBinningMode(getBinningModeHorizontal(), verticalBinning); + dexela_set_binning_mode(dexela_get_binning_mode_horizontal(), verticalBinning); break; } case PROP_GAIN_MODE: { const guint gain = g_value_get_uint(value); if (gain == 0) { - setGain(LOW); + dexela_set_gain(LOW); return; } if (gain == 1) { - setGain(HIGH); + dexela_set_gain(HIGH); return; } g_warning("Illegal attempt to set gain: %d", gain); -- cgit v1.2.3 From 7d8d5904eb7423a26a37cd3b0b69a7bd0cb59ab8 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 18 Sep 2012 14:11:14 +0200 Subject: Return full dimensions as roi. --- src/cameras/uca-dexela-camera.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 4671168..21b13b2 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -15,6 +15,7 @@ with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA */ +#include #include "uca-camera.h" #include "uca-dexela-camera.h" #include "uca-enums.h" @@ -197,6 +198,18 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G g_value_set_uint(value, priv->height); break; } + case PROP_ROI_WIDTH: + { + // use full frame for now + g_value_set_uint(value, priv->width); + break; + } + case PROP_ROI_HEIGHT: + { + // use full frame for now + g_value_set_uint(value, priv->height); + break; + } case PROP_SENSOR_HORIZONTAL_BINNING: { g_value_set_uint(value, dexela_get_binning_mode_horizontal()); -- cgit v1.2.3 From 5d99f2736d2340f50dadbfcb7e0db822372d3b72 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Wed, 26 Sep 2012 12:33:56 +0200 Subject: Bump version to prepare for SO fix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48592fd..e60cfe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(uca C) set(TARNAME "libuca") set(UCA_VERSION_MAJOR "1") set(UCA_VERSION_MINOR "0") -set(UCA_VERSION_PATCH "0") +set(UCA_VERSION_PATCH "1") set(UCA_DESCRIPTION "Unified Camera Access") set(UCA_VERSION_STRING "${UCA_VERSION_MAJOR}.${UCA_VERSION_MINOR}.${UCA_VERSION_PATCH}") -- cgit v1.2.3 From ee6b7a941f7ef7cdcc92c04b80a683d7370f52bd Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Wed, 26 Sep 2012 12:35:55 +0200 Subject: Bump version for next fixes --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e60cfe5..acf0386 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(uca C) set(TARNAME "libuca") set(UCA_VERSION_MAJOR "1") set(UCA_VERSION_MINOR "0") -set(UCA_VERSION_PATCH "1") +set(UCA_VERSION_PATCH "2-dev") set(UCA_DESCRIPTION "Unified Camera Access") set(UCA_VERSION_STRING "${UCA_VERSION_MAJOR}.${UCA_VERSION_MINOR}.${UCA_VERSION_PATCH}") -- cgit v1.2.3 From 5783156882cde177cd6c2f7e06451e8e0444e666 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 9 Oct 2012 14:18:28 +0200 Subject: Add test mode attribute. --- src/cameras/uca-dexela-camera.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 21b13b2..13e8b05 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -35,6 +35,7 @@ GQuark uca_dexela_camera_error_quark() enum { PROP_GAIN_MODE = N_BASE_PROPERTIES, + PROP_TEST_MODE, N_PROPERTIES }; @@ -241,6 +242,11 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G g_value_set_uint(value, dexela_get_gain()); break; } + case PROP_TEST_MODE: + { + g_value_set_boolean(value, dexela_get_control_register() & 1); + break; + } case PROP_TRIGGER_MODE: { map_dexela_trigger_mode_to_uca(value, dexela_get_trigger_mode()); @@ -299,6 +305,15 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c g_warning("Illegal attempt to set gain: %d", gain); break; } + case PROP_TEST_MODE: + { + if (g_value_get_boolean(value)) { + dexela_set_control_register(dexela_get_control_register() | 1); + return; + } + dexela_set_control_register(dexela_get_control_register() & 0xFFFE); + break; + } case PROP_TRIGGER_MODE: { set_trigger_mode(g_value_get_enum(value)); @@ -365,6 +380,11 @@ static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) "High or Low Full Well", "High (1) or Low (0) Full Well", 0, 1, 0, G_PARAM_READWRITE); + dexela_properties[PROP_TEST_MODE] = + g_param_spec_boolean("test-mode", + "Enable or disable test mode", + "Enable (true) or disable (false) test mode", + FALSE, G_PARAM_READWRITE); for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) { g_object_class_install_property(gobject_class, id, dexela_properties[id]); } -- cgit v1.2.3 From b73c7a9550a39566b881244d95cd0cb2a97e82b3 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 9 Oct 2012 14:20:11 +0200 Subject: fix SCHNEIDE-382: use correct micros to seconds factor. --- CMakeLists.txt | 4 ++-- src/cameras/uca-dexela-camera.c | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f7ef43..3c8c7cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(uca C) set(TARNAME "libuca") set(UCA_VERSION_MAJOR "0") set(UCA_VERSION_MINOR "6") -set(UCA_VERSION_PATCH "0") +set(UCA_VERSION_PATCH "1") set(UCA_DESCRIPTION "Unified Camera Access") set(UCA_VERSION_STRING "${UCA_VERSION_MAJOR}.${UCA_VERSION_MINOR}.${UCA_VERSION_PATCH}") @@ -17,7 +17,7 @@ set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket") set(CPACK_GENERATOR "DEB;RPM;") -set(CPACK_PACKAGE_RELEASE 4) +set(CPACK_PACKAGE_RELEASE 1) set(CPACK_DEBIAN_PACKAGE_NAME "libuca") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Matthias Vogelgesang ") set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${UCA_DESCRIPTION}) diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 13e8b05..7ec96e6 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -64,7 +64,7 @@ static gint base_overrideables[] = { static GParamSpec *dexela_properties[N_PROPERTIES] = { NULL, }; -static const gdouble MICROS_TO_SECONDS_FACTOR = 10e6d; +static const gdouble MICROS_TO_SECONDS_FACTOR = 1e6d; struct _UcaDexelaCameraPrivate { GValueArray *binnings; @@ -268,7 +268,7 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c case PROP_EXPOSURE_TIME: { const gdouble exposureTimeInSeconds = g_value_get_double(value); - dexela_set_exposure_time_micros(exposureTimeInSeconds * MICROS_TO_SECONDS_FACTOR); + dexela_set_exposure_time_micros((gint) (exposureTimeInSeconds * MICROS_TO_SECONDS_FACTOR)); break; } case PROP_SENSOR_HORIZONTAL_BINNING: @@ -342,12 +342,10 @@ static void uca_dexela_camera_grab(UcaCamera *camera, gpointer *data, GError **e g_debug("grab called"); g_return_if_fail(UCA_IS_DEXELA_CAMERA(camera)); UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); - g_debug("Data-pointer: %p, %p", data, *data); if (*data == NULL) { g_debug("Allocating buffer"); *data = g_malloc0(priv->width * priv->height * priv->num_bytes); } - // TODO: fetch image from libdexela // TODO: copy to the data buffer memcpy((gchar *) *data, dexela_grab(), priv->width * priv->height * priv->num_bytes); } -- cgit v1.2.3 From 37f48ae1b67b1205ba4884ec350afdf5ab7dd2d3 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Fri, 19 Oct 2012 16:40:52 +0200 Subject: Fix version stuff for rpm packaging. --- CMakeLists.txt | 2 +- libuca.spec.in | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acf0386..dffd35d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(uca C) set(TARNAME "libuca") set(UCA_VERSION_MAJOR "1") set(UCA_VERSION_MINOR "0") -set(UCA_VERSION_PATCH "2-dev") +set(UCA_VERSION_PATCH "2dev") set(UCA_DESCRIPTION "Unified Camera Access") set(UCA_VERSION_STRING "${UCA_VERSION_MAJOR}.${UCA_VERSION_MINOR}.${UCA_VERSION_PATCH}") diff --git a/libuca.spec.in b/libuca.spec.in index 9e21bb2..4ffc671 100644 --- a/libuca.spec.in +++ b/libuca.spec.in @@ -62,8 +62,8 @@ mv "@UCA_BUILD_DIR@/_CPack_Packages/Linux/RPM/tmpBBroot" $RPM_BUILD_ROOT %defattr(-,root,root,-) @CMAKE_INSTALL_PREFIX@/include/uca/*.h @CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/libuca.so -@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/libuca.so.@UCA_VERSION_MINOR@ -@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/libuca.so.@UCA_ABI_VERSION@ +@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/libuca.so.@UCA_VERSION_MAJOR@ +@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/libuca.so.@UCA_VERSION_MAJOR@.@UCA_VERSION_MINOR@ @CMAKE_INSTALL_PREFIX@/lib/pkgconfig/uca.pc -- cgit v1.2.3 From 9c6732c05f35bb06f92593b46990473aa7a0f799 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 25 Oct 2012 17:44:00 +0200 Subject: Start migrating to libuca 1.1 and glib plugins. --- plugins/CMakeLists.txt | 1 + plugins/dexela/uca-dexela-camera.c | 395 +++++++++++++++++++++++++++++++++++++ plugins/dexela/uca-dexela-camera.h | 68 +++++++ src/cameras/uca-dexela-camera.c | 395 ------------------------------------- src/cameras/uca-dexela-camera.h | 68 ------- src/config.h.in | 3 +- 6 files changed, 466 insertions(+), 464 deletions(-) create mode 100644 plugins/dexela/uca-dexela-camera.c create mode 100644 plugins/dexela/uca-dexela-camera.h delete mode 100644 src/cameras/uca-dexela-camera.c delete mode 100644 src/cameras/uca-dexela-camera.h diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 5131280..1cfff78 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -3,3 +3,4 @@ add_subdirectory(pf) add_subdirectory(pco) add_subdirectory(pylon) add_subdirectory(ufo) +add_subdirectory(dexela) diff --git a/plugins/dexela/uca-dexela-camera.c b/plugins/dexela/uca-dexela-camera.c new file mode 100644 index 0000000..7ec96e6 --- /dev/null +++ b/plugins/dexela/uca-dexela-camera.c @@ -0,0 +1,395 @@ +/* Copyright (C) 2011, 2012 Mihael Koep + (Softwareschneiderei GmbH) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2.1 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along + with this library; if not, write to the Free Software Foundation, Inc., 51 + Franklin St, Fifth Floor, Boston, MA 02110, USA */ + +#include +#include "uca-camera.h" +#include "uca-dexela-camera.h" +#include "uca-enums.h" +#include "dexela_api.h" + +#define UCA_DEXELA_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraPrivate)) + +G_DEFINE_TYPE(UcaDexelaCamera, uca_dexela_camera, UCA_TYPE_CAMERA) +/** + * UcaDexelaCameraError: + * @UCA_DEXELA_CAMERA_ERROR_LIBDEXELA_INIT: Initializing libdexela failed + */ +GQuark uca_dexela_camera_error_quark() +{ + return g_quark_from_static_string("uca-dexela-camera-error-quark"); +} + +enum { + PROP_GAIN_MODE = N_BASE_PROPERTIES, + PROP_TEST_MODE, + N_PROPERTIES +}; + +static gint base_overrideables[] = { + PROP_NAME, + PROP_SENSOR_WIDTH, + PROP_SENSOR_HEIGHT, + PROP_SENSOR_BITDEPTH, + PROP_SENSOR_HORIZONTAL_BINNING, + PROP_SENSOR_HORIZONTAL_BINNINGS, + PROP_SENSOR_VERTICAL_BINNING, + PROP_SENSOR_VERTICAL_BINNINGS, + PROP_SENSOR_MAX_FRAME_RATE, + PROP_EXPOSURE_TIME, + PROP_TRIGGER_MODE, + PROP_ROI_X, + PROP_ROI_Y, + PROP_ROI_WIDTH, + PROP_ROI_HEIGHT, + PROP_ROI_WIDTH_MULTIPLIER, + PROP_ROI_HEIGHT_MULTIPLIER, + PROP_HAS_STREAMING, + PROP_HAS_CAMRAM_RECORDING, + 0 +}; + +static GParamSpec *dexela_properties[N_PROPERTIES] = { NULL, }; + +static const gdouble MICROS_TO_SECONDS_FACTOR = 1e6d; + +struct _UcaDexelaCameraPrivate { + GValueArray *binnings; + guint width; + guint height; + guint bits; + gsize num_bytes; +}; + +/** + * Hardcode possible binnings for now + */ +static void fill_binnings(UcaDexelaCameraPrivate *priv) +{ + GValue val = {0}; + g_value_init(&val, G_TYPE_UINT); + + priv->binnings = g_value_array_new(3); + g_value_set_uint(&val, 1); + g_value_array_append(priv->binnings, &val); + g_value_set_uint(&val, 2); + g_value_array_append(priv->binnings, &val); + g_value_set_uint(&val, 4); + g_value_array_append(priv->binnings, &val); +} + +static void map_dexela_trigger_mode_to_uca(GValue* value, TriggerMode mode) +{ + if (mode == SOFTWARE) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_INTERNAL); + return; + } + if (mode == EDGE) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_EXTERNAL); + return; + } + // XXX: this mapping is only a hack/guess + if (mode == DURATION) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_AUTO); + return; + } + g_warning("Unsupported dexela trigger mode: %d", mode); +} + +static void set_trigger_mode(UcaCameraTrigger mode) +{ + if (mode == UCA_CAMERA_TRIGGER_INTERNAL) { + dexela_set_trigger_mode(SOFTWARE); + return; + } + if (mode == UCA_CAMERA_TRIGGER_EXTERNAL) { + dexela_set_trigger_mode(EDGE); + return; + } + if (mode == UCA_CAMERA_TRIGGER_AUTO) { + dexela_set_trigger_mode(DURATION); + return; + } + g_warning("Unsupported uca trigger mode: %d", mode); +} + +static gboolean is_binning_allowed(UcaDexelaCameraPrivate *priv, guint binning) +{ + for (int i = 0; i < priv->binnings->n_values; i++) { + guint allowedBinning = g_value_get_uint(g_value_array_get_nth(priv->binnings, i)); + if (binning == allowedBinning) { + return TRUE; + } + } + return FALSE; +} + +UcaDexelaCamera *uca_dexela_camera_new(GError **error) +{ + UcaDexelaCamera *camera = g_object_new(UCA_TYPE_DEXELA_CAMERA, NULL); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); + fill_binnings(priv); + /* + * Here we override property ranges because we didn't know them at property + * installation time. + */ + GObjectClass *camera_class = G_OBJECT_CLASS (UCA_CAMERA_GET_CLASS (camera)); + // TODO implement error checking + dexela_open_detector("/usr/share/dexela/dexela-1207_32.fmt"); + dexela_init_serial_connection(); + priv->bits = dexela_get_bit_depth(); + priv->width = dexela_get_width(); + priv->height = dexela_get_height(); + priv->num_bytes = 2; + return camera; +} + +static void uca_dexela_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + + switch (property_id) { + case PROP_NAME: + { + gchar* model = dexela_get_model(); + g_value_set_string(value, g_strdup_printf("Dexela %s", model)); + g_free(model); + break; + } + case PROP_EXPOSURE_TIME: + { + g_value_set_double(value, dexela_get_exposure_time_micros() / MICROS_TO_SECONDS_FACTOR); + break; + } + case PROP_HAS_CAMRAM_RECORDING: + { + g_value_set_boolean(value, FALSE); + break; + } + case PROP_HAS_STREAMING: + { + g_value_set_boolean(value, FALSE); + break; + } + case PROP_SENSOR_BITDEPTH: + { + g_value_set_uint(value, priv->bits); + break; + } + case PROP_SENSOR_WIDTH: + { + g_value_set_uint(value, priv->width); + break; + } + case PROP_SENSOR_HEIGHT: + { + g_value_set_uint(value, priv->height); + break; + } + case PROP_ROI_WIDTH: + { + // use full frame for now + g_value_set_uint(value, priv->width); + break; + } + case PROP_ROI_HEIGHT: + { + // use full frame for now + g_value_set_uint(value, priv->height); + break; + } + case PROP_SENSOR_HORIZONTAL_BINNING: + { + g_value_set_uint(value, dexela_get_binning_mode_horizontal()); + break; + } + case PROP_SENSOR_HORIZONTAL_BINNINGS: + { + g_value_set_boxed(value, priv->binnings); + break; + } + case PROP_SENSOR_VERTICAL_BINNING: + { + g_value_set_uint(value, dexela_get_binning_mode_vertical()); + break; + } + case PROP_SENSOR_VERTICAL_BINNINGS: + { + g_value_set_boxed(value, priv->binnings); + break; + } + case PROP_SENSOR_MAX_FRAME_RATE: + { + // TODO: we do not know how to compute the correct value, so just return 0 for now + g_value_set_float(value, 0.0f); + break; + } + case PROP_GAIN_MODE: + { + g_value_set_uint(value, dexela_get_gain()); + break; + } + case PROP_TEST_MODE: + { + g_value_set_boolean(value, dexela_get_control_register() & 1); + break; + } + case PROP_TRIGGER_MODE: + { + map_dexela_trigger_mode_to_uca(value, dexela_get_trigger_mode()); + break; + } + default: + { + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + break; + } + } +} + +static void uca_dexela_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + + switch (property_id) { + case PROP_EXPOSURE_TIME: + { + const gdouble exposureTimeInSeconds = g_value_get_double(value); + dexela_set_exposure_time_micros((gint) (exposureTimeInSeconds * MICROS_TO_SECONDS_FACTOR)); + break; + } + case PROP_SENSOR_HORIZONTAL_BINNING: + { + const guint horizontalBinning = g_value_get_uint(value); + if (!is_binning_allowed(priv, horizontalBinning)) { + g_warning("Tried to set illegal horizontal binning: %d", horizontalBinning); + return; + } + dexela_set_binning_mode(horizontalBinning, dexela_get_binning_mode_vertical()); + break; + } + case PROP_SENSOR_VERTICAL_BINNING: + { + const guint verticalBinning = g_value_get_uint(value); + if (!is_binning_allowed(priv, verticalBinning)) { + g_warning("Tried to set illegal vertical binning: %d", verticalBinning); + return; + } + dexela_set_binning_mode(dexela_get_binning_mode_horizontal(), verticalBinning); + break; + } + case PROP_GAIN_MODE: + { + const guint gain = g_value_get_uint(value); + if (gain == 0) { + dexela_set_gain(LOW); + return; + } + if (gain == 1) { + dexela_set_gain(HIGH); + return; + } + g_warning("Illegal attempt to set gain: %d", gain); + break; + } + case PROP_TEST_MODE: + { + if (g_value_get_boolean(value)) { + dexela_set_control_register(dexela_get_control_register() | 1); + return; + } + dexela_set_control_register(dexela_get_control_register() & 0xFFFE); + break; + } + case PROP_TRIGGER_MODE: + { + set_trigger_mode(g_value_get_enum(value)); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + return; + } +} + +static void uca_dexela_camera_start_recording(UcaCamera *camera, GError **error) +{ + g_debug("start recording called"); + dexela_start_acquisition(); +} + +static void uca_dexela_camera_stop_recording(UcaCamera *camera, GError **error) +{ + g_debug("stop recording called"); + dexela_stop_acquisition(); +} + +static void uca_dexela_camera_grab(UcaCamera *camera, gpointer *data, GError **error) +{ + g_debug("grab called"); + g_return_if_fail(UCA_IS_DEXELA_CAMERA(camera)); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); + if (*data == NULL) { + g_debug("Allocating buffer"); + *data = g_malloc0(priv->width * priv->height * priv->num_bytes); + } + // TODO: copy to the data buffer + memcpy((gchar *) *data, dexela_grab(), priv->width * priv->height * priv->num_bytes); +} + +static void uca_dexela_camera_finalize(GObject *object) +{ + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); + g_value_array_free(priv->binnings); + + G_OBJECT_CLASS(uca_dexela_camera_parent_class)->finalize(object); +} + +static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + gobject_class->set_property = uca_dexela_camera_set_property; + gobject_class->get_property = uca_dexela_camera_get_property; + gobject_class->finalize = uca_dexela_camera_finalize; + + UcaCameraClass *camera_class = UCA_CAMERA_CLASS(klass); + camera_class->start_recording = uca_dexela_camera_start_recording; + camera_class->stop_recording = uca_dexela_camera_stop_recording; + camera_class->grab = uca_dexela_camera_grab; + + for (guint i = 0; base_overrideables[i] != 0; i++) { + g_object_class_override_property(gobject_class, base_overrideables[i], uca_camera_props[base_overrideables[i]]); + } + dexela_properties[PROP_GAIN_MODE] = + g_param_spec_uint("gain-mode", + "High or Low Full Well", + "High (1) or Low (0) Full Well", + 0, 1, 0, G_PARAM_READWRITE); + dexela_properties[PROP_TEST_MODE] = + g_param_spec_boolean("test-mode", + "Enable or disable test mode", + "Enable (true) or disable (false) test mode", + FALSE, G_PARAM_READWRITE); + for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) { + g_object_class_install_property(gobject_class, id, dexela_properties[id]); + } + g_type_class_add_private(klass, sizeof(UcaDexelaCameraPrivate)); +} + +static void uca_dexela_camera_init(UcaDexelaCamera *self) +{ + self->priv = UCA_DEXELA_CAMERA_GET_PRIVATE(self); +} diff --git a/plugins/dexela/uca-dexela-camera.h b/plugins/dexela/uca-dexela-camera.h new file mode 100644 index 0000000..9badf10 --- /dev/null +++ b/plugins/dexela/uca-dexela-camera.h @@ -0,0 +1,68 @@ +/* Copyright (C) 2011, 2012 Mihael Koep + (Softwareschneiderei GmbH) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2.1 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along + with this library; if not, write to the Free Software Foundation, Inc., 51 + Franklin St, Fifth Floor, Boston, MA 02110, USA */ + +#ifndef __UCA_DEXELA_CAMERA_H +#define __UCA_DEXELA_CAMERA_H + +#include +#include "uca-camera.h" + +#define UCA_TYPE_DEXELA_CAMERA (uca_dexela_camera_get_type()) +#define UCA_DEXELA_CAMERA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCamera)) +#define UCA_IS_DEXELA_CAMERA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UCA_TYPE_DEXELA_CAMERA)) +#define UCA_DEXELA_CAMERA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraClass)) +#define UCA_IS_DEXELA_CAMERA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UCA_TYPE_DEXELA_CAMERA)) +#define UCA_DEXELA_CAMERA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraClass)) + +#define UCA_DEXELA_CAMERA_ERROR uca_dexela_camera_error_quark() +typedef enum { + UCA_DEXELA_CAMERA_ERROR_LIBPCO_INIT, +} UcaDexelaCameraError; + +typedef struct _UcaDexelaCamera UcaDexelaCamera; +typedef struct _UcaDexelaCameraClass UcaDexelaCameraClass; +typedef struct _UcaDexelaCameraPrivate UcaDexelaCameraPrivate; + +/** + * UcaDexelaCamera: + * + * Creates #UcaDexelaCamera instances by loading corresponding shared objects. The + * contents of the #UcaDexelaCamera structure are private and should only be + * accessed via the provided API. + */ +struct _UcaDexelaCamera { + /*< private >*/ + UcaCamera parent; + + UcaDexelaCameraPrivate *priv; +}; + +/** + * UcaDexelaCameraClass: + * + * #UcaDexelaCamera class + */ +struct _UcaDexelaCameraClass { + /*< private >*/ + UcaCameraClass parent; +}; + +UcaDexelaCamera *uca_dexela_camera_new(GError **error); + +GType uca_dexela_camera_get_type(void); + +#endif diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c deleted file mode 100644 index 7ec96e6..0000000 --- a/src/cameras/uca-dexela-camera.c +++ /dev/null @@ -1,395 +0,0 @@ -/* Copyright (C) 2011, 2012 Mihael Koep - (Softwareschneiderei GmbH) - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2.1 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - details. - - You should have received a copy of the GNU Lesser General Public License along - with this library; if not, write to the Free Software Foundation, Inc., 51 - Franklin St, Fifth Floor, Boston, MA 02110, USA */ - -#include -#include "uca-camera.h" -#include "uca-dexela-camera.h" -#include "uca-enums.h" -#include "dexela_api.h" - -#define UCA_DEXELA_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraPrivate)) - -G_DEFINE_TYPE(UcaDexelaCamera, uca_dexela_camera, UCA_TYPE_CAMERA) -/** - * UcaDexelaCameraError: - * @UCA_DEXELA_CAMERA_ERROR_LIBDEXELA_INIT: Initializing libdexela failed - */ -GQuark uca_dexela_camera_error_quark() -{ - return g_quark_from_static_string("uca-dexela-camera-error-quark"); -} - -enum { - PROP_GAIN_MODE = N_BASE_PROPERTIES, - PROP_TEST_MODE, - N_PROPERTIES -}; - -static gint base_overrideables[] = { - PROP_NAME, - PROP_SENSOR_WIDTH, - PROP_SENSOR_HEIGHT, - PROP_SENSOR_BITDEPTH, - PROP_SENSOR_HORIZONTAL_BINNING, - PROP_SENSOR_HORIZONTAL_BINNINGS, - PROP_SENSOR_VERTICAL_BINNING, - PROP_SENSOR_VERTICAL_BINNINGS, - PROP_SENSOR_MAX_FRAME_RATE, - PROP_EXPOSURE_TIME, - PROP_TRIGGER_MODE, - PROP_ROI_X, - PROP_ROI_Y, - PROP_ROI_WIDTH, - PROP_ROI_HEIGHT, - PROP_ROI_WIDTH_MULTIPLIER, - PROP_ROI_HEIGHT_MULTIPLIER, - PROP_HAS_STREAMING, - PROP_HAS_CAMRAM_RECORDING, - 0 -}; - -static GParamSpec *dexela_properties[N_PROPERTIES] = { NULL, }; - -static const gdouble MICROS_TO_SECONDS_FACTOR = 1e6d; - -struct _UcaDexelaCameraPrivate { - GValueArray *binnings; - guint width; - guint height; - guint bits; - gsize num_bytes; -}; - -/** - * Hardcode possible binnings for now - */ -static void fill_binnings(UcaDexelaCameraPrivate *priv) -{ - GValue val = {0}; - g_value_init(&val, G_TYPE_UINT); - - priv->binnings = g_value_array_new(3); - g_value_set_uint(&val, 1); - g_value_array_append(priv->binnings, &val); - g_value_set_uint(&val, 2); - g_value_array_append(priv->binnings, &val); - g_value_set_uint(&val, 4); - g_value_array_append(priv->binnings, &val); -} - -static void map_dexela_trigger_mode_to_uca(GValue* value, TriggerMode mode) -{ - if (mode == SOFTWARE) { - g_value_set_enum(value, UCA_CAMERA_TRIGGER_INTERNAL); - return; - } - if (mode == EDGE) { - g_value_set_enum(value, UCA_CAMERA_TRIGGER_EXTERNAL); - return; - } - // XXX: this mapping is only a hack/guess - if (mode == DURATION) { - g_value_set_enum(value, UCA_CAMERA_TRIGGER_AUTO); - return; - } - g_warning("Unsupported dexela trigger mode: %d", mode); -} - -static void set_trigger_mode(UcaCameraTrigger mode) -{ - if (mode == UCA_CAMERA_TRIGGER_INTERNAL) { - dexela_set_trigger_mode(SOFTWARE); - return; - } - if (mode == UCA_CAMERA_TRIGGER_EXTERNAL) { - dexela_set_trigger_mode(EDGE); - return; - } - if (mode == UCA_CAMERA_TRIGGER_AUTO) { - dexela_set_trigger_mode(DURATION); - return; - } - g_warning("Unsupported uca trigger mode: %d", mode); -} - -static gboolean is_binning_allowed(UcaDexelaCameraPrivate *priv, guint binning) -{ - for (int i = 0; i < priv->binnings->n_values; i++) { - guint allowedBinning = g_value_get_uint(g_value_array_get_nth(priv->binnings, i)); - if (binning == allowedBinning) { - return TRUE; - } - } - return FALSE; -} - -UcaDexelaCamera *uca_dexela_camera_new(GError **error) -{ - UcaDexelaCamera *camera = g_object_new(UCA_TYPE_DEXELA_CAMERA, NULL); - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); - fill_binnings(priv); - /* - * Here we override property ranges because we didn't know them at property - * installation time. - */ - GObjectClass *camera_class = G_OBJECT_CLASS (UCA_CAMERA_GET_CLASS (camera)); - // TODO implement error checking - dexela_open_detector("/usr/share/dexela/dexela-1207_32.fmt"); - dexela_init_serial_connection(); - priv->bits = dexela_get_bit_depth(); - priv->width = dexela_get_width(); - priv->height = dexela_get_height(); - priv->num_bytes = 2; - return camera; -} - -static void uca_dexela_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); - - switch (property_id) { - case PROP_NAME: - { - gchar* model = dexela_get_model(); - g_value_set_string(value, g_strdup_printf("Dexela %s", model)); - g_free(model); - break; - } - case PROP_EXPOSURE_TIME: - { - g_value_set_double(value, dexela_get_exposure_time_micros() / MICROS_TO_SECONDS_FACTOR); - break; - } - case PROP_HAS_CAMRAM_RECORDING: - { - g_value_set_boolean(value, FALSE); - break; - } - case PROP_HAS_STREAMING: - { - g_value_set_boolean(value, FALSE); - break; - } - case PROP_SENSOR_BITDEPTH: - { - g_value_set_uint(value, priv->bits); - break; - } - case PROP_SENSOR_WIDTH: - { - g_value_set_uint(value, priv->width); - break; - } - case PROP_SENSOR_HEIGHT: - { - g_value_set_uint(value, priv->height); - break; - } - case PROP_ROI_WIDTH: - { - // use full frame for now - g_value_set_uint(value, priv->width); - break; - } - case PROP_ROI_HEIGHT: - { - // use full frame for now - g_value_set_uint(value, priv->height); - break; - } - case PROP_SENSOR_HORIZONTAL_BINNING: - { - g_value_set_uint(value, dexela_get_binning_mode_horizontal()); - break; - } - case PROP_SENSOR_HORIZONTAL_BINNINGS: - { - g_value_set_boxed(value, priv->binnings); - break; - } - case PROP_SENSOR_VERTICAL_BINNING: - { - g_value_set_uint(value, dexela_get_binning_mode_vertical()); - break; - } - case PROP_SENSOR_VERTICAL_BINNINGS: - { - g_value_set_boxed(value, priv->binnings); - break; - } - case PROP_SENSOR_MAX_FRAME_RATE: - { - // TODO: we do not know how to compute the correct value, so just return 0 for now - g_value_set_float(value, 0.0f); - break; - } - case PROP_GAIN_MODE: - { - g_value_set_uint(value, dexela_get_gain()); - break; - } - case PROP_TEST_MODE: - { - g_value_set_boolean(value, dexela_get_control_register() & 1); - break; - } - case PROP_TRIGGER_MODE: - { - map_dexela_trigger_mode_to_uca(value, dexela_get_trigger_mode()); - break; - } - default: - { - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } - } -} - -static void uca_dexela_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); - - switch (property_id) { - case PROP_EXPOSURE_TIME: - { - const gdouble exposureTimeInSeconds = g_value_get_double(value); - dexela_set_exposure_time_micros((gint) (exposureTimeInSeconds * MICROS_TO_SECONDS_FACTOR)); - break; - } - case PROP_SENSOR_HORIZONTAL_BINNING: - { - const guint horizontalBinning = g_value_get_uint(value); - if (!is_binning_allowed(priv, horizontalBinning)) { - g_warning("Tried to set illegal horizontal binning: %d", horizontalBinning); - return; - } - dexela_set_binning_mode(horizontalBinning, dexela_get_binning_mode_vertical()); - break; - } - case PROP_SENSOR_VERTICAL_BINNING: - { - const guint verticalBinning = g_value_get_uint(value); - if (!is_binning_allowed(priv, verticalBinning)) { - g_warning("Tried to set illegal vertical binning: %d", verticalBinning); - return; - } - dexela_set_binning_mode(dexela_get_binning_mode_horizontal(), verticalBinning); - break; - } - case PROP_GAIN_MODE: - { - const guint gain = g_value_get_uint(value); - if (gain == 0) { - dexela_set_gain(LOW); - return; - } - if (gain == 1) { - dexela_set_gain(HIGH); - return; - } - g_warning("Illegal attempt to set gain: %d", gain); - break; - } - case PROP_TEST_MODE: - { - if (g_value_get_boolean(value)) { - dexela_set_control_register(dexela_get_control_register() | 1); - return; - } - dexela_set_control_register(dexela_get_control_register() & 0xFFFE); - break; - } - case PROP_TRIGGER_MODE: - { - set_trigger_mode(g_value_get_enum(value)); - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - return; - } -} - -static void uca_dexela_camera_start_recording(UcaCamera *camera, GError **error) -{ - g_debug("start recording called"); - dexela_start_acquisition(); -} - -static void uca_dexela_camera_stop_recording(UcaCamera *camera, GError **error) -{ - g_debug("stop recording called"); - dexela_stop_acquisition(); -} - -static void uca_dexela_camera_grab(UcaCamera *camera, gpointer *data, GError **error) -{ - g_debug("grab called"); - g_return_if_fail(UCA_IS_DEXELA_CAMERA(camera)); - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(camera); - if (*data == NULL) { - g_debug("Allocating buffer"); - *data = g_malloc0(priv->width * priv->height * priv->num_bytes); - } - // TODO: copy to the data buffer - memcpy((gchar *) *data, dexela_grab(), priv->width * priv->height * priv->num_bytes); -} - -static void uca_dexela_camera_finalize(GObject *object) -{ - UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE(object); - g_value_array_free(priv->binnings); - - G_OBJECT_CLASS(uca_dexela_camera_parent_class)->finalize(object); -} - -static void uca_dexela_camera_class_init(UcaDexelaCameraClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->set_property = uca_dexela_camera_set_property; - gobject_class->get_property = uca_dexela_camera_get_property; - gobject_class->finalize = uca_dexela_camera_finalize; - - UcaCameraClass *camera_class = UCA_CAMERA_CLASS(klass); - camera_class->start_recording = uca_dexela_camera_start_recording; - camera_class->stop_recording = uca_dexela_camera_stop_recording; - camera_class->grab = uca_dexela_camera_grab; - - for (guint i = 0; base_overrideables[i] != 0; i++) { - g_object_class_override_property(gobject_class, base_overrideables[i], uca_camera_props[base_overrideables[i]]); - } - dexela_properties[PROP_GAIN_MODE] = - g_param_spec_uint("gain-mode", - "High or Low Full Well", - "High (1) or Low (0) Full Well", - 0, 1, 0, G_PARAM_READWRITE); - dexela_properties[PROP_TEST_MODE] = - g_param_spec_boolean("test-mode", - "Enable or disable test mode", - "Enable (true) or disable (false) test mode", - FALSE, G_PARAM_READWRITE); - for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) { - g_object_class_install_property(gobject_class, id, dexela_properties[id]); - } - g_type_class_add_private(klass, sizeof(UcaDexelaCameraPrivate)); -} - -static void uca_dexela_camera_init(UcaDexelaCamera *self) -{ - self->priv = UCA_DEXELA_CAMERA_GET_PRIVATE(self); -} diff --git a/src/cameras/uca-dexela-camera.h b/src/cameras/uca-dexela-camera.h deleted file mode 100644 index 9badf10..0000000 --- a/src/cameras/uca-dexela-camera.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2011, 2012 Mihael Koep - (Softwareschneiderei GmbH) - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2.1 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - details. - - You should have received a copy of the GNU Lesser General Public License along - with this library; if not, write to the Free Software Foundation, Inc., 51 - Franklin St, Fifth Floor, Boston, MA 02110, USA */ - -#ifndef __UCA_DEXELA_CAMERA_H -#define __UCA_DEXELA_CAMERA_H - -#include -#include "uca-camera.h" - -#define UCA_TYPE_DEXELA_CAMERA (uca_dexela_camera_get_type()) -#define UCA_DEXELA_CAMERA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCamera)) -#define UCA_IS_DEXELA_CAMERA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UCA_TYPE_DEXELA_CAMERA)) -#define UCA_DEXELA_CAMERA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraClass)) -#define UCA_IS_DEXELA_CAMERA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UCA_TYPE_DEXELA_CAMERA)) -#define UCA_DEXELA_CAMERA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraClass)) - -#define UCA_DEXELA_CAMERA_ERROR uca_dexela_camera_error_quark() -typedef enum { - UCA_DEXELA_CAMERA_ERROR_LIBPCO_INIT, -} UcaDexelaCameraError; - -typedef struct _UcaDexelaCamera UcaDexelaCamera; -typedef struct _UcaDexelaCameraClass UcaDexelaCameraClass; -typedef struct _UcaDexelaCameraPrivate UcaDexelaCameraPrivate; - -/** - * UcaDexelaCamera: - * - * Creates #UcaDexelaCamera instances by loading corresponding shared objects. The - * contents of the #UcaDexelaCamera structure are private and should only be - * accessed via the provided API. - */ -struct _UcaDexelaCamera { - /*< private >*/ - UcaCamera parent; - - UcaDexelaCameraPrivate *priv; -}; - -/** - * UcaDexelaCameraClass: - * - * #UcaDexelaCamera class - */ -struct _UcaDexelaCameraClass { - /*< private >*/ - UcaCameraClass parent; -}; - -UcaDexelaCamera *uca_dexela_camera_new(GError **error); - -GType uca_dexela_camera_get_type(void); - -#endif diff --git a/src/config.h.in b/src/config.h.in index ec1fb62..d16158b 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -6,4 +6,5 @@ #cmakedefine HAVE_DEXELA_CL #cmakedefine HAVE_MOCK_CAMERA -#define CONTROL_GLADE_PATH "${CMAKE_INSTALL_PREFIX}/share/libuca/control.glade" +//#define CONTROL_GLADE_PATH "${CMAKE_INSTALL_PREFIX}/share/libuca/control.glade" +#define CONTROL_GLADE_PATH "./control.glade" -- cgit v1.2.3 From 8ce877dfe1dcf1fc1896142405c61a76d5b8b00f Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 30 Oct 2012 17:54:36 +0100 Subject: Fix incomplete committ... --- .gitignore | 6 +++++- cmake/FindDEXELA.cmake | 2 ++ plugins/dexela/CMakeLists.txt | 24 ++++++++++++++++++++++++ plugins/dexela/uca-dexela-camera.c | 4 ++-- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 plugins/dexela/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 8bea720..e233eae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -CMake* +CMakeFiles *~ *.cmake Makefile @@ -6,3 +6,7 @@ src/libuca.so* test/ libuca.spec src/config.h +*.rpm +install_manifest.txt +_CPack_Packages +*.orig diff --git a/cmake/FindDEXELA.cmake b/cmake/FindDEXELA.cmake index 1fef7af..0412b19 100644 --- a/cmake/FindDEXELA.cmake +++ b/cmake/FindDEXELA.cmake @@ -17,3 +17,5 @@ mark_as_advanced( DEXELA_INCLUDE_DIRS DEXELA_LIBRARIES ) + +message("-- Dexela libraries found: ${DEXELA_FOUND}") diff --git a/plugins/dexela/CMakeLists.txt b/plugins/dexela/CMakeLists.txt new file mode 100644 index 0000000..8522192 --- /dev/null +++ b/plugins/dexela/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8) +project(ucadexela C) + +find_package(DEXELA) + +if (DEXELA_FOUND) + set(UCA_CAMERA_NAME "dexela") + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../package-plugin.sh.in + ${CMAKE_CURRENT_BINARY_DIR}/../../package-plugin-${UCA_CAMERA_NAME}.sh) + + include_directories(${DEXELA_INCLUDE_DIRS}) + + add_library(ucadexela SHARED + uca-dexela-camera.c) + + target_link_libraries(ucadexela + ${UCA_DEPS} + ${DEXELA_LIBRARIES}) + + install(TARGETS ucadexela + LIBRARY DESTINATION ${LIB_INSTALL_DIR}/uca + COMPONENT ${UCA_CAMERA_NAME}) +endif() diff --git a/plugins/dexela/uca-dexela-camera.c b/plugins/dexela/uca-dexela-camera.c index 7ec96e6..425b742 100644 --- a/plugins/dexela/uca-dexela-camera.c +++ b/plugins/dexela/uca-dexela-camera.c @@ -94,7 +94,7 @@ static void fill_binnings(UcaDexelaCameraPrivate *priv) static void map_dexela_trigger_mode_to_uca(GValue* value, TriggerMode mode) { if (mode == SOFTWARE) { - g_value_set_enum(value, UCA_CAMERA_TRIGGER_INTERNAL); + g_value_set_enum(value, UCA_CAMERA_TRIGGER_SOFTWARE); return; } if (mode == EDGE) { @@ -111,7 +111,7 @@ static void map_dexela_trigger_mode_to_uca(GValue* value, TriggerMode mode) static void set_trigger_mode(UcaCameraTrigger mode) { - if (mode == UCA_CAMERA_TRIGGER_INTERNAL) { + if (mode == UCA_CAMERA_TRIGGER_SOFTWARE) { dexela_set_trigger_mode(SOFTWARE); return; } -- cgit v1.2.3 From c11a6c7bed07d50fb654984fe603b27613e9abc2 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 30 Oct 2012 18:01:17 +0100 Subject: Add configuring of the spec-file. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bef3712..e9d49fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,8 @@ set(UCA_ENUM_HDRS configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package.sh.in ${CMAKE_CURRENT_BINARY_DIR}/package.sh) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libuca.spec.in" + "${CMAKE_CURRENT_BINARY_DIR}/libuca.spec" @ONLY IMMEDIATE) # --- Common flags ------------------------------------------------------------ -- cgit v1.2.3 From 4245ad0b8d12574a3c2c15bd057246065e5026ca Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 30 Oct 2012 18:07:36 +0100 Subject: Fix rpm version substitution. --- libuca.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libuca.spec.in b/libuca.spec.in index 4ffc671..3835d89 100644 --- a/libuca.spec.in +++ b/libuca.spec.in @@ -2,7 +2,7 @@ Buildroot: @UCA_BUILD_DIR@/_CPack_Packages/Linux/RPM/@CPACK_PACKAGE_FILE_NAME@ Summary: Abstract interface for different camera classes and frame grabber devices Name: libuca -Version: @VERSION@ +Version: @PACKAGE_VERSION@ Release: @CPACK_PACKAGE_RELEASE@ License: unknown Group: unknown -- cgit v1.2.3 From 7bd33f1eb88ce537e21693a805390d6385e43b80 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 30 Oct 2012 18:21:05 +0100 Subject: Include CPack in the build process and set the package file name correctly. --- CMakeLists.txt | 4 ++++ libuca.spec.in | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d49fa..6856df1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set(CPACK_DEBIAN_PACKAGE_NAME "libuca") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Matthias Vogelgesang ") set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${UCA_DESCRIPTION}) set(CPACK_DEBIAN_PACKAGE_DESCRIPTION_SUMMARY ${UCA_DESCRIPTION}) +set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") @@ -72,3 +73,6 @@ add_subdirectory(src) add_subdirectory(plugins) add_subdirectory(test) add_subdirectory(tools) + +include(CPack) + diff --git a/libuca.spec.in b/libuca.spec.in index 3835d89..0f77f95 100644 --- a/libuca.spec.in +++ b/libuca.spec.in @@ -60,11 +60,10 @@ mv "@UCA_BUILD_DIR@/_CPack_Packages/Linux/RPM/tmpBBroot" $RPM_BUILD_ROOT %files %defattr(-,root,root,-) +@CMAKE_INSTALL_PREFIX@/bin/control @CMAKE_INSTALL_PREFIX@/include/uca/*.h -@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/libuca.so -@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/libuca.so.@UCA_VERSION_MAJOR@ -@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/libuca.so.@UCA_VERSION_MAJOR@.@UCA_VERSION_MINOR@ -@CMAKE_INSTALL_PREFIX@/lib/pkgconfig/uca.pc +@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/* +@CMAKE_INSTALL_PREFIX@/share/* %changelog -- cgit v1.2.3 From 7b45ba3f7a80161cb0ec4ea30375b64abffb9079 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 21 Feb 2013 11:51:32 +0100 Subject: add some binaries to gitignore. --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index e233eae..5ee492f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,9 @@ src/config.h install_manifest.txt _CPack_Packages *.orig +tools/benchmark +tools/gen-doc +tools/grab +tools/grab-async +tools/gui/control +tools/perf -- cgit v1.2.3 From 73246448ec8294d781bb7f223fce395d49bfb6e4 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Thu, 7 Mar 2013 17:37:41 +0100 Subject: Improve dexela plugin packaging. --- plugins/dexela/CMakeLists.txt | 6 ++++++ plugins/dexela/changelog.txt | 2 ++ plugins/package-plugin.sh.in | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 plugins/dexela/changelog.txt diff --git a/plugins/dexela/CMakeLists.txt b/plugins/dexela/CMakeLists.txt index 8522192..81a0de0 100644 --- a/plugins/dexela/CMakeLists.txt +++ b/plugins/dexela/CMakeLists.txt @@ -5,6 +5,12 @@ find_package(DEXELA) if (DEXELA_FOUND) set(UCA_CAMERA_NAME "dexela") + set(PLUGIN_REVISION "2") + set(PLUGIN_VERSION "1.0.0") + set(PLUGIN_CHANGELOG "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt") + set(PLUGIN_REQUIRES "libuca = 1.1.0, libdexela >= 0.9.2") + set(PLUGIN_SPECIFIC_FLAGS + "-D CPACK_PACKAGE_NAME=\"uca-plugin-dexela\" -D CPACK_PACKAGE_VERSION=\"${PLUGIN_VERSION}\" -D CPACK_RPM_PACKAGE_RELEASE=\"${PLUGIN_REVISION}\" -D CPACK_RPM_CHANGELOG_FILE=${PLUGIN_CHANGELOG} -D CPACK_RPM_PACKAGE_REQUIRES=${PLUGIN_REQUIRES}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../package-plugin.sh.in ${CMAKE_CURRENT_BINARY_DIR}/../../package-plugin-${UCA_CAMERA_NAME}.sh) diff --git a/plugins/dexela/changelog.txt b/plugins/dexela/changelog.txt new file mode 100644 index 0000000..8b84fa5 --- /dev/null +++ b/plugins/dexela/changelog.txt @@ -0,0 +1,2 @@ +* Thu Mar 7 2013 Mihael Koep 1.0.0-2 +- add changelog and improve package metadata diff --git a/plugins/package-plugin.sh.in b/plugins/package-plugin.sh.in index c624d52..bfd1eb3 100644 --- a/plugins/package-plugin.sh.in +++ b/plugins/package-plugin.sh.in @@ -1 +1 @@ -cpack -D CPACK_INSTALL_CMAKE_PROJECTS="${CMAKE_CURRENT_BINARY_DIR}/;Project;${UCA_CAMERA_NAME};/" -D CPACK_PACKAGE_FILE_NAME="uca-plugin-${UCA_CAMERA_NAME}-${UCA_VERSION_MAJOR}.${UCA_VERSION_MINOR}.${UCA_VERSION_PATCH}" +cpack -D CPACK_INSTALL_CMAKE_PROJECTS="${CMAKE_CURRENT_BINARY_DIR}/;Project;${UCA_CAMERA_NAME};/" -D CPACK_PACKAGE_FILE_NAME="uca-plugin-${UCA_CAMERA_NAME}-${UCA_VERSION_MAJOR}.${UCA_VERSION_MINOR}.${UCA_VERSION_PATCH}-${PLUGIN_VERSION}-${PLUGIN_REVISION}" ${PLUGIN_SPECIFIC_FLAGS} -- cgit v1.2.3