void wopt_init(struct imwindow *imwindow, const char *target) { char nnick[NUSER_LEN]; char buf[NUSER_LEN + 256]; char *pork_dir; char *p; pref_val_t *wopt = imwindow->opts; memset(wopt, 0, sizeof(pref_val_t) * WOPT_NUM_OPTS); wopt[WOPT_ACTIVITY_TYPES].i = opt_get_int(OPT_ACTIVITY_TYPES); wopt[WOPT_BEEP_ON_OUTPUT].b = opt_get_bool(OPT_BEEP_ON_OUTPUT); wopt[WOPT_HISTORY_LEN].i = opt_get_int(OPT_HISTORY_LEN); wopt[WOPT_LOG].b = opt_get_bool(OPT_LOG); wopt[WOPT_LOG_TYPES].i = opt_get_int(OPT_LOG_TYPES); wopt[WOPT_PRIVATE_INPUT].b = opt_get_bool(OPT_PRIVATE_INPUT); wopt[WOPT_SCROLL_ON_INPUT].b = opt_get_bool(OPT_SCROLL_ON_INPUT); wopt[WOPT_SCROLL_ON_OUTPUT].b = opt_get_bool(OPT_SCROLL_ON_OUTPUT); wopt[WOPT_SCROLLBUF_LEN].i = opt_get_int(OPT_SCROLLBUF_LEN); wopt[WOPT_TIMESTAMP].b = opt_get_bool(OPT_TIMESTAMP); wopt[WOPT_WORDWRAP].b = opt_get_bool(OPT_WORDWRAP); wopt[WOPT_WORDWRAP_CHAR].c = opt_get_char(OPT_WORDWRAP_CHAR); normalize(nnick, target, sizeof(nnick)); while ((p = strchr(nnick, '/')) != NULL) *p = '_'; pork_dir = opt_get_str(OPT_NCIC_DIR); snprintf(buf, sizeof(buf), "%s/%s/logs/%s.log", pork_dir, imwindow->owner->username, nnick); wopt[WOPT_LOGFILE].s = xstrdup(buf); }
static void catch_in_unit_test(print_fn_t fn, const loc_t *loc, const char *fmt, va_list ap) { if (opt_get_int("unit-test")) { char *strp LOCAL = prepare_msg(fmt, ap, error_force_plain); error_fn(strp, loc != NULL ? loc : &LOC_INVALID); }
void init_list() { list = newwin(LIST_LINES, LIST_COLS, LIST_TOP, 0); scrollok(list, TRUE); scroll_speed = abs(opt_get_int(INT_SCROLL_SPEED)); }
static void scrollbuf_len_update(void) { uint32_t scrollbuf_len; scrollbuf_len = opt_get_int(OPT_SCROLLBUF_LEN); if (scrollbuf_len < cur_window()->swindow.rows) global_pref[OPT_SCROLLBUF_LEN].val.i = cur_window()->swindow.rows; }
void group_nets(tree_t top) { const int nnets = tree_attr_int(top, nnets_i, 0); group_nets_ctx_t ctx; group_init_context(&ctx, nnets); tree_visit(top, group_nets_visit_fn, &ctx); group_write_netdb(top, &ctx); if (opt_get_int("verbose")) { int ngroups = 0; for (group_t *it = ctx.groups; it != NULL; it = it->next) ngroups++; notef("%d nets, %d groups", nnets, ngroups); notef("nets:groups ratio %.3f", (float)nnets / (float)ngroups); } group_free_list(ctx.groups); group_free_list(ctx.free_list); free(ctx.lookup); }
static void usage(void) { printf("Usage: %s [OPTION]... COMMAND [OPTION]...\n" "\n" "COMMAND is one of:\n" " -a [OPTION]... FILE...\tAnalyse FILEs into work library\n" " -e [OPTION]... UNIT\t\tElaborate and generate code for UNIT\n" " -r [OPTION]... UNIT\t\tExecute previously elaborated UNIT\n" " --codegen UNIT\t\tGenerate native shared library for UNIT\n" " --dump [OPTION]... UNIT\t\tPrint out previously analysed UNIT\n" " --make [OPTION]... [UNIT]...\tGenerate makefile to rebuild UNITs\n" "\n" "Global options may be placed before COMMAND:\n" " -L PATH\t\tAdd PATH to library search paths\n" " -h, --help\t\tDisplay this message and exit\n" " --std=REV\t\tVHDL standard revision to use\n" " -v, --version\t\tDisplay version and copyright information\n" " --work=NAME\tUse NAME as the work library\n" "\n" "Analyse options:\n" " --bootstrap\tAllow compilation of STANDARD package\n" " --prefer-explicit\tExplict operators always hide implicit\n" "\n" "Elaborate options:\n" " --cover\t\tEnable code coverage reporting\n" " --disable-opt\tDisable LLVM optimisations\n" " --dump-llvm\tPrint generated LLVM IR\n" " --native\t\tGenerate native code shared library\n" "\n" "Run options:\n" " -b, --batch\t\tRun in batch mode (default)\n" " -c, --command\t\tRun in TCL command line mode\n" " --exclude=GLOB\tExclude signals matching GLOB from wave dump\n" " --format=FMT\tWaveform format is one of lxt, fst, or vcd\n" " --include=GLOB\tInclude signals matching GLOB in wave dump\n" " --stats\t\tPrint statistics at end of run\n" " --stop-delta=N\tStop after N delta cycles (default %d)\n" " --stop-time=T\tStop after simulation time T (e.g. 5ns)\n" " --trace\t\tTrace simulation events\n" " -w, --wave=FILE\tWrite waveform data; file name is optional\n" "\n" "Dump options:\n" " -e, --elab\t\tDump an elaborated unit\n" " -b, --body\t\tDump package body\n" " --nets\t\tShow mapping from signals to nets\n" "\n" "Make options:\n" " --deps-only\tOutput dependencies without actions\n" " --native\t\tGenerate actions for native code generation\n" " --posix\t\tStrictly POSIX compliant makefile\n" "\n", PACKAGE, opt_get_int("stop-delta")); printf("Library search paths:\n"); void *token = NULL; const char *path; while ((path = lib_enum_search_paths(&token)) != NULL) printf(" %s\n", path); printf("\nReport bugs to %s\n", PACKAGE_BUGREPORT); }
// Main int main(int argc, char **argv) { playerc_client_t *client; rtk_app_t *app; mainwnd_t *mainwnd; opt_t *opt; const char *host; int port; int i; int count; double rate; char section[256]; int device_count; device_t devices[PLAYER_MAX_DEVICES]; device_t *device; struct timeval tv, tc = {0, 0}; struct timespec st = {0, (1.0/GUI_UPDATE_RATE) * 1e9}; printf("PlayerViewer %s\n", PLAYER_VERSION); // Initialise rtk lib (after we have read the program options we // want). rtk_init(&argc, &argv); // Register signal handlers signal(SIGINT, sig_quit); signal(SIGQUIT, sig_quit); // Load program options opt = opt_init(argc, argv, NULL); if (!opt) { print_usage(); return -1; } // Pick out some important program options host = opt_get_string(opt, "", "host", NULL); if (!host) host = opt_get_string(opt, "", "h", "localhost"); port = opt_get_int(opt, "", "port", -1); if (port < 0) port = opt_get_int(opt, "", "p", 6665); rate = opt_get_double(opt, "", "rate", 5.0); if(rate < 0.0) rate = 0.0; // Connect to the server printf("Connecting to [%s:%d]\n", host, port); client = playerc_client_create(NULL, host, port); if (playerc_client_connect(client) != 0) { PRINT_ERR1("%s", playerc_error_str()); print_usage(); return -1; } if(rate == 0.0) { printf("Setting delivery mode to PLAYER_DATAMODE_PUSH\n"); // Change the server's data delivery mode. if (playerc_client_set_replace_rule(client, -1, -1, -1, -1, 0) != 0) { PRINT_ERR1("%s", playerc_error_str()); return -1; } // Change the server's data delivery mode. // PLAYERC_DATAMODE_PUSH, PLAYERC_DATAMODE_PULL if (playerc_client_datamode(client, PLAYERC_DATAMODE_PUSH) != 0) { PRINT_ERR1("%s", playerc_error_str()); return -1; } } // Get the available devices. if (playerc_client_get_devlist(client) != 0) { PRINT_ERR1("%s", playerc_error_str()); return -1; } // Create gui app = rtk_app_create(); // Create a window for most of the sensor data mainwnd = mainwnd_create(app, host, port); if (!mainwnd) return -1; // Create a list of available devices, with their gui proxies. device_count = 0; for (i = 0; i < client->devinfo_count; i++) { device = devices + device_count; device->addr = client->devinfos[i].addr; device->drivername = strdup(client->devinfos[i].drivername); // See if the device should be subscribed immediately. snprintf(section, sizeof(section), "%s:%d", interf_to_str(device->addr.interf), device->addr.index); device->subscribe = opt_get_int(opt, section, "", 0); device->subscribe = opt_get_int(opt, section, "subscribe", device->subscribe); if (device->addr.index == 0) { snprintf(section, sizeof(section), "%s", interf_to_str(device->addr.interf)); device->subscribe = opt_get_int(opt, section, "", device->subscribe); device->subscribe = opt_get_int(opt, section, "subscribe", device->subscribe); } // Allow for --position instead of --position2d if(device->addr.interf == PLAYER_POSITION2D_CODE) { snprintf(section, sizeof(section), "%s:%d", PLAYER_POSITION2D_STRING, device->addr.index); device->subscribe = opt_get_int(opt, section, "", device->subscribe); device->subscribe = opt_get_int(opt, section, "subscribe", device->subscribe); if (device->addr.index == 0) { snprintf(section, sizeof(section), "%s", PLAYER_POSITION2D_STRING); device->subscribe = opt_get_int(opt, section, "", device->subscribe); device->subscribe = opt_get_int(opt, section, "subscribe", device->subscribe); } } // Create the GUI proxy for this device. create_proxy(device, opt, mainwnd, client); device_count++; } // Print the list of available devices. printf("Available devices: %s:%d\n", host, port); for (i = 0; i < device_count; i++) { device = devices + i; snprintf(section, sizeof(section), "%s:%d", interf_to_str(device->addr.interf), device->addr.index); printf("%-16s %-40s", section, device->drivername); if (device->proxy) { if (device->subscribe) printf("subscribed"); else printf("ready"); } else printf("unsupported"); printf("\n"); } // Print out a list of unused options. opt_warn_unused(opt); // Start the gui; dont run in a separate thread and dont let it do // its own updates. rtk_app_main_init(app); // start out timer if in pull mode if(rate > 0.0) gettimeofday(&tv, NULL); while (!quit) { // Let gui process messages rtk_app_main_loop(app); if(rate == 0.0) // if we're in push mode { // see if there's data count = playerc_client_peek(client, 50); if (count < 0) { PRINT_ERR1("%s", playerc_error_str()); break; } if (count > 0) { /*proxy = */playerc_client_read_nonblock(client); } } else // we're in pull mode { // we only want to request new data at the target rate gettimeofday(&tc, NULL); if(((tc.tv_sec - tv.tv_sec) + (tc.tv_usec - tv.tv_usec)/1e6) > 1.0/rate) { tv = tc; // this requests a round of data from the server to be read playerc_client_requestdata(client); playerc_client_read_nonblock(client); } else { // sleep for the minimum time we can, so we don't use up too much // processor nanosleep(&st, NULL); } } // Update the devices for (i = 0; i < device_count; i++) { device = devices + i; if(device->proxy) (*(device->fnupdate)) (device->proxy); } // Update the main window if (mainwnd_update(mainwnd) != 0) break; } // Stop the gui rtk_app_main_term(app); // Destroy devices for (i = 0; i < device_count; i++) { device = devices + i; if (device->proxy) (*(device->fndestroy)) (device->proxy); free(device->drivername); } // Disconnect from server if (playerc_client_disconnect(client) != 0) { PRINT_ERR1("%s", playerc_error_str()); return -1; } playerc_client_destroy(client); // For some reason, either of the following calls makes the program // segfault on exit. I haven't figured out why, so I'm commenting them out. - BPG // Destroy the windows //mainwnd_destroy(mainwnd); // Destroy the gui //rtk_app_destroy(app); opt_term(opt); return 0; }
static void usage(void) { printf("Usage: %s [OPTION]... COMMAND [OPTION]...\n" "\n" "COMMAND is one of:\n" " -a [OPTION]... FILE...\t\tAnalyse FILEs into work library\n" " -e [OPTION]... UNIT\t\tElaborate and generate code for UNIT\n" " -r [OPTION]... UNIT\t\tExecute previously elaborated UNIT\n" " --codegen UNIT\t\t\tGenerate native shared library for UNIT\n" " --dump [OPTION]... UNIT\tPrint out previously analysed UNIT\n" " --list\t\t\t\tPrint all units in the library\n" " --make [OPTION]... [UNIT]...\tGenerate makefile to rebuild UNITs\n" " --syntax FILE...\t\tCheck FILEs for syntax errors only\n" "\n" "Global options may be placed before COMMAND:\n" " --force-init\tCreate a library in an existing directory\n" " -h, --help\t\tDisplay this message and exit\n" " --ignore-time\tSkip source file timestamp check\n" " -L PATH\t\tAdd PATH to library search paths\n" " --map=LIB:PATH\tMap library LIB to PATH\n" " --messages=STYLE\tSelect full or compact message format\n" " --std=REV\t\tVHDL standard revision to use\n" " -v, --version\t\tDisplay version and copyright information\n" " --work=NAME\tUse NAME as the work library\n" "\n" "Analyse options:\n" " --bootstrap\tAllow compilation of STANDARD package\n" " --relax=RULES\tDisable certain pedantic rule checks\n" "\n" "Elaborate options:\n" " --cover\t\tEnable code coverage reporting\n" " --disable-opt\tDisable LLVM optimisations\n" " --dump-llvm\tPrint generated LLVM IR\n" " --dump-vcode\tPrint generated intermediate code\n" " -g NAME=VALUE\t\tSet top level generic NAME to VALUE\n" " --native\t\tGenerate native code shared library\n" " -V, --verbose\t\tPrint resource usage at each step\n" "\n" "Run options:\n" " -b, --batch\t\tRun in batch mode (default)\n" " -c, --command\t\tRun in TCL command line mode\n" " --exclude=GLOB\tExclude signals matching GLOB from wave dump\n" " --exit-severity=S\tExit after assertion failure of severity S\n" " --format=FMT\tWaveform format is one of lxt, fst, or vcd\n" " --include=GLOB\tInclude signals matching GLOB in wave dump\n" #ifdef ENABLE_VHPI " --load=PLUGIN\tLoad VHPI plugin at startup\n" #endif " --stats\t\tPrint statistics at end of run\n" " --stop-delta=N\tStop after N delta cycles (default %d)\n" " --stop-time=T\tStop after simulation time T (e.g. 5ns)\n" " --trace\t\tTrace simulation events\n" #ifdef ENABLE_VHPI " --vhpi-trace\tTrace VHPI calls and events\n" #endif " -w, --wave=FILE\tWrite waveform data; file name is optional\n" "\n" "Dump options:\n" " -e, --elab\t\tDump an elaborated unit\n" " -b, --body\t\tDump package body\n" " --nets\t\tShow mapping from signals to nets\n" "\n" "Make options:\n" " --deps-only\tOutput dependencies without actions\n" " --native\t\tGenerate actions for native code generation\n" " --posix\t\tStrictly POSIX compliant makefile\n" "\n", PACKAGE, opt_get_int("stop-delta")); printf("Library search paths:\n"); void *token = NULL; const char *path; while ((path = lib_enum_search_paths(&token)) != NULL) printf(" %s\n", path); printf("\nReport bugs to %s\n", PACKAGE_BUGREPORT); }