reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
sensor_simulator.h File Reference

Simple terminal-based user interface based on ncurses. More...

Go to the source code of this file.

Functions

void end_sensor_simulator ()
 End ncurses control of the terminal.
int register_sensor_key (char key, void *action)
 Register a keyboard key to trigger the specified action.
void show_tick (const char *character)
 Place a tick (usually a single character) in the tick window.
int start_sensor_simulator (const char *message_lines[], int number_of_lines, int tick_window_width, char *log_file, int log_level)
 Start the sensor simulator if it has not been already started.

Detailed Description

Simple terminal-based user interface based on ncurses.

Author
Edward A. Lee

When prototyping Lingua Franca programs on a laptop, it is convenient to use the laptop keyboard to simulate asynchronous sensor input. This small library provides a convenient way to do that.

To use this, include the following flags in your target properties:

target C {
files: [
"/lib/c/reactor-c/util/sensor_simulator.c",
"/lib/c/reactor-c/util/sensor_simulator.h",
],
cmake-include: [
"/lib/c/reactor-c/util/sensor_simulator.cmake",
]
};

This requires ncurses, a library providing somewhat portable keyboard access.

In addition, you need this in your Lingua Franca file:

preamble {=
#include "sensor_simulator.c"
=}

To start the sensor simulator, call start_sensor_simulator passing it an array of strings to print and the width of the window to use to display characters using the show_tick function.

To print messages to the screen, rather than using printf(), you should use the messaging functions in util.h, such as lf_print(). Otherwise, your messages will be printed over other information.