int main() { dc_init(); rm_make_dump_file("test00-start-"OPT".log"); int* p = (int*)dc_malloc(sizeof(int)); dc_begin_at(); dc_dump_cell(stdout, p); *p = 10; // write reactive cell dc_dump_cell(stdout, p); dc_end_at(); /* int x = *p; // read reactive cell printf("x = %d\n", x); */ //dc_free(p); //rm_make_dump_file("test00-end-"OPT".log"); return 0; }
int main(int argc, char* argv[]) { // Start the Dark Core Reactor! dc_init(640, 480); world = dc_world_create(); generate_map(&world); dc_object obj = dc_object_create(); dc_object_set_x(&obj, 10); dc_object_set_y(&obj, 1); dc_object_set_on_key_press(&obj, obj_on_key_press); dc_world_add_object(&world, &obj); // Load the texture struct dc_texture tex; dc_texture_create(&tex, "resources/grass-tiles-2-small.png", "png"); dc_world_add_texture(&world, &tex); // Map tiles to texture dc_tile t1, t2, t3; dc_texture_map(&world, &t1, "Grass", 0, 0, 6, 2, 0); dc_world_add_tile(&world, &t1); dc_texture_map(&world, &t2, "Grass", 5, 0, 6, 2, 0); dc_world_add_tile(&world, &t2); dc_texture_map(&world, &t3, "Dirt", 4, 0, 6, 2, 1); dc_world_add_tile(&world, &t3); dc_run(&world); dc_texture_destory(&tex); return 0; }
// --------------------------------------------------------------------- // main // --------------------------------------------------------------------- int main() { unsigned long long count = 0; // number of executed constraints puts("--starting program"); dc_init(); #if MAKE_DUMP_FILE rm_make_dump_file("logs/"_sorter_name"-start.dump"); #endif srand(131); #ifndef LARGE_TEST test_small(&count); #else test_large(&count); #endif #if MAKE_DUMP_FILE rm_make_dump_file("logs/"_sorter_name"-end.dump"); #endif printf ("--total number of cached instructions executed = %u\n", g_stats.exec_cache_instr_count); return 0; }
void dc_start(struct channel *sc) { u32 val; if (!(sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP)) return; dc_init(sc); /* get actual LOS and OOF status */ switch (sc->p.frame_type) { case SBE_2T3E3_FRAME_TYPE_E3_G751: case SBE_2T3E3_FRAME_TYPE_E3_G832: val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2); dev_dbg(&sc->pdev->dev, "Start Framer Rx Status = %02X\n", val); sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0; break; case SBE_2T3E3_FRAME_TYPE_T3_CBIT: case SBE_2T3E3_FRAME_TYPE_T3_M13: val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS); dev_dbg(&sc->pdev->dev, "Start Framer Rx Status = %02X\n", val); sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0; break; default: break; } cpld_LOS_update(sc); /* start receive and transmit processes */ dc_transmitter_onoff(sc, SBE_2T3E3_ON); dc_receiver_onoff(sc, SBE_2T3E3_ON); /* start interrupts */ dc_start_intr(sc); }
// // Native thread that runs the actual nullDC emulator // static void *ThreadHandler(void *UserData) { char *Args[3]; const char *P; // Make up argument list P = (const char *)UserData; Args[0] = "dc"; Args[1] = "-config"; Args[2] = P&&P[0]? (char *)malloc(strlen(P)+32):0; if(Args[2]) { strcpy(Args[2],"config:image="); strcat(Args[2],P); } // Add additonal controllers for (int i = 0; i < 3; i++) { if (add_controllers[i]) mcfg_Create(MDT_SegaController,i+1,5); } // Run nullDC emulator dc_init(Args[2]? 3:1,Args); }
struct datacenter * server_get_dc(struct server_pool *pool, struct string *dcname) { struct datacenter *dc; uint32_t i, len; if (log_loggable(LOG_DEBUG)) { log_debug(LOG_DEBUG, "server_get_dc pool '%.*s'", dcname->len, dcname->data); } for (i = 0, len = array_n(&pool->datacenters); i < len; i++) { dc = (struct datacenter *) array_get(&pool->datacenters, i); ASSERT(dc != NULL); ASSERT(dc->name != NULL); if (string_compare(dc->name, dcname) == 0) { return dc; } } dc = array_push(&pool->datacenters); dc_init(dc); string_copy(dc->name, dcname->data, dcname->len); if (log_loggable(LOG_DEBUG)) { log_debug(LOG_DEBUG, "server_get_dc pool about to exit '%.*s'", dc->name->len, dc->name->data); } return dc; }
static int global_init(void) { int r; // TODO check all retcodes setlocale(LC_ALL, ""); initscr(); init_dialog(stdin, stdout); dialog_vars.item_help = 0; start_color(); init_my_colors(); noecho(); cbreak(); scrollok(stdscr, FALSE); keypad(stdscr, TRUE); clear_body(); // init libdevcheck r = dc_init(); assert(!r); RENDERER_REGISTER(sliding_window); RENDERER_REGISTER(whole_space); dc_log_set_callback(log_cb, NULL); r = atexit(global_fini); assert(r == 0); return 0; }
int main() { dc_init(); rm_make_dump_file("test07-start-"OPT".log"); volatile size_t* size = dc_malloc(sizeof(size_t)); node_t** head = dc_malloc(sizeof(node_t*)); *size = 5; i_list* l = i_list_new((size_t*)size, head); *size = 3; *size = 9; *size = 0; *size = 13; i_list_delete(l); rm_make_dump_file("test07-end-"OPT".log"); return 0; }
void t3e3_init(struct channel *sc) { cpld_init(sc); dc_reset(sc); dc_init(sc); exar7250_init(sc); exar7300_init(sc); }
int main(int argc, wchar* argv[]) { //if (argc==2) //ndcid=atoi(argv[1]); if (setup_curses() < 0) die("failed to setup curses!\n"); #ifdef TARGET_PANDORA signal(SIGSEGV, clean_exit); signal(SIGKILL, clean_exit); #endif #if defined(USES_HOMEDIR) && HOST_OS != OS_DARWIN string home = (string)getenv("HOME"); if(home.c_str()) { home += "/.reicast"; mkdir(home.c_str(), 0755); // create the directory if missing SetHomeDir(home); } else SetHomeDir("."); #else SetHomeDir("."); #endif /* #if defined(SUPPORT_X11) x11_keymap[113] = DPad_Left; x11_keymap[114] = DPad_Right; x11_keymap[111] = DPad_Up; x11_keymap[116] = DPad_Down; x11_keymap[52] = Btn_Y; x11_keymap[53] = Btn_X; x11_keymap[54] = Btn_B; x11_keymap[55] = Btn_A; x11_keymap[36] = Btn_Start; #endif */ printf("Home dir is: %s\n",GetPath("/").c_str()); common_linux_setup(); SetupInput(); settings.profile.run_counts=0; dc_init(argc,argv); dc_run(); #ifdef TARGET_PANDORA clean_exit(0); #endif return 0; }
void dc_restart(struct channel *sc) { dev_warn(&sc->pdev->dev, "SBE 2T3E3: 21143 restart\n"); dc_stop(sc); dc_reset(sc); dc_init(sc); /* stop + reset + init */ dc_start(sc); }
void* emuthread(void* ) { printf("Emu thread starting up"); char *Args[3]; Args[0] = "dc"; set_user_config_dir("/http"); set_user_data_dir("/http"); dc_init(1,Args); dc_run(); return 0; }
int main( int argc, char **argv ) { int i, j; dc_init (); //allocates vector... // max N is 1024... v=(int *)dc_malloc (4096); //allocates MyQGraphicsRectItem vector... vr=(MyQGraphicsRectItem **)malloc (N*sizeof (MyQGraphicsRectItem **)); /*generates random seed...*/ srand((unsigned)time (NULL)); //fills vector with values... printf ("Generated vector: \n"); for (i=0; i<N; i++) { /*generates random number in (0,1)...*/ j = rand() % (N*N); //without this printf it won't work with -O2... //printf ("%d ", j); v[i] = j; } printf ("\n"); QApplication a( argc, argv ); w=new MyWidget (); w->show(); int ret_value=a.exec(); //frees main page... dc_free (v); //frees MyQGraphicsRectItem vector... free (vr); //deallocates constraint parameter data structs... for (i=0; i<N; i++) { free (gDataArray[i]); } return ret_value; }
static void acpi_test(int ac, char **av) { unsigned int i; unsigned int k; unsigned int sleep_gpio_save[13]; ls1a_save_gpio_val(sleep_gpio_save); suspend_save(); i = strtoul(av[1], 0, 0); // printf ("you set %d for test !\n", i); if (i & 1) *(volatile unsigned int *)0xbfe7c004 = 1 << 8; //power button k = *(volatile unsigned int *)0xbfe7c024; k &= ~((1 << 8) | (1 << 9)); *(volatile unsigned int *)0xbfe7c024 = (i & 0x3) << 8; //[8:9]RI_EN、PME_EN // *(volatile unsigned int *)0xbfe7c008 = (1 << 13) | (5 << 10); //sleep to ram flushcache(); __asm__ volatile ( "la $2, 2f\n\t" "li $3, 0xa01ffc00\n\t" "sw $2, 0x0($3)\n\t" //save return address "li $2, 0xaffffe34\n\t" "lw $3, 0x0($2)\n\t" "or $3, 0x1\n\t" "sw $3, 0x0($2)\n\t" //enable ddr autorefresh "li $2, 0xbfe7c008\n\t" "li $3, (1<<13) | (5<<10)\n\t" "sw $3, 0x0($2)\n\t" //go to sleep "1:\n\t" "bal 1b\n\t" "nop\n\t" "2:\n\t" :: : "$2","$3","memory" // "move %0,$2\n\t" // : "=r" (p) // : "0" (p), "r" (len), "r" (1) // : "$2","$3","$4","$5" ); ls1a_restore_gpio_val(sleep_gpio_save); dc_init(); outstring("acpi resume back here !\n"); // printf ("acpi resume back here !\n"); }
int main() { const Pin pins_stack[] = {PINS_STACK}; PIO_Configure(pins_stack, PIO_LISTSIZE(pins_stack)); brick_hardware_version[0] = BRICK_HARDWARE_VERSION_MAJOR; brick_hardware_version[1] = BRICK_HARDWARE_VERSION_MINOR; brick_hardware_version[2] = BRICK_HARDWARE_VERSION_REVISION; brick_init(); wdt_restart(); #ifdef PROFILING profiling_init(); #endif if(usb_is_connected()) { logi("Configure as USB device\n\r"); usb_init(); wdt_restart(); xTaskCreate(usb_message_loop, (signed char *)"usb_ml", 2000, NULL, 1, (xTaskHandle *)NULL); } else { usb_first_connection = false; logi("Configure as Stack Participant (SPI)\n\r"); spi_stack_slave_init(); wdt_restart(); xTaskCreate(spi_stack_slave_message_loop, (signed char *)"spi_ml", 2500, NULL, 1, (xTaskHandle *)NULL); } dc_init(); wdt_restart(); brick_init_start_tick_task(); wdt_restart(); vTaskStartScheduler(); }
// This is our CnC phase. // We instantiate the dist_cnc_init object, put a number of tags and wait. // The function can be called with different parameters. We need the // communicator in any case, but of course it can be MPI_Comm_World. // If dist_env is true we do it the SPMD-way: every process, not only // root, executes everything. If dist_env is false only the root // executes things outside the dist_cnc_init constructor. void cnc_phase( MPI_Comm mc, bool dist_env ) { #ifdef _DIST_ // Init distribution infrastructure (RAII), most likely behaves like a barrier // if dist_env==false client processes get blocked in here forever. CnC::dist_cnc_init< my_context > dc_init( mc, dist_env ); #endif // as we provided a communicator to dc_init, all processes // continue here (by default only rank 0 gets here) std::cout << "Let's go\n"; // now let's get MPI rank etc. int numranks = 0; MPI_Comm_rank(mc,&rank); MPI_Comm_size(mc,&numranks); // The environment code should be executed on rank 0 and // on all client processes of a distributed environment. // We might have more than one rank 0 // if different communicators are in use. // Multiple environments are semantically tricky, combined with // CnC they make sense if the MPI phase creates distributed // data to be used by CnC. We mimic this by distributing // the control-puts across all processes of a distributed env. if( rank == 0 || dist_env ) { // create the context, the runtime will distribute it under the hood my_context c; // dist_env requires a sync, e.g. a barrier if( dist_env ) MPI_Barrier( mc ); // start tag, 0 if root int s = rank; // in a dist env each process puts a subset of tags // we do this by setting the loop-increment to the number // of processes in the env int inc = dist_env ? numranks : 1; // Simply put all (owned) control tags for (int number = s; number < N; number += inc) { c.m_tags.put(number); } // everyone in the env waits for quiescence c.wait(); std::cout << "done\n"; } // here the CnC distribution infrastructure gets shut down // when the dist_cnc_init object gets destructed (RAII) }
static int init(struct conduit *conduit) { static int inited = 0; struct data *data; if(!inited) { dc_init(); inited = 1; } data = smalloc(sizeof(*data)); memset(data, 0, sizeof(*data)); data->fd = -1; data->gdkread = data->gdkwrite = -1; conduit->cdata = data; return(0); }
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShowCmd) { ReserveBottomMemory(); tick_thd.Start(); int argc=0; wchar* cmd_line=GetCommandLineA(); wchar** argv=CommandLineToArgvA(cmd_line,&argc); if(strstr(cmd_line,"NoConsole")==0) { if (AllocConsole()) { freopen("CON","w",stdout); freopen("CON","w",stderr); freopen("CON","r",stdin); } SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ); } SetupPath(); //SetUnhandledExceptionFilter(&ExeptionHandler); __try { int dc_init(int argc,wchar* argv[]); void dc_run(); void dc_term(); dc_init(argc,argv); #ifdef _WIN64 setup_seh(); #endif dc_run(); dc_term(); } __except( ExeptionHandler(GetExceptionInformation()) ) { printf("Unhandled exception - Emulation thread halted...\n"); } SetUnhandledExceptionFilter(0); return 0; }
void digital_cam_uart_init(void) { // Call common DC init dc_init(); digital_cam_uart_thumbnails = 0; for (int t = 0; t < THUMB_COUNT; t++) { for (int i = 0; i < THUMB_MSG_SIZE; i++) { thumbs[t][i] = 0; } } #if PERIODIC_TELEMETRY register_periodic_telemetry(&telemetry_Ap, "PAYLOAD", send_thumbnails); #endif #ifdef SITL serial_init("/dev/ttyUSB0"); #endif }
int main(int argc, wchar* argv[]) { //if (argc==2) //ndcid=atoi(argv[1]); #if defined(USES_HOMEDIR) string home = (string)getenv("HOME"); if(home.c_str()) { home += "/.reicast"; mkdir(home.c_str(), 0755); // create the directory if missing SetHomeDir(home); } else SetHomeDir("."); #else SetHomeDir("."); #endif printf("Home dir is: %s\n",GetPath("/").c_str()); common_linux_setup(); printf("common linux setup done\n"); settings.profile.run_counts=0; dc_init(argc,argv); if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)==-1) die("error initializing SDL"); SetupInput(); #ifdef USE_OSS init_sound(); #endif dc_run(); clean_exit(0); return 0; }
int main( int argc, char **argv ) { int i=0; int h, k; /*double avgAct=0.0; int maxAct=0; double avgFinalAct=0.0; int maxFinalAct=0; double avgTime=0.0; double maxTime=0.0;*/ //initializes ww[][] (pointers to ellipses)... for (h=0; h<N; h++) for (k=0; k<N; k++) ww[h][k]=NULL; dc_init (); //allocates vector... // max N is 16... //v=(int *)LWP_AllocPages (1); //v=(int *)dc_malloc (4096); v=(int *)dc_malloc (N*N*sizeof (int)); //installs constraints... for (h=0; h<N; h++) for (k=0; k<N; k++) { //we are assuming lots of things here... int theData=(h<<16)+k; //LCP_NewCons (GeneralConstraint, NULL, (void *)theData); dc_new_cons (GeneralConstraint, (void *)theData, NULL); } //QApplication a( argc, argv ); MyApplication a( argc, argv ); w=new MyWidget (); //a.setMainWidget( w ); w->show(); //sets up board... _whiteMove (N/2-1, N/2-1); _whiteMove (N/2, N/2); _blackMove (N/2-1, N/2); _blackMove (N/2, N/2-1); gSetup=0; //just testing... /* printf ("\nInitial board:\n"); _printBoard (); while (i<1) { int a, b; printf ("Black move:\ni: "); scanf ("%d", &a); printf ("j: "); scanf ("%d", &b); _blackMove (a, b); _printBoard (); printf ("White move:\ni: "); scanf ("%d", &a); printf ("j: "); scanf ("%d", &b); _whiteMove (a, b); _printBoard (); i++; }*/ replayThread = new MyThread (); int ret_value=a.exec(); delete replayThread; //LCP_CleanUp (); //frees main page... //LWP_FreePages ((void *)v, 1); dc_free (v); /*debugging...*/ //printf ("\n[DEBUG] LMemory_GetBlocksCount() says: %u\n", (unsigned int)LMemory_GetBlocksCount ()); // dump DC profiling info if (dc_profile_on()) dc_dump_profile_diff(stdout, &log_array_prof[0], &log_array_prof[iter-1]); else { //computes avg and max resize evt processing time... elapsed_time_t avg; avg.real=0; avg.user=0; avg.system=0; avg.child_user=0; avg.child_system=0; double max=log_array[0].real; for (i=0; i<iter; i++) { avg.real=avg.real+log_array[i].real; avg.user=avg.user+log_array[i].user; avg.system=avg.system+log_array[i].system; avg.child_user=avg.child_user+log_array[i].child_user; avg.child_system=avg.child_system+log_array[i].child_system; if (log_array[i].real>max) max=log_array[i].real; } divide_elapsed_time_by(&avg, iter); printf ("\nTotal times per move:\n"); printf ("Avg real = %f\n", avg.real); printf ("Avg user = %f\n", avg.user); printf ("Avg system = %f\n", avg.system); printf ("Avg child_user = %f\n", avg.child_user); printf ("Avg child_system = %f\n", avg.child_system); printf ("Max real = %f\n", max); avg.real=0; avg.user=0; avg.system=0; avg.child_user=0; avg.child_system=0; max=inter_array[1].real; for (i=0; i<iter; i++) { avg.real=avg.real+inter_array[i].real; avg.user=avg.user+inter_array[i].user; avg.system=avg.system+inter_array[i].system; avg.child_user=avg.child_user+inter_array[i].child_user; avg.child_system=avg.child_system+inter_array[i].child_system; if (inter_array[i].real>max) max=inter_array[i].real; } divide_elapsed_time_by(&avg, iter); printf ("\nPropagation times only:\n"); printf ("Avg real = %f\n", avg.real); printf ("Avg user = %f\n", avg.user); printf ("Avg system = %f\n", avg.system); printf ("Avg child_user = %f\n", avg.child_user); printf ("Avg child_system = %f\n", avg.child_system); printf ("Max real = %f\n", max); } return ret_value; }
void atmega_i2c_cam_ctrl_init(void) { dc_init(); }
int main ( int argc, char *argv[] ) /************************************************************************ * DCTAF * * * * This program decodes TAF reports and writes the output to a GEMPAK * * surface forecast file. * * * * Command line: * * dctaf [options] filename * * filename output file name/template * ** * * Log: * * D. Kidwell/NCEP 9/02 Based on DCMETR * * A. Hardy/NCEP 12/02 Changed stn tbl sfstns.tbl->tafstn.tbl * * m.gamazaychikov/SAIC 07/05 Added parameters to CS of dc_gopt * * H. Zeng/SAIC 08/05 Added parameters to CS of dc_gopt * * L. Lin/NCEP 04/08 Modified fcst times from 24 to 30 * * L. Hinson/AWC 06/08 Added circflg to dc_gopt and call to * * tf_dcod * * S. Jacobs/NCEP 3/14 Added black list station table * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCTAF"; char *defprm = "taf.pack"; char *defstn = "tafstn.tbl"; char *dfstn2 = "tafblacklist.tbl"; int idfadd = 25; /* idfmax was set to 24 - default number of forecast time ** now it has been changed to 30 */ int idfmax = 30; int ndfhr1 = 5; int ndfhr2 = 24; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret; char gemfil[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, circflg, iwndht; /*---------------------------------------------------------------------*/ /* ** Initialize the output logs, set the time out and ** parse the command line parameters. */ dc_init ( prgnam, argc, argv, nexp, parms, &num, &iret ); /* ** Check for an initialization error. ** On an error, exit gracefully. */ if ( iret < 0 ) { dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &circflg, &iwndht, &iret ); /* ** The output file name must be present. ** ** Change this section for the specific decoder. */ strcpy ( gemfil, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ tf_dcod ( curtim, gemfil, stntbl, stntb2, prmfil, &iadstn, &maxtim, &nhours, &circflg, &iret, strlen(curtim), strlen(gemfil), strlen(stntbl), strlen(stntb2), strlen(prmfil) ); /* ** Send a shut down message to the logs and close the log files. */ dc_exit ( &iret ); }
int main ( int argc, char *argv[] ) /************************************************************************ * DCREDBOOK * * * * This program decodes REDBOOK graphics files and outputs them as * * standard graphics format files from GEMPAK device drivers. * * * * Command line: * * dcgrib [options] device * * device output file device * ** * * Log: * * Chiz/Unidata 8/00 * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCREDBOOK"; char *defprm = " "; char *defstn = " "; char *dfstn2 = " "; int idfadd = 0; int idfmax = 1; int ndfhr1 = 0; int ndfhr2 = 0; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret, ier; char gemdev[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, crcflg, iwndht; char errstr[DCMXLN]; /*---------------------------------------------------------------------*/ /* ** Initialize the output logs, set the time out and ** parse the command line parameters. dc_init calls in_bdta in 5.4.3+. */ dc_init ( prgnam, argc, argv, nexp, parms, &num, &iret ); /* ** Check for an initialization error. ** On an error, exit gracefully. */ if (( iret < 0 )&&(iret != -11)) { sprintf ( errstr, "Error initializing\0" ); dc_wclg ( 0, "DC", iret, errstr, &ier ); dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &crcflg, &iwndht, &iret ); /* ** The if the output file name is not present, use gribkey table ** ** Change this section for the specific decoder. */ strcpy ( gemdev, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ decode_redbook (gemdev, stntbl, &iret); /* ** Send shut down message and close the log files. */ dc_exit ( &iret ); }
void debug_console(void (*_func)(void)) { int done = 0; while( key_inkey() ) { os_poll(); } if ( !debug_inited ) { dc_init(); } dc_draw(TRUE); while (!done) { // poll the os os_poll(); int k = key_inkey(); switch( k ) { case KEY_SHIFTED+KEY_ENTER: case KEY_ESC: done = TRUE; break; case KEY_BACKSP: if (!dc_command_buf.empty()) { dc_command_buf.erase(dc_command_buf.size() - 1); } break; case KEY_F3: case KEY_UP: if (last_oldcommand < (dc_history.end() - 1)) { ++last_oldcommand; } dc_command_buf = *last_oldcommand; break; case KEY_DOWN: if (last_oldcommand > dc_history.begin()) { --last_oldcommand; } dc_command_buf = *last_oldcommand; break; case KEY_PAGEUP: if (dc_scroll_y > 1) { dc_scroll_y--; } break; case KEY_PAGEDOWN: if (dc_scroll_y < (DBROWS - DROWS)) { dc_scroll_y++; } else { dc_scroll_y = (DBROWS - DROWS); } break; case KEY_ENTER: dc_scroll_y = (DBROWS - DROWS); // Set the scroll to look at the bottom last_oldcommand = dc_history.begin(); // Reset the last oldcommand lastline = 0; // Reset the line counter // Clear the command line on the window, but don't print the prompt until the command has processed // Stuff a copy of the command line onto the history // Search for the command // If not found: // abort, // dc_printf("Error: Invalid or Missing command %s", cmd.c_str()), and // dc_printf(dc_prompt) when ready for input // Call the function for that command, and strip the cmd token from the command line string if (dc_command_buf.empty()) { dc_printf("No command given.\n"); break; } // Else, continue to process the cmd_line // z64: Thread Note: Maybe lock a mutex here to allow a previous DCF to finish/abort before starting a new one // z64: We'll just assume we won't be here unless a command has finished... dc_history.push_front(dc_command_buf); // Push the command onto the history queue last_oldcommand = dc_history.begin(); // Reset oldcommand while (dc_history.size() > DCMDS) { dc_history.pop_back(); // Keep the commands less than or equal to DCMDS } dc_command_str = dc_command_buf; // Xfer to the command string for processing dc_command_buf.resize(0); // Nullify the buffer dc_printf("%s%s\n", dc_prompt, dc_command_str.c_str()); // Print the command w/ prompt. dc_draw(FALSE); // Redraw the console without the command line. dc_do_command(&dc_command_str); // Try to do the command break; default: // Not any of the control key codes, so it's probably a letter or number. ubyte c = (ubyte)key_to_ascii(k); if ((c != 255) && (dc_command_buf.size() < MAX_CLI_LEN)) { dc_command_buf.push_back(c); } } // Do the passed function if ( _func ) { _func(); } // All done, and ready for new entry dc_draw(TRUE); } while( key_inkey() ) { os_poll(); } }
int main ( int argc, char *argv[] ) /************************************************************************ * DCMSFC * * * * This program decodes ship, buoy, C-MAN, and Coast Guard reports and * * writes the output to a GEMPAK surface file. * * * * Command line: * * dcmsfc [options] filename * * filename output file name/template * ** * * Log: * * K. Tyle/GSC 4/97 Based on DCMETR * * D. Kidwell/NCEP 10/97 Eliminated bufr references * * I. Durham/GSC 5/98 Changed underscore decl. to an include * * A. Hardy/GSC 1/01 Added full prototype * * S. Jacobs/NCEP 2/01 Removed all references to ulog * * F. J. Yen/NCEP 4/01 Added Coast Guard reports to prolog * * D. Kidwell/NCEP 1/03 Increased idfmax to MMHDRS - 1 * * m.gamazaychikov/SAIC 07/05 Added parameters to CS of dc_gopt * * H. Zeng/SAIC 08/05 Added parameters to CS of dc_gopt * * L. Hinson/AWC 06/08 Added circflg parameter to dc_gopt * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCMSFC"; char *defprm = "msfc.pack"; char *defstn = "msfstns.tbl"; char *dfstn2 = " "; int idfadd = 25; int idfmax = MMHDRS - 1; int ndfhr1 = 5; int ndfhr2 = 24; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret; char gemfil[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, circflg, iwndht; /*---------------------------------------------------------------------*/ /* ** Initialize the output logs, set the time out and ** parse the command line parameters. */ dc_init ( prgnam, argc, argv, nexp, parms, &num, &iret ); /* ** Check for an initialization error. ** On an error, exit gracefully. */ if ( iret < 0 ) { dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &circflg, &iwndht, &iret ); /* ** The output file name must be present. ** ** Change this section for the specific decoder. */ strcpy ( gemfil, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ ma_dcod ( curtim, gemfil, stntbl, prmfil, &iadstn, &maxtim, &nhours, &iret, strlen(curtim), strlen(gemfil), strlen(stntbl), strlen(prmfil) ); /* ** Send a shut down message to the logs and close the log files. */ dc_exit ( &iret ); return(0); }
/* * The main loop of the player thread, during playback. This is * basically a state machine, which multiplexes data between the * decoder thread and the output threads. */ static void do_play(struct decoder_control *dc) { struct player player = { .dc = dc, .buffering = true, .decoder_starting = false, .paused = false, .queued = true, .output_open = false, .song = NULL, .xfade = XFADE_UNKNOWN, .cross_fading = false, .cross_fade_chunks = 0, .cross_fade_tag = NULL, .elapsed_time = 0.0, }; player_unlock(); player.pipe = music_pipe_new(); player_dc_start(&player, player.pipe); if (!player_wait_for_decoder(&player)) { player_dc_stop(&player); player_command_finished(); music_pipe_free(player.pipe); event_pipe_emit(PIPE_EVENT_PLAYLIST); player_lock(); return; } player_lock(); if (pc.command == PLAYER_COMMAND_SEEK) player.elapsed_time = pc.seek_where; pc.state = PLAYER_STATE_PLAY; player_command_finished_locked(); while (true) { player_process_command(&player); if (pc.command == PLAYER_COMMAND_STOP || pc.command == PLAYER_COMMAND_EXIT || pc.command == PLAYER_COMMAND_CLOSE_AUDIO) { player_unlock(); audio_output_all_cancel(); break; } player_unlock(); if (player.buffering) { /* buffering at the start of the song - wait until the buffer is large enough, to prevent stuttering on slow machines */ if (music_pipe_size(player.pipe) < pc.buffered_before_play && !decoder_lock_is_idle(dc)) { /* not enough decoded buffer space yet */ if (!player.paused && player.output_open && audio_output_all_check() < 4 && !player_send_silence(&player)) break; decoder_lock(dc); /* XXX race condition: check decoder again */ player_wait_decoder(dc); decoder_unlock(dc); player_lock(); continue; } else { /* buffering is complete */ player.buffering = false; } } if (player.decoder_starting) { /* wait until the decoder is initialized completely */ if (!player_check_decoder_startup(&player)) break; player_lock(); continue; } #ifndef NDEBUG /* music_pipe_check_format(&play_audio_format, player.next_song_chunk, &dc->out_audio_format); */ #endif if (decoder_lock_is_idle(dc) && player.queued && dc->pipe == player.pipe) { /* the decoder has finished the current song; make it decode the next song */ assert(dc->pipe == NULL || dc->pipe == player.pipe); player_dc_start(&player, music_pipe_new()); } if (player_dc_at_next_song(&player) && player.xfade == XFADE_UNKNOWN && !decoder_lock_is_starting(dc)) { /* enable cross fading in this song? if yes, calculate how many chunks will be required for it */ player.cross_fade_chunks = cross_fade_calc(pc.cross_fade_seconds, dc->total_time, pc.mixramp_db, pc.mixramp_delay_seconds, dc->replay_gain_db, dc->replay_gain_prev_db, dc->mixramp_start, dc->mixramp_prev_end, &dc->out_audio_format, &player.play_audio_format, music_buffer_size(player_buffer) - pc.buffered_before_play); if (player.cross_fade_chunks > 0) { player.xfade = XFADE_ENABLED; player.cross_fading = false; } else /* cross fading is disabled or the next song is too short */ player.xfade = XFADE_DISABLED; } if (player.paused) { player_lock(); if (pc.command == PLAYER_COMMAND_NONE) player_wait(); continue; } else if (!music_pipe_empty(player.pipe)) { /* at least one music chunk is ready - send it to the audio output */ play_next_chunk(&player); } else if (audio_output_all_check() > 0) { /* not enough data from decoder, but the output thread is still busy, so it's okay */ /* XXX synchronize in a better way */ g_usleep(10000); } else if (player_dc_at_next_song(&player)) { /* at the beginning of a new song */ if (!player_song_border(&player)) break; } else if (decoder_lock_is_idle(dc)) { /* check the size of the pipe again, because the decoder thread may have added something since we last checked */ if (music_pipe_empty(player.pipe)) { /* wait for the hardware to finish playback */ audio_output_all_drain(); break; } } else if (player.output_open) { /* the decoder is too busy and hasn't provided new PCM data in time: send silence (if the output pipe is empty) */ if (!player_send_silence(&player)) break; } player_lock(); } player_dc_stop(&player); music_pipe_clear(player.pipe, player_buffer); music_pipe_free(player.pipe); if (player.cross_fade_tag != NULL) tag_free(player.cross_fade_tag); player_lock(); if (player.queued) { assert(pc.next_song != NULL); pc.next_song = NULL; } pc.state = PLAYER_STATE_STOP; player_unlock(); event_pipe_emit(PIPE_EVENT_PLAYLIST); player_lock(); } static gpointer player_task(G_GNUC_UNUSED gpointer arg) { struct decoder_control dc; dc_init(&dc); decoder_thread_start(&dc); player_buffer = music_buffer_new(pc.buffer_chunks); player_lock(); while (1) { switch (pc.command) { case PLAYER_COMMAND_SEEK: case PLAYER_COMMAND_QUEUE: assert(pc.next_song != NULL); do_play(&dc); break; case PLAYER_COMMAND_STOP: player_unlock(); audio_output_all_cancel(); player_lock(); /* fall through */ case PLAYER_COMMAND_PAUSE: pc.next_song = NULL; player_command_finished_locked(); break; case PLAYER_COMMAND_CLOSE_AUDIO: player_unlock(); audio_output_all_release(); player_lock(); player_command_finished_locked(); #ifndef NDEBUG /* in the DEBUG build, check for leaked music_chunk objects by freeing the music_buffer */ music_buffer_free(player_buffer); player_buffer = music_buffer_new(pc.buffer_chunks); #endif break; case PLAYER_COMMAND_UPDATE_AUDIO: player_unlock(); audio_output_all_enable_disable(); player_lock(); player_command_finished_locked(); break; case PLAYER_COMMAND_EXIT: player_unlock(); dc_quit(&dc); dc_deinit(&dc); audio_output_all_close(); music_buffer_free(player_buffer); player_command_finished(); return NULL; case PLAYER_COMMAND_CANCEL: pc.next_song = NULL; player_command_finished_locked(); break; case PLAYER_COMMAND_REFRESH: /* no-op when not playing */ player_command_finished_locked(); break; case PLAYER_COMMAND_NONE: player_wait(); break; } } } void player_create(void) { assert(pc.thread == NULL); GError *e = NULL; pc.thread = g_thread_create(player_task, NULL, true, &e); if (pc.thread == NULL) MPD_ERROR("Failed to spawn player task: %s", e->message); }
void atmega_i2c_cam_ctrl_init(void) { atmega_i2c_cam_ctrl_trans.status = I2CTransDone; dc_init(); }
int main(int args,char *argv[]){ const int smallOutputNumber=-1; int i,j; cJSON *root; int num_chromosome; int req_type=1; char buffer[30]; char req_gene[20]={0}; cJSON *msg; char req_kind[50]="E.coli K12-DH10B"; pi=0; ini=0; req_restrict.rfc10=0; req_restrict.rfc12=0; req_restrict.rfc12a=0; req_restrict.rfc21=0; req_restrict.rfc23=0; req_restrict.rfc25=0; char *req_str=argv_default; if(args==2) req_str=argv[1]; cJSON *request=cJSON_Parse(req_str); if(check_req(request)){ onError("illegal args"); return 0; } i=1; j=1; cJSON *cJSON_temp; cJSON_temp=cJSON_GetObjectItem(request,"type"); if(cJSON_temp) req_type=cJSON_temp->valueint; char req_pam[PAM_LEN+1]; int req_pam_len; strcpy(req_pam,cJSON_GetObjectItem(request,"pam")->valuestring); req_pam_len=(int)strlen(req_pam); char req_specie[30]; struct return_struct rs; int ptts_num; int len[NUM_CHROMOSOME]; strcpy(req_specie,cJSON_GetObjectItem(request,"specie")->valuestring); if(strcmp(req_specie,"SARS")==0){ rs=info_readin(PTT_SARS,ptts,str,wai,NULL); }else if(strcmp(req_specie,"E.coli")==0){ cJSON_temp=cJSON_GetObjectItem(request,"kind"); if(cJSON_temp) strcpy(req_kind,cJSON_temp->valuestring); rs=info_readin(PTT_ECOLI,ptts,str,wai,req_kind); }else if(strcmp(req_specie,"Saccharomycetes")==0){ rs=info_readin(PTT_SACCHAROMYCETES,ptts,str,wai,NULL); }else{ onError("no specie"); return 0; } ptts_num=rs.ptts_num; num_chromosome=rs.num_chromosome; for(i=1;i<=num_chromosome;i++) len[i]=rs.len[i]; double req_r1=0.65; cJSON_temp=cJSON_GetObjectItem(request,"gene"); if(cJSON_temp){ req_r1=cJSON_GetObjectItem(request,"r1")->valuedouble; } cJSON_temp=cJSON_GetObjectItem(request,"gene"); int req_id,req_gene_start,req_gene_end; if(cJSON_temp){ strcpy(req_gene,cJSON_temp->valuestring); for(int i=0;i<ptts_num;i++){ if(strcmp(req_gene,ptts[i].gene)==0){ req_id=ptts[i].chromosome; req_gene_start=ptts[i].s; req_gene_end=ptts[i].t; break; } } }else{ char req_location[20]; strcpy(req_location,cJSON_GetObjectItem(request,"location")->valuestring); sscanf(req_location,"%d:%d..%d",&req_id,&req_gene_start,&req_gene_end); } char req_rfc[10]; strcpy(req_rfc,cJSON_GetObjectItem(request,"rfc")->valuestring); req_restrict.rfc10=req_rfc[0]-48; req_restrict.rfc12=req_rfc[1]-48; req_restrict.rfc12a=req_rfc[2]-48; req_restrict.rfc21=req_rfc[3]-48; req_restrict.rfc23=req_rfc[4]-48; req_restrict.rfc25=req_rfc[5]-48; generate_filename(buffer,req_specie,req_kind,req_pam,req_type); dc_init(buffer); /* This part above is for read in JSON-style request. The result stored in req_specie, req_pam, req_gene_start, req_gene_end, rfc and so on. At the same time, it reads in ptt file for specie, and also open files. */ for(int id=1;id<=num_chromosome;id++){ for(i=LEN;i<len[id]-req_pam_len;i++){ // All possible gRNAs, +direction if(check_pam(str[id]+i,req_pam)){ psb_site[pi].index=i; psb_site[pi].strand='+'; psb_site[pi].chromosome=id; for(j=0;j<req_pam_len;j++) psb_site[pi].pam[j]=(str[id]+i)[j]; psb_site[pi].pam[j]=0; for(j=0;j<LEN;j++) psb_site[pi].nt[j]=(str[id]+i-LEN)[j]; psb_site[pi].nt[j]=0; pi++; } } char req_pam_rev[PAM_LEN]; int last=-1; dna_rev(req_pam_rev,req_pam,req_pam_len); for(i=0;i<len[id]-LEN-req_pam_len;i++){ // All possible gRNAs, -direction if(check_pam(str[id]+i,req_pam_rev)){ psb_site[pi].index=i+req_pam_len-1; psb_site[pi].strand='-'; psb_site[pi].chromosome=id; if(req_pam_len!=last){ last=req_pam_len; } for(j=0;j<req_pam_len;j++) psb_site[pi].pam[j]=dna_rev_char((str[id]+i)[req_pam_len-1-j]); psb_site[pi].pam[j]=0; for(j=0;j<LEN;j++) psb_site[pi].nt[j]=dna_rev_char((str[id]+i+req_pam_len)[LEN-j-1]); psb_site[pi].nt[j]=0; pi++; } } } for(i=0;i<pi;i++){ fflush(stdout); if(psb_site[i].chromosome!=req_id) continue; if(psb_site[i].strand=='+'){ if(psb_site[i].index<req_gene_start || psb_site[i].index+req_pam_len-1>req_gene_end) continue; for(j=psb_site[i].index-LEN;j<psb_site[i].index+req_pam_len-1;j++){ if(wai[req_id][j]!=1) break; } if(j<psb_site[i].index+req_pam_len-1) j=0; else j=1; }else{ if(psb_site[i].index-req_pam_len+1<req_gene_start || psb_site[i].index>req_gene_end) continue; for(j=psb_site[i].index-req_pam_len+1;j<psb_site[i].index+LEN;j++){ if(wai[req_id][j]!=1) break; } if(j<psb_site[i].index+LEN) j=0; else j=1; } if(j){ score(i,&ini,req_type,req_r1); } } dc_save(); sort(in_site,in_site+ini,cmp_in_site); // Sort & Output root=cJSON_CreateObject(); cJSON_AddNumberToObject(root,"status",0); msg=cJSON_CreateObject(); cJSON_AddStringToObject(msg,"specie",req_specie); cJSON_AddStringToObject(msg,"kind",req_kind); cJSON_AddStringToObject(msg,"gene",req_gene); sprintf(buffer,"%d:%d..%d",req_id,req_gene_start,req_gene_end); cJSON_AddStringToObject(msg,"location",buffer); cJSON_AddItemToObject(root,"message",msg); vector<cJSON*> list; list.clear(); for(i=0;i<ini && i!=smallOutputNumber;i++){ cJSON *ans=cJSON_CreateObject(); sprintf(buffer,"#%d",i+1); cJSON_AddStringToObject(ans,"key",buffer); sprintf(buffer,"%s%s",in_site[i].nt,in_site[i].pam); cJSON_AddStringToObject(ans,"grna",buffer); sprintf(buffer,"%d:%d",in_site[i].chromosome,in_site[i].index); cJSON_AddStringToObject(ans,"position",buffer); char xs[2]; xs[0]=in_site[i].strand; xs[1]=0; cJSON_AddStringToObject(ans,"strand",xs); cJSON_AddNumberToObject(ans,"total_score",(int)in_site[i].score); cJSON_AddNumberToObject(ans,"Sspe",(int)(req_r1*in_site[i].Sspe_nor)); cJSON_AddNumberToObject(ans,"Seff",(int)((1.0-req_r1)*in_site[i].Seff_nor)); cJSON_AddNumberToObject(ans,"count",in_site[i].count); cJSON_AddItemToObject(ans,"offtarget",in_site[i].otj); list.push_back(ans); } cJSON_AddItemToObject(root,"result",Create_array_of_anything(&(list[0]),list.size())); printf("%s\n",NomoreSpace(argv[0]=cJSON_Print(root))); free(argv[0]); return 0; }
int main ( int argc, char *argv[] ) /************************************************************************ * DCHRCN * * * * This program decodes the WTNT23, WTNT24 and WTPZ23 tropical storm * * and hurricane forecast/advisory reports and writes the output to an * * ASCII file. * * * * Command line: * * dcwtch [options] filename * * filename output file name/template * ** * * Log: * * A. Hardy/GSC 9/99 * * A. Hardy/GSC 1/01 Added full prototype * * S. Jacobs/NCEP 2/01 Removed all references to ulog * * m.gamazaychikov/SAIC 07/05 Added parameters to CS of dc_gopt * * H. Zeng/SAIC 08/05 Added parameters to CS of dc_gopt * * L. Hinson/AWC 06/08 Added circflg parameter to dc_gopt * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCHRCN"; char *defprm = " "; char *defstn = " "; char *dfstn2 = " "; int idfadd = 25; int idfmax = 24; int ndfhr1 = 5; int ndfhr2 = 24; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret; char gemfil[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, circflg, iwndht; /*---------------------------------------------------------------------*/ /* ** Initialize the output logs, set the time out and ** parse the command line parameters. */ dc_init ( prgnam, argc, argv, nexp, parms, &num, &iret ); /* ** Check for an initialization error. ** On an error, exit gracefully. */ if ( iret < 0 ) { dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &circflg, &iwndht, &iret ); /* ** The output file name must be present. ** ** Change this section for the specific decoder. */ strcpy ( gemfil, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ hc_dcod ( curtim, gemfil, stntbl, prmfil, &iadstn, &maxtim, &nhours, &iret, strlen(curtim), strlen(gemfil), strlen(stntbl), strlen(prmfil) ); /* ** Send a shut down message to the logs and close the log files. */ dc_exit ( &iret ); return 0; }