From 453701eddba38052a466e91d614fd999b52bca4a Mon Sep 17 00:00:00 2001 From: Timo Dritschler Date: Mon, 2 Mar 2015 15:57:23 +0100 Subject: Added check for 'writable during acquisition' to all set_property calls --- plugins/dexela/uca-dexela-camera.c | 8 +++++++- plugins/file/uca-file-camera.c | 8 +++++++- plugins/mock/uca-mock-camera.c | 19 ++++++++++++------- plugins/pco/uca-pco-camera.c | 11 ++++++++++- plugins/pf/uca-pf-camera.c | 9 ++++++++- plugins/pylon/uca-pylon-camera.c | 8 +++++++- plugins/ufo/uca-ufo-camera.c | 8 +++++++- 7 files changed, 58 insertions(+), 13 deletions(-) diff --git a/plugins/dexela/uca-dexela-camera.c b/plugins/dexela/uca-dexela-camera.c index 49f4635..81d9f74 100644 --- a/plugins/dexela/uca-dexela-camera.c +++ b/plugins/dexela/uca-dexela-camera.c @@ -264,7 +264,13 @@ 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); + g_return_if_fail (UCA_IS_DEXELA_CAMERA (object)); + UcaDexelaCameraPrivate *priv = UCA_DEXELA_CAMERA_GET_PRIVATE (object); + + if (uca_camera_is_recording (UCA_CAMERA (object)) && !uca_camera_is_writable_during_acquisition (UCA_CAMERA (object), pspec->name)) { + g_warning ("Property '%s' cant be changed during acquisition", pspec->name); + return; + } switch (property_id) { case PROP_EXPOSURE_TIME: diff --git a/plugins/file/uca-file-camera.c b/plugins/file/uca-file-camera.c index 5c7b5cb..632b8e8 100644 --- a/plugins/file/uca-file-camera.c +++ b/plugins/file/uca-file-camera.c @@ -221,7 +221,13 @@ uca_file_camera_set_property (GObject *object, guint property_id, const GValue * static void uca_file_camera_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - UcaFileCameraPrivate *priv = UCA_FILE_CAMERA_GET_PRIVATE(object); + g_return_if_fail (UCA_IS_FILE_CAMERA (object)); + UcaFileCameraPrivate *priv = UCA_FILE_CAMERA_GET_PRIVATE (object); + + if (uca_camera_is_recording(UCA_CAMERA(object)) && !uca_camera_is_writable_during_acquisition(UCA_CAMERA(object), pspec->name)) { + g_warning ("Property '%s' cant be changed during acquisition", pspec->name); + return; + } switch (property_id) { case PROP_NAME: diff --git a/plugins/mock/uca-mock-camera.c b/plugins/mock/uca-mock-camera.c index eb41fcf..a406f93 100644 --- a/plugins/mock/uca-mock-camera.c +++ b/plugins/mock/uca-mock-camera.c @@ -293,27 +293,32 @@ uca_mock_camera_grab (UcaCamera *camera, gpointer data, GError **error) static void uca_mock_camera_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - g_return_if_fail(UCA_IS_MOCK_CAMERA(object)); - UcaMockCameraPrivate *priv = UCA_MOCK_CAMERA_GET_PRIVATE(object); + g_return_if_fail (UCA_IS_MOCK_CAMERA (object)); + UcaMockCameraPrivate *priv = UCA_MOCK_CAMERA_GET_PRIVATE (object); + + if (uca_camera_is_recording (UCA_CAMERA (object)) && !uca_camera_is_writable_during_acquisition (UCA_CAMERA (object), pspec->name)) { + g_warning ("Property '%s' cant be changed during acquisition", pspec->name); + return; + } switch (property_id) { case PROP_EXPOSURE_TIME: priv->exposure_time = g_value_get_double (value); break; case PROP_ROI_X: - priv->roi_x = g_value_get_uint(value); + priv->roi_x = g_value_get_uint (value); break; case PROP_ROI_Y: - priv->roi_y = g_value_get_uint(value); + priv->roi_y = g_value_get_uint (value); break; case PROP_ROI_WIDTH: - priv->roi_width = g_value_get_uint(value); + priv->roi_width = g_value_get_uint (value); break; case PROP_ROI_HEIGHT: - priv->roi_height = g_value_get_uint(value); + priv->roi_height = g_value_get_uint (value); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); return; } } diff --git a/plugins/pco/uca-pco-camera.c b/plugins/pco/uca-pco-camera.c index 52fded5..b10d815 100644 --- a/plugins/pco/uca-pco-camera.c +++ b/plugins/pco/uca-pco-camera.c @@ -687,9 +687,15 @@ uca_pco_camera_grab(UcaCamera *camera, gpointer data, GError **error) static void uca_pco_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - UcaPcoCameraPrivate *priv = UCA_PCO_CAMERA_GET_PRIVATE(object); + g_return_if_fail (UCA_IS_PCO_CAMERA (object)); + UcaPcoCameraPrivate *priv = UCA_PCO_CAMERA_GET_PRIVATE (object); guint err = PCO_NOERROR; + if (uca_camera_is_recording (UCA_CAMERA (object)) && !uca_camera_is_writable_during_acquisition (UCA_CAMERA (object), pspec->name)) { + g_warning ("Property '%s' cant be changed during acquisition", pspec->name); + return; + } + switch (property_id) { case PROP_SENSOR_EXTENDED: { @@ -1781,6 +1787,9 @@ uca_pco_camera_init (UcaPcoCamera *self) uca_camera_register_unit (camera, "cooling-point-default", UCA_UNIT_DEGREE_CELSIUS); uca_camera_register_unit (camera, "sensor-adcs", UCA_UNIT_COUNT); uca_camera_register_unit (camera, "sensor-max-adcs", UCA_UNIT_COUNT); + + uca_camera_set_writable (camera, "exposure-time"); + uca_camera_set_writable (camera, "frames-per-second"); } G_MODULE_EXPORT GType diff --git a/plugins/pf/uca-pf-camera.c b/plugins/pf/uca-pf-camera.c index 6515700..26f8d0d 100644 --- a/plugins/pf/uca-pf-camera.c +++ b/plugins/pf/uca-pf-camera.c @@ -208,9 +208,16 @@ uca_pf_camera_trigger(UcaCamera *camera, GError **error) static void uca_pf_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { + g_return_if_fail (UCA_IS_PF_CAMERA (object)); + + if (uca_camera_is_recording (UCA_CAMERA (object)) && !uca_camera_is_writable_during_acquisition (UCA_CAMERA (object), pspec->name)) { + g_warning ("Property '%s' cant be changed during acquisition", pspec->name); + return; + } + switch (property_id) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); return; } } diff --git a/plugins/pylon/uca-pylon-camera.c b/plugins/pylon/uca-pylon-camera.c index 4420d58..af6b8cf 100644 --- a/plugins/pylon/uca-pylon-camera.c +++ b/plugins/pylon/uca-pylon-camera.c @@ -135,9 +135,15 @@ static gboolean uca_pylon_camera_grab(UcaCamera *camera, gpointer data, GError * static void uca_pylon_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE(object); + g_return_if_fail (UCA_IS_PYLON_CAMERA (object)); + UcaPylonCameraPrivate *priv = UCA_PYLON_CAMERA_GET_PRIVATE (object); GError* error = NULL; + if (uca_camera_is_recording (UCA_CAMERA (object)) && !uca_camera_is_writable_during_acquisition (UCA_CAMERA (object), pspec->name)) { + g_warning ("Property '%s' cant be changed during acquisition", pspec->name); + return; + } + switch (property_id) { case PROP_SENSOR_HORIZONTAL_BINNING: /* intentional fall-through*/ diff --git a/plugins/ufo/uca-ufo-camera.c b/plugins/ufo/uca-ufo-camera.c index d718eb0..91b9b65 100644 --- a/plugins/ufo/uca-ufo-camera.c +++ b/plugins/ufo/uca-ufo-camera.c @@ -424,7 +424,13 @@ total_readout_time (UcaUfoCamera *camera) static void uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE(object); + g_return_if_fail (UCA_IS_UFO_CAMERA (object)); + UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE (object); + + if (uca_camera_is_recording (UCA_CAMERA (object)) && !uca_camera_is_writable_during_acquisition (UCA_CAMERA (object), pspec->name)) { + g_warning ("Property '%s' cant be changed during acquisition", pspec->name); + return; + } switch (property_id) { case PROP_EXPOSURE_TIME: -- cgit v1.2.3 From c9b2ba6558c8212e59bd3701a2e26744caead33b Mon Sep 17 00:00:00 2001 From: Timo Dritschler Date: Mon, 2 Mar 2015 16:17:15 +0100 Subject: Added test case for 'no write during acquisition' policy --- test/test-mock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test-mock.c b/test/test-mock.c index 5573666..3fc8988 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -285,8 +285,12 @@ test_can_be_written (Fixture *fixture, gconstpointer data) uca_camera_set_writable (fixture->camera, "roi-height", TRUE); uca_camera_start_recording (fixture->camera, &error); g_assert_no_error (error); - g_object_set (fixture->camera, "roi-height", 128, NULL); +#if (GLIB_CHECK_VERSION (2, 34, 0)) + g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Property 'exposure-time' cant be changed during acquisition"); + g_object_set (fixture->camera, "exposure-time", 1.0, NULL); + g_test_assert_expected_messages (); +#endif uca_camera_stop_recording (fixture->camera, &error); g_assert_no_error (error); } -- cgit v1.2.3