void mapper_monitor_autorequest(mapper_monitor mon, int enable) { if (enable) mapper_db_add_device_callback(&mon->db, on_device_autorequest, mon); else mapper_db_remove_device_callback(&mon->db, on_device_autorequest, mon); }
int recmonitor_start() { mon = mapper_monitor_new(0, 0); if (mon) { db = mapper_monitor_get_db(mon); mapper_db_add_device_callback(db, device_callback, 0); mapper_db_add_signal_callback(db, signal_callback, 0); return 0; } return 1; }
int main(int argc, char **argv) { int i, j, result = 0; // process flags for -v verbose, -t terminate, -h help for (i = 1; i < argc; i++) { if (argv[i] && argv[i][0] == '-') { int len = strlen(argv[i]); for (j = 1; j < len; j++) { switch (argv[i][j]) { case 'h': printf("testmonitor.c: possible arguments " "-q quiet (suppress output), " "-t terminate automatically, " "-h help\n"); return 1; break; case 'q': verbose = 0; break; case 't': terminate = 1; break; default: break; } } } } signal(SIGINT, ctrlc); if (setup_monitor()) { printf("Error initializing monitor.\n"); result = 1; goto done; } mapper_db_add_device_callback(db, on_device, 0); mapper_db_add_signal_callback(db, on_signal, 0); mapper_db_add_connection_callback(db, on_connection, 0); mapper_db_add_link_callback(db, on_link, 0); loop(); done: mapper_db_remove_device_callback(db, on_device, 0); mapper_db_remove_signal_callback(db, on_signal, 0); mapper_db_remove_connection_callback(db, on_connection, 0); mapper_db_remove_link_callback(db, on_link, 0); cleanup_monitor(); return result; }
struct _agentInfo *agentInit() { obs[0] = obs[1] = 0; id = 0; struct _agentInfo *info = &agentInfo; memset(info, 0, sizeof(struct _agentInfo)); info->influence_device_name = strdup("/influence.1"); info->xagora_device_name = strdup("/XAgora_receiver.1"); info->admin = mapper_admin_new(0, 0, 0); // add device info->dev = mdev_new("agent", 9000 + id, info->admin); while (!mdev_ready(info->dev)) { mdev_poll(info->dev, 100); } printf("ordinal: %d\n", mdev_ordinal(info->dev)); fflush(stdout); // add monitor and monitor callbacks info->mon = mapper_monitor_new(info->admin, 0); info->db = mapper_monitor_get_db(info->mon); mapper_db_add_device_callback(info->db, dev_db_callback, info); mapper_db_add_link_callback(info->db, link_db_callback, info); // add signals float mn=-1, mx=1; mdev_add_input(info->dev, "observation", 2, 'f', "norm", &mn, &mx, signal_handler, 0); int imn=0, imx=WIDTH; info->sig_pos = mdev_add_output(info->dev, "position", 2, 'i', 0, &imn, &imx); info->sig_gain = mdev_add_output(info->dev, "gain", 1, 'f', "normalized", &mn, &mx); mx = 0.9; info->sig_fade = mdev_add_output(info->dev, "fade", 1, 'f', "normalized", &mn, &mx); mn = -1.5; mx = 1.5; info->sig_spin = mdev_add_output(info->dev, "spin", 1, 'f', "radians", &mn, &mx); mn = -3.1415926; mx = 3.1315926; info->sig_dir = mdev_add_output(info->dev, "direction", 1, 'f', "radians", &mn, &mx); mn = -1; info->sig_flow = mdev_add_output(info->dev, "flow", 1, 'f', "noramlized", &mn, &mx); return info; }