diff options
Diffstat (limited to 'plugins/xkit')
| -rw-r--r-- | plugins/xkit/CMakeLists.txt | 32 | ||||
| -rw-r--r-- | plugins/xkit/uca-xkit-camera.cc | 254 | ||||
| -rw-r--r-- | plugins/xkit/uca-xkit-camera.h | 76 | 
3 files changed, 362 insertions, 0 deletions
diff --git a/plugins/xkit/CMakeLists.txt b/plugins/xkit/CMakeLists.txt new file mode 100644 index 0000000..f328f25 --- /dev/null +++ b/plugins/xkit/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 2.8) +project(ucaxkit CXX) + +set(UCA_CAMERA_NAME "xkit") +set(PLUGIN_VERSION "0.1.0") +set(PLUGIN_REVISION "0") +set(PLUGIN_REQUIRES "libuca >= 1.2.0") + +find_path (XKIT_INCLUDE_DIR +           NAMES dll_api.h mpxhw.h) + +find_library (XKIT_LIBRARIES +              NAMES xKIT) + +if (XKIT_INCLUDE_DIR AND XKIT_LIBRARIES) +    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../package-plugin.sh.in +                   ${CMAKE_CURRENT_BINARY_DIR}/../../package-plugin-${UCA_CAMERA_NAME}.sh) +    include_directories(${XKIT_INCLUDE_DIR}) + +    # We have to compile with g++ because the included header files have C++ +    # style comments ... +    add_library(ucaxkit SHARED +                uca-xkit-camera.cc) + +    target_link_libraries(ucaxkit +                          ${UCA_DEPS} +                          ${XKIT_LIBRARIES}) + +    install(TARGETS ucaxkit +            LIBRARY DESTINATION ${LIB_INSTALL_DIR}/uca +            COMPONENT ${UCA_CAMERA_NAME}) +endif () diff --git a/plugins/xkit/uca-xkit-camera.cc b/plugins/xkit/uca-xkit-camera.cc new file mode 100644 index 0000000..525aa79 --- /dev/null +++ b/plugins/xkit/uca-xkit-camera.cc @@ -0,0 +1,254 @@ +/* Copyright (C) 2011-2013 Matthias Vogelgesang <matthias.vogelgesang@kit.edu> +   (Karlsruhe Institute of Technology) + +   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 <dll_api.h> + +#undef FALSE +#undef TRUE + +#include <gio/gio.h> +#include <gmodule.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +#include "uca-camera.h" +#include "uca-xkit-camera.h" + + +#define UCA_XKIT_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_XKIT_CAMERA, UcaXkitCameraPrivate)) + +static void uca_xkit_camera_initable_iface_init (GInitableIface *iface); + +G_DEFINE_TYPE_WITH_CODE (UcaXkitCamera, uca_xkit_camera, UCA_TYPE_CAMERA, +                         G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, +                                                uca_xkit_camera_initable_iface_init)) + +GQuark uca_xkit_camera_error_quark() +{ +    return g_quark_from_static_string("uca-ufo-camera-error-quark"); +} + +enum { +    PROP_SENSOR_TEMPERATURE = N_BASE_PROPERTIES, +    PROP_FPGA_TEMPERATURE, +    PROP_UFO_START, +    N_MAX_PROPERTIES = 512 +}; + +static gint base_overrideables[] = { +    PROP_SENSOR_BITDEPTH, +    PROP_ROI_WIDTH, +    PROP_ROI_HEIGHT, +    0, +}; + +static GParamSpec *ufo_properties[N_MAX_PROPERTIES] = { NULL, }; + +static guint N_PROPERTIES; + +struct _UcaXkitCameraPrivate { +    GError  *construct_error; +}; + + +static gboolean +setup_xkit (UcaXkitCameraPrivate *priv) +{ +    Mpx2Interface *interface; + +    interface = getMpx2Interface(); + +    return TRUE; +} + +static void +uca_xkit_camera_start_recording (UcaCamera *camera, +                                 GError **error) +{ +    g_return_if_fail (UCA_IS_XKIT_CAMERA (camera)); +} + +static void +uca_xkit_camera_stop_recording (UcaCamera *camera, +                                GError **error) +{ +    g_return_if_fail (UCA_IS_XKIT_CAMERA (camera)); +} + +static void +uca_xkit_camera_start_readout (UcaCamera *camera, +                               GError **error) +{ +    g_return_if_fail( UCA_IS_XKIT_CAMERA (camera)); +} + +static void +uca_xkit_camera_stop_readout (UcaCamera *camera, +                              GError **error) +{ +    g_return_if_fail (UCA_IS_XKIT_CAMERA (camera)); +} + +static gboolean +uca_xkit_camera_grab (UcaCamera *camera, +                      gpointer data, +                      GError **error) +{ +    g_return_val_if_fail (UCA_IS_XKIT_CAMERA (camera), FALSE); +    return TRUE; +} + +static void +uca_xkit_camera_trigger (UcaCamera *camera, +                         GError **error) +{ +    g_return_if_fail (UCA_IS_XKIT_CAMERA (camera)); +} + +static void +uca_xkit_camera_set_property (GObject *object, +                              guint property_id, +                              const GValue *value, +                              GParamSpec *pspec) +{ +    /* UcaXkitCameraPrivate *priv = UCA_XKIT_CAMERA_GET_PRIVATE(object); */ + +    switch (property_id) { +        default: +            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +            return; +    } +} + +static void +uca_xkit_camera_get_property (GObject *object, +                              guint property_id, +                              GValue *value, +                              GParamSpec *pspec) +{ +    /* UcaXkitCameraPrivate *priv = UCA_XKIT_CAMERA_GET_PRIVATE(object); */ + +    switch (property_id) { +        case PROP_ROI_WIDTH: +            g_value_set_uint (value, 512); +            break; +        case PROP_ROI_HEIGHT: +            g_value_set_uint (value, 512); +            break; +        case PROP_SENSOR_BITDEPTH: +            g_value_set_uint (value, 11); +            break; +        default: +            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +            break; +    } +} + +static void +uca_xkit_camera_finalize(GObject *object) +{ +    UcaXkitCameraPrivate *priv; + +    priv = UCA_XKIT_CAMERA_GET_PRIVATE (object); +    g_clear_error (&priv->construct_error); + +    G_OBJECT_CLASS (uca_xkit_camera_parent_class)->finalize (object); +} + +static gboolean +ufo_xkit_camera_initable_init (GInitable *initable, +                               GCancellable *cancellable, +                               GError **error) +{ +    UcaXkitCamera *camera; +    UcaXkitCameraPrivate *priv; + +    g_return_val_if_fail (UCA_IS_XKIT_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; +    } + +    camera = UCA_XKIT_CAMERA (initable); +    priv = camera->priv; + +    if (priv->construct_error != NULL) { +        if (error) +            *error = g_error_copy (priv->construct_error); + +        return FALSE; +    } + +    return TRUE; +} + +static void +uca_xkit_camera_initable_iface_init (GInitableIface *iface) +{ +    iface->init = ufo_xkit_camera_initable_init; +} + +static void +uca_xkit_camera_class_init (UcaXkitCameraClass *klass) +{ +    GObjectClass *gobject_class = G_OBJECT_CLASS(klass); +    gobject_class->set_property = uca_xkit_camera_set_property; +    gobject_class->get_property = uca_xkit_camera_get_property; +    gobject_class->finalize = uca_xkit_camera_finalize; + +    UcaCameraClass *camera_class = UCA_CAMERA_CLASS(klass); +    camera_class->start_recording = uca_xkit_camera_start_recording; +    camera_class->stop_recording = uca_xkit_camera_stop_recording; +    camera_class->start_readout = uca_xkit_camera_start_readout; +    camera_class->stop_readout = uca_xkit_camera_stop_readout; +    camera_class->grab = uca_xkit_camera_grab; +    camera_class->trigger = uca_xkit_camera_trigger; + +    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]]); + +    g_type_class_add_private(klass, sizeof(UcaXkitCameraPrivate)); +} + +static void +uca_xkit_camera_init(UcaXkitCamera *self) +{ +    UcaCamera *camera; +    UcaXkitCameraPrivate *priv; +    GObjectClass *oclass; + +    self->priv = priv = UCA_XKIT_CAMERA_GET_PRIVATE(self); +    priv->construct_error = NULL; + +    if (!setup_xkit (priv)) +        return; + +    oclass = G_OBJECT_GET_CLASS (self); + +    for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) +        g_object_class_install_property(oclass, id, ufo_properties[id]); +} + +G_MODULE_EXPORT GType +uca_camera_get_type (void) +{ +    return UCA_TYPE_XKIT_CAMERA; +} diff --git a/plugins/xkit/uca-xkit-camera.h b/plugins/xkit/uca-xkit-camera.h new file mode 100644 index 0000000..6dc66f2 --- /dev/null +++ b/plugins/xkit/uca-xkit-camera.h @@ -0,0 +1,76 @@ +/* Copyright (C) 2011, 2012 Matthias Vogelgesang <matthias.vogelgesang@kit.edu> +   (Karlsruhe Institute of Technology) + +   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_XKIT_CAMERA_H +#define __UCA_XKIT_CAMERA_H + +#include <glib-object.h> +#include "uca-camera.h" + +G_BEGIN_DECLS + +#define UCA_TYPE_XKIT_CAMERA             (uca_xkit_camera_get_type()) +#define UCA_XKIT_CAMERA(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), UCA_TYPE_XKIT_CAMERA, UcaXkitCamera)) +#define UCA_IS_XKIT_CAMERA(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), UCA_TYPE_XKIT_CAMERA)) +#define UCA_XKIT_CAMERA_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), UCA_TYPE_XKIT_CAMERA, UcaXkitCameraClass)) +#define UCA_IS_XKIT_CAMERA_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), UCA_TYPE_XKIT_CAMERA)) +#define UCA_XKIT_CAMERA_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), UCA_TYPE_XKIT_CAMERA, UcaXkitCameraClass)) + +#define UCA_XKIT_CAMERA_ERROR uca_xkit_camera_error_quark() +typedef enum { +    UCA_XKIT_CAMERA_ERROR_INIT, +    UCA_XKIT_CAMERA_ERROR_START_RECORDING, +    UCA_XKIT_CAMERA_ERROR_STOP_RECORDING, +    UCA_XKIT_CAMERA_ERROR_TRIGGER, +    UCA_XKIT_CAMERA_ERROR_NEXT_EVENT, +    UCA_XKIT_CAMERA_ERROR_NO_DATA, +    UCA_XKIT_CAMERA_ERROR_MAYBE_CORRUPTED +} UcaXkitCameraError; + +typedef struct _UcaXkitCamera           UcaXkitCamera; +typedef struct _UcaXkitCameraClass      UcaXkitCameraClass; +typedef struct _UcaXkitCameraPrivate    UcaXkitCameraPrivate; + +/** + * UcaXkitCamera: + * + * Creates #UcaXkitCamera instances by loading corresponding shared objects. The + * contents of the #UcaXkitCamera structure are private and should only be + * accessed via the provided API. + */ +struct _UcaXkitCamera { +    /*< private >*/ +    UcaCamera parent; + +    UcaXkitCameraPrivate *priv; +}; + +/** + * UcaXkitCameraClass: + * + * #UcaXkitCamera class + */ +struct _UcaXkitCameraClass { +    /*< private >*/ +    UcaCameraClass parent; +}; + +GType uca_xkit_camera_get_type(void); + +G_END_DECLS + +#endif  | 
