static void handle_replicate_json (UfoDaemon *daemon, UfoMessage *msg) { UfoDaemonPrivate *priv = UFO_DAEMON_GET_PRIVATE (daemon); gchar *json; UfoTaskGraph *graph; GError *error = NULL; json = read_json (daemon, msg); // send ack UfoMessage *response = ufo_message_new (UFO_MESSAGE_ACK, 0); ufo_messenger_send_blocking (priv->msger, response, NULL); ufo_message_free (response); graph = UFO_TASK_GRAPH (ufo_task_graph_new ()); ufo_task_graph_read_from_data (graph, priv->manager, json, &error); if (error != NULL) { g_printerr ("%s\n", error->message); goto replicate_json_free; } ufo_scheduler_run (priv->scheduler, graph, NULL); g_object_unref (priv->scheduler); priv->scheduler = ufo_scheduler_new (priv->config, NULL); replicate_json_free: g_object_unref (graph); g_free (json); }
static gpointer run_scheduler (UfoDaemon *daemon) { UfoDaemonPrivate *priv = UFO_DAEMON_GET_PRIVATE (daemon); g_message ("Start scheduler"); ufo_scheduler_run (priv->scheduler, priv->task_graph, NULL); g_message ("Done"); g_object_unref (priv->scheduler); priv->scheduler = ufo_scheduler_new (priv->config, NULL); return NULL; }
UfoDaemon * ufo_daemon_new (UfoConfig *config, gchar *listen_address) { UfoDaemon *daemon; g_return_val_if_fail (listen_address != NULL, NULL); g_return_val_if_fail (config != NULL, NULL); daemon = UFO_DAEMON (g_object_new (UFO_TYPE_DAEMON, NULL)); UfoDaemonPrivate *priv = UFO_DAEMON_GET_PRIVATE (daemon); priv->config = config; priv->listen_address = listen_address; priv->manager = ufo_plugin_manager_new (priv->config); priv->scheduler = ufo_scheduler_new (priv->config, NULL); #ifdef MPI priv->msger = UFO_MESSENGER (ufo_mpi_messenger_new ()); #else priv->msger = UFO_MESSENGER (ufo_zmq_messenger_new ()); #endif return daemon; }
int main(int n_args, char *argv[]) { GError *error = NULL; UfoTaskGraph *ufo_task_graph; UfoScheduler *ufo_scheduler; UfoPluginManager *ufo_plugin_manager; UfoNode *reader; UfoNode *cut_sinogram; UfoNode *zeropadding; UfoNode *fft; UfoNode *dfi_sinc; UfoNode *swap_quadrants; UfoNode *ifft; UfoNode *swap_quadrants_inverse; UfoNode *region_of_interest; UfoNode *backproject; UfoNode *filter; UfoNode *writer; g_type_init (); ufo_task_graph = ufo_task_graph_new(); ufo_plugin_manager = ufo_plugin_manager_new (NULL); ufo_scheduler = ufo_scheduler_new (NULL, NULL); g_object_set (G_OBJECT (ufo_scheduler), "enable-tracing", TRUE, NULL); backproject = ufo_plugin_manager_get_task (ufo_plugin_manager, "backproject", &error); g_object_set (G_OBJECT (backproject), "axis-pos", 928.0f, NULL); reader = ufo_plugin_manager_get_task (ufo_plugin_manager, "reader", &error); g_object_set (G_OBJECT (reader), "path", IN_FILE_NAME, NULL); cut_sinogram = ufo_plugin_manager_get_task (ufo_plugin_manager, "cut_sinogram", &error); g_object_set (G_OBJECT(cut_sinogram), "center-of-rotation", 928.0f, NULL); zeropadding = ufo_plugin_manager_get_task (ufo_plugin_manager, "zeropadding", &error); g_object_set (G_OBJECT(zeropadding), "oversampling", 2, NULL); filter = ufo_plugin_manager_get_task (ufo_plugin_manager, "filter", &error); g_object_set (G_OBJECT(filter), NULL); fft = ufo_plugin_manager_get_task (ufo_plugin_manager, "fft", &error); g_object_set (G_OBJECT(fft), "dimensions", 1, "auto-zeropadding", 0, NULL); dfi_sinc = ufo_plugin_manager_get_task (ufo_plugin_manager, "dfi_sinc", &error); g_object_set (G_OBJECT(dfi_sinc), "kernel-size", 7, "number-presampled-values", 2047, "roi-size", 1696, NULL); swap_quadrants = ufo_plugin_manager_get_task (ufo_plugin_manager, "swap_quadrants", &error); g_object_set (G_OBJECT(swap_quadrants), NULL); ifft = ufo_plugin_manager_get_task (ufo_plugin_manager, "ifft", &error); g_object_set (G_OBJECT(ifft), "dimensions", 2, NULL); swap_quadrants_inverse = ufo_plugin_manager_get_task (ufo_plugin_manager, "swap_quadrants", &error); g_object_set (G_OBJECT(swap_quadrants_inverse), NULL); region_of_interest = ufo_plugin_manager_get_task (ufo_plugin_manager, "region_of_interest", &error); g_object_set (G_OBJECT(region_of_interest), "x", 368, "y", 538, "width", 1311, "height", 1331, NULL); writer = ufo_plugin_manager_get_task (ufo_plugin_manager, "null", &error); g_object_set (G_OBJECT (writer), NULL); ufo_graph_connect_nodes (ufo_task_graph, reader, cut_sinogram, NULL); ufo_graph_connect_nodes (ufo_task_graph, cut_sinogram, zeropadding, NULL); ufo_graph_connect_nodes (ufo_task_graph, zeropadding, fft, NULL); ufo_graph_connect_nodes (ufo_task_graph, fft, dfi_sinc, NULL); ufo_graph_connect_nodes (ufo_task_graph, dfi_sinc, swap_quadrants, NULL); ufo_graph_connect_nodes (ufo_task_graph, swap_quadrants, ifft, NULL); ufo_graph_connect_nodes (ufo_task_graph, ifft, swap_quadrants_inverse, NULL); ufo_graph_connect_nodes (ufo_task_graph, swap_quadrants_inverse, region_of_interest, NULL); ufo_graph_connect_nodes (ufo_task_graph, region_of_interest, writer, NULL); ufo_scheduler_run (ufo_scheduler, ufo_task_graph, &error); if (error) printf("\nError: Run was unsuccessful: %s\n", error->message); g_object_unref (ufo_task_graph); g_object_unref (ufo_scheduler); g_object_unref (ufo_plugin_manager); g_object_unref (writer); g_object_unref (cut_sinogram); g_object_unref (zeropadding); g_object_unref (fft); g_object_unref (dfi_sinc); g_object_unref (swap_quadrants); g_object_unref (ifft); g_object_unref (swap_quadrants_inverse); g_object_unref (region_of_interest); g_object_unref (reader); return 0; }