MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); init_comm(); }
DEFINE_THREAD_ROUTINE(receive_gps, data) { init_comm(); start_comm(); stop_comm(); return C_OK; }
RobotAction::RobotAction() { /* Connect to the IPC server */ init_comm(); connect_to_server(); subcribeAndPublish(); listen(); // Initialize timeout this->setTimeout(25); }
RobotAction::RobotAction(const string& IPAddress) { /* Connect to the IPC server */ init_comm(); connect_to_server(IPAddress.c_str()); subcribeAndPublish(); listen(); // Initialize timeout this->setTimeout(25); }
int build_comm(char *filename,double ***pcomm){ int i; int N; double **comm; N=nb_lines(filename); comm=(double**)malloc(N*sizeof(double*)); for(i=0;i<N;i++) comm[i]=(double*)malloc(N*sizeof(double)); init_comm(filename,N,comm); *pcomm=comm; return N; }
void send_boundary_data(Field* f, Array* a){ BoundaryComm * comm = init_comm(a); send(f, a, comm); pprintf("sent\n"); MPI_Barrier(MPI_COMM_WORLD); unpack(f, a, comm); pprintf("received\n"); MPI_Barrier(MPI_COMM_WORLD); free_comm(comm); pprintf("freed\n"); MPI_Barrier(MPI_COMM_WORLD); }
void upsdrv_shutdown(void) { char parm[20]; if (!init_comm()) printf("Status failed. Assuming it's on battery and trying a shutdown anyway.\n"); auto_reboot(1); /* in case the power is on, tell it to automatically reboot. if it is off, this has no effect. */ snprintf(parm, sizeof(parm), "%d", 1); /* delay before reboot, in minutes */ do_command(SET, SHUTDOWN_RESTART, parm, NULL); snprintf(parm, sizeof(parm), "%d", 5); /* delay before shutdown, in seconds */ do_command(SET, SHUTDOWN_ACTION, parm, NULL); }
int build_comm(char *filename,double ***pcomm) { double **comm = NULL; int i,N; if(get_verbose_level() >= INFO) printf("Reading communication matrix file: %s\n",filename); N = nb_lines(filename); comm = (double**)MALLOC(N*sizeof(double*)); for( i = 0 ; i < N ; i++) /* the last column stores the sum of the line*/ comm[i] = (double*)MALLOC((N+1)*sizeof(double)); init_comm(filename,N,comm); *pcomm = comm; if(get_verbose_level() >= INFO) printf("Communication matrix built from %s!\n",filename); return N; }
int main(int ac, char **av) { t_cam *c; ac = ac; av = av; #ifdef __APPLE__ //pthread_t thread; printf("Killing PTPCamera process\n"); system("killall PTPCamera"); //pthread_create(&thread, NULL, initUSBDetect, (void *)c); #endif signal_inib(); c = malloc(sizeof(*c)); c->first_func_ptr = NULL; init(c); get_all_widget_and_choices(c); add_func_ptr_list(c, "capture", trigger_capture); add_func_ptr_list(c, "liveview", liveview); add_func_ptr_list(c, "auto_focus", auto_focus); add_func_ptr_list(c, "liveviewfps", liveviewfps); add_func_ptr_list(c, "get_liveviewfps", get_liveviewfps); add_func_ptr_list(c, "defaultpath", set_default_folder_path); add_func_ptr_list(c, "get_defaultpath", get_default_folder_path); pthread_create(&c->liveview_thread, NULL, liveview_launcher, (void*)c); init_comm(c, UNIX_SOCKET_PATH); gp_camera_exit(c->camera, c->context); return (0); }
int16 main(void) { GRECT n = {0,0,0,0}; GRECT r1; EVNTDATA ev; int16 bclicks, bmask, bstate; boolean leave; quit = FALSE; debug_init("MControl", null, NULL); init_app("mcontrol.rsc"); init_rsrc(); init_conf(); init_dial(); init_comm(); init_beta(); /* Callback f�r modale Fensterdialoge, Fenster-Alerts usw. */ set_mdial_wincb(handle_msg); graf_mkstate( &ev ); wdial_hover( ev.x, ev.y, &r1, &leave ); while (!quit) { mbutton = 0; if( !((ev.bstate) & 3) ) bclicks = 258; else bclicks = 0; bmask = 3; bstate = 0; event = evnt_multi( MU_BUTTON|MU_M1|MU_MESAG|MU_KEYBD, bclicks, bmask, bstate, leave, &r1, 0, &n, msg, 0l, &ev, &kreturn, &mclick ); msx = ev.x; msy = ev.y; mbutton = ev.bstate; kstate = ev.kstate; if (event & MU_MESAG) { if( msg[0] == WM_MOVED ) wdial_hover( msx, msy, &r1, &leave ); handle_msg(msg); } if (event & MU_BUTTON) { if( mbutton == 2 ) menu_context( msx, msy ); else if (!click_wdial(mclick, msx, msy, kstate, mbutton)) ; } if (event & MU_M1) wdial_hover( msx, msy, &r1, &leave ); if (event & MU_KEYBD) { int16 title, item; if (is_menu_key(kreturn, kstate, &title, &item)) handle_menu(title, item); else { key_wdial(kreturn, kstate); key_sdial(kreturn, kstate); } } } exit_comm(); exit_dial(); exit_rsrc(); debug_exit(); exit_app(0); return 0; }
int main(int argc, char *argv[]) { struct termios pts; /* termios settings on port */ struct termios sts; /* termios settings on stdout/in */ struct sigaction sact; /* used to initialize the signal handler */ int opt; strcpy(device, "/dev/ttyUSB0"); while ( (opt = getopt(argc, argv, "h?D:b:d:p:f:s:e:r:")) != -1 ) { switch (opt) { /* help message */ case 'h': usage(); return 0; break; /* set the serial device name */ case 'D': strcpy(device, optarg); break; /* set the baud rate */ case 'b': curr_state.baud_rate = atoi(optarg); break; /* data bits */ case 'd': curr_state.data_bits = optarg[0]; break; /* parity */ case 'p': curr_state.parity = optarg[0]; break; /* setup flow control */ case 'f': curr_state.flow_control = optarg[0]; break; /* stop bits */ case 's': curr_state.stop_bits = optarg[0]; break; /* echo type */ case 'e': curr_state.echo_type = optarg[0]; break; /* NL to CR mapping on output */ case 'r': curr_state.onlcr_mapping = optarg[0]; break; default: break; } /* end switch */ } /* end while */ /* open the device */ pf = open(device, O_RDWR); if (pf < 0) { fprintf(stderr, "\n ERROR: cannot open device %s\n\n", device); exit(1); } /* save old serial port config */ tcgetattr(pf, &pts); memcpy(&pots, &pts, sizeof(pots)); /* setup serial port with new settings */ init_comm(&pts); fprintf(stdout, "\nWelcome to Nanocomsole " VERSION); display_state(); fprintf(stdout, "Press CTRL+T for menu options\n\n"); /* Now deal with the local terminal side */ tcgetattr(STDIN_FILENO, &sts); memcpy(&sots, &sts, sizeof(sots)); /* to be used upon exit */ init_stdin(&sts); tcsetattr(STDIN_FILENO, TCSANOW, &sts); /* set the signal handler to restore the old termios handler */ sact.sa_handler = cleanup_termios; sigaction(SIGHUP, &sact, NULL); sigaction(SIGINT, &sact, NULL); sigaction(SIGPIPE, &sact, NULL); sigaction(SIGTERM, &sact, NULL); /* run the main program loop */ mux_loop(pf); /* unreachable line ?? */ cleanup_termios(0); return 0; }
void upsdrv_initinfo(void) { char response[MAX_RESPONSE_LENGTH]; unsigned int min_low_transfer, max_low_transfer; unsigned int min_high_transfer, max_high_transfer; unsigned int i; char *ptr; if (!init_comm()) fatalx(EXIT_FAILURE, "Unable to detect Tripp Lite SmartOnline UPS on port %s\n", device_path); min_low_transfer = max_low_transfer = 0; min_high_transfer = max_high_transfer = 0; /* get all the read-only fields here */ if (do_command(POLL, MANUFACTURER, "", response) > 0) dstate_setinfo("ups.mfr", "%s", response); if (do_command(POLL, MODEL, "", response) > 0) dstate_setinfo("ups.model", "%s", response); if (do_command(POLL, VERSION_CMD, "", response) > 0) dstate_setinfo("ups.firmware", "%s", response); if (do_command(POLL, RATINGS, "", response) > 0) { ptr = field(response, 0); if (ptr) dstate_setinfo("input.voltage.nominal", "%d", atoi(ptr)); ptr = field(response, 2); if (ptr) { dstate_setinfo("output.voltage.nominal", "%d", atoi(ptr)); } ptr = field(response, 14); if (ptr) dstate_setinfo("battery.voltage.nominal", "%d", atoi(ptr)); ptr = field(response, 10); if (ptr) min_low_transfer = atoi(ptr); ptr = field(response, 9); if (ptr) max_low_transfer = atoi(ptr); ptr = field(response, 12); if (ptr) min_high_transfer = atoi(ptr); ptr = field(response, 11); if (ptr) max_high_transfer = atoi(ptr); } if (do_command(POLL, OUTLET_RELAYS, "", response) > 0) ups.outlet_banks = atoi(response); /* define things that are settable */ if (get_identification()) { dstate_setflags("ups.id", ST_FLAG_RW | ST_FLAG_STRING); dstate_setaux("ups.id", 100); } if (get_transfer_voltage_low() && max_low_transfer) { dstate_setflags("input.transfer.low", ST_FLAG_RW); for (i = min_low_transfer; i <= max_low_transfer; i++) dstate_addenum("input.transfer.low", "%d", i); } if (get_transfer_voltage_high() && max_low_transfer) { dstate_setflags("input.transfer.high", ST_FLAG_RW); for (i = min_high_transfer; i <= max_high_transfer; i++) dstate_addenum("input.transfer.high", "%d", i); } if (get_sensitivity()) { dstate_setflags("input.sensitivity", ST_FLAG_RW); for (i = 0; i < sizeof(sensitivity) / sizeof(sensitivity[0]); i++) dstate_addenum("input.sensitivity", "%s", sensitivity[i].name); } if (ups.outlet_banks) { dstate_addcmd("load.off"); dstate_addcmd("load.on"); } dstate_addcmd("shutdown.reboot"); dstate_addcmd("shutdown.reboot.graceful"); dstate_addcmd("shutdown.return"); #if 0 /* doesn't work */ dstate_addcmd("shutdown.stayoff"); #endif dstate_addcmd("shutdown.stop"); dstate_addcmd("test.battery.start"); dstate_addcmd("test.battery.stop"); /* add all the variables that change regularly */ upsdrv_updateinfo(); upsh.instcmd = instcmd; upsh.setvar = setvar; printf("Detected %s %s on %s\n", dstate_getinfo("ups.mfr"), dstate_getinfo("ups.model"), device_path); }
int main (int argc, char** argv) { char* servername = NULL; char* filename = NULL; GSList* task_list = NULL; int option; int num_ites; int i; extern char *optarg; /*default number of phase is 1*/ num_ites = 1; while ((option = getopt(argc, argv, "N:h")) != -1){ switch(option){ case 'N': if (sscanf(optarg, "%d", &num_ites) <= 0) { usage(argv[0]); exit(1); } break; case 'h': default: usage(argv[0]); exit(1); } } gi.clientID = 0; for (i = optind ; i < argc; i++) { if (filename == NULL){ filename = argv[i]; } else { servername = argv[i]; gi.clientID = 1; } } if (filename == NULL){ usage(argv[0]); exit(1); } gi.testpass = 0; gi.testwarn = 0; gi.testfail = 0; strlcpy(gi.filename, filename, sizeof(gi.filename)); init_comm(servername); for (i = 0; i < num_ites; i++){ output("Iteration %d: \n", i); task_list = generate_task_list(); runtests(task_list); remove_task_list(task_list); } test_exit(); return 0; }
//c--------------------------------------------------------------------- //c //c Authors: S. Weeratunga //c V. Venkatakrishnan //c E. Barszcz //c M. Yarrow //c C-version: Rob Van der Wijngaart, Intel Corporation //c //c--------------------------------------------------------------------- // // Copyright 2010 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // int RCCE_APP(int argc, char **argv){ //c--------------------------------------------------------------------- //c //c driver for the performance evaluation of the solver for //c five coupled parabolic/elliptic partial differential equations. //c //c--------------------------------------------------------------------- char class; double mflops; int ierr, i, j, k, mm, iverified; //c--------------------------------------------------------------------- //c initialize communications //c--------------------------------------------------------------------- init_comm(&argc, &argv); // RCCE_debug_set(RCCE_DEBUG_SYNCH); //c--------------------------------------------------------------------- //c read input data //c--------------------------------------------------------------------- read_input(); //c--------------------------------------------------------------------- //c set up processor grid //c--------------------------------------------------------------------- proc_grid(); //c--------------------------------------------------------------------- //c determine the neighbors //c--------------------------------------------------------------------- neighbors(); //c--------------------------------------------------------------------- //c set up sub-domain sizes //c--------------------------------------------------------------------- subdomain(); //c--------------------------------------------------------------------- //c set up coefficients //c--------------------------------------------------------------------- setcoeff(); //c--------------------------------------------------------------------- //c set the boundary values for dependent variables //c--------------------------------------------------------------------- setbv(); //c--------------------------------------------------------------------- //c set the initial values for dependent variables //c--------------------------------------------------------------------- setiv(); //c--------------------------------------------------------------------- //c compute the forcing term based on prescribed exact solution //c--------------------------------------------------------------------- erhs(); ////c--------------------------------------------------------------------- ////c perform one SSOR iteration to touch all data and program pages ////c--------------------------------------------------------------------- ssor(1); // ////c--------------------------------------------------------------------- ////c reset the boundary and initial values ////c--------------------------------------------------------------------- setbv(); setiv(); // ////c--------------------------------------------------------------------- ////c perform the SSOR iterations ////c--------------------------------------------------------------------- ssor(itmax); ////c--------------------------------------------------------------------- ////c compute the solution error ////c--------------------------------------------------------------------- error(); ////c--------------------------------------------------------------------- ////c compute the surface integral ////c--------------------------------------------------------------------- pintgr(); // ////c--------------------------------------------------------------------- ////c verification test ////c--------------------------------------------------------------------- if (id ==0) { verify( rsdnm, errnm, &frc, &class ); mflops = (double)(itmax)*(1984.77*(double)( nx0 ) *(double)( ny0 ) *(double)( nz0 ) -10923.3*((double)( nx0+ny0+nz0 )/3.)*((double)( nx0+ny0+nz0 )/3.) +27770.9* (double)( nx0+ny0+nz0 )/3. -144010.) / (maxtime*1000000.); print_results("LU", &class, &nx0, &ny0, &nz0, &itmax, &nnodes_compiled, &num, &maxtime, &mflops, " floating point", &iverified, NPBVERSION, COMPILETIME, CS1, CS2, CS3, CS4, CS5, CS6); // FILE *perf_file; // char name[50] = "/shared/DEMOS/RCCE/NPB_LU/perf."; // char postfix[50]; // sprintf(postfix, "%d", nnodes_compiled); // strcat(name, postfix); // perf_file = fopen(name,"w"); // fprintf(perf_file, "%d", (int)mflops); // fclose(perf_file); }
int main(int argc, char *argv[]) { const struct rlimit rlim = { .rlim_cur = RLIM_INFINITY, .rlim_max = RLIM_INFINITY }; ev_signal signal_usr1; ev_signal signal_usr2; ev_signal signal_pipe; int c; /* unlimited size for cores */ setrlimit(RLIMIT_CORE, &rlim); logx_level = LOG_INFO; while (1) { int option_index = 0; static struct option long_options[] = { {"log", 1, 0, 'l'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "hl:x", long_options, &option_index); if (c == -1) break; switch (c) { case 'h': usage(); break; case 'l': { struct in_addr addr; if (inet_aton(optarg, &addr) == 0) { fprintf(stderr, "Invalid IP address: '%s'\n", optarg); exit(EXIT_FAILURE); } else logx_remote(addr); break; } case 'x': logx_level = LOG_DEBUG; break; default: printf("?? getopt returned character code 0%o ??\n", c); } } logx_open(basename(argv[0]), 0, LOG_DAEMON); ev_signal_init(&signal_usr1, sig_usr1, SIGUSR1); ev_signal_start(EV_DEFAULT_ &signal_usr1); ev_signal_init(&signal_usr2, sig_usr2, SIGUSR2); ev_signal_start(EV_DEFAULT_ &signal_usr2); ev_signal_init(&signal_pipe, sig_pipe, SIGPIPE); ev_signal_start(EV_DEFAULT_ &signal_pipe); init_comm(EV_DEFAULT); logx(LOG_NOTICE, "startup %s %s (pid %d)\n", _ident, _build, getpid()); ev_run(EV_DEFAULT, 0); return 0; }