From 1b78ff35cd7a13828621bb664772227c3954902a Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Wed, 19 Mar 2014 14:54:53 +0100 Subject: Update dexela plugin to libdexela 1.1.0 --- plugins/dexela/CMakeLists.txt | 6 +++--- plugins/dexela/changelog.txt | 3 +++ plugins/dexela/uca-dexela-camera.c | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/dexela/CMakeLists.txt b/plugins/dexela/CMakeLists.txt index 1dbae27..101f11e 100644 --- a/plugins/dexela/CMakeLists.txt +++ b/plugins/dexela/CMakeLists.txt @@ -1,17 +1,17 @@ cmake_minimum_required(VERSION 2.6) project(ucadexela C) -set(VERSION "1.0.2") +set(VERSION "1.0.3") find_package(DEXELA) if (DEXELA_FOUND) set(UCA_CAMERA_NAME "dexela") - set(PLUGIN_REVISION "2") + set(PLUGIN_REVISION "1") set(PLUGIN_VERSION ${VERSION}) set(PLUGIN_SUMMARY "Dexela plugin for libuca") set(PLUGIN_CHANGELOG "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt") set(PLUGIN_DESCRIPTION "Plugin for the Dexela 1207 detector.") - set(PLUGIN_REQUIRES "libuca = 1.3.0, libdexela >= 1.0.0") + set(PLUGIN_REQUIRES "libuca = 1.3.0, libdexela >= 1.1.0") set(PLUGIN_VENDOR "ANKA Computing Group") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../package-plugin.sh.in diff --git a/plugins/dexela/changelog.txt b/plugins/dexela/changelog.txt index 027b3ea..7ee4c54 100644 --- a/plugins/dexela/changelog.txt +++ b/plugins/dexela/changelog.txt @@ -1,3 +1,6 @@ +* Wed Mar 19 2014 Mihael Koep 1.0.3-1 +- bump libdexela requirement to 1.1.0 +- use new libdexela API for FMT file * Tue Oct 15 2013 Mihael Koep 1.0.2-2 - bump libuca requirement to 1.3.0 * Wed Mar 27 2013 Mihael Koep 1.0.2-1 diff --git a/plugins/dexela/uca-dexela-camera.c b/plugins/dexela/uca-dexela-camera.c index 0003f22..aa0a049 100644 --- a/plugins/dexela/uca-dexela-camera.c +++ b/plugins/dexela/uca-dexela-camera.c @@ -18,7 +18,7 @@ #include #include #include "uca-dexela-camera.h" -#include "dexela_api.h" +#include "dexela/dexela_api.h" #define UCA_DEXELA_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_DEXELA_CAMERA, UcaDexelaCameraPrivate)) @@ -147,7 +147,7 @@ UcaDexelaCamera *uca_dexela_camera_new(GError **error) */ 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_open_detector(DEFAULT_FMT_FILE_PATH); dexela_init_serial_connection(); priv->bits = dexela_get_bit_depth(); priv->width = dexela_get_width(); -- cgit v1.2.3 From 9136bc7ed3e057290bfd7d8a8beae424f1079182 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Wed, 19 Mar 2014 15:19:27 +0100 Subject: Improve lookup of libdexela headers --- cmake/FindDEXELA.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindDEXELA.cmake b/cmake/FindDEXELA.cmake index 1fef7af..a68bf6c 100644 --- a/cmake/FindDEXELA.cmake +++ b/cmake/FindDEXELA.cmake @@ -8,7 +8,7 @@ find_package(PackageHandleStandardArgs) -find_path(DEXELA_INCLUDE_DIRS dexela_api.h PATHS /usr/include) +find_path(DEXELA_INCLUDE_DIRS dexela_api.h PATHS /usr/include /usr/include/dexela) find_library(DEXELA_LIBRARIES dexela) find_package_handle_standard_args(DEXELA DEFAULT_MSG DEXELA_LIBRARIES DEXELA_INCLUDE_DIRS) -- cgit v1.2.3 From 0e4338b82c6995f4b8647ec668a752b69085c052 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Wed, 9 Apr 2014 12:09:54 +0200 Subject: Make pylon plugin compatible with current libuca --- cmake/FindPylon.cmake | 8 +-- plugins/pylon/CMakeLists.txt | 10 +-- plugins/pylon/changelog.txt | 4 +- plugins/pylon/uca-pylon-camera.c | 127 ++++++++++++++++++++++----------------- plugins/pylon/uca-pylon-camera.h | 2 - 5 files changed, 85 insertions(+), 66 deletions(-) diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake index d3f8879..e096bb4 100644 --- a/cmake/FindPylon.cmake +++ b/cmake/FindPylon.cmake @@ -1,11 +1,11 @@ -# Try to find libpco.so +# Try to find libpylon.so # # Defines # -# PYLON_FOUND - system has libpco -# PYLON_INCLUDE_DIR - libpco include directory -# PYLON_LIB - pco library +# PYLON_FOUND - system has libpylon +# PYLON_INCLUDE_DIR - libpylon include directory +# PYLON_LIB - pylon library # check for environment variable PYLON_ROOT find_package(YAT) diff --git a/plugins/pylon/CMakeLists.txt b/plugins/pylon/CMakeLists.txt index 7e573f1..3f8569c 100644 --- a/plugins/pylon/CMakeLists.txt +++ b/plugins/pylon/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 2.6) project(ucapylon C) -set(VERSION "1.0.0") +set(VERSION "1.1.0") find_package(Pylon) if (PYLON_FOUND) set(UCA_CAMERA_NAME "pylon") + set(PLUGIN_REVISION "1") set(PLUGIN_VERSION ${VERSION}) - set(PLUGIN_REVISION "2") set(PLUGIN_SUMMARY "Pylon plugin for libuca") set(PLUGIN_CHANGELOG "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt") set(PLUGIN_DESCRIPTION "Plugin for the Basler GigE CCD Camera.") @@ -25,10 +25,10 @@ if (PYLON_FOUND) create_enums(uca-pylon-enums ${CMAKE_CURRENT_SOURCE_DIR}/../../src/uca-enums uca-pylon-camera.h) - + add_library(ucapylon SHARED - uca-pylon-enums.c - uca-pylon-camera.c) + uca-pylon-camera.c + uca-pylon-enums.c) target_link_libraries(ucapylon ${UCA_DEPS} diff --git a/plugins/pylon/changelog.txt b/plugins/pylon/changelog.txt index 78c6406..755233e 100644 --- a/plugins/pylon/changelog.txt +++ b/plugins/pylon/changelog.txt @@ -1,4 +1,6 @@ -* Tue Oct 15 2013 Mihael Koep 1.0.0-2 +* Wed Apr 9 2014 Mihael Koep 1.1.0-1 +- make compatible with current libuca +* Tue Oct 15 2013 Mihael Koep 1.0.2-2 - updated to libuca 1.3.0 * Tue Apr 23 2013 Vasili Kvockin 1.0.0-1 - repackaged as part of libuca 1.* diff --git a/plugins/pylon/uca-pylon-camera.c b/plugins/pylon/uca-pylon-camera.c index 97c7d35..069d573 100644 --- a/plugins/pylon/uca-pylon-camera.c +++ b/plugins/pylon/uca-pylon-camera.c @@ -20,12 +20,17 @@ #include #include #include +#include #include "uca-pylon-camera.h" #include "uca-pylon-enums.h" #define UCA_PYLON_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_PYLON_CAMERA, UcaPylonCameraPrivate)) -G_DEFINE_TYPE(UcaPylonCamera, uca_pylon_camera, UCA_TYPE_CAMERA) +static void uca_pylon_camera_initable_iface_init (GInitableIface *iface); + +G_DEFINE_TYPE_WITH_CODE (UcaPylonCamera, uca_pylon_camera, UCA_TYPE_CAMERA, + G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, + uca_pylon_camera_initable_iface_init)) #define PROP_GAIN_MIN 300 #define PROP_GAIN_MAX 400 @@ -50,7 +55,7 @@ enum { PROP_ROI_HEIGHT_DEFAULT, PROP_GAIN, PROP_BALANCE_WHITE_AUTO, - N_PROPERTIES + N_PROPERTIES }; static gint base_overrideables[] = { @@ -103,29 +108,6 @@ static void pylon_set_roi(GObject *object, GError** error) pylon_camera_set_roi(priv->roi_x, priv->roi_y, priv->roi_width, priv->roi_height, error); } -UcaPylonCamera *uca_pylon_camera_new(GError **error) -{ - UcaPylonCamera *camera = g_object_new(UCA_TYPE_PYLON_CAMERA, NULL); - UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(camera); - - gchar* pylon_camera_ip = getenv("PYLON_CAMERA_IP"); - if(!pylon_camera_ip) { - g_error("no environment variable PYLON_CAMERA_IP found"); - } - - pylon_camera_new("/usr/local/lib64", pylon_camera_ip, error); - - if (*error != NULL) - return NULL; - - pylon_camera_get_sensor_size(&priv->width, &priv->height, error); - - if (*error != NULL) - return NULL; - - return camera; -} - static void uca_pylon_camera_start_recording(UcaCamera *camera, GError **error) { g_return_if_fail(UCA_IS_PYLON_CAMERA(camera)); @@ -133,7 +115,6 @@ static void uca_pylon_camera_start_recording(UcaCamera *camera, GError **error) priv->num_bytes = 2; pylon_camera_start_acquision(error); - } static void uca_pylon_camera_stop_recording(UcaCamera *camera, GError **error) @@ -142,15 +123,16 @@ static void uca_pylon_camera_stop_recording(UcaCamera *camera, GError **error) pylon_camera_stop_acquision(error); } -static void uca_pylon_camera_grab(UcaCamera *camera, gpointer *data, GError **error) +static gboolean uca_pylon_camera_grab(UcaCamera *camera, gpointer data, GError **error) { - g_return_if_fail(UCA_IS_PYLON_CAMERA(camera)); + g_return_val_if_fail(UCA_IS_PYLON_CAMERA(camera), FALSE); UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(camera); - if (*data == NULL) { - *data = g_malloc0(priv->roi_width * priv->roi_height * priv->num_bytes); + if (data == NULL) { + data = g_malloc0(priv->roi_width * priv->roi_height * priv->num_bytes); } - pylon_camera_grab(data, error); + pylon_camera_grab(&data, error); + return TRUE; } static void uca_pylon_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) @@ -166,9 +148,9 @@ static void uca_pylon_camera_set_property(GObject *object, guint property_id, co case PROP_TRIGGER_MODE: break; case PROP_BALANCE_WHITE_AUTO: - { - pylon_camera_set_int_attribute("BalanceWhiteAuto", g_value_get_enum(value), &error); - } + { + pylon_camera_set_int_attribute("BalanceWhiteAuto", g_value_get_enum(value), &error); + } break; case PROP_ROI_X: @@ -211,12 +193,12 @@ static void uca_pylon_camera_set_property(GObject *object, guint property_id, co G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); return; } - + if (error) { if(error->message) { - g_warning("failed to set property %d: %s", property_id, error->message); + g_warning("failed to set property %d: %s", property_id, error->message); } else { - g_warning("failed to set property %d", property_id); + g_warning("failed to set property %d", property_id); } } } @@ -228,13 +210,13 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV switch (property_id) { case PROP_BALANCE_WHITE_AUTO: - { - gint enum_value = UCA_CAMERA_BALANCE_WHITE_OFF; - pylon_camera_get_int_attribute("BalanceWhiteAuto", &enum_value, &error); - UcaCameraBalanceWhiteAuto mode = enum_value; - g_value_set_enum(value, mode); - break; - } + { + gint enum_value = UCA_CAMERA_BALANCE_WHITE_OFF; + pylon_camera_get_int_attribute("BalanceWhiteAuto", &enum_value, &error); + UcaCameraBalanceWhiteAuto mode = enum_value; + g_value_set_enum(value, mode); + break; + } case PROP_SENSOR_WIDTH: pylon_camera_get_sensor_size(&priv->width, &priv->height, &error); g_value_set_uint(value, priv->width); @@ -345,11 +327,11 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV break; case PROP_NAME: - { - const gchar* name = NULL; - pylon_camera_get_string_attribute("ModelName", &name, &error); - g_value_set_string(value, name); - } + { + const gchar* name = NULL; + pylon_camera_get_string_attribute("ModelName", &name, &error); + g_value_set_string(value, name); + } break; default: @@ -358,9 +340,9 @@ static void uca_pylon_camera_get_property(GObject *object, guint property_id, GV } if (error) { if(error->message) { - g_warning("failed to get property %d: %s", property_id, error->message); + g_warning("failed to get property %d: %s", property_id, error->message); } else { - g_warning("failed to get property %d", property_id); + g_warning("failed to get property %d", property_id); } } //g_debug("pylon_get_property end\n"); @@ -374,6 +356,42 @@ static void uca_pylon_camera_finalize(GObject *object) G_OBJECT_CLASS(uca_pylon_camera_parent_class)->finalize(object); } +static gboolean uca_pylon_camera_initable_init(GInitable *initable, GCancellable *cancellable, GError **error) +{ + g_return_val_if_fail (UCA_IS_PYLON_CAMERA (initable), FALSE); + + if (cancellable != NULL) { + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + "Cancellable initialization not supported"); + return FALSE; + } + + UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(initable); + + gchar* pylon_camera_ip = getenv("PYLON_CAMERA_IP"); + if(!pylon_camera_ip) { + g_error("no environment variable PYLON_CAMERA_IP found"); + } + + pylon_camera_new("/usr/local/lib64", pylon_camera_ip, error); + if (*error != NULL) { + return FALSE; + } + + pylon_camera_get_sensor_size(&priv->width, &priv->height, error); + if (*error != NULL) { + return FALSE; + } + + return TRUE; +} + +static void uca_pylon_camera_initable_iface_init(GInitableIface *iface) +{ + iface->init = uca_pylon_camera_initable_init; +} + + static void uca_pylon_camera_class_init(UcaPylonCameraClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); @@ -430,6 +448,7 @@ static void uca_pylon_camera_class_init(UcaPylonCameraClass *klass) static void uca_pylon_camera_init(UcaPylonCamera *self) { + self->priv = UCA_PYLON_CAMERA_GET_PRIVATE(self); /* binnings */ @@ -440,8 +459,8 @@ static void uca_pylon_camera_init(UcaPylonCamera *self) g_value_array_append(self->priv->binnings, &val); } -G_MODULE_EXPORT UcaCamera * -uca_camera_impl_new (GError **error) +G_MODULE_EXPORT GType +uca_camera_get_type (void) { - return UCA_CAMERA(uca_pylon_camera_new(error)); + return UCA_TYPE_PYLON_CAMERA; } diff --git a/plugins/pylon/uca-pylon-camera.h b/plugins/pylon/uca-pylon-camera.h index ed95544..f3d7bb5 100644 --- a/plugins/pylon/uca-pylon-camera.h +++ b/plugins/pylon/uca-pylon-camera.h @@ -71,8 +71,6 @@ struct _UcaPylonCameraClass { UcaCameraClass parent; }; -UcaPylonCamera *uca_pylon_camera_new(GError **error); - GType uca_pylon_camera_get_type(void); G_END_DECLS -- cgit v1.2.3 From 10c2e35112d43c06fc715014b33094761f01c992 Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Wed, 9 Apr 2014 14:58:01 +0200 Subject: Remove unnecessary allocation We now require libpyloncam 0.3.0 or better and got rid of a unnecessary memory check and allocation --- plugins/pylon/CMakeLists.txt | 4 ++-- plugins/pylon/changelog.txt | 3 +++ plugins/pylon/uca-pylon-camera.c | 6 +----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/pylon/CMakeLists.txt b/plugins/pylon/CMakeLists.txt index 3f8569c..5864b84 100644 --- a/plugins/pylon/CMakeLists.txt +++ b/plugins/pylon/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.6) project(ucapylon C) -set(VERSION "1.1.0") +set(VERSION "1.1.1") find_package(Pylon) @@ -11,7 +11,7 @@ if (PYLON_FOUND) set(PLUGIN_SUMMARY "Pylon plugin for libuca") set(PLUGIN_CHANGELOG "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt") set(PLUGIN_DESCRIPTION "Plugin for the Basler GigE CCD Camera.") - set(PLUGIN_REQUIRES "libuca >= 1.3.0, libpyloncam >= 0.2.3") + set(PLUGIN_REQUIRES "libuca >= 1.3.0, libpyloncam >= 0.3.0") set(PLUGIN_VENDOR "ANKA Computing Group") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../package-plugin.sh.in diff --git a/plugins/pylon/changelog.txt b/plugins/pylon/changelog.txt index 755233e..adfa95b 100644 --- a/plugins/pylon/changelog.txt +++ b/plugins/pylon/changelog.txt @@ -1,3 +1,6 @@ +* Wed Apr 9 2014 Mihael Koep 1.1.1-1 +- remove unneeded memory allocation +- require libpyloncam 0.3.0 * Wed Apr 9 2014 Mihael Koep 1.1.0-1 - make compatible with current libuca * Tue Oct 15 2013 Mihael Koep 1.0.2-2 diff --git a/plugins/pylon/uca-pylon-camera.c b/plugins/pylon/uca-pylon-camera.c index 069d573..02d6795 100644 --- a/plugins/pylon/uca-pylon-camera.c +++ b/plugins/pylon/uca-pylon-camera.c @@ -126,12 +126,8 @@ static void uca_pylon_camera_stop_recording(UcaCamera *camera, GError **error) static gboolean uca_pylon_camera_grab(UcaCamera *camera, gpointer data, GError **error) { g_return_val_if_fail(UCA_IS_PYLON_CAMERA(camera), FALSE); - UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(camera); - if (data == NULL) { - data = g_malloc0(priv->roi_width * priv->roi_height * priv->num_bytes); - } - pylon_camera_grab(&data, error); + pylon_camera_grab(data, error); return TRUE; } -- cgit v1.2.3