aboutsummaryrefslogtreecommitdiff
path: root/src/gui_backend_local.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-12-02 16:57:01 +0100
committerThomas White <taw@physics.org>2020-12-02 16:57:49 +0100
commit2d00bfeca27c416b1f14bccf5b1e7c09a9755765 (patch)
treef18333e44062ab442656a26bf5a8d079b2a87f7c /src/gui_backend_local.c
parent1a842e532bebbc5bc32dd584526aee5020f17848 (diff)
Local BE: Run merging
Diffstat (limited to 'src/gui_backend_local.c')
-rw-r--r--src/gui_backend_local.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/gui_backend_local.c b/src/gui_backend_local.c
index 4e630ad2..42d01883 100644
--- a/src/gui_backend_local.c
+++ b/src/gui_backend_local.c
@@ -37,6 +37,7 @@
#include "gui_project.h"
#include "gui_index.h"
+#include "gui_merge.h"
struct local_indexing_opts
@@ -413,13 +414,57 @@ static GtkWidget *make_merging_parameters_widget(void *opts_priv)
}
+static gboolean merge_readable(GIOChannel *source, GIOCondition cond,
+ void *vp)
+{
+ GIOStatus r;
+ GError *err = NULL;
+ struct local_job *job = vp;
+ gchar *line;
+
+ r = g_io_channel_read_line(source, &line, NULL, NULL, &err);
+ if ( r == G_IO_STATUS_EOF ) {
+ STATUS("End of output.\n");
+ return FALSE;
+ }
+ if ( r != G_IO_STATUS_NORMAL ) {
+ if ( job->pid != 0 ) {
+ STATUS("Read error?\n");
+ } else {
+ STATUS("End of output (merge exited)\n");
+ }
+ return FALSE;
+ }
+
+ /* FIXME: Calculate the fraction complete */
+ job->frac_complete = 0.5;
+
+ g_free(line);
+
+ return TRUE;
+}
+
+
static void *run_merging(const char *job_title,
const char *job_notes,
struct crystfelproject *proj,
struct gui_result *input,
void *opts_priv)
{
- return NULL;
+ char n_thread_str[64];
+ char **args;
+ struct local_job *job;
+ struct local_merging_opts *opts = opts_priv;
+
+ snprintf(n_thread_str, 63, "%i", opts->n_threads);
+ args = merging_command_line(n_thread_str,
+ input,
+ &proj->merging_params);
+
+ job = start_local_job(args, job_title, job_notes, proj,
+ merge_readable);
+
+ return job;
}