From e03b82dd89295305e655bea301b321b7f8e15844 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 2 Jun 2023 14:30:53 +0200 Subject: ASAP::O: Use input stream name as output (add _hits to data source) This means we don't need a stream name any more, so --asapo-output-stream became a simple flag parameter. --- src/im-asapo.c | 16 ++++------------ src/im-asapo.h | 2 +- src/indexamajig.c | 6 +++--- 3 files changed, 8 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/im-asapo.c b/src/im-asapo.c index 4ae4d291..6bc43b11 100644 --- a/src/im-asapo.c +++ b/src/im-asapo.c @@ -54,7 +54,6 @@ struct im_asapo AsapoProducerHandle producer; AsapoStringHandle group_id; int wait_for_stream; - char *output_stream; }; @@ -79,8 +78,7 @@ static int create_producer(struct im_asapo *a, struct im_asapo_params *params) AsapoSourceCredentialsHandle cred; AsapoErrorHandle err = asapo_new_handle(); - if ( params->output_stream == NULL ) { - a->output_stream = NULL; + if ( !params->write_output_stream ) { a->producer = NULL; return 0; } @@ -98,6 +96,7 @@ static int create_producer(struct im_asapo *a, struct im_asapo_params *params) "", /* beamline */ source, params->token); + STATUS("Writing hits-only output stream as data source '%s'\n", source); free(source); a->producer = asapo_create_producer(params->endpoint, @@ -115,7 +114,6 @@ static int create_producer(struct im_asapo *a, struct im_asapo_params *params) } asapo_free_handle(&err); - a->output_stream = strdup(params->output_stream); return 0; } @@ -146,12 +144,6 @@ struct im_asapo *im_asapo_connect(struct im_asapo_params *params) ERROR("ASAP::O stream not specified.\n"); return NULL; } - if ( (params->output_stream != NULL) - && (strcmp(params->stream, params->output_stream) == 0) ) - { - ERROR("ASAP::O input and output streams cannot be the same.\n"); - return NULL; - } a = malloc(sizeof(struct im_asapo)); if ( a == NULL ) return NULL; @@ -301,7 +293,7 @@ static void send_real(struct im_asapo *a, struct image *image) 0); /* Auto ID */ asapo_producer_send(a->producer, header, image->data_block, - kDefaultIngestMode, a->output_stream, + kDefaultIngestMode, a->stream, send_callback, &err); if ( asapo_is_error(err) ) { show_asapo_error("Couldn't ASAP::O message", err); @@ -329,7 +321,7 @@ static void send_placeholder(struct im_asapo *a, struct image *image) 0); /* Auto ID */ asapo_producer_send(a->producer, header, "SKIPPED", - kDefaultIngestMode, a->output_stream, + kDefaultIngestMode, a->stream, send_callback, &err); if ( asapo_is_error(err) ) { show_asapo_error("Couldn't ASAP::O message", err); diff --git a/src/im-asapo.h b/src/im-asapo.h index 85fffc8a..43691700 100644 --- a/src/im-asapo.h +++ b/src/im-asapo.h @@ -43,7 +43,7 @@ struct im_asapo_params char *source; char *stream; int wait_for_stream; - char *output_stream; + int write_output_stream; }; struct im_asapo; diff --git a/src/indexamajig.c b/src/indexamajig.c index 3bcc06b9..a7b5ec9d 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -449,7 +449,7 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) break; case 222 : - args->asapo_params.output_stream = strdup(arg); + args->asapo_params.write_output_stream = 1; break; case 223 : @@ -891,7 +891,7 @@ int main(int argc, char *argv[]) args.asapo_params.source = NULL; args.asapo_params.stream = NULL; args.asapo_params.wait_for_stream = 0; - args.asapo_params.output_stream = NULL; + args.asapo_params.write_output_stream = 0; args.cpu_pin = 0; args.serial_start = 1; args.if_peaks = 1; @@ -1014,7 +1014,7 @@ int main(int argc, char *argv[]) {"asapo-stream", 220, "str", OPTION_NO_USAGE, "ASAP::O stream name"}, {"asapo-wait-for-stream", 221, NULL, OPTION_NO_USAGE, "Wait for ASAP::O stream to appear"}, - {"asapo-output-stream", 222, "str", OPTION_NO_USAGE, "ASAP::O output stream name"}, + {"asapo-output-stream", 222, NULL, OPTION_NO_USAGE, "Create an ASAP::O hits-only stream"}, {"cpu-pin", 223, NULL, OPTION_NO_USAGE, "Pin worker processes to CPUs"}, {NULL, 0, 0, OPTION_DOC, "Peak search options:", 3}, -- cgit v1.2.3