Implements the RIP Farm Test Tool as an example usage of the RIP Farm. More...
#include <signal.h>
#include <stdio.h>
#include "czmq.h"
#include "std.h"
#include "ripfarmtesttool.h"
Data Structures | |
struct | keyboard_ack_t |
Data returned from keyboard_event() to relay_keyboard_string() in a ZeroMQ message between the main UI and keyboard_worker threads. More... | |
struct | RELAY_KEYBOARD_CTXT |
Structure used by relay_keyboard_string(). It is anonymously passed through keyboard_loop(). More... | |
Typedefs | |
typedef struct keyboard_ack_t | keyboard_ack_t |
Data returned from keyboard_event() to relay_keyboard_string() in a ZeroMQ message between the main UI and keyboard_worker threads. | |
Functions | |
static void | prompt (void) |
void | keyboard_loop (RELAY_KEYBOARD_CTXT *kbd_ctxt) |
Keyboard commands from stdin are monitored and passed to the test tool reactor via relay_keyboard_string. The test tool reactor will direct the command to process_keyboard_cmd(). More... | |
HqBool | relay_keyboard_string (char *str, RELAY_KEYBOARD_CTXT *kbd_ctxt, int *waitms) |
Relays keyboard strings between the keyboard_worker and main UI threads by sending a messages over a ZeroMQ socket to keyboard_event(). More... | |
void | keyboard_worker (zsock_t *keyboard_pipe, void *arg) |
Keyboard strokes from stdin are monitored and passed to the test tool reactor via a ZeroMQ message over keyboard_pipe. The test tool reactor will direct the message to keyboard_event(). More... | |
int | keyboard_event (zloop_t *loop, zsock_t *socket, void *arg) |
Receives the ZeroMQ messages from relay_keyboard_string() via the test tool reactor, then calls process_keyboard_cmd() to process the message. Then sends a reply message in the reverse direction. More... | |
Implements the RIP Farm Test Tool as an example usage of the RIP Farm.
This file implements the inter-thread messaging between the keyboard_worker and UI threads of the test tool.
Refer to the design notes and data flow diagrams in ripfarmtesttool.c.
Keyboard input. A dedicated thread runs keyboard_worker() which simply runs the keyboard_loop() for the UI to implement. A separate thread is used because it is otherwise difficult to monitor both keyboard input and ZeroMQ messages in the same thread, at least on Windows.
Lines of text are passed from relay_keyboard_string() to keyboard_event(), running in keyboard_worker and main UI threads respectively, using a ZeroMQ socket and the test tool reactor.
The exit and waitms data items are passed in the reverse direction over the same ZeroMQ socket.
Copyright (C) 2023 Global Graphics Software Ltd. All rights reserved. Global Graphics Software Ltd. Confidential Information.
int keyboard_event | ( | zloop_t * | loop, |
zsock_t * | socket, | ||
void * | arg | ||
) |
Receives the ZeroMQ messages from relay_keyboard_string() via the test tool reactor, then calls process_keyboard_cmd() to process the message. Then sends a reply message in the reverse direction.
This function runs in the main UI thread.
loop | Unused. | |
[in] | socket | The ZeroMQ socket which the message is received from. |
[in] | arg | Contains the libripfarm interface context. Created in testtool_reactor(). |
0 | Normal value. The test tool reactor continues processing keyboard events, even when some errors are encountered. |
-1 | Abort the test tool reactor. Normally this should only happen if an exit message was passed from the keyboard. |
void keyboard_loop | ( | RELAY_KEYBOARD_CTXT * | kbd_ctxt | ) |
Keyboard commands from stdin are monitored and passed to the test tool reactor via relay_keyboard_string. The test tool reactor will direct the command to process_keyboard_cmd().
This function runs in the keyboard_worker thread.
[in] | kbd_ctxt | Anonymous context for passing to relay_keyboard_string(). |
void keyboard_worker | ( | zsock_t * | keyboard_pipe, |
void * | arg | ||
) |
Keyboard strokes from stdin are monitored and passed to the test tool reactor via a ZeroMQ message over keyboard_pipe. The test tool reactor will direct the message to keyboard_event().
This function runs in the keyboard_worker thread.
[in] | keyboard_pipe | ZeroMQ socket to use for comms in relay_keyboard_string(). |
arg | Unused. |
|
static |
Print out a prompt on the monitor. This function runs in the keyboard_worker thread.
HqBool relay_keyboard_string | ( | char * | str, |
RELAY_KEYBOARD_CTXT * | kbd_ctxt, | ||
int * | waitms | ||
) |
Relays keyboard strings between the keyboard_worker and main UI threads by sending a messages over a ZeroMQ socket to keyboard_event().
Waits for a reply from keyboard_event() which contains a keyboard_ack_t struct.
This function runs in the keyboard_worker thread.
[in] | str | The keyboard string. |
[in] | kbd_ctxt | The context from keyboard_worker() passed anonymously via keyboard_loop(). |
[out] | waitms | Normally 0. It is the value, in ms, of the delay that keyboard_loop() should wait before accepting the next command. |
TRUE | Normal return value. |
FALSE | IFF the response from keyboard_event() is to exit the test tool. |