summaryrefslogtreecommitdiffstats
path: root/src/ufo-roof-read-task.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ufo-roof-read-task.c')
-rw-r--r--src/ufo-roof-read-task.c62
1 files changed, 58 insertions, 4 deletions
diff --git a/src/ufo-roof-read-task.c b/src/ufo-roof-read-task.c
index 1582437..a8ddded 100644
--- a/src/ufo-roof-read-task.c
+++ b/src/ufo-roof-read-task.c
@@ -39,6 +39,9 @@ struct _UfoRoofReadTaskPrivate {
guint id; // Reader ID (defince sequential port number)
gboolean stop; // Flag requiring termination
+ gboolean simulate; // Indicates if we are running in network or simulation modes
+ gchar *path; // UFO file path for simulation mode
+ guint first_file_number; // Number of a first simulated file (0 or 1)
};
static void ufo_task_interface_init (UfoTaskIface *iface);
@@ -54,6 +57,9 @@ enum {
PROP_ID,
PROP_STOP,
PROP_CONFIG,
+ PROP_SIMULATE,
+ PROP_PATH,
+ PROP_FIRST,
N_PROPERTIES
};
@@ -77,7 +83,7 @@ ufo_roof_read_task_setup (UfoTask *task,
if (!priv->config)
roof_setup_error(error, "ROOF configuration is not specified");
- priv->cfg = ufo_roof_config_new(priv->config, &gerr);
+ priv->cfg = ufo_roof_config_new(priv->config, priv->simulate?UFO_ROOF_CONFIG_SIMULATION:UFO_ROOF_CONFIG_DEFAULT, &gerr);
if (!priv->cfg) roof_propagate_error(error, gerr, "roof_config_new: ");
// Consistency checks
@@ -85,9 +91,12 @@ ufo_roof_read_task_setup (UfoTask *task,
roof_setup_error(error, "Specified Stream ID is %u, but only %u data streams is configured", priv->id, priv->cfg->n_streams);
// Start actual reader
- if (priv->cfg->path)
- priv->reader = ufo_roof_read_file_new(priv->cfg, priv->id, &gerr);
- else
+ if (priv->simulate) {
+ if (!priv->path)
+ roof_setup_error(error, "Path to simulated data should be specified");
+
+ priv->reader = ufo_roof_read_file_new(priv->cfg, priv->path, priv->id + priv->first_file_number, &gerr);
+ } else
priv->reader = ufo_roof_read_socket_new(priv->cfg, priv->id, &gerr);
if (!priv->reader)
@@ -115,6 +124,11 @@ ufo_roof_read_task_finalize (GObject *object)
priv->config = NULL;
}
+ if (priv->path) {
+ g_free(priv->path);
+ priv->path = NULL;
+ }
+
G_OBJECT_CLASS (ufo_roof_read_task_parent_class)->finalize (object);
}
@@ -206,6 +220,16 @@ ufo_roof_read_task_set_property (GObject *object,
case PROP_STOP:
priv->stop = g_value_get_boolean (value);
break;
+ case PROP_SIMULATE:
+ priv->simulate = g_value_get_boolean (value);
+ break;
+ case PROP_PATH:
+ if (priv->path) g_free(priv->path);
+ priv->path = g_value_dup_string(value);
+ break;
+ case PROP_FIRST:
+ priv->first_file_number = g_value_get_uint (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -230,6 +254,15 @@ ufo_roof_read_task_get_property (GObject *object,
case PROP_STOP:
g_value_set_boolean (value, priv->stop);
break;
+ case PROP_SIMULATE:
+ g_value_set_boolean (value, priv->simulate);
+ break;
+ case PROP_PATH:
+ g_value_set_string(value, priv->path?priv->path:"");
+ break;
+ case PROP_FIRST:
+ g_value_set_uint (value, priv->first_file_number);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -277,6 +310,27 @@ ufo_roof_read_task_class_init (UfoRoofReadTaskClass *klass)
FALSE,
G_PARAM_READWRITE);
+ properties[PROP_SIMULATE] =
+ g_param_spec_boolean ("simulate",
+ "Simulation mode",
+ "Read data from the specified files instead of network",
+ FALSE,
+ G_PARAM_READWRITE);
+
+ properties[PROP_PATH] =
+ g_param_spec_string ("path",
+ "Input files for simulation mode",
+ "Optional path to input files for simulation mode (parameter from configuration file is used if not specified)",
+ "",
+ G_PARAM_READWRITE);
+
+ properties[PROP_FIRST] =
+ g_param_spec_uint ("first_file_number",
+ "Offset to the first read file",
+ "Offset to the first read file",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE);
+
for (guint i = PROP_0 + 1; i < N_PROPERTIES; i++)
g_object_class_install_property (oclass, i, properties[i]);